# SelfMakefile 0.1 # # http://www.cscience.org/~fmierlo/Projects/SelfMakefile/ # # What is this? # # A nice Makefile. You must need setup some variables # after generate a template Makefile and it's working. # # Why ccache is cool? # # When you change a header and your Makefile don't # know that your source depend of it, the make don't # rebuild your source :'( # # ccache can do this work for you ;-), leave it cache # your builds and decide when it must be rebuild. Just # be carrefull with disk usage. # # http://ccache.samba.org/ # # Why Self? # # It's because you can just do # # make -f SelfMakefile helpex >> Makefile && make help # # to have a template make file. # # Obs: in GoboLinux world you must do `which make` to # disable ColorMake. # # -- fabio.m foo: @ \ CXXFLAGS="$(INC) $(CXXFLAGS)" \ CFLAGS="$(INC) $(CFLAGS)" \ LDFLAGS="$(LIB) $(LDFLAGS)" \ make $(OUT) $(OUT): $(OBJ) run: foo $(OUT) $(RUN) debug: @ \ CXXFLAGS=$(CXXDEBUGFLAGS) \ CFLAGS=$(CDEBUGFLAGS) \ LDFLAGS=$(LDDEBUGFLAGS) \ make debugrun: debug $(OUT) $(RUN) clean: rm -f $(OUT) $(OBJ) happy: @echo ":-)" show: @echo CXXFLAGS = $(CXXFLAGS) @echo CFLAGS = $(CFLAGS) @echo LDFLAGS = $(LDFLAGS) @echo CXXDEBUGFLAGS = $(CXXDEBUGFLAGS) @echo CDEBUGFLAGS = $(CDEBUGFLAGS) @echo LDDEBUGDFLAGS = $(LDDEBUGFLAGS) @echo INC = $(INC) @echo LIB = $(LIB) @echo RUN = $(RUN) @echo OUT = $(OUT) @echo OBJ = $(OBJ) help: @echo "Targets:" @echo "make - build $(OUT)" @echo "make run - run '$(OUT) $(RUN)'" @echo "make debug - replace CXX and C flags for debug flags and build $(OUT)" @echo "make debugrun - do a 'make debug' followed by 'make run'" @echo "make show - show build variables" @echo "make clean - remove builded files" @echo "make help - you already know" @echo "make helpex - nice try" @echo "" @echo "Variables:" @echo "CXXFLAGS - CXX options" @echo "CFLAGS - C options" @echo "LDFLAGS - ld options" @echo "CXXDEBUGFLAGS - CXX debug options" @echo "CDEBUGFLAGS - C debug options" @echo "LDDEBUGFLAGS - ls debug options" @echo "INC - -I (include path) and others options" @echo "LIB - -I (include path) and others options" @echo "RUN - run parameters" @echo "OUT - output file" @echo "OBJ - input objects (.o files)" helpex: @echo "# Example:" @echo "" @echo "# Begin of the Makefile" @echo "" @echo "PREFIX=$(HOME)" @echo "" @echo "INC += -I\$$(PREFIX)/foo/include" @echo "LIB += -L\$$(PREFIX)/foo/lib" @echo "LIB += -lfoo" @echo "" @echo "INC += -I\$$(PREFIX)/bar/include" @echo "LIB += -L\$$(PREFIX)/bar/lib" @echo "LIB += -llib" @echo "" @echo "CXXDEBUGFLAGS = -g" @echo "CDEBUGFLAGS = -g" @echo "" @echo "RUN = -i foo -o bar" @echo "" @echo "OUT = main" @echo "" @echo "OBJ = \\" @echo " main.o \\" @echo " myfoo.o \\" @echo " mybar.o \\" @echo "" @echo "include SelfMakefile" @echo "" @echo "# End of the Makefile"