Generic Makefiles

Tired of editing your makefile for every .c file you add/remove/rename in your project?
Tired of having to recompile everything to be safe after any .h file modification?
Tired of reading the gmake manual to decipher the makefile language?

Just drop a Generic Makefiles in your source directory, type make all, et voilà!


~/C/YourProject> ls -l
total 24
-rw-r--r--    1 marc     marc           58 Mar  3 18:11 global.h
-rw-r--r--    1 marc     marc          119 Mar  3 18:18 main.c
-rw-r--r--    1 marc     marc           42 Mar  3 18:04 one.c
-rw-r--r--    1 marc     marc           66 Mar  3 18:11 one.h
-rw-r--r--    1 marc     marc           42 Mar  3 18:04 two.c
-rw-r--r--    1 marc     marc           66 Mar  3 18:09 two.h
~/C/YourProject> cp ../GenericMakefiles-0.3.1/GNUmakefile_C Makefile
~/C/YourProject> make all
Makefile:208: main.d: No such file or directory
Makefile:208: one.d: No such file or directory
Makefile:208: two.d: No such file or directory
rm -f ./a.out ./Last_make_goal_was_* ./main.o ./one.o ./two.o ./main.d ./one.d ./two.d
touch Last_make_goal_was_all
/bin/sh -ec 'gcc -MM -I.  two.c |\
sed '\''s@\(two\)\.o[ :]*@./\1.o two.d: $(goal_flag_file) @g'\'' > two.d;\
[ -s two.d ] || rm -f two.d'
/bin/sh -ec 'gcc -MM -I.  one.c |\
sed '\''s@\(one\)\.o[ :]*@./\1.o one.d: $(goal_flag_file) @g'\'' > one.d;\
[ -s one.d ] || rm -f one.d'
/bin/sh -ec 'gcc -MM -I.  main.c |\
sed '\''s@\(main\)\.o[ :]*@./\1.o main.d: $(goal_flag_file) @g'\'' > main.d;\
[ -s main.d ] || rm -f main.d'
gcc -c main.c -I. -s  -Wall -Wno-uninitialized -ansi -pedantic -O3 -fomit-frame-pointer   -o main.o
gcc -c one.c -I. -s  -Wall -Wno-uninitialized -ansi -pedantic -O3 -fomit-frame-pointer   -o one.o
gcc -c two.c -I. -s  -Wall -Wno-uninitialized -ansi -pedantic -O3 -fomit-frame-pointer   -o two.o
gcc main.o one.o two.o -o a.out -s -lm 
~/C/YourProject> ./a.out
Hello 1 2

The makefile has automatically:

Besides all, the following goals are provided:

Generic Makefiles targets
usageprint available goals
listlist the source files
allbuild the executable
debugbuild the executable with debug options
profbuild the executable with profiling options
cleanremove all files created by build

The makefile is customizable by editing the following variables:

User variables in Generic Makefiles
variabledefault value
BWARN_OPTS-Wall -ansi
EWARN_OPTS$(BWARN_OPTS) -pedantic -Wtraditional -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wredundant-decls -Wnested-externs -Winline $(BWARN_OPTS) -pedantic -Wtraditional -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wredundant-decls -Wnested-externs -Woverloaded-virtual -Winline


This software is released under the GNU General Public License.


VersionRelease dateFile
0.3.1 2003-03-12 GenericMakefiles-0.3.1.tar.gz
0.3 2000-11-06 GenericMakefiles-0.3.tar.gz
0.2 2000-10-10 GenericMakefiles-0.2.tar.gz


Version 0.3.1

Version 0.3

Version 0.2

Powered by W2ML © 2000, 2001, 2003, Marc Mongenet, last update and validation: --.