- support on-the-fly dependency file generation with gcc >=3.0
(the dependency files are generated while compiling the object
file, eliminating another gcc+sed invocation)
- support for using makedepend -f- for generating dependencies
E.g.: make cfg MKDEP="makedepend -f-". In general gcc should be
preferred if available (use this if you don't have gcc and your
compiler doesn't generate good deps).
# from the host (andrei)
# 2009-10-01 use -fsigned-char for gcc on ppc, ppc64, arm and arm6
# (on those archs char is unsigned by default) (andrei)
# from the host (andrei)
# 2009-10-01 use -fsigned-char for gcc on ppc, ppc64, arm and arm6
# (on those archs char is unsigned by default) (andrei)
+# 2010-03-10 added CC_MKDEP_OPTS, which contains to the list of options
+# needed to generate dependencies on-the-fly while compiling
+# or is empty if the compiler doesn't support it (andrei)
quiet?=$(if $(filter 1 yes on,$(Q)),silent,verbose)
quiet?=$(if $(filter 1 yes on,$(Q)),silent,verbose)
# -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
# sed with POSIX.1 regex doesn't support |, + or ?
# (darwin, solaris ...) => this complicated expression
# -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
# sed with POSIX.1 regex doesn't support |, + or ?
# (darwin, solaris ...) => this complicated expression
#transform gcc version into 2.9x or 3.0
CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
sed -e 's/[^0-9]*-\(.*\)/\1/'| \
#transform gcc version into 2.9x or 3.0
CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
sed -e 's/[^0-9]*-\(.*\)/\1/'| \
's/3\.[4-9]/3.4/' -e 's/4\.[0-1]\..*/4.x/' -e \
's/4\.[0-1]/4.x/' -e 's/4\.[2-9]\..*/4.2+/' -e \
's/4\.[2-9]$$/4.2+/')
's/3\.[4-9]/3.4/' -e 's/4\.[0-1]\..*/4.x/' -e \
's/4\.[0-1]/4.x/' -e 's/4\.[2-9]\..*/4.2+/' -e \
's/4\.[2-9]$$/4.2+/')
+ifeq (,$(strip $(filter-out 3.0 3.4 4.x 4.2+,$(CC_SHORTVER))))
+ # dependencies can be generated on-the-fly while compiling *.c
+ CC_MKDEP_OPTS=-MMD -MP
+endif # 3.0 <= $(CC_SHORTVER) <= 4.x
+endif # gcc
ifneq (, $(findstring Sun, $(CC_LONGVER)))
CC_NAME=suncc
ifneq (, $(findstring Sun, $(CC_LONGVER)))
CC_NAME=suncc
saved_fixed_vars:= MAIN_NAME CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
SRC_NAME RELEASE OS ARCH \
C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
saved_fixed_vars:= MAIN_NAME CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
SRC_NAME RELEASE OS ARCH \
C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
LIB_SUFFIX LIB_PREFIX \
LIBS \
MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
LIB_SUFFIX LIB_PREFIX \
LIBS \
# used only for "temporary" defines/includes inside modules or
# libs, C_DEFS and C_INCLUDES are used for the common stuff)
# (andrei)
# used only for "temporary" defines/includes inside modules or
# libs, C_DEFS and C_INCLUDES are used for the common stuff)
# (andrei)
+# 2010-03-09 generate dependencies when compiling .o instead of on
+# include .d and fix build errors when a .h is moved
+# support for using MKDEP="makedepend-f-" (andrei)
+# 2010-03-10 support for on the-fly dependency generation (while compiling,
+# see CC_MKDEP_OPTS) (andrei)
# check if the saved cfg corresponds with the current one
# check if the saved cfg corresponds with the current one
cmd_LD=$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) \
-o $(NAME)
cmd_LD=$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) \
-o $(NAME)
+ifeq (,$(CC_MKDEP_OPTS))
+# if CCC_MKDEP_OPTS is empty => CC cannot generate dependencies on the fly
+cmd_MKDEP=$(MKDEP) $(filter -D% -I%,$(CFLAGS)) $(C_INCLUDES) $(INCLUDES) \
+ $(C_DEFS) $(DEFS) $< \
+ | sed -e 's/\#.*//' -e '/:[ ]*$$/d' -e '/^[ ]*$$/d' \
+ -e 's|.*:|$@: $$(wildcard |' -e 's/\([^\\]\)$$/\1)/'> $*.d
+else
+# deps can be generated on the fly by cmd_CC
+cmd_CC+=$(CC_MKDEP_OPTS)
+# no MKDEP command any more
+cmd_MKDEP=
+endif # CC_MKDEP_OPTS
+
# what will be displayed if quiet==silent
silent_cmd_CC=CC ($(CC)) [$(strip $(crt_type) $(NAME))] $@
silent_cmd_LD=LD ($(LD)) [$(strip $(crt_type) $(NAME))] $@
# what will be displayed if quiet==silent
silent_cmd_CC=CC ($(CC)) [$(strip $(crt_type) $(NAME))] $@
silent_cmd_LD=LD ($(LD)) [$(strip $(crt_type) $(NAME))] $@
#implicit rules
%.o:%.c $(ALLDEP)
$(call exec_cmd,CC)
#implicit rules
%.o:%.c $(ALLDEP)
$(call exec_cmd,CC)
- @$(MKDEP) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) $< \
- | sed -e 's/#.*//' -e '/:[ ]*$$/d' -e '/^[ ]*$$/d' \
- -e 's#.*:#$@: $$(wildcard #g' -e 's/\([^\\]\)$$/\1)/'> $*.d
# use RPATH and SER_LIBS if needed (make install and the module depends
# on some ser libs)
# use RPATH and SER_LIBS if needed (make install and the module depends
# on some ser libs)