I usually use something like this, in this example, the source files are main.c file2.c file3.c file4.c , to add more, you just add var to OBJECTS .
They all depend on the Makefile , so a simple touch Makefile enough to completely recompile.
PROGNAME = hi2u LIBS = -ljpeg -ldirectfb -pthread INCLUDES = -I/usr/local/include/directfb LDFLAGS = -Llibs/ OBJECTS = main.o file2.o \ file3.o file4.o CFLAGS = -W -Wall -O2 -ggdb all: $(PROGNAME) $(PROGNAME): $(OBJECTS) gcc -o $(PROGNAME) $(OBJECTS) $(LIBS) $(INCLUDES) $(LDFLAGS) $(OBJECTS): Makefile .co: gcc -c $(CFLAGS) $(INCLUDES) -o $@ $< clean: rm *.o $(PROGNAME)
source share