Support new build system
authorAlan T. DeKok <aland@freeradius.org>
Mon, 23 Jan 2012 17:11:20 +0000 (18:11 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 23 Jan 2012 17:11:20 +0000 (18:11 +0100)
After 10+ years, recursive make should be left behind.
This new framework is taken from:

https://github.com/dmoulding/boilermake

with some changes by myself.  The basic framework is ~500 lines
of GNU Makefile code.  Adding libtool-style wrappers and install
frameworks is another ~500 LoC.  The result is that we now
have a build system which all developers should use.
Each individual Makefile is small, simple, etc.  Dependencies
are automatically calculated and tracked, so the developer
doesn't have to worry.

The minor downside is that you can't do "cd X;make".  This is
a GOOD thing, because Make now handles all dependencies.  i.e.
building in a subdirectory should NEVER be necessary.

All output goes into the "build" directory, which is a bit of
a change.

70 files changed:
main.mk [new file with mode: 0644]
scripts/boiler.mk [new file with mode: 0644]
scripts/install.mk [new file with mode: 0644]
scripts/libtool.mk [new file with mode: 0644]
scripts/main.mk [new file with mode: 0644]
src/all.mk [new file with mode: 0644]
src/include/all.mk [new file with mode: 0644]
src/lib/all.mk [new file with mode: 0644]
src/main/all.mk [new file with mode: 0644]
src/main/radclient.mk [new file with mode: 0644]
src/main/radiusd.mk [new file with mode: 0644]
src/modules/all.mk [new file with mode: 0644]
src/modules/rlm_acct_unique/all.mk [new file with mode: 0644]
src/modules/rlm_acctlog/all.mk [new file with mode: 0644]
src/modules/rlm_always/all.mk [new file with mode: 0644]
src/modules/rlm_attr_filter/all.mk [new file with mode: 0644]
src/modules/rlm_attr_rewrite/all.mk [new file with mode: 0644]
src/modules/rlm_chap/all.mk [new file with mode: 0644]
src/modules/rlm_checkval/all.mk [new file with mode: 0644]
src/modules/rlm_copy_packet/all.mk [new file with mode: 0644]
src/modules/rlm_counter/all.mk [new file with mode: 0644]
src/modules/rlm_cram/all.mk [new file with mode: 0644]
src/modules/rlm_dbm/all.mk [new file with mode: 0644]
src/modules/rlm_detail/all.mk [new file with mode: 0644]
src/modules/rlm_digest/all.mk [new file with mode: 0644]
src/modules/rlm_dynamic_clients/all.mk [new file with mode: 0644]
src/modules/rlm_eap/all.mk [new file with mode: 0644]
src/modules/rlm_eap/libeap/all.mk [new file with mode: 0644]
src/modules/rlm_eap/radeapclient.mk [new file with mode: 0644]
src/modules/rlm_eap/rlm_eap.mk [new file with mode: 0644]
src/modules/rlm_eap/types/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_gtc/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_leap/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_md5/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_mschapv2/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_peap/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_tls/all.mk [new file with mode: 0644]
src/modules/rlm_eap/types/rlm_eap_ttls/all.mk [new file with mode: 0644]
src/modules/rlm_eap2/all.mk [new file with mode: 0644]
src/modules/rlm_exec/all.mk [new file with mode: 0644]
src/modules/rlm_expiration/all.mk [new file with mode: 0644]
src/modules/rlm_expr/all.mk [new file with mode: 0644]
src/modules/rlm_fastusers/all.mk [new file with mode: 0644]
src/modules/rlm_files/all.mk [new file with mode: 0644]
src/modules/rlm_ippool/all.mk [new file with mode: 0644]
src/modules/rlm_jradius/all.mk [new file with mode: 0644]
src/modules/rlm_krb5/all.mk [new file with mode: 0644]
src/modules/rlm_ldap/all.mk [new file with mode: 0644]
src/modules/rlm_linelog/all.mk [new file with mode: 0644]
src/modules/rlm_logintime/all.mk [new file with mode: 0644]
src/modules/rlm_mschap/all.mk [new file with mode: 0644]
src/modules/rlm_mschap/rlm_mschap.mk [new file with mode: 0644]
src/modules/rlm_mschap/smbencrypt.mk [new file with mode: 0644]
src/modules/rlm_otp/all.mk [new file with mode: 0644]
src/modules/rlm_pam/all.mk [new file with mode: 0644]
src/modules/rlm_pap/all.mk [new file with mode: 0644]
src/modules/rlm_passwd/all.mk [new file with mode: 0644]
src/modules/rlm_perl/all.mk [new file with mode: 0644]
src/modules/rlm_policy/all.mk [new file with mode: 0644]
src/modules/rlm_preprocess/all.mk [new file with mode: 0644]
src/modules/rlm_python/all.mk [new file with mode: 0644]
src/modules/rlm_radutmp/all.mk [new file with mode: 0644]
src/modules/rlm_realm/all.mk [new file with mode: 0644]
src/modules/rlm_sim_files/all.mk [new file with mode: 0644]
src/modules/rlm_sql/all.mk [new file with mode: 0644]
src/modules/rlm_sql_log/all.mk [new file with mode: 0644]
src/modules/rlm_sqlcounter/all.mk [new file with mode: 0644]
src/modules/rlm_sqlippool/all.mk [new file with mode: 0644]
src/modules/rlm_unix/all.mk [new file with mode: 0644]
src/modules/rlm_wimax/all.mk [new file with mode: 0644]

diff --git a/main.mk b/main.mk
new file mode 100644 (file)
index 0000000..79d45ce
--- /dev/null
+++ b/main.mk
@@ -0,0 +1 @@
+SUBMAKEFILES := src/all.mk
diff --git a/scripts/boiler.mk b/scripts/boiler.mk
new file mode 100644 (file)
index 0000000..b150b1c
--- /dev/null
@@ -0,0 +1,563 @@
+# boilermake: A reusable, but flexible, boilerplate Makefile.
+#
+# Copyright 2008, 2009, 2010 Dan Moulding, Alan T. DeKok
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Caution: Don't edit this Makefile! Create your own main.mk and other
+#          submakefiles, which will be included by this Makefile.
+#          Only edit this if you need to modify boilermake's behavior (fix
+#          bugs, add features, etc).
+
+# Note: Parameterized "functions" in this makefile that are marked with
+#       "USE WITH EVAL" are only useful in conjuction with eval. This is
+#       because those functions result in a block of Makefile syntax that must
+#       be evaluated after expansion. Since they must be used with eval, most
+#       instances of "$" within them need to be escaped with a second "$" to
+#       accomodate the double expansion that occurs when eval is invoked.
+
+# ADD_CLEAN_RULE - Parameterized "function" that adds a new rule and phony
+#   target for cleaning the specified target (removing its build-generated
+#   files).
+#
+#   USE WITH EVAL
+#
+define ADD_CLEAN_RULE
+    clean: clean_$(notdir ${1})
+    .PHONY: clean_$(notdir ${1})
+    clean_$(notdir ${1}):
+       @$(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}))
+       $${${1}_POSTCLEAN}
+
+endef
+
+# FILTER_DEPENDS: function to turn a *.d file into a *.mk file.
+#   We start off with the dependencies as created by the compiler,
+#   CPP, or makedepend.  We then ensure that there is an empty dependency
+#   for each header file.  The blank target ensures that the build
+#   can proceed even if the header file has been deleted.
+#
+#  COMMON filters:
+#      remove comments
+#      remove dependencies on global include files
+#      remove empty dependencies
+#      remove CPP hacks like "foo: <built-in>"
+#
+#  1) Filter the .d file to remove unnecessary cruft
+#
+#      COMMON
+#      Replace ".o" with "${OBJ_EXT}"
+#      delete empty continuation lines
+#      delete blank lines
+#      replace "build/" with "${BUILD_DIR}/" when it's at the start of a line
+#      delete references to ${BUILD_DIR}/make/include, the "config.mk"
+#      file adds these dependencies automatically.
+#      replace "build/" with "${BUILD_DIR}/" when it's in the middle of a line
+#      
+#      remove sequential duplicate lines
+#      
+#  2) Create empty dependencies from the files
+#
+#      COMMON
+#      remove existing targets
+#      remove continuations (to make the targets stand by themselves)
+#      delete blank lines
+#      add in empty dependency for each file.
+#      remove sequential duplicate lines
+#
+define FILTER_DEPENDS
+       @mkdir -p $$(dir $${BUILD_DIR}/make/src/$$*)
+       @mkdir -p $$(dir $${BUILD_DIR}/objs/$$*)
+       @sed  -e 's/#.*//' \
+         -e 's, /[^: ]*,,g' \
+         -e 's,^ *[^:]* *: *$$$$,,' \
+         -e '/: </ d' \
+         -e 's/\.o: /.$$$${OBJ_EXT}: /' \
+         -e '/^ *\\$$$$/ d' \
+         -e 's,^$${BUILD_DIR},$$$${BUILD_DIR},' \
+         -e 's, $${BUILD_DIR}/make/include/[^ :]*,,' \
+         -e 's, $${BUILD_DIR}, $$$${BUILD_DIR},' \
+         -e '/^$$$$/ d' \
+         < $${BUILD_DIR}/objs/$$*.d | sed -e '$$$$!N; /^\(.*\)\n\1$$$$/!P; D' \
+         >  $${BUILD_DIR}/make/src/$$*.mk
+       @sed -e 's/#.*//' \
+         -e 's, /[^: ]*,,g' \
+         -e 's,^ *[^:]* *: *$$$$,,' \
+         -e '/: </ d' \
+         -e 's, $${BUILD_DIR}/make/include/[^ :]*,,' \
+         -e 's/^[^:]*: *//' \
+         -e 's/ *\\$$$$//' \
+         -e '/^$$$$/ d' \
+         -e 's/$$$$/ :/' \
+         < $${BUILD_DIR}/objs/$$*.d | sed -e '$$$$!N; /^\(.*\)\n\1$$$$/!P; D' \
+        >> $${BUILD_DIR}/make/src/$$*.mk
+        @rm -f $${BUILD_DIR}/objs/$$*.d
+endef
+
+# ADD_OBJECT_RULE - Parameterized "function" that adds a pattern rule, using
+#   the commands from the second argument, for building object files from
+#   source files with the filename extension specified in the first argument.
+#
+#   This function assumes that the C/C++ sources files have filenames
+#   *relative* to the source root.  If they have absolute pathnames, it
+#   creates the wrong filenames...
+#
+#   USE WITH EVAL
+#
+ifeq "${CPP_MAKEDEPEND}" "yes"
+define ADD_OBJECT_RULE
+$${BUILD_DIR}/objs/%.${OBJ_EXT} $${BUILD_DIR}/objs/%.d: ${1}
+       ${2}
+       $${CPP} $${CPPFLAGS} $${SRC_INCDIRS} $${SRC_DEFS} $$< | sed \
+         -n 's,^\# *[0-9][0-9]* *"\([^"]*\)".*,$$@: \1,p' > $${BUILD_DIR}/objs/$$*.d
+${FILTER_DEPENDS}
+endef
+
+else
+define ADD_OBJECT_RULE
+$${BUILD_DIR}/objs/%.${OBJ_EXT} $${BUILD_DIR}/objs/%.d: ${1}
+       ${2}
+${FILTER_DEPENDS}
+endef
+endif
+
+# ADD_TARGET_DIR - Parameterized "function" that makes a link from
+#   TARGET_DIR to the executable or library in the BUILD_DIR directory.
+#
+#   USE WITH EVAL
+#
+ifneq "${TARGET_DIR}" ""
+    define ADD_TARGET_DIR
+        all: $${TARGET_DIR}/$$(notdir ${1})
+
+        $${TARGET_DIR}/$$(notdir ${1}): ${1}
+           [ -f $${TARGET_DIR}/$$(notdir ${1}) ] || ln -s ${1} $${TARGET_DIR}/$$(notdir ${1})
+
+    endef
+endif
+
+# ADD_TARGET_TO_ALL - Parameterized "function" that adds the target,
+#   and makes "all" depend on it.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_TO_ALL
+    all: ${1}
+
+endef
+
+# ADD_TARGET_RULE.* - Parameterized "functions" that adds a new target to the
+#   Makefile.  There should be one ADD_TARGET_RULE definition for each
+#   type of target that is used in the build.  
+#
+#   New rules can be added by copying one of the existing ones, and
+#   replacing the line after the "mkdir"
+#
+
+# ADD_TARGET_RULE.exe - Build an executable target.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_RULE.exe
+    # So "make ${1}" works
+    .PHONY: ${1}
+    ${1}: $${${1}_BUILD}/${1}
+
+    # Create executable ${1}
+    $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PRBIN} $${${1}_PRLIBS}
+           @$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
+           @echo LINK $${${1}_BUILD}/${1}
+           @$${${1}_LINKER} -o $${${1}_BUILD}/${1} $${RPATH_FLAGS} $${LDFLAGS} \
+                $${${1}_LDFLAGS} $${${1}_OBJS} $${${1}_PRLIBS} \
+                $${LDLIBS} $${${1}_LDLIBS}
+           @$${${1}_POSTMAKE}
+
+endef
+
+# ADD_TARGET_RULE.a - Build a static library target.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_RULE.a
+    # So "make ${1}" works
+    .PHONY: ${1}
+    ${1}: $${${1}_BUILD}/${1}
+
+    # Create static library ${1}
+    $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PREREQS}
+           @$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
+           @echo LINK $${${1}_BUILD}/${1}
+           @$${AR} $${ARFLAGS} $${${1}_BUILD}/${1} $${${1}_OBJS}
+           @$${${1}_POSTMAKE}
+
+endef
+
+# ADD_TARGET_RULE.so - Build a ".so" target.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_RULE.so
+$(error Please add rules to build a ".so" file.)
+endef
+
+# ADD_TARGET_RULE.dll - Build a ".dll" target.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_RULE.dll
+$(error Please add rules to build a ".dll" file.)
+endef
+
+# ADD_TARGET_RULE.dylib - Build a ".dylib" target.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_RULE.dylib
+$(error Please add rules to build a ".dylib" file.)
+endef
+
+# CANONICAL_PATH - Given one or more paths, converts the paths to the canonical
+#   form. The canonical form is the path, relative to the project's top-level
+#   directory (the directory from which "make" is run), and without
+#   any "./" or "../" sequences. For paths that are not  located below the
+#   top-level directory, the canonical form is the absolute path (i.e. from
+#   the root of the filesystem) also without "./" or "../" sequences.
+define CANONICAL_PATH
+$(patsubst ${CURDIR}/%,%,$(abspath ${1}))
+endef
+
+# COMPILE_C_CMDS - Commands for compiling C source code.
+define COMPILE_C_CMDS
+       @mkdir -p $(dir $@)
+       @echo CC $<
+       @$(strip ${COMPILE.c} -o $@ -c -MD ${CFLAGS} ${SRC_CFLAGS} ${INCDIRS} \
+           ${SRC_INCDIRS} ${SRC_DEFS} ${DEFS} $<)
+endef
+
+# COMPILE_CXX_CMDS - Commands for compiling C++ source code.
+define COMPILE_CXX_CMDS
+       @mkdir -p $(dir $@)
+       @$(strip ${COMPILE.cxx} -o $@ -c -MD ${CXXFLAGS} ${SRC_CXXFLAGS} ${INCDIRS} \
+           ${SRC_INCDIRS} ${SRC_DEFS} ${DEFS} $<)
+endef
+
+# INCLUDE_SUBMAKEFILE - Parameterized "function" that includes a new
+#   "submakefile" fragment into the overall Makefile. It also recursively
+#   includes all submakefiles of the specified submakefile fragment.
+#
+#   USE WITH EVAL
+#
+define INCLUDE_SUBMAKEFILE
+    # Initialize all variables that can be defined by a makefile fragment, then
+    # include the specified makefile fragment.
+    TARGET :=
+    TGT_LDFLAGS :=
+    TGT_LDLIBS :=
+    TGT_LINKER :=
+    TGT_POSTCLEAN :=
+    TGT_POSTMAKE :=
+    TGT_PREREQS :=
+    TGT_POSTINSTALL :=
+    TGT_INSTALLDIR := ..
+    TGT_CHECK_HEADERS :=
+    TGT_CHECK_LIBS :=
+
+    SOURCES :=
+    SRC_CFLAGS :=
+    SRC_CXXFLAGS :=
+    SRC_DEFS :=
+    SRC_INCDIRS :=
+    MAN :=
+
+    SUBMAKEFILES :=
+
+    # A directory stack is maintained so that the correct paths are used as we
+    # recursively include all submakefiles. Get the makefile's directory and
+    # push it onto the stack.
+    DIR := $(call CANONICAL_PATH,$(dir ${1}))
+    DIR_STACK := $$(call PUSH,$${DIR_STACK},$${DIR})
+
+    include ${1}
+
+    # Initialize internal local variables.
+    OBJS :=
+
+    # Determine which target this makefile's variables apply to. A stack is
+    # used to keep track of which target is the "current" target as we
+    # recursively include other submakefiles.
+    ifneq "$$(strip $${TARGET})" ""
+        # This makefile defined a new target. Target variables defined by this
+        # makefile apply to this new target. Initialize the target's variables.
+
+        # libs go into ${BUILD_DIR}/lib
+        # everything else goes into ${BUILD_DIR}/bin
+#        TGT := $$(strip $$(if $$(suffix $${TARGET}),$${BUILD_DIR}/lib,$${BUILD_DIR}/bin)/$${TARGET})
+        TGT := $${TARGET}
+
+        # A "hook" to rewrite "libfoo.a" -> "libfoo.la" when using libtool
+        $$(eval $$(call ADD_LIBTOOL_SUFFIX))
+
+        ALL_TGTS += $${TGT}
+        $${TGT}_LDFLAGS := $${TGT_LDFLAGS}
+        $${TGT}_LDLIBS := $${TGT_LDLIBS}
+        $${TGT}_LINKER := $${TGT_LINKER}
+        $${TGT}_POSTMAKE := $${TGT_POSTMAKE}
+        $${TGT}_POSTCLEAN := $${TGT_POSTCLEAN}
+        $${TGT}_POSTINSTALL := $${TGT_POSTINSTALL}
+        $${TGT}_PREREQS := $${TGT_PREREQS}
+        $${TGT}_PRBIN := $$(addprefix $${BUILD_DIR}/bin/,$$(filter-out %.a %.so %.la,$${TGT_PREREQS}))
+        $${TGT}_PRLIBS := $$(addprefix $${BUILD_DIR}/lib/,$$(filter %.a %.so %.la,$${TGT_PREREQS}))
+        $${TGT}_DEPS :=
+        $${TGT}_OBJS :=
+        $${TGT}_SOURCES :=
+        $${TGT}_MAN := $${MAN}
+        $${TGT}_SUFFIX := $$(if $$(suffix $${TGT}),$$(suffix $${TGT}),.exe)
+        $${TGT}_BUILD := $$(if $$(suffix $${TGT}),$${BUILD_DIR}/lib,$${BUILD_DIR}/bin)
+        $${TGT}_MAKEFILES += ${1}
+        $${TGT}_CHECK_HEADERS := $${TGT_CHECK_HEADERS}
+        $${TGT}_CHECK_LIBS := $${TGT_CHECK_LIBS}
+    else
+        # The values defined by this makefile apply to the the "current" target
+        # as determined by which target is at the top of the stack.
+        TGT := $$(strip $$(call PEEK,$${TGT_STACK}))
+        $${TGT}_LDFLAGS   += $${TGT_LDFLAGS}
+        $${TGT}_LDLIBS    += $${TGT_LDLIBS}
+        $${TGT}_POSTCLEAN += $${TGT_POSTCLEAN}
+        $${TGT}_POSTMAKE  += $${TGT_POSTMAKE}
+        $${TGT}_PREREQS   += $${TGT_PREREQS}
+    endif
+
+    # Push the current target onto the target stack.
+    TGT_STACK := $$(call PUSH,$${TGT_STACK},$${TGT})
+
+    ifneq "$$(strip $${SOURCES})" ""
+        # This makefile builds one or more objects from source. Validate the
+        # specified sources against the supported source file types.
+        BAD_SRCS := $$(strip $$(filter-out $${ALL_SRC_EXTS},$${SOURCES}))
+        ifneq "$${BAD_SRCS}" ""
+            $$(error Unsupported source file(s) found in ${1} [$${BAD_SRCS}])
+        endif
+
+        # Qualify and canonicalize paths.
+        SOURCES     := $$(call QUALIFY_PATH,$${DIR},$${SOURCES})
+        SOURCES     := $$(call CANONICAL_PATH,$${SOURCES})
+        SRC_INCDIRS := $$(call QUALIFY_PATH,$${DIR},$${SRC_INCDIRS})
+        SRC_INCDIRS := $$(call CANONICAL_PATH,$${SRC_INCDIRS})
+
+        # Save the list of source files for this target.
+        $${TGT}_SOURCES += $${SOURCES}
+
+        # Convert the source file names to their corresponding object file
+        # names.
+        OBJS := $$(addprefix $${BUILD_DIR}/objs/,\
+                   $$(addsuffix .${OBJ_EXT},$$(basename $${SOURCES})))
+
+        # Add the objects to the current target's list of objects, and create
+        # target-specific variables for the objects based on any source
+        # variables that were defined.
+        $${TGT}_OBJS += $${OBJS}
+        $${TGT}_DEPS += $$(addprefix $${BUILD_DIR}/make/src/,\
+                   $$(addsuffix .mk,$$(basename $${SOURCES})))
+
+        # A "hook" to define variables needed by the "legacy" makefiles.
+        $$(eval $$(call ADD_LEGACY_VARIABLES,$$(dir ${1}),$${TGT}))
+
+        $${OBJS}: SRC_CFLAGS := $${SRC_CFLAGS}
+        $${OBJS}: SRC_CXXFLAGS := $${SRC_CXXFLAGS}
+        $${OBJS}: SRC_DEFS := $$(addprefix -D,$${SRC_DEFS})
+        $${OBJS}: SRC_INCDIRS := $$(addprefix -I,$${SRC_INCDIRS})
+    endif
+
+    ifneq "$$(strip $${SUBMAKEFILES})" ""
+        # This makefile has submakefiles. Recursively include them.
+        $$(foreach MK,$${SUBMAKEFILES},\
+           $$(eval $$(call INCLUDE_SUBMAKEFILE,\
+                      $$(call CANONICAL_PATH,\
+                         $$(call QUALIFY_PATH,$${DIR},$${MK})))))
+    endif
+
+    # Reset the "current" target to it's previous value.
+    TGT_STACK := $$(call POP,$${TGT_STACK})
+    # If we're about to change targets, create the rules for the target
+    ifneq "$${TGT}" "$$(call PEEK,$${TGT_STACK})"
+        # add rules to build the target, and have "all" depend on it.
+        $$(eval $$(call ADD_TARGET_TO_ALL,$${TGT}))
+
+        # A "hook" to add rules for ${TARGET_DIR}/foo, if TARGET_DIR
+        # is defined.  Otherwise, we leave the source directory untouched.
+        $$(eval $$(call ADD_TARGET_DIR,$${TGT}))
+
+        # A "hook" to build the libtool target.
+        $$(eval $$(call ADD_LIBTOOL_TARGET))
+
+        # Choose the correct linker.
+        ifeq "$$(strip $$(filter $${CXX_SRC_EXTS},$${$${TGT}_SOURCES}))" ""
+            ifeq "$${$${TGT}_LINKER}" ""
+                $${TGT}_LINKER := ${LL}$${LINK.c}
+            endif
+        else
+            ifeq "$${$${TGT}_LINKER}" ""
+                $${TGT}_LINKER := ${LL}$${LINK.cxx}
+            endif
+        endif
+
+        # add rules to build the target
+        $$(eval $$(call ADD_TARGET_RULE$${$${TGT}_SUFFIX},$${TGT}))
+
+        # generate the clean rule for this target.
+        $$(eval $$(call ADD_CLEAN_RULE,$${TGT}))
+
+        # Hook to add an installation target
+        $$(eval $$(call ADD_INSTALL_TARGET,$${TGT}))
+
+        # Hook to add a configuration target
+        $$(eval $$(call ADD_TARGET_CONFIG,$${TGT}))
+
+        # "hook" for legacy Makefiles
+        $$(eval $$(call ADD_LEGACY_RULE,$${TGT}))
+    endif
+
+    TGT := $$(call PEEK,$${TGT_STACK})
+
+    # Reset the "current" directory to it's previous value.
+    DIR_STACK := $$(call POP,$${DIR_STACK})
+    DIR := $$(call PEEK,$${DIR_STACK})
+endef
+
+# MIN - Parameterized "function" that results in the minimum lexical value of
+#   the two values given.
+define MIN
+$(firstword $(sort ${1} ${2}))
+endef
+
+# PEEK - Parameterized "function" that results in the value at the top of the
+#   specified colon-delimited stack.
+define PEEK
+$(lastword $(subst :, ,${1}))
+endef
+
+# POP - Parameterized "function" that pops the top value off of the specified
+#   colon-delimited stack, and results in the new value of the stack. Note that
+#   the popped value cannot be obtained using this function; use peek for that.
+define POP
+${1:%:$(lastword $(subst :, ,${1}))=%}
+endef
+
+# PUSH - Parameterized "function" that pushes a value onto the specified colon-
+#   delimited stack, and results in the new value of the stack.
+define PUSH
+${2:%=${1}:%}
+endef
+
+# QUALIFY_PATH - Given a "root" directory and one or more paths, qualifies the
+#   paths using the "root" directory (i.e. appends the root directory name to
+#   the paths) except for paths that are absolute.
+define QUALIFY_PATH
+$(addprefix ${1}/,$(filter-out /%,${2})) $(filter /%,${2})
+endef
+
+###############################################################################
+#
+# Start of Makefile Evaluation
+#
+###############################################################################
+
+# Older versions of GNU Make lack capabilities needed by boilermake.
+# With older versions, "make" may simply output "nothing to do", likely leading
+# to confusion. To avoid this, check the version of GNU make up-front and
+# inform the user if their version of make doesn't meet the minimum required.
+MIN_MAKE_VERSION := 3.81
+MIN_MAKE_VER_MSG := boilermake requires GNU Make ${MIN_MAKE_VERSION} or greater
+ifeq "${MAKE_VERSION}" ""
+    $(info GNU Make not detected)
+    $(error ${MIN_MAKE_VER_MSG})
+endif
+ifneq "${MIN_MAKE_VERSION}" "$(call MIN,${MIN_MAKE_VERSION},${MAKE_VERSION})"
+    $(info This is GNU Make version ${MAKE_VERSION})
+    $(error ${MIN_MAKE_VER_MSG})
+endif
+
+# Define the source file extensions that we know how to handle.
+OBJ_EXT := o
+C_SRC_EXTS := %.c
+CXX_SRC_EXTS := %.C %.cc %.cp %.cpp %.CPP %.cxx %.c++
+ALL_SRC_EXTS := ${C_SRC_EXTS} ${CXX_SRC_EXTS}
+
+# Initialize global variables.
+ALL_TGTS :=
+DEFS :=
+DIR_STACK :=
+INCDIRS :=
+TGT_STACK :=
+
+ifeq "${top_builddir}" ""
+    top_builddir := .
+endif
+
+# Ensure that valid values are set for BUILD_DIR
+ifeq "$(strip ${BUILD_DIR})" ""
+    ifeq "${top_builddir}" "${PWD}"
+        BUILD_DIR := build
+    else
+        BUILD_DIR := ${top_builddir}/build
+    endif
+else
+    BUILD_DIR := $(call CANONICAL_PATH,${BUILD_DIR})
+endif
+
+# Define compilers and linkers
+#
+COMPILE.c = ${CC}
+COMPILE.cxx = ${CXX}
+CPP = cc -E
+LINK.c = ${CC}
+LINK.cxx = ${CXX}
+
+# Define the "all" target (which simply builds all user-defined targets) as the
+# default goal.
+.PHONY: all
+all: 
+
+# Add "clean" rules to remove all build-generated files.
+.PHONY: clean
+clean:
+
+top_makedir := $(dir $(lastword ${MAKEFILE_LIST}))
+
+-include ${top_makedir}/install.mk
+-include ${top_makedir}/libtool.mk
+
+# Include the main user-supplied submakefile. This also recursively includes
+# all other user-supplied submakefiles.
+$(eval $(call INCLUDE_SUBMAKEFILE,${top_builddir}/main.mk))
+
+# Perform post-processing on global variables as needed.
+DEFS := $(addprefix -D,${DEFS})
+INCDIRS := $(addprefix -I,$(call CANONICAL_PATH,${INCDIRS}))
+
+# Add pattern rule(s) for creating compiled object code from C source.
+$(foreach EXT,${C_SRC_EXTS},\
+  $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_C_CMDS})))
+
+# Add pattern rule(s) for creating compiled object code from C++ source.
+$(foreach EXT,${CXX_SRC_EXTS},\
+  $(eval $(call ADD_OBJECT_RULE,${EXT},$${COMPILE_CXX_CMDS})))
+
+# Don't include the target dependencies if we're doing a "make clean"
+# Future: have a list of targets that don't require dependency generation,
+#  and see if MAKECMDGOALS is one of them.
+ifneq "$(MAKECMDGOALS)" "clean"
+    $(foreach TGT,${ALL_TGTS},\
+      $(eval -include ${${TGT}_DEPS}))
+endif
diff --git a/scripts/install.mk b/scripts/install.mk
new file mode 100644 (file)
index 0000000..10b3474
--- /dev/null
@@ -0,0 +1,228 @@
+# boilermake: A reusable, but flexible, boilerplate Makefile.
+#
+# Copyright 2008, 2009, 2010 Dan Moulding, Alan T. DeKok
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# ADD_INSTALL_RULE.* - Parameterized "functions" that adds a new
+#   installation to the Makefile.  There should be one ADD_INSTALL_RULE
+#   definition for each type of target that is used in the build.
+#
+#   New rules can be added by copying one of the existing ones, and
+#   replacing the line after the "mkdir"
+#
+
+# ADD_INSTALL_RULE.exe - Parameterized "function" that adds a new rule
+#   and phony target for installing an executable.
+#
+#   USE WITH EVAL
+#
+define ADD_INSTALL_RULE.exe
+    ALL_INSTALL += $${${1}_INSTALLDIR}/$(notdir ${1})
+
+    # Global install depends on ${1}
+    install: $${${1}_INSTALLDIR}/$(notdir ${1})
+
+    # Install executable ${1}
+    $${${1}_INSTALLDIR}/$(notdir ${1}): $${${1}_BUILD}/$${RELINK}${1}
+       @echo INSTALL $${${1}_INSTALLDIR}
+       @$${PROGRAM_INSTALL} -d -m 755 $${${1}_INSTALLDIR}
+       @$${PROGRAM_INSTALL} -c -m 755 $${BUILD_DIR}/bin/$${RELINK}${1} $${${1}_INSTALLDIR}/
+       @$${${1}_POSTINSTALL}
+
+endef
+
+# ADD_INSTALL_RULE.a - Parameterized "function" that adds a new rule
+#   and phony target for installing a static library
+#
+#   USE WITH EVAL
+#
+define ADD_INSTALL_RULE.a
+    ALL_INSTALL += $${${1}_INSTALLDIR}/$(notdir ${1})
+
+    # Global install depends on ${1}
+    install: $${${1}_INSTALLDIR}/$(notdir ${1})
+
+    # Install static library ${1}
+    $${${1}_INSTALLDIR}/$(notdir ${1}): ${1}
+       @echo INSTALL ${1}
+       @$${PROGRAM_INSTALL} -d -m 755 $${${1}_INSTALLDIR}
+       @$${PROGRAM_INSTALL} -c -m 755 $${BUILD_DIR}/lib/${1} $${${1}_INSTALLDIR}/
+       @$${${1}_POSTINSTALL}
+
+endef
+
+# ADD_INSTALL_RULE.la - Parameterized "function" that adds a new rule
+#   and phony target for installing a libtool library
+#
+#   FIXME: The libtool install *also* installs a bunch of other files.
+#          ensure that those are removed, too.
+#
+#   USE WITH EVAL
+#
+define ADD_INSTALL_RULE.la
+    ALL_INSTALL += $${${1}_INSTALLDIR}/$(notdir ${1})
+
+    # Global install depends on ${1}
+    install: $${${1}_INSTALLDIR}/$(notdir ${1})
+
+    # Install libtool library ${1}
+    $${${1}_INSTALLDIR}/$(notdir ${1}): $${${1}_BUILD}/$${RELINK}${1}
+       @echo INSTALL ${1}
+       @$${PROGRAM_INSTALL} -d -m 755 $${${1}_INSTALLDIR}
+       @$${PROGRAM_INSTALL} -c -m 755 $${BUILD_DIR}/lib/$${RELINK}${1} $${${1}_INSTALLDIR}/
+       @$${${1}_POSTINSTALL}
+
+endef
+
+# ADD_INSTALL_RULE.man - Parameterized "function" that adds a new rule
+#   and phony target for installing a "man" page.  It will take care of
+#   installing it into the correct subdirectory of "man".
+#
+#   USE WITH EVAL
+#
+define ADD_INSTALL_RULE.man
+    ALL_INSTALL += ${2}/$(notdir ${1})
+
+    # Global install depends on ${1}
+    install: ${2}/$(notdir ${1})
+
+    # Install manual page ${1}
+    ${2}/$(notdir ${1}): ${1} ${2}
+       @echo INSTALL ${1}
+       @$${PROGRAM_INSTALL} -c -m 644 ${1} ${2}/
+
+endef
+
+
+# ADD_INSTALL_TARGET - Parameterized "function" that adds a new rule
+#   which installs everything for the target.
+#
+#   USE WITH EVAL
+#
+define ADD_INSTALL_TARGET
+    # Figure out which target rule to use for installation.
+    ifeq "$${${1}_SUFFIX}" ".exe"
+        ifeq "$${TGT_INSTALLDIR}" ".."
+            TGT_INSTALLDIR := $${bindir}
+        endif
+    else 
+        ifeq "$${TGT_INSTALLDIR}" ".."
+            TGT_INSTALLDIR := $${libdir}
+        endif
+    endif
+
+    ${1}_INSTALLDIR := ${LL}$${DESTDIR}$${TGT_INSTALLDIR}
+
+    # add rules to install the target
+    ifneq "$${${1}_INSTALLDIR}" ""
+        $$(eval $$(call ADD_INSTALL_RULE$${${1}_SUFFIX},${1}))
+    endif
+
+    # add rules to install the MAN pages.
+    ifneq "$$(strip $${${1}_MAN})" ""
+        ifeq "$${mandir}" ""
+            $$(error You must define 'mandir' in order to be able to install MAN pages.)
+        endif
+
+        MAN := $$(call QUALIFY_PATH,$${DIR},$${MAN})
+        MAN := $$(call CANONICAL_PATH,$${MAN})
+
+        $$(foreach PAGE,$${MAN},\
+            $$(eval $$(call ADD_INSTALL_RULE.man,$${PAGE},\
+              $${DESTDIR}$${mandir}/man$$(subst .,,$$(suffix $${PAGE})))))
+    endif
+endef
+
+.PHONY: install
+install:
+
+ALL_INSTALL :=
+
+# Define reasonable defaults for all of the installation directories.
+# The user can over-ride these, but these are the defaults.
+ifeq "${prefix}" ""
+    prefix = /usr/local
+endif
+ifeq "${exec_prefix}" ""
+    exec_prefix = ${prefix}
+endif
+ifeq "${bindir}" ""
+    bindir = ${exec_prefix}/bin
+endif
+ifeq "${sbindir}" ""
+    sbindir = ${exec_prefix}/sbin
+endif
+ifeq "${libdir}" ""
+    libdir = ${exec_prefix}/lib
+endif
+ifeq "${sysconfdir}" ""
+    sysconfdir = ${prefix}/etc
+endif
+ifeq "${localstatedir}" ""
+    localstatedir = ${prefix}/var
+endif
+ifeq "${datarootdir}" ""
+    datarootdir = ${prefix}/share
+endif
+ifeq "${datadir}" ""
+    datadir = ${prefix}/share
+endif
+ifeq "${mandir}" ""
+    mandir = ${datadir}/man
+endif
+ifeq "${docdir}" ""
+    ifneq "${PROJECT_NAME}" ""
+        docdir = ${datadir}/doc/${PROJECT_NAME}
+    endif
+endif
+ifeq "${logdir}" ""
+    logdir = ${localstatedir}/log/
+endif
+ifeq "${includedir}" ""
+    includedir = ${prefix}/include
+endif
+
+
+# Un-install any installed programs.  We DON'T want to depend on the
+# install target.  Doing so would cause "make uninstall" to build it,
+# install it, and then remove it.
+#
+# We also want to uninstall only when there are "install_foo" targets.
+.PHONY: uninstall
+uninstall:
+       @rm -f ${ALL_INSTALL} ./.no_such_file
+
+# Wrapper around INSTALL
+ifeq "${PROGRAM_INSTALL}" ""
+    PROGRAM_INSTALL := ${INSTALL}
+
+endif
+
+# Make just the installation directories
+.PHONY: installdirs
+installdirs:
+
+# Be nice to the user.  If there is no INSTALL program, then print out
+# a helpful message.  Without this check, the "install" rules defined
+# above would try to run a command-line with a blank INSTALL, and give
+# some inscrutable error.
+ifeq "${INSTALL}" ""
+install: install_ERROR
+
+.PHONY: install_ERROR
+install_ERROR:
+       @echo Please define INSTALL in order to enable the installation rules.
+       @exit 1
+endif
diff --git a/scripts/libtool.mk b/scripts/libtool.mk
new file mode 100644 (file)
index 0000000..c58569a
--- /dev/null
@@ -0,0 +1,212 @@
+# Copyright 2008, 2009, 2010 Dan Moulding, Alan T. DeKok
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Add these rules only when LIBTOOL is being used.
+ifneq "${LIBTOOL}" ""
+
+# JLIBTOOL - check if we're using the local (fast) jlibtool, rather
+#   than the GNU (slow) libtool shell script.  If so, add rules
+#   to build it.
+
+ifeq "${LIBTOOL}" "JLIBTOOL"
+    JLIBTOOL := ${BUILD_DIR}/make/jlibtool
+
+    # Add a rule to build jlibtool BEFORE any other targets.  This
+    # means that we can use it to build the later targets.
+    all install: ${JLIBTOOL}
+
+    # Note that we need to use a compilation rule that does NOT
+    # include referencing ${LIBTOOL}, as we don't have a jlibtool
+    # binary!
+    jlibtool ${JLIBTOOL}: ${top_makedir}/jlibtool.c
+       @mkdir -p $(dir ${JLIBTOOL})
+       ${CC} $< -o ${JLIBTOOL}
+
+    clean: jlibtool_clean
+
+    .PHONY: jlibtool_clean
+    jlibtool_clean:
+       @rm -f ${JLIBTOOL}
+
+    # Tell GNU Make to use this value, rather than anything specified
+    # on the command line.
+    override LIBTOOL := ${JLIBTOOL}
+endif    # else we're not using jlibtool
+
+# When using libtool, it produces a '.libs' directory.  Ensure that it
+# is removed on "make clean", too.
+#
+clean: .libs_clean
+
+.PHONY: .libs_clean
+.libs_clean:
+       @rm -rf ${BUILD_DIR}/.libs/
+
+# Re-define compilers and linkers
+#
+OBJ_EXT = lo
+COMPILE.c = ${LIBTOOL} --silent --mode=compile ${CC}
+COMPILE.cxx = ${LIBTOOL} --mode=compile ${CXX}
+LINK.c = ${LIBTOOL} --silent --mode=link ${CC}
+LINK.cxx = ${LIBTOOL} --mode=link ${CXX}
+PROGRAM_INSTALL = ${LIBTOOL} --silent --mode=install ${INSTALL}
+
+
+# LIBTOOL_ENDINGS - Given a library ending in ".a" or ".so", replace that
+#   extension with ".la".
+#
+define LIBTOOL_ENDINGS
+$(patsubst %.a,%.la,$(patsubst %.so,%.la,${1}))
+endef
+
+# ADD_TARGET_RULE.la - Build a ".la" target.
+#
+#   USE WITH EVAL
+#
+define ADD_TARGET_RULE.la
+    # So "make ${1}" works
+    .PHONY: ${1}
+    ${1}: $${${1}_BUILD}/${1}
+
+    # Create libtool library ${1}
+    $${${1}_BUILD}/${1}: $${${1}_OBJS} $${${1}_PREREQS}
+           @$(strip mkdir -p $(dir $${${1}_BUILD}/${1}))
+           @echo LINK $${${1}_BUILD}/${1}
+           @$${${1}_LINKER} -o $${${1}_BUILD}/${1} $${RPATH_FLAGS} $${LDFLAGS} \
+                $${${1}_LDFLAGS} $${${1}_OBJS} $${LDLIBS} $${${1}_LDLIBS}
+           @$${${1}_POSTMAKE}
+
+endef
+
+# ADD_RELINK_RULE.exe - Parametric "function" that adds a rule to relink
+#   the target before installation, so that the paths are correct.
+#
+#   USE WITH EVAL
+#
+define ADD_RELINK_RULE.exe
+    ${1}: $${${1}_BUILD}/$${${1}_RELINK}
+
+    # used to fix up RPATH for ${1} on install.
+    $${${1}_BUILD}/$${${1}_RELINK}: $${${1}_OBJS} $${${1}_PRBIN} $${${1}_R_PRLIBS}
+           @$(strip mkdir -p $${${1}_BUILD}/${RELINK}/)
+           @$${${1}_LINKER} -o $${${1}_BUILD}/$${${1}_RELINK} $${RELINK_FLAGS} $${LDFLAGS} \
+                $${${1}_LDFLAGS} $${${1}_OBJS} $${${1}_R_PRLIBS} \
+                $${LDLIBS} $${${1}_LDLIBS}
+           @$${${1}_POSTMAKE}
+endef
+
+# ADD_RELINK_RULE.la - Parametric "function" that adds a rule to relink
+#   the target before installation, so that the paths are correct.
+#
+#   USE WITH EVAL
+#
+define ADD_RELINK_RULE.la
+    ${1}: $${${1}_BUILD}/$${${1}_RELINK}
+
+    # used to fix up RPATH for ${1} on install.
+    $${${1}_BUILD}/$${${1}_RELINK}: $${${1}_OBJS} $${${1}_PREREQS}
+           @$(strip mkdir -p $${${1}_BUILD}/${RELINK}/)
+           @$${${1}_LINKER} -o $${${1}_BUILD}/$${${1}_RELINK} $${RELINK_FLAGS} $${LDFLAGS} \
+                $${${1}_LDFLAGS} $${${1}_OBJS} $${LDLIBS} $${${1}_LDLIBS}
+           @$${${1}_POSTMAKE}
+
+endef
+
+# By default, if libdir is defined, we build shared libraries.
+# However, we can disable shared libraries if explicitly told to.
+ifneq "${libdir}" ""
+    ifneq "bm_shared_libs" "no"
+        bm_shared_libs := yes
+    endif
+endif
+
+# Default to building static libraries, too.
+ifneq "${bm_static_libs}" "no"
+    bm_static_libs := yes
+endif
+
+# Check if we build shared libraries.
+ifeq "${bm_shared_libs}" "yes"
+    # RPATH  : flags use to build executables that can be run
+    #          from the build directory / source tree.
+    # RELINK : flags use to build executables that are installed,
+    #          with no dependency on the source. 
+    RPATH_FLAGS := -rpath $(abspath ${BUILD_DIR})/lib/.libs -rdynamic
+    RELINK_FLAGS := -rpath ${libdir} -rdynamic
+    RELINK := relink/
+
+    ifneq "${bm_static_libs}" "yes"
+        RPATH_FLAGS += --shared
+        RELINK_FLAGS += --shared
+    endif
+else
+    ifneq "${bm_static_libs}" "yes"
+        $(error Building without static libraries requires you to set 'INSTALL' or 'libdir')
+    endif
+
+    RPATH_FLAGS := -static
+endif
+
+# UPDATE_TARGET_ENDINGS - Function to turn target into a libtool target
+#   e.g. "libfoo.a" -> libfoo.la"
+#
+#   If the target is an executable, then its extension doesn't change
+#   when we use libtool, and we don't do any re-writing.
+#
+#   USE WITH EVAL
+#
+define ADD_LIBTOOL_SUFFIX
+    ifneq "$$(call LIBTOOL_ENDINGS,$${TGT})" "$${TGT}"
+        TGT_NOLIBTOOL := $${TGT}
+        TGT := $$(call LIBTOOL_ENDINGS,$${TGT})
+        $${TGT}_NOLIBTOOL := $${TGT_NOLIBTOOL}
+    endif
+
+    ifneq "$${RELINK_FLAGS}" ""
+        $${TGT}_RELINK := ${RELINK}$${TGT}
+    endif
+
+    # re-write all of the dependencies to have the libtool endings.
+    TGT_PREREQS := $$(call LIBTOOL_ENDINGS,$${TGT_PREREQS})
+endef
+
+# ADD_LIBTOOL_TARGET - Function to ensure that the object files depend
+#   on our jlibtool target.  This ensures that jlibtool is built before
+#   it's used to build the object files.
+#
+#   USE WITH EVAL
+#
+define ADD_LIBTOOL_TARGET
+    ifneq "${JLIBTOOL}" ""
+        $${$${TGT}_OBJS}: $${JLIBTOOL}
+    endif
+
+    ifneq "$${$${TGT}_NOLIBTOOL}" ""
+        $$(notdir $${$${TGT}_NOLIBTOOL}): $${TGT}
+    endif
+
+    # If we need to relink, add the relink targets now.
+    ifneq "$${$${TGT}_RELINK}" ""
+        # add rules to relink the target
+
+        $${TGT}_R_PRLIBS := $$(subst /lib/,/lib/relink/,$${$${TGT}_PRLIBS})
+
+        $$(eval $$(call ADD_RELINK_RULE$${$${TGT}_SUFFIX},$${TGT}))
+    endif
+
+endef
+
+
+endif
diff --git a/scripts/main.mk b/scripts/main.mk
new file mode 100644 (file)
index 0000000..4184970
--- /dev/null
@@ -0,0 +1,44 @@
+# We don't use boilermake here because we want to run the test-app
+# as a self-contained system that runs boilermake.
+#
+
+all: run-tests
+
+APP := ./test-app/build/bin/talk
+
+.PHONY: run-tests
+run-tests:
+       ${MAKE} clean
+       ${MAKE} -C test-app/
+       ${APP} > found.txt
+       diff expected.txt found.txt
+       ${MAKE} -C test-app/ DESTDIR=`pwd`/R INSTALL=`pwd`/install-sh install
+       find R/* -print > found-install.txt
+       diff expected-install.txt found-install.txt
+       ${APP} > found.txt
+       diff expected.txt found.txt
+       ${MAKE} -C test-app/ DESTDIR=`pwd`/R INSTALL=`pwd`/install-sh uninstall
+       find R/* -print > found-install.txt
+       diff empty-install.txt found-install.txt
+       ${MAKE} clean
+       ${MAKE} -C test-app/ LIBTOOL=JLIBTOOL DESTDIR=`pwd`/R INSTALL=`pwd`/install-sh all
+       ${APP} > found.txt
+       diff expected.txt found.txt
+       ${MAKE} -C test-app/ LIBTOOL=JLIBTOOL DESTDIR=`pwd`/R INSTALL=`pwd`/install-sh install
+# don't do "find", as we have *.la files installed, rather than *.a
+       ${APP} > found.txt
+       diff expected.txt found.txt
+       ${MAKE} clean
+       rm -rf R found found-install.txt
+
+clean: clean.local
+
+clean.local:
+       ${MAKE} -C test-app/ clean
+       ${MAKE} -C test-app/ LIBTOOL=x clean
+       rm -rf ./R *~ found.txt found-install.txt
+
+check-legacy:
+       @grep '$$(' `find test-app/build/make -type f -name "*\.mk" -print` || true
+       @grep ' /' `find test-app/build/make -type f -name "*\.mk" -print` || true
+       @grep ' build' `find test-app/build/make -type f -name "*\.mk" -print` || true
diff --git a/src/all.mk b/src/all.mk
new file mode 100644 (file)
index 0000000..1591b7b
--- /dev/null
@@ -0,0 +1,11 @@
+# add this dependency BEFORE including the other submakefiles.
+all: ${BUILD_DIR}/make/include/freeradius-devel
+
+#TARGET        := src/freeradius-devel
+
+# Ensure that the devel files have access to radpaths.h
+${BUILD_DIR}/make/include/freeradius-devel: src/include/radpaths.h
+       [ -e $@ ] || (mkdir -p $(dir $@) && ln -s ${top_builddir}/src/include $@)
+
+SUBMAKEFILES := include/all.mk lib/all.mk modules/all.mk main/all.mk
+
diff --git a/src/include/all.mk b/src/include/all.mk
new file mode 100644 (file)
index 0000000..93597c4
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# Makefile
+#
+# Version:     $Id$
+#
+
+HEADERS        = autoconf.h conf.h conffile.h detail.h dhcp.h event.h hash.h heap.h \
+       ident.h libradius.h md4.h md5.h missing.h modcall.h modules.h \
+       packet.h rad_assert.h radius.h radiusd.h radpaths.h \
+       radutmp.h realms.h sha1.h stats.h sysutmp.h token.h \
+       udpfromto.h vmps.h vqp.h
+
+# Our target
+TARGET := src/include/radpaths.h
+
+src/include/radpaths.h: src/include/build-radpaths-h
+       cd src/include && /bin/sh build-radpaths-h
+
+# global install depends on the local rule
+install: install.src.include
+
+# define the installation directory
+SRC_INCLUDE_DIR := ${R}${includedir}/freeradius
+
+# the local rule depends on the installed headers
+install.src.include: $(addprefix ${SRC_INCLUDE_DIR}/,${HEADERS})
+
+# the installed headers require a directory
+$(addprefix ${SRC_INCLUDE_DIR}/,${HEADERS}): ${SRC_INCLUDE_DIR}/
+
+# make the directory
+.PHONY: 
+${SRC_INCLUDE_DIR}/:
+       $(INSTALL) -d -m 755 $@
+
+# install the headers by re-writing the local files
+${SRC_INCLUDE_DIR}/%.h: ${top_srcdir}/src/include/%.h
+       @echo INSTALL $(notdir $<)
+       @sed 's/^#include <freeradius-devel/#include <freeradius/' < $^ > $@
+       @chmod 644 $@
diff --git a/src/lib/all.mk b/src/lib/all.mk
new file mode 100644 (file)
index 0000000..15f6c9b
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# Makefile
+#
+# Version:      $Id$
+#
+
+SOURCES                := dict.c filters.c hash.c hmac.c hmacsha1.c isaac.c log.c \
+                 misc.c missing.c md4.c md5.c print.c radius.c rbtree.c \
+                 sha1.c snprintf.c strlcat.c strlcpy.c token.c udpfromto.c \
+                 valuepair.c fifo.c packet.c event.c getaddrinfo.c vqp.c \
+                 heap.c dhcp.c tcp.c
+
+INCLUDES       = ../include/radius.h ../include/libradius.h \
+                 ../include/missing.h ../include/autoconf.h \
+                 ../include/ident.h
+
+SRC_CFLAGS     := -D_LIBRADIUS -I$(top_builddir)/src
+
+TARGET         := libfreeradius-radius.a
diff --git a/src/main/all.mk b/src/main/all.mk
new file mode 100644 (file)
index 0000000..f14e331
--- /dev/null
@@ -0,0 +1 @@
+SUBMAKEFILES := radclient.mk radiusd.mk
diff --git a/src/main/radclient.mk b/src/main/radclient.mk
new file mode 100644 (file)
index 0000000..1b72ac1
--- /dev/null
@@ -0,0 +1,8 @@
+TGT_PREREQS := libfreeradius-radius.a
+SRC_CFLAGS := -I${top_srcdir}/src/modules/rlm_mschap
+SRC_CFLAGS     += -DRADIUSD_VERSION=\"${RADIUSD_VERSION}\"
+
+SOURCES        := radclient.c ${top_srcdir}/src/modules/rlm_mschap/smbdes.c \
+          ${top_srcdir}/src/modules/rlm_mschap/mschap.c
+
+TARGET := radclient
diff --git a/src/main/radiusd.mk b/src/main/radiusd.mk
new file mode 100644 (file)
index 0000000..c9304ea
--- /dev/null
@@ -0,0 +1,68 @@
+SOURCES := acct.c auth.c client.c conffile.c crypt.c exec.c files.c \
+                 listen.c log.c mainconfig.c modules.c modcall.c \
+                 radiusd.c stats.c soh.c \
+                 session.c threads.c util.c valuepair.c version.c  \
+                 xlat.c process.c realms.c evaluate.c vmps.c detail.c
+ifneq ($(OPENSSL_LIBS),)
+SOURCES        += cb.c tls.c
+endif
+
+SRC_CFLAGS     := -DHOSTINFO=\"${HOSTINFO}\"
+SRC_CFLAGS     += -DRADIUSD_VERSION=\"${RADIUSD_VERSION}\"
+SRC_CFLAGS     += $(OPENSSL_INCLUDE)
+TGT_INSTALLDIR  := ${sbindir}
+TGT_LDLIBS     := $(OPENSSL_LIBS)
+TGT_LDFLAGS     := -framework DirectoryService
+
+TGT_PREREQS    := libfreeradius-radius.a $(filter rlm_%,${ALL_TGTS})
+
+ifneq "${LIBTOOL}" ""
+SRC_FLAGS      += -DWITH_DLOPEN
+else
+${DIR}/modules.c:      ${BUILD_DIR}/make/include/lt_dlmodules.c
+
+# Find the modules
+ALL_MODULES    := $(patsubst %.a,%,$(filter rlm_%,${ALL_TGTS}))
+ALL_MODULES    := $(patsubst %.la,%,$(filter rlm_%,${ALL_MODULES}))
+
+# Filter out ones with additional library dependencies.
+# For the future, go through ALL modules and add their library dependencies
+# to the TGT_LDLIBS.
+ALL_MODULES    := $(filter-out rlm_perl rlm_ldap rlm_pam rlm_krb5 rlm_python,${ALL_MODULES})
+
+# EAP and SQL require different variable declarations.
+EAP_MODULES    := $(filter rlm_eap_%,${ALL_MODULES})
+SQL_MODULES    := $(filter rlm_sql_%,${ALL_MODULES})
+
+BASE_MODULES   := $(filter-out ${EAP_MODULES} ${SQL_MODULES},${ALL_MODULES})
+
+#
+#  Create the intermediate file which links to the modules.
+#  And have it depend on this Makefile, which creates it.
+#
+${BUILD_DIR}/make/include/lt_dlmodules.c: $(addprefix ${BUILD_DIR}/lib/,$(filter rlm_%,${ALL_TGTS})) $(lastword ${MAKEFILE_LIST})
+       @rm -f $@
+       @for x in ${BASE_MODULES}; do \
+               echo "extern module_t $$x;" >> $@; \
+       done
+       @for x in ${EAP_MODULES}; do \
+               echo "extern EAP_TYPE $$x;" >> $@; \
+       done
+       @for x in ${SQL_MODULES}; do \
+               echo "extern rlm_sql_module_t $$x;" >> $@; \
+       done
+       @echo "static const lt_dlmodule_t lt_dlmodules[] = {" >> $@
+       @for x in ${ALL_MODULES}; do \
+               echo "{ \"$$x\", &$$x }," >> $@; \
+       done
+       @echo "{ NULL, NULL }" >> $@
+       @echo "};" >> $@
+endif
+
+# Libraries can't depend on libraries (oops), so make the binary
+# depend on the EAP code...
+ifneq "$(filter rlm_eap_%,${ALL_TGTS})" ""
+TGT_PREREQS    += libfreeradius-eap.a
+endif
+
+TARGET         := radiusd
diff --git a/src/modules/all.mk b/src/modules/all.mk
new file mode 100644 (file)
index 0000000..fb41496
--- /dev/null
@@ -0,0 +1 @@
+SUBMAKEFILES := $(wildcard ${top_srcdir}/src/modules/rlm_*/all.mk)
diff --git a/src/modules/rlm_acct_unique/all.mk b/src/modules/rlm_acct_unique/all.mk
new file mode 100644 (file)
index 0000000..08a6a41
--- /dev/null
@@ -0,0 +1,3 @@
+SOURCES                := rlm_acct_unique.c
+
+TARGET         := rlm_acct_unique.a
diff --git a/src/modules/rlm_acctlog/all.mk b/src/modules/rlm_acctlog/all.mk
new file mode 100644 (file)
index 0000000..84fad35
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET      := rlm_acctlog.a
+
+SOURCES     := rlm_acctlog.c
diff --git a/src/modules/rlm_always/all.mk b/src/modules/rlm_always/all.mk
new file mode 100644 (file)
index 0000000..8fa6663
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET         := rlm_always.a
+
+SOURCES                := rlm_always.c
diff --git a/src/modules/rlm_attr_filter/all.mk b/src/modules/rlm_attr_filter/all.mk
new file mode 100644 (file)
index 0000000..6eb4442
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_attr_filter.a
+SOURCES                = rlm_attr_filter.c
diff --git a/src/modules/rlm_attr_rewrite/all.mk b/src/modules/rlm_attr_rewrite/all.mk
new file mode 100644 (file)
index 0000000..17c6e9c
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = rlm_attr_rewrite.a
+SOURCES        = rlm_attr_rewrite.c
diff --git a/src/modules/rlm_chap/all.mk b/src/modules/rlm_chap/all.mk
new file mode 100644 (file)
index 0000000..19b0d95
--- /dev/null
@@ -0,0 +1,3 @@
+SOURCES := rlm_chap.c
+
+TARGET := rlm_chap.a
diff --git a/src/modules/rlm_checkval/all.mk b/src/modules/rlm_checkval/all.mk
new file mode 100644 (file)
index 0000000..f66d692
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = rlm_checkval.a
+SOURCES        = rlm_checkval.c
diff --git a/src/modules/rlm_copy_packet/all.mk b/src/modules/rlm_copy_packet/all.mk
new file mode 100644 (file)
index 0000000..0223986
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_copy_packet.a
+SOURCES                = rlm_copy_packet.c
diff --git a/src/modules/rlm_counter/all.mk b/src/modules/rlm_counter/all.mk
new file mode 100644 (file)
index 0000000..ded5427
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = 
+SOURCES        = rlm_counter.c
diff --git a/src/modules/rlm_cram/all.mk b/src/modules/rlm_cram/all.mk
new file mode 100644 (file)
index 0000000..15998f0
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_cram.a
+SOURCES                = rlm_cram.c
diff --git a/src/modules/rlm_dbm/all.mk b/src/modules/rlm_dbm/all.mk
new file mode 100644 (file)
index 0000000..c37bc82
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = 
+SOURCES        = rlm_dbm.c
diff --git a/src/modules/rlm_detail/all.mk b/src/modules/rlm_detail/all.mk
new file mode 100644 (file)
index 0000000..01227d8
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET = rlm_detail.a
+SOURCES        = rlm_detail.c
diff --git a/src/modules/rlm_digest/all.mk b/src/modules/rlm_digest/all.mk
new file mode 100644 (file)
index 0000000..9bf0567
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_digest.a
+SOURCES                = rlm_digest.c
diff --git a/src/modules/rlm_dynamic_clients/all.mk b/src/modules/rlm_dynamic_clients/all.mk
new file mode 100644 (file)
index 0000000..b4e7f50
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_dynamic_clients.a
+SOURCES                = rlm_dynamic_clients.c
diff --git a/src/modules/rlm_eap/all.mk b/src/modules/rlm_eap/all.mk
new file mode 100644 (file)
index 0000000..f2cb44b
--- /dev/null
@@ -0,0 +1 @@
+SUBMAKEFILES := libeap/all.mk rlm_eap.mk types/all.mk radeapclient.mk
diff --git a/src/modules/rlm_eap/libeap/all.mk b/src/modules/rlm_eap/libeap/all.mk
new file mode 100644 (file)
index 0000000..ff48e67
--- /dev/null
@@ -0,0 +1,10 @@
+TARGET := libfreeradius-eap.a
+
+SOURCES        := eapcommon.c eapcrypto.c eapsimlib.c fips186prf.c
+ifneq (${OPENSSL_LIBS},)
+SOURCES                += eap_tls.c mppe_keys.c
+endif
+
+SRC_CFLAGS     := -DEAPLIB $(OPENSSL_INCLUDE)
+
+SRC_INCDIRS    := . ..
diff --git a/src/modules/rlm_eap/radeapclient.mk b/src/modules/rlm_eap/radeapclient.mk
new file mode 100644 (file)
index 0000000..fde6d9c
--- /dev/null
@@ -0,0 +1,7 @@
+TARGET   := radeapclient
+SOURCES := radeapclient.c
+
+TGT_PREREQS := libfreeradius-radius.a libfreeradius-eap.a
+TGT_PRLIBS  := ${OPENSSL_LIBS}
+
+SRC_INCDIRS  := libeap
diff --git a/src/modules/rlm_eap/rlm_eap.mk b/src/modules/rlm_eap/rlm_eap.mk
new file mode 100644 (file)
index 0000000..974d4bd
--- /dev/null
@@ -0,0 +1,10 @@
+TARGET := rlm_eap.a
+
+SOURCES := rlm_eap.c eap.c mem.c
+
+SRC_INCDIRS := . libeap
+
+# FIXME: This target is "phony", which means that every "make"
+# re-builds rlm_eap.  We need to re-write this to be the name
+# of the ${BUILD_DIR}/.../filename!
+#TGT_PREREQS := libfreeradius-eap.a
diff --git a/src/modules/rlm_eap/types/all.mk b/src/modules/rlm_eap/types/all.mk
new file mode 100644 (file)
index 0000000..b85d501
--- /dev/null
@@ -0,0 +1 @@
+SUBMAKEFILES := $(wildcard ${top_srcdir}/src/modules/rlm_eap/types/rlm_eap_*/all.mk)
diff --git a/src/modules/rlm_eap/types/rlm_eap_gtc/all.mk b/src/modules/rlm_eap/types/rlm_eap_gtc/all.mk
new file mode 100644 (file)
index 0000000..519a7b3
--- /dev/null
@@ -0,0 +1,4 @@
+TARGET      := rlm_eap_gtc.a
+SOURCES     := rlm_eap_gtc.c
+
+SRC_INCDIRS := ../.. ../../libeap
diff --git a/src/modules/rlm_eap/types/rlm_eap_leap/all.mk b/src/modules/rlm_eap/types/rlm_eap_leap/all.mk
new file mode 100644 (file)
index 0000000..d385a26
--- /dev/null
@@ -0,0 +1,4 @@
+TARGET      = rlm_eap_leap.a
+SOURCES        = rlm_eap_leap.c eap_leap.c smbdes.c
+SRC_INCDIRS  = ../.. ../../libeap
+HEADERS     = eap_leap.h  ../../eap.h ../../rlm_eap.h
diff --git a/src/modules/rlm_eap/types/rlm_eap_md5/all.mk b/src/modules/rlm_eap/types/rlm_eap_md5/all.mk
new file mode 100644 (file)
index 0000000..60c3ea2
--- /dev/null
@@ -0,0 +1,5 @@
+TARGET      := rlm_eap_md5.a
+SOURCES     := rlm_eap_md5.c eap_md5.c
+HEADERS     = eap_md5.h
+
+SRC_INCDIRS := ../.. ../../libeap
diff --git a/src/modules/rlm_eap/types/rlm_eap_mschapv2/all.mk b/src/modules/rlm_eap/types/rlm_eap_mschapv2/all.mk
new file mode 100644 (file)
index 0000000..b2a91eb
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET      = rlm_eap_mschapv2.a
+SOURCES      = rlm_eap_mschapv2.c
+SRC_INCDIRS  = ../.. ../../libeap
diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/all.mk b/src/modules/rlm_eap/types/rlm_eap_peap/all.mk
new file mode 100644 (file)
index 0000000..d727d5c
--- /dev/null
@@ -0,0 +1,6 @@
+TARGET      = rlm_eap_peap.a
+SOURCES        = rlm_eap_peap.c peap.c
+SRC_INCDIRS  = ../.. ../../libeap
+TGT_LDLIBS = $(OPENSSL_INCLUDE) 
+TGT_LDLIBS    =  $(OPENSSL_LIBS)
+#TGT_PREREQS = libfreeradius-eap.a
diff --git a/src/modules/rlm_eap/types/rlm_eap_tls/all.mk b/src/modules/rlm_eap/types/rlm_eap_tls/all.mk
new file mode 100644 (file)
index 0000000..5a8d688
--- /dev/null
@@ -0,0 +1,6 @@
+TARGET      = rlm_eap_tls.a
+SOURCES     = rlm_eap_tls.c
+SRC_INCDIRS  = ../.. ../../libeap 
+SRC_CFLAGS = $(OPENSSL_INCLUDE) 
+TGT_LDLIBS    =  $(OPENSSL_LIBS)
+#TGT_PREREQS  = libfreeradius-eap.a
diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/all.mk b/src/modules/rlm_eap/types/rlm_eap_ttls/all.mk
new file mode 100644 (file)
index 0000000..c79e6f9
--- /dev/null
@@ -0,0 +1,6 @@
+TARGET      = rlm_eap_ttls.a
+SOURCES        = rlm_eap_ttls.c ttls.c
+SRC_INCDIRS  = ../.. ../../libeap
+TGT_LDLIBS = $(OPENSSL_INCLUDE) 
+TGT_LDLIBS    =  $(OPENSSL_LIBS)
+#TGT_PREREQS = libfreeradius-eap.a
diff --git a/src/modules/rlm_eap2/all.mk b/src/modules/rlm_eap2/all.mk
new file mode 100644 (file)
index 0000000..4a1c5a1
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET      = 
+SOURCES        = rlm_eap2.c
+## this uses the RLM_CFLAGS and RLM_LIBS and SOURCES defs to make TARGET.
diff --git a/src/modules/rlm_exec/all.mk b/src/modules/rlm_exec/all.mk
new file mode 100644 (file)
index 0000000..60f61f3
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_exec.a
+SOURCES                = rlm_exec.c
diff --git a/src/modules/rlm_expiration/all.mk b/src/modules/rlm_expiration/all.mk
new file mode 100644 (file)
index 0000000..0b40eb2
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET  = rlm_expiration.a
+SOURCES    = rlm_expiration.c
diff --git a/src/modules/rlm_expr/all.mk b/src/modules/rlm_expr/all.mk
new file mode 100644 (file)
index 0000000..110867e
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_expr.a
+SOURCES                = rlm_expr.c paircmp.c
diff --git a/src/modules/rlm_fastusers/all.mk b/src/modules/rlm_fastusers/all.mk
new file mode 100644 (file)
index 0000000..7ca7c1e
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET = rlm_fastusers.a
+SOURCES        = rlm_fastusers.c
diff --git a/src/modules/rlm_files/all.mk b/src/modules/rlm_files/all.mk
new file mode 100644 (file)
index 0000000..c26c934
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET = rlm_files.a
+SOURCES        = rlm_files.c
diff --git a/src/modules/rlm_ippool/all.mk b/src/modules/rlm_ippool/all.mk
new file mode 100644 (file)
index 0000000..847dcdd
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = 
+SOURCES        = rlm_ippool.c
diff --git a/src/modules/rlm_jradius/all.mk b/src/modules/rlm_jradius/all.mk
new file mode 100644 (file)
index 0000000..d7d42bd
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET      = rlm_jradius.a
+SOURCES        = rlm_jradius.c 
+## this uses the RLM_CFLAGS and RLM_LIBS and SOURCES defs to make TARGET.
diff --git a/src/modules/rlm_krb5/all.mk b/src/modules/rlm_krb5/all.mk
new file mode 100644 (file)
index 0000000..0d51b1c
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET     = rlm_krb5.a
+SOURCES       = rlm_krb5.c
diff --git a/src/modules/rlm_ldap/all.mk b/src/modules/rlm_ldap/all.mk
new file mode 100644 (file)
index 0000000..53db5b5
--- /dev/null
@@ -0,0 +1,5 @@
+TARGET     = rlm_ldap.a
+SOURCES       = rlm_ldap.c 
+
+SRC_CFLAGS =    -DHAVE_LDAP_START_TLS -DHAVE_LDAP_INITIALIZE -DLDAP_DEPRECATED -DLDAP_SET_REBIND_PROC_ARGS=3
+TGT_LDLIBS   = -lldap_r 
diff --git a/src/modules/rlm_linelog/all.mk b/src/modules/rlm_linelog/all.mk
new file mode 100644 (file)
index 0000000..bd8ae68
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_linelog.a
+SOURCES                = rlm_linelog.c
diff --git a/src/modules/rlm_logintime/all.mk b/src/modules/rlm_logintime/all.mk
new file mode 100644 (file)
index 0000000..f23b508
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET  = rlm_logintime.a
+SOURCES    = rlm_logintime.c timestr.c
diff --git a/src/modules/rlm_mschap/all.mk b/src/modules/rlm_mschap/all.mk
new file mode 100644 (file)
index 0000000..ed6fb82
--- /dev/null
@@ -0,0 +1 @@
+SUBMAKEFILES := rlm_mschap.mk smbencrypt.mk
diff --git a/src/modules/rlm_mschap/rlm_mschap.mk b/src/modules/rlm_mschap/rlm_mschap.mk
new file mode 100644 (file)
index 0000000..9755f38
--- /dev/null
@@ -0,0 +1,4 @@
+
+SOURCES := rlm_mschap.c smbdes.c opendir.c mschap.c
+
+TARGET := rlm_mschap.a
diff --git a/src/modules/rlm_mschap/smbencrypt.mk b/src/modules/rlm_mschap/smbencrypt.mk
new file mode 100644 (file)
index 0000000..1208eb1
--- /dev/null
@@ -0,0 +1,4 @@
+TGT_PREREQS := libfreeradius-radius.a
+SOURCES := smbencrypt.c smbdes.c
+
+TARGET := smbencrypt
diff --git a/src/modules/rlm_otp/all.mk b/src/modules/rlm_otp/all.mk
new file mode 100644 (file)
index 0000000..7fb6e63
--- /dev/null
@@ -0,0 +1,8 @@
+# TARGET should be set by autoconf only.  Don't touch it.
+# The SOURCES definition should list ALL source files.
+TARGET         = rlm_otp.a
+SOURCES           = otp_rlm.c otp_radstate.c otp_pwe.c otp_pw_valid.c
+SOURCES          += otp_util.c otp_mppe.c
+SRC_CFLAGS     =  $(OPENSSL_INCLUDE)
+TGT_LDLIBS       =  $(OPENSSL_LIBS)
+
diff --git a/src/modules/rlm_pam/all.mk b/src/modules/rlm_pam/all.mk
new file mode 100644 (file)
index 0000000..8a6455e
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET     = rlm_pam.a
+SOURCES       = rlm_pam.c
diff --git a/src/modules/rlm_pap/all.mk b/src/modules/rlm_pap/all.mk
new file mode 100644 (file)
index 0000000..714a1af
--- /dev/null
@@ -0,0 +1,3 @@
+SOURCES := rlm_pap.c
+
+TARGET := rlm_pap.a
diff --git a/src/modules/rlm_passwd/all.mk b/src/modules/rlm_passwd/all.mk
new file mode 100644 (file)
index 0000000..6e9ece5
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET     = rlm_passwd.a
+SOURCES       = rlm_passwd.c
diff --git a/src/modules/rlm_perl/all.mk b/src/modules/rlm_perl/all.mk
new file mode 100644 (file)
index 0000000..117ade9
--- /dev/null
@@ -0,0 +1,5 @@
+TARGET      =  rlm_perl.a
+SOURCES        = rlm_perl.c
+
+SRC_CFLAGS  = `perl -MExtUtils::Embed -e ccopts`
+TGT_LDLIBS    = `perl -MExtUtils::Embed -e ldopts`
diff --git a/src/modules/rlm_policy/all.mk b/src/modules/rlm_policy/all.mk
new file mode 100644 (file)
index 0000000..468f346
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_policy.a
+SOURCES                = rlm_policy.c parse.c evaluate.c
diff --git a/src/modules/rlm_preprocess/all.mk b/src/modules/rlm_preprocess/all.mk
new file mode 100644 (file)
index 0000000..5d9eaf8
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET = rlm_preprocess.a
+SOURCES        = rlm_preprocess.c
diff --git a/src/modules/rlm_python/all.mk b/src/modules/rlm_python/all.mk
new file mode 100644 (file)
index 0000000..7c5c091
--- /dev/null
@@ -0,0 +1,5 @@
+TARGET     = rlm_python.a
+SOURCES       = rlm_python.c
+
+TGT_LDLIBS   = -L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config                         -ldl  -lpython2.6 -lm
+SRC_CFLAGS = -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
diff --git a/src/modules/rlm_radutmp/all.mk b/src/modules/rlm_radutmp/all.mk
new file mode 100644 (file)
index 0000000..359a532
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET     = rlm_radutmp.a
+SOURCES       = rlm_radutmp.c
diff --git a/src/modules/rlm_realm/all.mk b/src/modules/rlm_realm/all.mk
new file mode 100644 (file)
index 0000000..8e35ac7
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET         := rlm_realm.a
+
+SOURCES                := rlm_realm.c
diff --git a/src/modules/rlm_sim_files/all.mk b/src/modules/rlm_sim_files/all.mk
new file mode 100644 (file)
index 0000000..a357ce8
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET = rlm_sim_files.a
+SOURCES        = rlm_sim_files.c
diff --git a/src/modules/rlm_sql/all.mk b/src/modules/rlm_sql/all.mk
new file mode 100644 (file)
index 0000000..779aeea
--- /dev/null
@@ -0,0 +1,3 @@
+TARGET         = rlm_sql.a
+SOURCES                = rlm_sql.c sql.c
+# this uses the RLM_CFLAGS and RLM_LIBS and SOURCES defs to make TARGET.
diff --git a/src/modules/rlm_sql_log/all.mk b/src/modules/rlm_sql_log/all.mk
new file mode 100644 (file)
index 0000000..ec12feb
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = rlm_sql_log.a
+SOURCES        = rlm_sql_log.c
diff --git a/src/modules/rlm_sqlcounter/all.mk b/src/modules/rlm_sqlcounter/all.mk
new file mode 100644 (file)
index 0000000..b70adb5
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET      = rlm_sqlcounter.a
+SOURCES        = rlm_sqlcounter.c
diff --git a/src/modules/rlm_sqlippool/all.mk b/src/modules/rlm_sqlippool/all.mk
new file mode 100644 (file)
index 0000000..108112c
--- /dev/null
@@ -0,0 +1,4 @@
+TARGET      = rlm_sqlippool.a
+SOURCES        = rlm_sqlippool.c
+
+SRC_INCDIRS := $(top_builddir)/src/modules/rlm_sql
diff --git a/src/modules/rlm_unix/all.mk b/src/modules/rlm_unix/all.mk
new file mode 100644 (file)
index 0000000..95c0c1d
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET     = rlm_unix.a
+SOURCES       = rlm_unix.c
diff --git a/src/modules/rlm_wimax/all.mk b/src/modules/rlm_wimax/all.mk
new file mode 100644 (file)
index 0000000..af16806
--- /dev/null
@@ -0,0 +1,2 @@
+TARGET         = rlm_wimax.a
+SOURCES                = rlm_wimax.c