More than a decade ago we had to the same thing (defelop a makefile
generator) as there were enough members in the team who coudn't be bothered
to learn how to write makefiles. Not to speak of configuring the much more
complex automake...
Anyway, why is it such a big issue for most people to write a simple
makefile ? I have been reading a tutorial for the last hour and it
does not seem that hard to write simple makefiles.
eg. if there are files main.c, file1.c, file2.c
main.c includes file1.h and file2.h. file1.c includes file1.h and
file2.c includes file2.h
One can write a makefile for such a program:
# top-level rule to compile the whole program.
all: prog
# program is made of several source files.
prog: main.o file1.o file2.o
gcc main.o file1.o file2.o -o prog
# rule for file "main.o".
main.o: main.c file1.h file2.h
gcc -g -Wall -c main.c
# rule for file "file1.o".
file1.o: file1.c file1.h
gcc -g -Wall -c file1.c
# rule for file "file2.o".
file2.o: file2.c file2.h
gcc -g -Wall -c file2.c
# rule for cleaning files generated during compilations.
clean:
/bin/rm -f prog main.o file1.o file2.o
Howver, the problem that I see with this approach that one has to keep
track of all the dependencies. It will get cumbersome with huge
projects but I believe there is a way out.