Rename SQL data types so they don't conflict with drivers
[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} ${JLIBTOOL}
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} ${JLIBTOOL}
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}_PRLIBS}
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     # If there's no target, don't build the sources.
345     ifneq "$$(strip $${TARGET})" ""
346
347     # if there's no sources, don't do the automatic object build
348     ifneq "$$(strip $${SOURCES})" ""
349         # This makefile builds one or more objects from source. Validate the
350         # specified sources against the supported source file types.
351         BAD_SRCS := $$(strip $$(filter-out $${ALL_SRC_EXTS},$${SOURCES}))
352         ifneq "$${BAD_SRCS}" ""
353             $$(error Unsupported source file(s) found in ${1} [$${BAD_SRCS}])
354         endif
355
356         # Qualify and canonicalize paths.
357         SOURCES     := $$(call QUALIFY_PATH,$${DIR},$${SOURCES})
358         SOURCES     := $$(call CANONICAL_PATH,$${SOURCES})
359         SRC_INCDIRS := $$(call QUALIFY_PATH,$${DIR},$${SRC_INCDIRS})
360         SRC_INCDIRS := $$(call CANONICAL_PATH,$${SRC_INCDIRS})
361
362         # Save the list of source files for this target.
363         $${TGT}_SOURCES += $${SOURCES}
364
365         # Convert the source file names to their corresponding object file
366         # names.
367         OBJS := $$(addprefix $${BUILD_DIR}/objs/,\
368                    $$(addsuffix .${OBJ_EXT},$$(basename $${SOURCES})))
369
370         # Add the objects to the current target's list of objects, and create
371         # target-specific variables for the objects based on any source
372         # variables that were defined.
373         $${TGT}_OBJS += $${OBJS}
374         $${TGT}_DEPS += $$(addprefix $${BUILD_DIR}/make/src/,\
375                    $$(addsuffix .mk,$$(basename $${SOURCES})))
376
377         # A "hook" to define variables needed by the "legacy" makefiles.
378         $$(eval $$(call ADD_LEGACY_VARIABLES,$$(dir ${1}),$${TGT}))
379
380         $${OBJS}: SRC_CFLAGS := $${SRC_CFLAGS}
381         $${OBJS}: SRC_CXXFLAGS := $${SRC_CXXFLAGS}
382         $${OBJS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
383         $${OBJS}: SRC_INCDIRS := $$(addprefix -I,$${SRC_INCDIRS})
384     endif
385     endif
386
387     ifneq "$$(strip $${SUBMAKEFILES})" ""
388         # This makefile has submakefiles. Recursively include them.
389         $$(foreach MK,$${SUBMAKEFILES},\
390            $$(eval $$(call INCLUDE_SUBMAKEFILE,\
391                       $$(call CANONICAL_PATH,\
392                          $$(call QUALIFY_PATH,$${DIR},$${MK})))))
393     endif
394
395     # Reset the "current" target to it's previous value.
396     TGT_STACK := $$(call POP,$${TGT_STACK})
397     # If we're about to change targets, create the rules for the target
398     ifneq "$${TGT}" "$$(call PEEK,$${TGT_STACK})"
399         # add rules to build the target, and have "all" depend on it.
400         $$(eval $$(call ADD_TARGET_TO_ALL,$${TGT}))
401
402         # A "hook" to add rules for ${TARGET_DIR}/foo, if TARGET_DIR
403         # is defined.  Otherwise, we leave the source directory untouched.
404         $$(eval $$(call ADD_TARGET_DIR,$${TGT}))
405
406         # A "hook" to build the libtool target.
407         $$(eval $$(call ADD_LIBTOOL_TARGET))
408
409         # Choose the correct linker.
410         ifeq "$$(strip $$(filter $${CXX_SRC_EXTS},$${$${TGT}_SOURCES}))" ""
411             ifeq "$${$${TGT}_LINKER}" ""
412                 $${TGT}_LINKER := ${LL}$${LINK.c}
413             endif
414         else
415             ifeq "$${$${TGT}_LINKER}" ""
416                 $${TGT}_LINKER := ${LL}$${LINK.cxx}
417             endif
418         endif
419
420         # add rules to build the target
421         $$(eval $$(call ADD_TARGET_RULE$${$${TGT}_SUFFIX},$${TGT}))
422
423         # generate the clean rule for this target.
424         $$(eval $$(call ADD_CLEAN_RULE,$${TGT}))
425
426         # Hook to add an installation target
427         $$(eval $$(call ADD_INSTALL_TARGET,$${TGT}))
428
429         # Hook to add a configuration target
430         $$(eval $$(call ADD_TARGET_CONFIG,$${TGT}))
431
432         # "hook" for legacy Makefiles
433         $$(eval $$(call ADD_LEGACY_RULE,$${TGT}))
434     endif
435
436     TGT := $$(call PEEK,$${TGT_STACK})
437
438     # Reset the "current" directory to it's previous value.
439     DIR_STACK := $$(call POP,$${DIR_STACK})
440     DIR := $$(call PEEK,$${DIR_STACK})
441 endef
442
443 # MIN - Parameterized "function" that results in the minimum lexical value of
444 #   the two values given.
445 define MIN
446 $(firstword $(sort ${1} ${2}))
447 endef
448
449 # PEEK - Parameterized "function" that results in the value at the top of the
450 #   specified colon-delimited stack.
451 define PEEK
452 $(lastword $(subst :, ,${1}))
453 endef
454
455 # POP - Parameterized "function" that pops the top value off of the specified
456 #   colon-delimited stack, and results in the new value of the stack. Note that
457 #   the popped value cannot be obtained using this function; use peek for that.
458 define POP
459 ${1:%:$(lastword $(subst :, ,${1}))=%}
460 endef
461
462 # PUSH - Parameterized "function" that pushes a value onto the specified colon-
463 #   delimited stack, and results in the new value of the stack.
464 define PUSH
465 ${2:%=${1}:%}
466 endef
467
468 # QUALIFY_PATH - Given a "root" directory and one or more paths, qualifies the
469 #   paths using the "root" directory (i.e. appends the root directory name to
470 #   the paths) except for paths that are absolute.
471 define QUALIFY_PATH
472 $(addprefix ${1}/,$(filter-out /%,${2})) $(filter /%,${2})
473 endef
474
475 ###############################################################################
476 #
477 # Start of Makefile Evaluation
478 #
479 ###############################################################################
480
481 # Older versions of GNU Make lack capabilities needed by boilermake.
482 # With older versions, "make" may simply output "nothing to do", likely leading
483 # to confusion. To avoid this, check the version of GNU make up-front and
484 # inform the user if their version of make doesn't meet the minimum required.
485 MIN_MAKE_VERSION := 3.81
486 MIN_MAKE_VER_MSG := boilermake requires GNU Make ${MIN_MAKE_VERSION} or greater
487 ifeq "${MAKE_VERSION}" ""
488     $(info GNU Make not detected)
489     $(error ${MIN_MAKE_VER_MSG})
490 endif
491 ifneq "${MIN_MAKE_VERSION}" "$(call MIN,${MIN_MAKE_VERSION},${MAKE_VERSION})"
492     $(info This is GNU Make version ${MAKE_VERSION})
493     $(error ${MIN_MAKE_VER_MSG})
494 endif
495
496 # Define the source file extensions that we know how to handle.
497 OBJ_EXT := o
498 C_SRC_EXTS := %.c
499 CXX_SRC_EXTS := %.C %.cc %.cp %.cpp %.CPP %.cxx %.c++
500 ALL_SRC_EXTS := ${C_SRC_EXTS} ${CXX_SRC_EXTS}
501
502 # Initialize global variables.
503 ALL_TGTS :=
504 DEFS :=
505 DIR_STACK :=
506 INCDIRS :=
507 TGT_STACK :=
508
509 ifeq "${top_builddir}" ""
510     top_builddir := .
511 endif
512
513 # Ensure that valid values are set for BUILD_DIR
514 ifeq "$(strip ${BUILD_DIR})" ""
515     ifeq "${top_builddir}" "${PWD}"
516         BUILD_DIR := build
517     else
518         BUILD_DIR := ${top_builddir}/build
519     endif
520 else
521     BUILD_DIR := $(call CANONICAL_PATH,${BUILD_DIR})
522 endif
523
524 # Define compilers and linkers
525 #
526 COMPILE.c = ${CC}
527 COMPILE.cxx = ${CXX}
528 CPP = cc -E
529 LINK.c = ${CC}
530 LINK.cxx = ${CXX}
531
532 # Set ECHO to "true" for *very* quiet builds
533 ECHO = echo
534
535 # Define the "all" target (which simply builds all user-defined targets) as the
536 # default goal.
537 .PHONY: all
538 all: 
539
540 # Add "clean" rules to remove all build-generated files.
541 .PHONY: clean
542 clean:
543
544 top_makedir := $(dir $(lastword ${MAKEFILE_LIST}))
545
546 -include ${top_makedir}/install.mk
547 -include ${top_makedir}/libtool.mk
548
549 # Include the main user-supplied submakefile. This also recursively includes
550 # all other user-supplied submakefiles.
551 $(eval $(call INCLUDE_SUBMAKEFILE,${top_builddir}/main.mk))
552
553 # Perform post-processing on global variables as needed.
554 DEFS := $(addprefix -D,${DEFS})
555 INCDIRS := $(addprefix -I,$(call CANONICAL_PATH,${INCDIRS}))
556
557 # Add pattern rule(s) for creating compiled object code from C source.
558 $(foreach EXT,${C_SRC_EXTS},\
559   $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_C_CMDS})))
560
561 # Add pattern rule(s) for creating compiled object code from C++ source.
562 $(foreach EXT,${CXX_SRC_EXTS},\
563   $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_CXX_CMDS})))
564
565 # Don't include the target dependencies if we're doing a "make clean"
566 # Future: have a list of targets that don't require dependency generation,
567 #  and see if MAKECMDGOALS is one of them.
568 ifneq "$(MAKECMDGOALS)" "clean"
569     $(foreach TGT,${ALL_TGTS},\
570       $(eval -include ${${TGT}_DEPS}))
571 endif