I have about 10 source files (.c) with headers (.h). Only two source files (.c) are associated with executable files (ELF) and contain the main function. Most files are compiled into (.o) and (re) objects used (statically linked) with executable files.
I tried to define a general rule for creating all objects:
%.o : %.c
$(CC) $(CCFLAGS) -c -o $@ $<
This works great for sources compiled into objects. I don’t have to worry about updating the makefile every time I add a new source file.
But I do not know what would be the best way to create rules for creating executable files?
exec1 : object1.o object2.o object3.o
call the linker
exec2 : object1.o object2.o object4.o object5.o
call the linker
This will work; but when I include the new header (foo.h), I will also need to remember the list of objects for this rule (add foo.o).
- make (, ?)?
?
: , . ?
!