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