X-Git-Url: https://git.llucax.com/software/makeit.git/blobdiff_plain/ebc72ef1a2989900178d36a7d173cccc35b2ae05..2c3ae410630adfbb6c35a871382bf05624181c9b:/Makeit.mak?ds=inline diff --git a/Makeit.mak b/Makeit.mak index a4b6dfb..8964fe2 100644 --- a/Makeit.mak +++ b/Makeit.mak @@ -30,8 +30,16 @@ COLOR_CMD ?= 00;33 # See COLOR_CMD comment for details. COLOR_ARG ?= -# Flavor (variant), should be one of "dbg", "opt" or "cov" -F ?= opt +# ANSI color used for the warnings if $(COLOR) is non-empty +# See COLOR_CMD comment for details. +COLOR_WARN ?= 00;36 + +# ANSI color used for commands output if $(COLOR) is non-empty +# See COLOR_CMD comment for details. +COLOR_OUT ?= 00;31 + +# Flavor (variant), can be defined by the user in Config.mak +F ?= default # Use C++ linker by default LINKER := $(CXX) @@ -66,6 +74,12 @@ SPHINX_FORMAT ?= html # Paper size for Sphinx LaTeX output (a4, letter, etc.) SPHINX_PAPERSIZE ?= a4 +# Name of the build directory (to use when excluding some paths) +BUILD_DIR_NAME ?= build + +# Directories to exclude from the build directory tree replication +BUILD_DIR_EXCLUDE ?= $(BUILD_DIR_NAME) .git .hg .bzr _darcs .svn CVS + # Directories ############## @@ -85,7 +99,7 @@ T := $(abspath $T) R := $(subst $T,,$(patsubst $T/%,%,$(CURDIR))) # Base directory where to put variants (Variants Directory) -VD ?= $T/build +VD ?= $T/$(BUILD_DIR_NAME) # Generated files top directory G ?= $(VD)/$F @@ -157,23 +171,33 @@ abbr = $(if $(call eq,$(call abbr_helper,$1),$1),$1,$(addprefix \ # pretty print. vexec_pc = $(if $1,\033[$1m%s\033[00m,%s) vexec_p = $(if $(COLOR), \ - ' $(call vexec_pc,$(COLOR_CMD)) $(call vexec_pc,$(COLOR_ARG))\n', \ + ' $(call vexec_pc,$(COLOR_CMD)) $(call vexec_pc,$(COLOR_ARG))\n$(if \ + $(COLOR_OUT),\033[$(COLOR_OUT)m)', \ ' %s %s\n') vexec = $(if $V,printf $(vexec_p) \ '$(call abbr,$(if $3,$(strip $3),$(firstword $1)))' \ - '$(call abbr,$(if $2,$(strip $2),$@))' ; )$1 + '$(call abbr,$(if $2,$(strip $2),$@))' ; )$1 \ + $(if $V,$(if $(COLOR),$(if $(COLOR_OUT), \ + ; r=$$? ; printf '\033[00m' ; exit $$r))) # Same as vexec but it silence the echo command (prepending a @ if $V). exec = $V$(call vexec,$1,$2,$3) -# Compile a source file to an object, generating pre-compiled headers and -# dependencies. The pre-compiled headers are generated only if the system -# includes change. This function is designed to be used as a command in a rule. -# The first argument is the type of file to compile (typically "c" or "cpp"). -# What to compile and the output files are built using the automatic variables -# from a rule. The second argument is the base output directory (typically -# $O). You can add non-propagated object-specific flags defining a variable -# with the name of the target followed with ".EXTRA_FLAGS". +# Compile a source file to an object, generating pre-compiled headers (if +# $(GCH) is non-empty) and dependencies. The pre-compiled headers are generated +# only if the system includes change. This function is designed to be used as +# a command in a rule. The first argument is the type of file to compile +# (typically "c" or "cpp"). What to compile and the output files are built +# using the automatic variables from a rule. The second argument is the base +# output directory (typically $O). You can add non-propagated object-specific +# flags defining a variable with the name of the target followed with +# ".EXTRA_FLAGS". +# +# XXX: The pre-compiled headers generation is not very useful if you include +# local files using #include <...>, because the system headers detection +# is a little simplistic now, it just parse the source file and all its +# dependencies searching for lines starting with "#include <" and +# extracting the included files from them. define compile $(if $(GCH),\ $Vif test -f $2/$*.d; then \ @@ -256,7 +280,8 @@ symlink_include_dir = $(shell \ # have changed (optional). This should be used as a rule action or something # where a shell script is expected. gen_rebuild_flags = $(shell if test x"$2" != x"`cat $1 2>/dev/null`"; then \ - $(if $3,test -f $1 && echo "$3";) \ + $(if $3,test -f $1 && echo "$(if $(COLOR),$(if $(COLOR_WARN),\ + \033[$(COLOR_WARN)m$3\033[00m,$3),$3);";) \ echo "$2" > $1 ; fi) # Include sub-directory's Build.mak. The only argument is a list of @@ -286,43 +311,19 @@ valgrind = $(call exec,$(if $(VALGRIND),$(VALGRIND_CMD)) $1,\ # Overridden flags ################## -# Warn about everything -override CPPFLAGS += -Wall - # Use the includes directories to search for includes override CPPFLAGS += -I$(INCLUDE_DIR) # Let the program know where it will be installed override CPPFLAGS += -DPREFIX=$(prefix) -# Be standard compliant -override CFLAGS += -std=c99 -pedantic -override CXXFLAGS += -std=c++98 -pedantic - # Use the generated library directory to for libraries -override LDFLAGS += -L$L -Wall +override LDFLAGS += -L$L # Make sure the generated libraries can be found export LD_LIBRARY_PATH := $L:$(LD_LIBRARY_PATH) -# Variant flags -################ - -ifeq ($F,dbg) -override CPPFLAGS += -ggdb -DDEBUG -endif - -ifeq ($F,opt) -override CPPFLAGS += -O2 -DNDEBUG -endif - -ifeq ($F,cov) -override CPPFLAGS += -ggdb -pg --coverage -override LDFLAGS += -pg --coverage -endif - - # Automatic dependency handling ################################ @@ -356,20 +357,33 @@ $L/%.pc: $(call replace,$(PC_VARS),$*-PC-) # Run doxygen to build the documentation. It expects the first prerequisite to -# be the Doxyfile to use and the next prerequisites the input files. This rule -# is a little restrictive, but you can always make your own if it doesn't fit -# your needs ;) +# be the Doxyfile to use and the next prerequisites the input files. You +# can override Doxyfile configuration variables by defining a DOXYGEN_VARS +# Make variable for this rule. For example, defining: +# PROJECT_NAME := myproj +# DOXYGEN_VARS := PROJECT_NAME +# You can override Doxygen's PROJECT_NAME configuration option. Optionally, you +# can define DOXYGEN_VARS_PREFIX too, to avoid polluting your Makefile with +# Doxygen variables. For example: +# DOXY.PROJECT_NAME := myproj +# DOXYGEN_VARS_PREFIX := DOXY. +# DOXYGEN_VARS := PROJECT_NAME +# This rule might be still a little restrictive, but you can always make your +# own if it doesn't fit your needs ;) $D/%/doxygen-stamp: $V mkdir -p $(@D) $(call exec,(cat $<; \ echo "FULL_PATH_NAMES=YES"; \ - echo "INPUT=$(patsubst $(