I wish to convert this statement into a makefile:
gcc -Wall -I/usr/local/include -c my_program.c
I wrote this makefile:
CC=gcc
CFLAGS=-c -Wall -I:/usr/local/include
LDFLAGS= -LE:/usr/local/include
LIBS= -lgsl
SOURCES=my_program.c
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=my_program
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
.c.o:
$(CC) $(CFLAGS) $< -o $@
However, I have an error which specifies undefined references and shows this:
collect2: error: ld returned 1 exit status
make: *** [my_program] Error 1
In this program, I am using GNU GSL library stored at /usr/local/include
I read various tutorials on makefiles and the man make page and I'm still stuck. Please let me know if you have any suggestions to fix this. Thank you!