I have 3 files which should included in static library (file1.c,file2.c,file3.c) and one file which should include the main function (main.c file) and linked to the static library.
I would like to create one makefile that create the library and then create the executable.
My base makefile is:
CC=gcc CFLAGS=-c -Wall LDFLAGS= SOURCES=file1.c file2.c file3.c OBJECTS=$(SOURCES:.c=.o) OUT=libctest.a EXECUTABLE=hello LDFLAGS = -static .c.o: $(CC) $(CFLAGS) -c $< -o [email protected] $(OUT): $(OBJECTS) ar rcs $(OUT) $(OBJECTS) all: (CC) -o $(EXECUTABLE) main.c $(OUT) clean: rm -f $(OBJECTS) $(OUT)
The library is created but the executable doesn't created (all: (CC) -o $(EXECUTABLE) main.c $(OUT)) Any idea what is needed?