6888f868436097e65f60466edf7a2ab85d4ea531
[freeradius.git] / scripts / boiler.mk
1 # boilermake: A reusable, but flexible, boilerplate Makefile.
2 #
3 # Copyright 2008, 2009, 2010 Dan Moulding, Alan T. DeKok
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Caution: Don't edit this Makefile! Create your own main.mk and other
19 #          submakefiles, which will be included by this Makefile.
20 #          Only edit this if you need to modify boilermake's behavior (fix
21 #          bugs, add features, etc).
22
23 # Note: Parameterized "functions" in this makefile that are marked with
24 #       "USE WITH EVAL" are only useful in conjuction with eval. This is
25 #       because those functions result in a block of Makefile syntax that must
26 #       be evaluated after expansion. Since they must be used with eval, most
27 #       instances of "$" within them need to be escaped with a second "$" to
28 #       accomodate the double expansion that occurs when eval is invoked.
29
30 # ADD_CLEAN_RULE - Parameterized "function" that adds a new rule and phony
31 #   target for cleaning the specified target (removing its build-generated
32 #   files).
33 #
34 #   USE WITH EVAL
35 #
36 define ADD_CLEAN_RULE
37     clean: clean_$(notdir ${1})
38     .PHONY: clean_$(notdir ${1})
39     clean_$(notdir ${1}):
40         @$(strip rm -f ${${1}_BUILD}/${1} ${${1}_NOLIBTOOL} ${${1}_BUILD}/${${1}_RELINK} $${${1}_OBJS} $${${1}_DEPS} $${${1}_OBJS:%.${OBJ_EXT}=%.[do]}) $(if ${TARGET_DIR},$${TARGET_DIR}/$(notdir ${1}))
41         $${${1}_POSTCLEAN}
42
43 endef
44
45 # FILTER_DEPENDS: function to turn a *.d file into a *.mk file.
46 #   We start off with the dependencies as created by the compiler,
47 #   CPP, or makedepend.  We then ensure that there is an empty dependency
48 #   for each header file.  The blank target ensures that the build
49 #   can proceed even if the header file has been deleted.
50 #
51 #  COMMON filters:
52 #       remove comments
53 #       remove dependencies on global include files
54 #       remove empty dependencies
55 #       remove CPP hacks like "foo: <built-in>"
56 #
57 #  1) Filter the .d file to remove unnecessary cruft
58 #
59 #       COMMON
60 #       Replace ".o" with "${OBJ_EXT}"
61 #       delete empty continuation lines
62 #       delete blank lines
63 #       replace "build/" with "${BUILD_DIR}/" when it's at the start of a line
64 #       delete references to ${BUILD_DIR}/make/include, the "config.mk"
65 #       file adds these dependencies automatically.
66 #       replace "build/" with "${BUILD_DIR}/" when it's in the middle of a line
67 #       
68 #       remove sequential duplicate lines
69 #       
70 #  2) Create empty dependencies from the files
71 #
72 #       COMMON
73 #       remove existing targets
74 #       remove continuations (to make the targets stand by themselves)
75 #       delete blank lines
76 #       add in empty dependency for each file.
77 #       remove sequential duplicate lines
78 #
79 define FILTER_DEPENDS
80         @mkdir -p $$(dir $${BUILD_DIR}/make/src/$$*)
81         @mkdir -p $$(dir $${BUILD_DIR}/objs/$$*)
82         @sed  -e 's/#.*//' \
83           -e 's, /[^: ]*,,g' \
84           -e 's,^ *[^:]* *: *$$$$,,' \
85           -e '/: </ d' \
86           -e 's/\.o: /.$$$${OBJ_EXT}: /' \
87           -e '/^ *\\$$$$/ d' \
88           -e 's,^$${BUILD_DIR},$$$${BUILD_DIR},' \
89           -e 's, $${BUILD_DIR}/make/include/[^ :]*,,' \
90           -e 's, $${BUILD_DIR}, $$$${BUILD_DIR},' \
91           < $${BUILD_DIR}/objs/$$*.d | sed -e '$$$$!N; /^\(.*\)\n\1$$$$/!P; D' \
92           >  $${BUILD_DIR}/make/src/$$*.mk
93         @sed -e 's/#.*//' \
94           -e 's, /[^: ]*,,g' \
95           -e 's,^ *[^:]* *: *$$$$,,' \
96           -e '/: </ d' \
97           -e 's, $${BUILD_DIR}/make/include/[^ :]*,,' \
98           -e 's/^[^:]*: *//' \
99           -e 's/ *\\$$$$//' \
100           -e 's/$$$$/ :/' \
101           < $${BUILD_DIR}/objs/$$*.d | sed -e '$$$$!N; /^\(.*\)\n\1$$$$/!P; D' \
102          >> $${BUILD_DIR}/make/src/$$*.mk
103          @rm -f $${BUILD_DIR}/objs/$$*.d
104 endef
105
106 # ADD_OBJECT_RULE - Parameterized "function" that adds a pattern rule, using
107 #   the commands from the second argument, for building object files from
108 #   source files with the filename extension specified in the first argument.
109 #
110 #   This function assumes that the C/C++ sources files have filenames
111 #   *relative* to the source root.  If they have absolute pathnames, it
112 #   creates the wrong filenames...
113 #
114 #   USE WITH EVAL
115 #
116 ifeq "${CPP_MAKEDEPEND}" "yes"
117 define ADD_OBJECT_RULE
118 $${BUILD_DIR}/objs/%.${OBJ_EXT} $${BUILD_DIR}/objs/%.d: ${1}
119         ${2}
120         $${CPP} $${CPPFLAGS} $${SRC_INCDIRS} $${SRC_DEFS} $$< | sed \
121           -n 's,^\# *[0-9][0-9]* *"\([^"]*\)".*,$$@: \1,p' > $${BUILD_DIR}/objs/$$*.d
122 ${FILTER_DEPENDS}
123 endef
124
125 else
126 define ADD_OBJECT_RULE
127 $${BUILD_DIR}/objs/%.${OBJ_EXT} $${BUILD_DIR}/objs/%.d: ${1}
128         ${2}
129 ${FILTER_DEPENDS}
130 endef
131 endif
132
133 # ADD_TARGET_DIR - Parameterized "function" that makes a link from
134 #   TARGET_DIR to the executable or library in the BUILD_DIR directory.
135 #
136 #   USE WITH EVAL
137 #
138 ifneq "${TARGET_DIR}" ""
139     define ADD_TARGET_DIR
140         all: $${TARGET_DIR}/$$(notdir ${1})
141
142         $${TARGET_DIR}/$$(notdir ${1}): ${1}
143             [ -f $${TARGET_DIR}/$$(notdir ${1}) ] || ln -s ${1} $${TARGET_DIR}/$$(notdir ${1})
144
145     endef
146 endif
147
148 # ADD_TARGET_TO_ALL - Parameterized "function" that adds the target,
149 #   and makes "all" depend on it.
150 #
151 #   USE WITH EVAL
152 #
153 define ADD_TARGET_TO_ALL
154     all: ${1}
155
156 endef
157
158 # ADD_TARGET_RULE.* - Parameterized "functions" that adds a new target to the
159 #   Makefile.  There should be one ADD_TARGET_RULE definition for each
160 #   type of target that is used in the build.  
161 #
162 #   New rules can be added by copying one of the existing ones, and
163 #   replacing the line after the "mkdir"
164 #
165
166 # ADD_TARGET_RULE.exe - Build an executable target.
167 #
168 #   USE WITH EVAL
169 #
170 define ADD_TARGET_RULE.exe
171     # So "make ${1}" works
172     .PHONY: ${1}
173     ${1}: $${${1}_BUILD}/${1}
174
175     # Create executable ${1}
176     $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PRBIN} $${${1}_PRLIBS}
177             @$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
178             @echo LINK $${${1}_BUILD}/${1}
179             @$${${1}_LINKER} -o $${${1}_BUILD}/${1} $${RPATH_FLAGS} $${LDFLAGS} \
180                 $${${1}_LDFLAGS} $${${1}_OBJS} $${${1}_PRLIBS} \
181                 $${LDLIBS} $${${1}_LDLIBS}
182             @$${${1}_POSTMAKE}
183
184 endef
185
186 # ADD_TARGET_RULE.a - Build a static library target.
187 #
188 #   USE WITH EVAL
189 #
190 define ADD_TARGET_RULE.a
191     # So "make ${1}" works
192     .PHONY: ${1}
193     ${1}: $${${1}_BUILD}/${1}
194
195     # Create static library ${1}
196     $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PREREQS}
197             @$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
198             @echo LINK $${${1}_BUILD}/${1}
199             @$${AR} $${ARFLAGS} $${${1}_BUILD}/${1} $${${1}_OBJS}
200             @$${${1}_POSTMAKE}
201
202 endef
203
204 # ADD_TARGET_RULE.so - Build a ".so" target.
205 #
206 #   USE WITH EVAL
207 #
208 define ADD_TARGET_RULE.so
209 $(error Please add rules to build a ".so" file.)
210 endef
211
212 # ADD_TARGET_RULE.dll - Build a ".dll" target.
213 #
214 #   USE WITH EVAL
215 #
216 define ADD_TARGET_RULE.dll
217 $(error Please add rules to build a ".dll" file.)
218 endef
219
220 # ADD_TARGET_RULE.dylib - Build a ".dylib" target.
221 #
222 #   USE WITH EVAL
223 #
224 define ADD_TARGET_RULE.dylib
225 $(error Please add rules to build a ".dylib" file.)
226 endef
227
228 # CANONICAL_PATH - Given one or more paths, converts the paths to the canonical
229 #   form. The canonical form is the path, relative to the project's top-level
230 #   directory (the directory from which "make" is run), and without
231 #   any "./" or "../" sequences. For paths that are not  located below the
232 #   top-level directory, the canonical form is the absolute path (i.e. from
233 #   the root of the filesystem) also without "./" or "../" sequences.
234 define CANONICAL_PATH
235 $(patsubst ${CURDIR}/%,%,$(abspath ${1}))
236 endef
237
238 # COMPILE_C_CMDS - Commands for compiling C source code.
239 define COMPILE_C_CMDS
240         @mkdir -p $(dir $@)
241         @echo CC $<
242         @$(strip ${COMPILE.c} -o $@ -c -MD ${CFLAGS} ${SRC_CFLAGS} ${INCDIRS} \
243             ${SRC_INCDIRS} ${SRC_DEFS} ${DEFS} $<)
244 endef
245
246 # COMPILE_CXX_CMDS - Commands for compiling C++ source code.
247 define COMPILE_CXX_CMDS
248         @mkdir -p $(dir $@)
249         @$(strip ${COMPILE.cxx} -o $@ -c -MD ${CXXFLAGS} ${SRC_CXXFLAGS} ${INCDIRS} \
250             ${SRC_INCDIRS} ${SRC_DEFS} ${DEFS} $<)
251 endef
252
253 # INCLUDE_SUBMAKEFILE - Parameterized "function" that includes a new
254 #   "submakefile" fragment into the overall Makefile. It also recursively
255 #   includes all submakefiles of the specified submakefile fragment.
256 #
257 #   USE WITH EVAL
258 #
259 define INCLUDE_SUBMAKEFILE
260     # Initialize all variables that can be defined by a makefile fragment, then
261     # include the specified makefile fragment.
262     TARGET :=
263     TGT_LDFLAGS :=
264     TGT_LDLIBS :=
265     TGT_LINKER :=
266     TGT_POSTCLEAN :=
267     TGT_POSTMAKE :=
268     TGT_PREREQS :=
269     TGT_POSTINSTALL :=
270     TGT_INSTALLDIR := ..
271     TGT_CHECK_HEADERS :=
272     TGT_CHECK_LIBS :=
273
274     SOURCES :=
275     SRC_CFLAGS :=
276     SRC_CXXFLAGS :=
277     SRC_DEFS :=
278     SRC_INCDIRS :=
279     MAN :=
280
281     SUBMAKEFILES :=
282
283     # A directory stack is maintained so that the correct paths are used as we
284     # recursively include all submakefiles. Get the makefile's directory and
285     # push it onto the stack.
286     DIR := $(call CANONICAL_PATH,$(dir ${1}))
287     DIR_STACK := $$(call PUSH,$${DIR_STACK},$${DIR})
288
289     include ${1}
290
291     # Initialize internal local variables.
292     OBJS :=
293
294     # Determine which target this makefile's variables apply to. A stack is
295     # used to keep track of which target is the "current" target as we
296     # recursively include other submakefiles.
297     ifneq "$$(strip $${TARGET})" ""
298         # This makefile defined a new target. Target variables defined by this
299         # makefile apply to this new target. Initialize the target's variables.
300
301         # libs go into ${BUILD_DIR}/lib
302         # everything else goes into ${BUILD_DIR}/bin
303 #        TGT := $$(strip $$(if $$(suffix $${TARGET}),$${BUILD_DIR}/lib,$${BUILD_DIR}/bin)/$${TARGET})
304         TGT := $${TARGET}
305
306         # A "hook" to rewrite "libfoo.a" -> "libfoo.la" when using libtool
307         $$(eval $$(call ADD_LIBTOOL_SUFFIX))
308
309         ALL_TGTS += $${TGT}
310         $${TGT}_LDFLAGS := $${TGT_LDFLAGS}
311         $${TGT}_LDLIBS := $${TGT_LDLIBS}
312         $${TGT}_LINKER := $${TGT_LINKER}
313         $${TGT}_POSTMAKE := $${TGT_POSTMAKE}
314         $${TGT}_POSTCLEAN := $${TGT_POSTCLEAN}
315         $${TGT}_POSTINSTALL := $${TGT_POSTINSTALL}
316         $${TGT}_PREREQS := $${TGT_PREREQS}
317         $${TGT}_PRBIN := $$(addprefix $${BUILD_DIR}/bin/,$$(filter-out %.a %.so %.la,$${TGT_PREREQS}))
318         $${TGT}_PRLIBS := $$(addprefix $${BUILD_DIR}/lib/,$$(filter %.a %.so %.la,$${TGT_PREREQS}))
319         $${TGT}_DEPS :=
320         $${TGT}_OBJS :=
321         $${TGT}_SOURCES :=
322         $${TGT}_MAN := $${MAN}
323         $${TGT}_SUFFIX := $$(if $$(suffix $${TGT}),$$(suffix $${TGT}),.exe)
324         $${TGT}_BUILD := $$(if $$(suffix $${TGT}),$${BUILD_DIR}/lib,$${BUILD_DIR}/bin)
325         $${TGT}_MAKEFILES += ${1}
326         $${TGT}_CHECK_HEADERS := $${TGT_CHECK_HEADERS}
327         $${TGT}_CHECK_LIBS := $${TGT_CHECK_LIBS}
328     else
329         # The values defined by this makefile apply to the the "current" target
330         # as determined by which target is at the top of the stack.
331         TGT := $$(strip $$(call PEEK,$${TGT_STACK}))
332         $${TGT}_LDFLAGS   += $${TGT_LDFLAGS}
333         $${TGT}_LDLIBS    += $${TGT_LDLIBS}
334         $${TGT}_POSTCLEAN += $${TGT_POSTCLEAN}
335         $${TGT}_POSTMAKE  += $${TGT_POSTMAKE}
336         $${TGT}_PREREQS   += $${TGT_PREREQS}
337     endif
338
339     # Push the current target onto the target stack.
340     TGT_STACK := $$(call PUSH,$${TGT_STACK},$${TGT})
341
342     ifneq "$$(strip $${SOURCES})" ""
343         # This makefile builds one or more objects from source. Validate the
344         # specified sources against the supported source file types.
345         BAD_SRCS := $$(strip $$(filter-out $${ALL_SRC_EXTS},$${SOURCES}))
346         ifneq "$${BAD_SRCS}" ""
347             $$(error Unsupported source file(s) found in ${1} [$${BAD_SRCS}])
348         endif
349
350         # Qualify and canonicalize paths.
351         SOURCES     := $$(call QUALIFY_PATH,$${DIR},$${SOURCES})
352         SOURCES     := $$(call CANONICAL_PATH,$${SOURCES})
353         SRC_INCDIRS := $$(call QUALIFY_PATH,$${DIR},$${SRC_INCDIRS})
354         SRC_INCDIRS := $$(call CANONICAL_PATH,$${SRC_INCDIRS})
355
356         # Save the list of source files for this target.
357         $${TGT}_SOURCES += $${SOURCES}
358
359         # Convert the source file names to their corresponding object file
360         # names.
361         OBJS := $$(addprefix $${BUILD_DIR}/objs/,\
362                    $$(addsuffix .${OBJ_EXT},$$(basename $${SOURCES})))
363
364         # Add the objects to the current target's list of objects, and create
365         # target-specific variables for the objects based on any source
366         # variables that were defined.
367         $${TGT}_OBJS += $${OBJS}
368         $${TGT}_DEPS += $$(addprefix $${BUILD_DIR}/make/src/,\
369                    $$(addsuffix .mk,$$(basename $${SOURCES})))
370
371         # A "hook" to define variables needed by the "legacy" makefiles.
372         $$(eval $$(call ADD_LEGACY_VARIABLES,$$(dir ${1}),$${TGT}))
373
374         $${OBJS}: SRC_CFLAGS := $${SRC_CFLAGS}
375         $${OBJS}: SRC_CXXFLAGS := $${SRC_CXXFLAGS}
376         $${OBJS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
377         $${OBJS}: SRC_INCDIRS := $$(addprefix -I,$${SRC_INCDIRS})
378     endif
379
380     ifneq "$$(strip $${SUBMAKEFILES})" ""
381         # This makefile has submakefiles. Recursively include them.
382         $$(foreach MK,$${SUBMAKEFILES},\
383            $$(eval $$(call INCLUDE_SUBMAKEFILE,\
384                       $$(call CANONICAL_PATH,\
385                          $$(call QUALIFY_PATH,$${DIR},$${MK})))))
386     endif
387
388     # Reset the "current" target to it's previous value.
389     TGT_STACK := $$(call POP,$${TGT_STACK})
390     # If we're about to change targets, create the rules for the target
391     ifneq "$${TGT}" "$$(call PEEK,$${TGT_STACK})"
392         # add rules to build the target, and have "all" depend on it.
393         $$(eval $$(call ADD_TARGET_TO_ALL,$${TGT}))
394
395         # A "hook" to add rules for ${TARGET_DIR}/foo, if TARGET_DIR
396         # is defined.  Otherwise, we leave the source directory untouched.
397         $$(eval $$(call ADD_TARGET_DIR,$${TGT}))
398
399         # A "hook" to build the libtool target.
400         $$(eval $$(call ADD_LIBTOOL_TARGET))
401
402         # Choose the correct linker.
403         ifeq "$$(strip $$(filter $${CXX_SRC_EXTS},$${$${TGT}_SOURCES}))" ""
404             ifeq "$${$${TGT}_LINKER}" ""
405                 $${TGT}_LINKER := ${LL}$${LINK.c}
406             endif
407         else
408             ifeq "$${$${TGT}_LINKER}" ""
409                 $${TGT}_LINKER := ${LL}$${LINK.cxx}
410             endif
411         endif
412
413         # add rules to build the target
414         $$(eval $$(call ADD_TARGET_RULE$${$${TGT}_SUFFIX},$${TGT}))
415
416         # generate the clean rule for this target.
417         $$(eval $$(call ADD_CLEAN_RULE,$${TGT}))
418
419         # Hook to add an installation target
420         $$(eval $$(call ADD_INSTALL_TARGET,$${TGT}))
421
422         # Hook to add a configuration target
423         $$(eval $$(call ADD_TARGET_CONFIG,$${TGT}))
424
425         # "hook" for legacy Makefiles
426         $$(eval $$(call ADD_LEGACY_RULE,$${TGT}))
427     endif
428
429     TGT := $$(call PEEK,$${TGT_STACK})
430
431     # Reset the "current" directory to it's previous value.
432     DIR_STACK := $$(call POP,$${DIR_STACK})
433     DIR := $$(call PEEK,$${DIR_STACK})
434 endef
435
436 # MIN - Parameterized "function" that results in the minimum lexical value of
437 #   the two values given.
438 define MIN
439 $(firstword $(sort ${1} ${2}))
440 endef
441
442 # PEEK - Parameterized "function" that results in the value at the top of the
443 #   specified colon-delimited stack.
444 define PEEK
445 $(lastword $(subst :, ,${1}))
446 endef
447
448 # POP - Parameterized "function" that pops the top value off of the specified
449 #   colon-delimited stack, and results in the new value of the stack. Note that
450 #   the popped value cannot be obtained using this function; use peek for that.
451 define POP
452 ${1:%:$(lastword $(subst :, ,${1}))=%}
453 endef
454
455 # PUSH - Parameterized "function" that pushes a value onto the specified colon-
456 #   delimited stack, and results in the new value of the stack.
457 define PUSH
458 ${2:%=${1}:%}
459 endef
460
461 # QUALIFY_PATH - Given a "root" directory and one or more paths, qualifies the
462 #   paths using the "root" directory (i.e. appends the root directory name to
463 #   the paths) except for paths that are absolute.
464 define QUALIFY_PATH
465 $(addprefix ${1}/,$(filter-out /%,${2})) $(filter /%,${2})
466 endef
467
468 ###############################################################################
469 #
470 # Start of Makefile Evaluation
471 #
472 ###############################################################################
473
474 # Older versions of GNU Make lack capabilities needed by boilermake.
475 # With older versions, "make" may simply output "nothing to do", likely leading
476 # to confusion. To avoid this, check the version of GNU make up-front and
477 # inform the user if their version of make doesn't meet the minimum required.
478 MIN_MAKE_VERSION := 3.81
479 MIN_MAKE_VER_MSG := boilermake requires GNU Make ${MIN_MAKE_VERSION} or greater
480 ifeq "${MAKE_VERSION}" ""
481     $(info GNU Make not detected)
482     $(error ${MIN_MAKE_VER_MSG})
483 endif
484 ifneq "${MIN_MAKE_VERSION}" "$(call MIN,${MIN_MAKE_VERSION},${MAKE_VERSION})"
485     $(info This is GNU Make version ${MAKE_VERSION})
486     $(error ${MIN_MAKE_VER_MSG})
487 endif
488
489 # Define the source file extensions that we know how to handle.
490 OBJ_EXT := o
491 C_SRC_EXTS := %.c
492 CXX_SRC_EXTS := %.C %.cc %.cp %.cpp %.CPP %.cxx %.c++
493 ALL_SRC_EXTS := ${C_SRC_EXTS} ${CXX_SRC_EXTS}
494
495 # Initialize global variables.
496 ALL_TGTS :=
497 DEFS :=
498 DIR_STACK :=
499 INCDIRS :=
500 TGT_STACK :=
501
502 ifeq "${top_builddir}" ""
503     top_builddir := .
504 endif
505
506 # Ensure that valid values are set for BUILD_DIR
507 ifeq "$(strip ${BUILD_DIR})" ""
508     ifeq "${top_builddir}" "${PWD}"
509         BUILD_DIR := build
510     else
511         BUILD_DIR := ${top_builddir}/build
512     endif
513 else
514     BUILD_DIR := $(call CANONICAL_PATH,${BUILD_DIR})
515 endif
516
517 # Define compilers and linkers
518 #
519 COMPILE.c = ${CC}
520 COMPILE.cxx = ${CXX}
521 CPP = cc -E
522 LINK.c = ${CC}
523 LINK.cxx = ${CXX}
524
525 # Define the "all" target (which simply builds all user-defined targets) as the
526 # default goal.
527 .PHONY: all
528 all: 
529
530 # Add "clean" rules to remove all build-generated files.
531 .PHONY: clean
532 clean:
533
534 top_makedir := $(dir $(lastword ${MAKEFILE_LIST}))
535
536 -include ${top_makedir}/install.mk
537 -include ${top_makedir}/libtool.mk
538
539 # Include the main user-supplied submakefile. This also recursively includes
540 # all other user-supplied submakefiles.
541 $(eval $(call INCLUDE_SUBMAKEFILE,${top_builddir}/main.mk))
542
543 # Perform post-processing on global variables as needed.
544 DEFS := $(addprefix -D,${DEFS})
545 INCDIRS := $(addprefix -I,$(call CANONICAL_PATH,${INCDIRS}))
546
547 # Add pattern rule(s) for creating compiled object code from C source.
548 $(foreach EXT,${C_SRC_EXTS},\
549   $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_C_CMDS})))
550
551 # Add pattern rule(s) for creating compiled object code from C++ source.
552 $(foreach EXT,${CXX_SRC_EXTS},\
553   $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_CXX_CMDS})))
554
555 # Don't include the target dependencies if we're doing a "make clean"
556 # Future: have a list of targets that don't require dependency generation,
557 #  and see if MAKECMDGOALS is one of them.
558 ifneq "$(MAKECMDGOALS)" "clean"
559     $(foreach TGT,${ALL_TGTS},\
560       $(eval -include ${${TGT}_DEPS}))
561 endif