"Fossies" - the Fresh Open Source Software Archive

Member "freeradius-server-3.0.23/scripts/boiler.mk" (10 Jun 2021, 22631 Bytes) of package /linux/misc/freeradius-server-3.0.23.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Make source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "boiler.mk": 3.0.22_vs_3.0.23.

    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 #
   31 #  You can watch what it's doing by:
   32 #
   33 #   $ VERBOSE=1 make ... args ...
   34 #
   35 ifeq "${VERBOSE}" ""
   36     Q=@
   37 else
   38     Q=
   39 endif
   40 
   41 # ADD_CLEAN_RULE - Parameterized "function" that adds a new rule and phony
   42 #   target for cleaning the specified target (removing its build-generated
   43 #   files).
   44 #
   45 #   USE WITH EVAL
   46 #
   47 define ADD_CLEAN_RULE
   48     clean: clean_$(notdir ${1})
   49     .PHONY: clean_$(notdir ${1})
   50     clean_$(notdir ${1}):
   51     $(Q)$(strip rm -f ${${1}_BUILD}/${1} $${${1}_OBJS} $${${1}_DEPS} $${${1}_OBJS:%.${OBJ_EXT}=%.[do]}) $(if ${TARGET_DIR},$${TARGET_DIR}/$(notdir ${1}))
   52     $${${1}_POSTCLEAN}
   53 
   54 endef
   55 
   56 # FILTER_DEPENDS: function to turn a *.d file into a *.mk file.
   57 #   We start off with the dependencies as created by the compiler,
   58 #   CPP, or makedepend.  We then ensure that there is an empty dependency
   59 #   for each header file.  The blank target ensures that the build
   60 #   can proceed even if the header file has been deleted.
   61 #
   62 #  COMMON filters:
   63 #   remove comments
   64 #   remove dependencies on global include files
   65 #   remove empty dependencies
   66 #   remove CPP hacks like "foo: <built-in>"
   67 #
   68 #  1) Filter the .d file to remove unnecessary cruft
   69 #
   70 #   COMMON
   71 #   Replace ".o" with "${OBJ_EXT}"
   72 #   delete empty continuation lines
   73 #   delete blank lines
   74 #   replace "build/" with "${BUILD_DIR}/" when it's at the start of a line
   75 #   delete references to ${BUILD_DIR}/make/include, the "config.mk"
   76 #   file adds these dependencies automatically.
   77 #   replace "build/" with "${BUILD_DIR}/" when it's in the middle of a line
   78 #
   79 #   remove sequential duplicate lines
   80 #
   81 #  2) Create empty dependencies from the files
   82 #
   83 #   COMMON
   84 #   remove existing targets
   85 #   remove continuations (to make the targets stand by themselves)
   86 #   delete blank lines
   87 #   add in empty dependency for each file.
   88 #   remove sequential duplicate lines
   89 #
   90 define FILTER_DEPENDS
   91     $(Q)mkdir -p $$(dir $${BUILD_DIR}/make/src/$$*)
   92     $(Q)mkdir -p $$(dir $${BUILD_DIR}/objs/$$*)
   93     $(Q)sed  -e 's/#.*//' \
   94       -e 's,^$${top_srcdir},$$$${top_srcdir},' \
   95       -e 's, $${top_srcdir}, $$$${top_srcdir},' \
   96       -e 's,^$${BUILD_DIR},$$$${BUILD_DIR},' \
   97       -e 's, $${BUILD_DIR}/make/include/[^ :]*,,' \
   98       -e 's, $${BUILD_DIR}, $$$${BUILD_DIR},' \
   99       -e 's, /[^: ]*,,g' \
  100       -e 's,^ *[^:]* *: *$$$$,,' \
  101       -e '/: </ d' \
  102       -e 's/\.o: /.$$$${OBJ_EXT}: /' \
  103       -e '/^ *\\$$$$/ d' \
  104       < $${BUILD_DIR}/objs/$$*.d | sed -e '$$$$!N; /^\(.*\)\n\1$$$$/!P; D' \
  105       >  $${BUILD_DIR}/make/src/$$*.mk
  106     $(Q)sed -e 's/#.*//' \
  107       -e 's, $${BUILD_DIR}/make/include/[^ :]*,,' \
  108       -e 's, /[^: ]*,,g' \
  109       -e 's,^ *[^:]* *: *$$$$,,' \
  110       -e '/: </ d' \
  111       -e 's/^[^:]*: *//' \
  112       -e 's/ *\\$$$$//' \
  113       -e 's/$$$$/ :/' \
  114       < $${BUILD_DIR}/objs/$$*.d | sed -e '$$$$!N; /^\(.*\)\n\1$$$$/!P; D' \
  115      >> $${BUILD_DIR}/make/src/$$*.mk
  116      @rm -f $${BUILD_DIR}/objs/$$*.d
  117 endef
  118 
  119 # ADD_OBJECT_RULE - Parameterized "function" that adds a pattern rule, using
  120 #   the commands from the second argument, for building object files from
  121 #   source files with the filename extension specified in the first argument.
  122 #
  123 #   This function assumes that the C/C++ sources files have filenames
  124 #   *relative* to the source root.  If they have absolute pathnames, it
  125 #   creates the wrong filenames...
  126 #
  127 #   USE WITH EVAL
  128 #
  129 ifeq "${CPP_MAKEDEPEND}" "yes"
  130 define ADD_OBJECT_RULE
  131 $${BUILD_DIR}/objs/%.${OBJ_EXT} $${BUILD_DIR}/objs/%.d: ${1} | ${BOOTSTRAP_BUILD}
  132     ${2}
  133     $${CPP} $${CPPFLAGS} $$(addprefix -I,$${SRC_INCDIRS}) $${SRC_DEFS} $$< | sed \
  134       -n 's,^\# *[0-9][0-9]* *"\([^"]*\)".*,$$@: \1,p' > $${BUILD_DIR}/objs/$$*.d
  135 ${FILTER_DEPENDS}
  136 endef
  137 
  138 else
  139 define ADD_OBJECT_RULE
  140 $${BUILD_DIR}/objs/%.${OBJ_EXT} $${BUILD_DIR}/objs/%.d: ${1} | ${BOOTSTRAP_BUILD}
  141     ${2}
  142 ${FILTER_DEPENDS}
  143 endef
  144 endif
  145 
  146 define ADD_ANALYZE_RULE
  147 $${BUILD_DIR}/plist/%.plist: ${1}
  148     ${2}
  149 endef
  150 
  151 # ADD_TARGET_DIR - Parameterized "function" that makes a link from
  152 #   TARGET_DIR to the executable or library in the BUILD_DIR directory.
  153 #
  154 #   USE WITH EVAL
  155 #
  156 ifneq "${TARGET_DIR}" ""
  157     define ADD_TARGET_DIR
  158         all: $${TARGET_DIR}/$$(notdir ${1})
  159 
  160         $${TARGET_DIR}/$$(notdir ${1}): ${1}
  161         [ -f $${TARGET_DIR}/$$(notdir ${1}) ] || ln -s ${1} $${TARGET_DIR}/$$(notdir ${1})
  162 
  163     endef
  164 endif
  165 
  166 # ADD_TARGET_TO_ALL - Parameterized "function" that adds the target,
  167 #   and makes "all" depend on it.
  168 #
  169 #   USE WITH EVAL
  170 #
  171 define ADD_TARGET_TO_ALL
  172     all: ${1}
  173 
  174 endef
  175 
  176 # ADD_TARGET_RULE.* - Parameterized "functions" that adds a new target to the
  177 #   Makefile.  There should be one ADD_TARGET_RULE definition for each
  178 #   type of target that is used in the build.
  179 #
  180 #   New rules can be added by copying one of the existing ones, and
  181 #   replacing the line after the "mkdir"
  182 #
  183 
  184 # ADD_TARGET_RULE.exe - Build an executable target.
  185 #
  186 #   USE WITH EVAL
  187 #
  188 define ADD_TARGET_RULE.exe
  189     # So "make ${1}" works
  190     .PHONY: ${1}
  191     ${1}: $${${1}_BUILD}/${1}
  192 
  193     # Create executable ${1}
  194     $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PRBIN} $${${1}_PRLIBS}
  195         $(Q)$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
  196         $(Q)$(ECHO) LINK $${${1}_BUILD}/${1}
  197         $(Q)$${${1}_LINKER} -o $${${1}_BUILD}/${1} $${RPATH_FLAGS} $${LDFLAGS} \
  198                 $${${1}_LDFLAGS} $${${1}_OBJS} $${${1}_PRLIBS} \
  199                 $${LDLIBS} $${${1}_LDLIBS}
  200         $(Q)$${${1}_POSTMAKE}
  201 
  202     ifneq "${ANALYZE.c}" ""
  203         scan.${1}: $${${1}_PLISTS}
  204     endif
  205 
  206     .PHONY: $(DIR)
  207     $(DIR)/: ${1}
  208 endef
  209 
  210 # ADD_TARGET_RULE.a - Build a static library target.
  211 #
  212 #   USE WITH EVAL
  213 #
  214 define ADD_TARGET_RULE.a
  215     # So "make ${1}" works
  216     .PHONY: ${1}
  217     ${1}: $${${1}_BUILD}/${1}
  218 
  219     # Create static library ${1}
  220     $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PRLIBS}
  221         $(Q)$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
  222         $(Q)$(ECHO) LINK $${${1}_BUILD}/${1}
  223         $(Q)$${AR} $${ARFLAGS} $${${1}_BUILD}/${1} $${${1}_OBJS}
  224         $(Q)$${${1}_POSTMAKE}
  225 
  226     ifneq "${ANALYZE.c}" ""
  227         scan.${1}: $${${1}_PLISTS}
  228     endif
  229 
  230     .PHONY: $(DIR)
  231     $(DIR)/: ${1}
  232 endef
  233 
  234 # ADD_TARGET_RULE.so - Build a ".so" target.
  235 #
  236 #   USE WITH EVAL
  237 #
  238 define ADD_TARGET_RULE.so
  239 $(error Please add rules to build a ".so" file.)
  240 endef
  241 
  242 # ADD_TARGET_RULE.dll - Build a ".dll" target.
  243 #
  244 #   USE WITH EVAL
  245 #
  246 define ADD_TARGET_RULE.dll
  247 $(error Please add rules to build a ".dll" file.)
  248 endef
  249 
  250 # ADD_TARGET_RULE.dylib - Build a ".dylib" target.
  251 #
  252 #   USE WITH EVAL
  253 #
  254 define ADD_TARGET_RULE.dylib
  255 $(error Please add rules to build a ".dylib" file.)
  256 endef
  257 
  258 # CANONICAL_PATH - Given one or more paths, converts the paths to the canonical
  259 #   form. The canonical form is the path, relative to the project's top-level
  260 #   directory (the directory from which "make" is run), and without
  261 #   any "./" or "../" sequences. For paths that are not  located below the
  262 #   top-level directory, the canonical form is the absolute path (i.e. from
  263 #   the root of the filesystem) also without "./" or "../" sequences.
  264 define CANONICAL_PATH
  265 $(patsubst ${CURDIR}/%,%,$(abspath ${1}))
  266 endef
  267 
  268 # COMPILE_C_CMDS - Commands for compiling C source code.
  269 ifeq "$(CPPCHECK)" ""
  270 define COMPILE_C_CMDS
  271     $(Q)mkdir -p $(dir $@)
  272     $(Q)$(ECHO) CC $<
  273     $(Q)$(strip ${COMPILE.c} -o $@ -c -MD ${CPPFLAGS} ${CFLAGS} ${SRC_CFLAGS} ${INCDIRS} \
  274         $(addprefix -I, ${SRC_INCDIRS}) ${SRC_DEFS} ${DEFS} $<)
  275 endef
  276 else
  277 #
  278 #  do cppcheck AND compilation, so that we have correct dependencies
  279 #  Suppress variable scope warnings for now.  They're style, and don't really
  280 #  affect anything.
  281 #
  282 define COMPILE_C_CMDS
  283     $(Q)mkdir -p $(dir $@)
  284     $(Q)$(ECHO) CC $<
  285     $(Q)$(strip ${COMPILE.c} -o $@ -c -MD ${CPPFLAGS} ${CFLAGS} ${SRC_CFLAGS} ${INCDIRS} \
  286              $(addprefix -I,${SRC_INCDIRS}) ${SRC_DEFS} ${DEFS} $<)
  287     $(Q)cppcheck --enable=style -q ${CHECKFLAGS} $(filter -isystem%,${SRC_CFLAGS}) \
  288          $(filter -I%,${SRC_CFLAGS}) $(filter -D%,${SRC_CFLAGS}) ${INCDIRS} \
  289          $(addprefix -I,${SRC_INCDIRS}) ${SRC_DEFS} ${DEFS} --suppress=variableScope --suppress=invalidscanf $<
  290 endef
  291 endif
  292 
  293 # ANALYZE_C_CMDS - Commands for analyzing C source code with clang.
  294 define ANALYZE_C_CMDS
  295     $(Q)mkdir -p $(dir $@)
  296     $(Q)$(ECHO) SCAN $<
  297     $(Q)$(strip ${ANALYZE.c} --analyze -Xanalyzer -analyzer-output=html -c $< -o $@ ${CPPFLAGS} \
  298         ${CFLAGS} ${SRC_CFLAGS} ${INCDIRS} $(addprefix -I,${SRC_INCDIRS}) ${SRC_DEFS} ${DEFS}) || (rm -f $@ && false)
  299     $(Q)touch $@
  300 endef
  301 
  302 # COMPILE_CXX_CMDS - Commands for compiling C++ source code.
  303 define COMPILE_CXX_CMDS
  304     $(Q)mkdir -p $(dir $@)
  305     $(Q)$(strip ${COMPILE.cxx} -o $@ -c -MD ${CPPFLAGS} ${CXXFLAGS} ${SRC_CXXFLAGS} ${INCDIRS} \
  306         $(addprefix -I,${SRC_INCDIRS}) ${SRC_DEFS} ${DEFS} $<)
  307 endef
  308 
  309 # INCLUDE_SUBMAKEFILE - Parameterized "function" that includes a new
  310 #   "submakefile" fragment into the overall Makefile. It also recursively
  311 #   includes all submakefiles of the specified submakefile fragment.
  312 #
  313 #   USE WITH EVAL
  314 #
  315 define INCLUDE_SUBMAKEFILE
  316     # Initialize all variables that can be defined by a makefile fragment, then
  317     # include the specified makefile fragment.
  318     TARGET :=
  319     TGT_LDFLAGS :=
  320     TGT_LDLIBS :=
  321     TGT_LINKER :=
  322     TGT_POSTCLEAN :=
  323     TGT_POSTMAKE :=
  324     TGT_PREREQS :=
  325     TGT_POSTINSTALL :=
  326     TGT_INSTALLDIR := ..
  327     TGT_CHECK_HEADERS :=
  328     TGT_CHECK_LIBS :=
  329     TEST :=
  330 
  331     SOURCES :=
  332     SRC_CFLAGS :=
  333     SRC_CXXFLAGS :=
  334     SRC_DEFS :=
  335     SRC_INCDIRS :=
  336     MAN :=
  337     FILES :=
  338     OUTPUT :=
  339 
  340     SUBMAKEFILES :=
  341 
  342     # A directory stack is maintained so that the correct paths are used as we
  343     # recursively include all submakefiles. Get the makefile's directory and
  344     # push it onto the stack.
  345     DIR := $(call CANONICAL_PATH,$(dir ${1}))
  346     DIR_STACK := $$(call PUSH,$${DIR_STACK},$${DIR})
  347 
  348     include ${1}
  349 
  350     # Initialize internal local variables.
  351     OBJS :=
  352 
  353     # Determine which target this makefile's variables apply to. A stack is
  354     # used to keep track of which target is the "current" target as we
  355     # recursively include other submakefiles.
  356     ifneq "$$(strip $${TARGET})" ""
  357         # This makefile defined a new target. Target variables defined by this
  358         # makefile apply to this new target. Initialize the target's variables.
  359 
  360         # libs go into ${BUILD_DIR}/lib
  361         # everything else goes into ${BUILD_DIR}/bin
  362 #        TGT := $$(strip $$(if $$(suffix $${TARGET}),$${BUILD_DIR}/lib,$${BUILD_DIR}/bin)/$${TARGET})
  363         TGT := $${TARGET}
  364 
  365         # A "hook" to rewrite "libfoo.a" -> "libfoo.la" when using libtool
  366         $$(eval $$(call ADD_LIBTOOL_SUFFIX))
  367 
  368         ALL_TGTS += $${TGT}
  369         $${TGT}_LDFLAGS := $${TGT_LDFLAGS}
  370         $${TGT}_LDLIBS := $${TGT_LDLIBS}
  371         $${TGT}_LINKER := $${TGT_LINKER}
  372         $${TGT}_POSTMAKE := $${TGT_POSTMAKE}
  373         $${TGT}_POSTCLEAN := $${TGT_POSTCLEAN}
  374         $${TGT}_POSTINSTALL := $${TGT_POSTINSTALL}
  375         $${TGT}_PREREQS := $${TGT_PREREQS}
  376         $${TGT}_PRBIN := $$(addprefix $${BUILD_DIR}/bin/,$$(filter-out %.a %.so %.la,$${TGT_PREREQS}))
  377         $${TGT}_PRLIBS := $$(addprefix $${BUILD_DIR}/lib/,$$(filter %.a %.so %.la,$${TGT_PREREQS}))
  378         $${TGT}_DEPS :=
  379         $${TGT}_OBJS :=
  380         $${TGT}_SOURCES :=
  381         $${TGT}_MAN := $${MAN}
  382         $${TGT}_SUFFIX := $$(if $$(suffix $${TGT}),$$(suffix $${TGT}),.exe)
  383 
  384         # If it's an EXE, ensure that transitive library linking works.
  385         # i.e. we build libfoo.a which in turn requires -lbar.  So, the executable
  386         # has to be linked to both libfoo.a and -lbar.
  387         ifeq "$${$${TGT}_SUFFIX}" ".exe"
  388                 $${TGT}_LDLIBS += $$(filter-out %.a %.so %.la,$${$${TGT_PREREQS}_LDLIBS})
  389         endif
  390 
  391         $${TGT}_BUILD := $$(if $$(suffix $${TGT}),$${BUILD_DIR}/lib,$${BUILD_DIR}/bin)
  392         $${TGT}_MAKEFILES += ${1}
  393         $${TGT}_CHECK_HEADERS := $${TGT_CHECK_HEADERS}
  394         $${TGT}_CHECK_LIBS := $${TGT_CHECK_LIBS}
  395     else
  396         # The values defined by this makefile apply to the the "current" target
  397         # as determined by which target is at the top of the stack.
  398         TGT := $$(strip $$(call PEEK,$${TGT_STACK}))
  399         $${TGT}_LDFLAGS   += $${TGT_LDFLAGS}
  400         $${TGT}_LDLIBS    += $${TGT_LDLIBS}
  401         $${TGT}_POSTCLEAN += $${TGT_POSTCLEAN}
  402         $${TGT}_POSTMAKE  += $${TGT_POSTMAKE}
  403         $${TGT}_PREREQS   += $${TGT_PREREQS}
  404     endif
  405 
  406     # Push the current target onto the target stack.
  407     TGT_STACK := $$(call PUSH,$${TGT_STACK},$${TGT})
  408 
  409     # If there's no target, don't build the sources.
  410     ifneq "$$(strip $${TARGET})" ""
  411 
  412     # if there's no sources, don't do the automatic object build
  413     ifneq "$$(strip $${SOURCES})" ""
  414         # This makefile builds one or more objects from source. Validate the
  415         # specified sources against the supported source file types.
  416         BAD_SRCS := $$(strip $$(filter-out $${ALL_SRC_EXTS},$${SOURCES}))
  417         ifneq "$${BAD_SRCS}" ""
  418             $$(error Unsupported source file(s) found in ${1} [$${BAD_SRCS}])
  419         endif
  420 
  421         # Qualify and canonicalize paths.
  422         SOURCES     := $$(call QUALIFY_PATH,$${DIR},$${SOURCES})
  423         SOURCES     := $$(call CANONICAL_PATH,$${SOURCES})
  424         SRC_INCDIRS := $$(call QUALIFY_PATH,$${DIR},$${SRC_INCDIRS})
  425         SRC_INCDIRS := $$(call CANONICAL_PATH,$${SRC_INCDIRS})
  426 
  427         # Save the list of source files for this target.
  428         $${TGT}_SOURCES += $${SOURCES}
  429 
  430         # Convert the source file names to their corresponding object file
  431         # names.
  432         OBJS := $$(addprefix $${BUILD_DIR}/objs/,\
  433                    $$(addsuffix .${OBJ_EXT},$$(basename $${SOURCES})))
  434 
  435     PLISTS := $$(addprefix $${BUILD_DIR}/plist/,\
  436                    $$(addsuffix .plist,$$(basename $${SOURCES})))
  437     ALL_PLISTS += ${PLISTS}
  438 
  439         # Add the objects to the current target's list of objects, and create
  440         # target-specific variables for the objects based on any source
  441         # variables that were defined.
  442         $${TGT}_OBJS += $${OBJS}
  443         $${TGT}_PLISTS += $${PLISTS}
  444         $${TGT}_DEPS += $$(addprefix $${BUILD_DIR}/make/src/,\
  445                    $$(addsuffix .mk,$$(basename $${SOURCES})))
  446 
  447         # A "hook" to define variables needed by the "legacy" makefiles.
  448         $$(eval $$(call ADD_LEGACY_VARIABLES,$$(dir ${1}),$${TGT}))
  449 
  450         $${OBJS}: SRC_CFLAGS := $${SRC_CFLAGS}
  451         $${OBJS}: SRC_CXXFLAGS := $${SRC_CXXFLAGS}
  452         $${OBJS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
  453         $${OBJS}: SRC_INCDIRS := $${SRC_INCDIRS}
  454         $${OBJS}: ${1}
  455 
  456         $${PLISTS}: SRC_CFLAGS := $${SRC_CFLAGS}
  457         $${PLISTS}: SRC_CXXFLAGS := $${SRC_CXXFLAGS}
  458         $${PLISTS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
  459         $${PLISTS}: SRC_INCDIRS := $${SRC_INCDIRS}
  460         $${PLISTS}: ${1}
  461     endif
  462     endif
  463 
  464     ifneq "$$(strip $${SUBMAKEFILES})" ""
  465         # This makefile has submakefiles. Recursively include them.
  466         $$(foreach MK,$${SUBMAKEFILES},\
  467            $$(eval $$(call INCLUDE_SUBMAKEFILE,\
  468                       $$(call CANONICAL_PATH,\
  469                          $$(call QUALIFY_PATH,$${DIR},$${MK})))))
  470     endif
  471 
  472     # Reset the "current" target to it's previous value.
  473     TGT_STACK := $$(call POP,$${TGT_STACK})
  474     # If we're about to change targets, create the rules for the target
  475     ifneq "$${TGT}" "$$(call PEEK,$${TGT_STACK})"
  476         # add rules to build the target, and have "all" depend on it.
  477         $$(eval $$(call ADD_TARGET_TO_ALL,$${TGT}))
  478 
  479         # A "hook" to add rules for ${TARGET_DIR}/foo, if TARGET_DIR
  480         # is defined.  Otherwise, we leave the source directory untouched.
  481         $$(eval $$(call ADD_TARGET_DIR,$${TGT}))
  482 
  483         # A "hook" to build the libtool target.
  484         $$(eval $$(call ADD_LIBTOOL_TARGET))
  485 
  486         # Choose the correct linker.
  487         ifeq "$$(strip $$(filter $${CXX_SRC_EXTS},$${$${TGT}_SOURCES}))" ""
  488             ifeq "$${$${TGT}_LINKER}" ""
  489                 $${TGT}_LINKER := ${LL}$${LINK.c}
  490             endif
  491         else
  492             ifeq "$${$${TGT}_LINKER}" ""
  493                 $${TGT}_LINKER := ${LL}$${LINK.cxx}
  494             endif
  495         endif
  496 
  497         # add rules to build the target
  498         $$(eval $$(call ADD_TARGET_RULE$${$${TGT}_SUFFIX},$${TGT}))
  499 
  500         # generate the clean rule for this target.
  501         $$(eval $$(call ADD_CLEAN_RULE,$${TGT}))
  502 
  503         # Hook to add an installation target
  504         $$(eval $$(call ADD_INSTALL_TARGET,$${TGT}))
  505 
  506         # Hook to add a configuration target
  507         $$(eval $$(call ADD_TARGET_CONFIG,$${TGT}))
  508 
  509         # "hook" for legacy Makefiles
  510         $$(eval $$(call ADD_LEGACY_RULE,$${TGT}))
  511     endif
  512 
  513     TGT := $$(call PEEK,$${TGT_STACK})
  514 
  515     # Reset the "current" directory to it's previous value.
  516     DIR_STACK := $$(call POP,$${DIR_STACK})
  517     DIR := $$(call PEEK,$${DIR_STACK})
  518 endef
  519 
  520 # MIN - Parameterized "function" that results in the minimum lexical value of
  521 #   the two values given.
  522 define MIN
  523 $(firstword $(sort ${1} ${2}))
  524 endef
  525 
  526 # PEEK - Parameterized "function" that results in the value at the top of the
  527 #   specified colon-delimited stack.
  528 define PEEK
  529 $(lastword $(subst :, ,${1}))
  530 endef
  531 
  532 # POP - Parameterized "function" that pops the top value off of the specified
  533 #   colon-delimited stack, and results in the new value of the stack. Note that
  534 #   the popped value cannot be obtained using this function; use peek for that.
  535 define POP
  536 ${1:%:$(lastword $(subst :, ,${1}))=%}
  537 endef
  538 
  539 # PUSH - Parameterized "function" that pushes a value onto the specified colon-
  540 #   delimited stack, and results in the new value of the stack.
  541 define PUSH
  542 ${2:%=${1}:%}
  543 endef
  544 
  545 # QUALIFY_PATH - Given a "root" directory and one or more paths, qualifies the
  546 #   paths using the "root" directory (i.e. appends the root directory name to
  547 #   the paths) except for paths that are absolute.
  548 define QUALIFY_PATH
  549 $(addprefix ${1}/,$(filter-out /%,${2})) $(filter /%,${2})
  550 endef
  551 
  552 ###############################################################################
  553 #
  554 # Start of Makefile Evaluation
  555 #
  556 ###############################################################################
  557 
  558 # Older versions of GNU Make lack capabilities needed by boilermake.
  559 # With older versions, "make" may simply output "nothing to do", likely leading
  560 # to confusion. To avoid this, check the version of GNU make up-front and
  561 # inform the user if their version of make doesn't meet the minimum required.
  562 MIN_MAKE_VERSION := 3.81
  563 MIN_MAKE_VER_MSG := boilermake requires GNU Make ${MIN_MAKE_VERSION} or greater
  564 ifeq "${MAKE_VERSION}" ""
  565     $(info GNU Make not detected)
  566     $(error ${MIN_MAKE_VER_MSG})
  567 endif
  568 ifneq "${MIN_MAKE_VERSION}" "$(call MIN,${MIN_MAKE_VERSION},${MAKE_VERSION})"
  569     $(info This is GNU Make version ${MAKE_VERSION})
  570     $(error ${MIN_MAKE_VER_MSG})
  571 endif
  572 
  573 # Define the source file extensions that we know how to handle.
  574 OBJ_EXT := o
  575 C_SRC_EXTS := %.c
  576 CXX_SRC_EXTS := %.C %.cc %.cp %.cpp %.CPP %.cxx %.c++
  577 ALL_SRC_EXTS := ${C_SRC_EXTS} ${CXX_SRC_EXTS}
  578 
  579 # Initialize global variables.
  580 ALL_TGTS :=
  581 DEFS :=
  582 DIR_STACK :=
  583 INCDIRS :=
  584 TGT_STACK :=
  585 
  586 ifeq "${top_builddir}" ""
  587     top_builddir := .
  588 endif
  589 
  590 # Ensure that valid values are set for BUILD_DIR
  591 ifeq "$(strip ${BUILD_DIR})" ""
  592     ifeq "${top_builddir}" "${PWD}"
  593         BUILD_DIR := build
  594     else
  595         BUILD_DIR := ${top_builddir}/build
  596     endif
  597 else
  598     BUILD_DIR := $(call CANONICAL_PATH,${BUILD_DIR})
  599 endif
  600 
  601 .PHONY: $(BUILD_DIR)
  602 $(BUILD_DIR):
  603     @mkdir -p $@
  604 
  605 # Define compilers and linkers
  606 #
  607 BOOTSTRAP_BUILD = 
  608 COMPILE.c = ${CC}
  609 COMPILE.cxx = ${CXX}
  610 CPP = cc -E
  611 LINK.c = ${CC}
  612 LINK.cxx = ${CXX}
  613 
  614 # Set ECHO to "true" for *very* quiet builds
  615 ECHO = echo
  616 
  617 # Define the "all" target (which simply builds all user-defined targets) as the
  618 # default goal.
  619 .PHONY: all
  620 all:
  621 
  622 # Add "clean" rules to remove all build-generated files.
  623 .PHONY: clean
  624 clean:
  625 
  626 top_makedir := $(dir $(lastword ${MAKEFILE_LIST}))
  627 
  628 -include ${top_makedir}/install.mk
  629 -include ${top_makedir}/libtool.mk
  630 
  631 ifneq "${CPPCHECK}" ""
  632 CHECKFLAGS := -DCPPCHECK $(filter -isystem%,$(CPPFLAGS) $(CFLAGS)) $(filter -I%,$(CPPFLAGS) $(CFLAGS)) $(filter -D%,$(CPPFLAGS) $(CFLAGS))
  633 endif
  634 
  635 # Include the main user-supplied submakefile. This also recursively includes
  636 # all other user-supplied submakefiles.
  637 $(eval $(call INCLUDE_SUBMAKEFILE,${top_builddir}/main.mk))
  638 
  639 # Perform post-processing on global variables as needed.
  640 DEFS := $(addprefix -D,${DEFS})
  641 INCDIRS := $(addprefix -I,$(call CANONICAL_PATH,${INCDIRS}))
  642 
  643 # Add pattern rule(s) for creating compiled object code from C source.
  644 $(foreach EXT,${C_SRC_EXTS},\
  645   $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_C_CMDS})))
  646 
  647 ifneq "${ANALYZE.c}" ""
  648 $(foreach EXT,${C_SRC_EXTS},\
  649   $(eval $(call ADD_ANALYZE_RULE,${EXT},$${ANALYZE_C_CMDS})))
  650 endif
  651 
  652 # Add pattern rule(s) for creating compiled object code from C++ source.
  653 $(foreach EXT,${CXX_SRC_EXTS},\
  654   $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_CXX_CMDS})))
  655 
  656 # Don't include the target dependencies if we're doing a "make clean"
  657 # Future: have a list of targets that don't require dependency generation,
  658 #  and see if MAKECMDGOALS is one of them.
  659 ifneq "$(MAKECMDGOALS)" "clean"
  660     $(foreach TGT,${ALL_TGTS},\
  661       $(eval -include ${${TGT}_DEPS}))
  662 endif
  663 
  664 # Build rules for installation subdirectories
  665 $(foreach D,$(patsubst %/,%,$(sort $(dir ${ALL_INSTALL}))),\
  666   $(eval $(call ADD_INSTALL_RULE.dir,${D})))
  667 
  668 
  669 scan: ${ALL_PLISTS}
  670 
  671 .PHONY: clean.scan
  672 clean.scan:
  673     $(Q)rm -rf ${ALL_PLISTS}
  674 
  675 clean: clean.scan