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 ~/C/YourProject>
The generic makefile has automatically:
.c
files;.c
files into .o
files;.o
files to produce an a.out
executable.Besides all
, the following goals are provided:
goal | use |
---|---|
usage | print available goals |
list | list the source files |
all | build the executable |
debug | build the executable with debug options |
prof | build the executable with profiling options |
clean | remove all files created by build |
The makefile is customizable by editing the following variables:
variable | default value | |
---|---|---|
C | C++ | |
EXE | a.out | |
SOURCE_SUFFIX | c | cc |
CC | gcc | g++ |
srcdir | . | |
builddir | . | |
INC_PATH | -I$(srcdir) | |
LNK_LIBS |
| |
COMPILE_OPTS |
| |
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.
Version | Release date | File |
---|---|---|
0.3.1 | 12-MAR-2003 | GenericMakefiles-0.3.1.tar.gz |
0.3 | 06-NOV-2000 | GenericMakefiles-0.3.tar.gz |
0.2 | 10-OCT-2000 | GenericMakefiles-0.2.tar.gz |
list
goal to show compiled source files;srcdir
configurable variable;builddir
configurable variable.© 2000, 2001, 2003, Marc Mongenet, last update and validation: 12-MAR-2003.