build: Generate lists of source files at bootstrap time in src_vars.mk.
This moves the definition of SYSAPI_SRC, COMMON_SRC, LOCALTPM_SRC,
SAMPLE_SRC and TPMSOCKETS_SRC variables to src_vars.mk. This file is
generated at bootstrap time and the list of source files in each
variable generated dynamically. We leave the list of source files for
the applications (resourcemgr, tpmclient and tpmtest) in the
Makefile.am due to the Windows specific files in the tpmclient
directory that the bootstrap script would pickup. We can work around
these with #ifdefs in the future if necessary.
This resolves #26.
Signed-off-by: Philip Tricca <flihp@twobit.us>
diff --git a/bootstrap b/bootstrap
index 3df9fbb..c0411f1 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,5 +1,42 @@
#! /bin/sh
+# generate list of source files for use in Makefile.am
+# if you add new source files, you must run ./bootstrap again
+function src_listvar () {
+ basedir=$1
+ suffix=$2
+ var=$3
+
+ find "${basedir}" -name "${suffix}" | tr '\n' ' ' | (echo -n "${var} = " && cat)
+ echo ""
+}
+
+VARS_FILE=src_vars.mk
+
+echo "Generating file lists: ${VARS_FILE}"
+if [ -e ${VARS_FILE} ]; then rm ${VARS_FILE}; fi
+
+src_listvar "sysapi/include" "*.h" "SYSAPI_H" >> ${VARS_FILE}
+src_listvar "sysapi/sysapi" "*.c" "SYSAPI_C" >> ${VARS_FILE}
+src_listvar "sysapi/sysapi_util" "*.c" "SYSAPIUTIL_C" >> ${VARS_FILE}
+echo -e "SYSAPI_SRC = \$(SYSAPI_H) \$(SYSAPI_C) \$(SYSAPIUTIL_C)\n" >> ${VARS_FILE}
+
+src_listvar "common" "*.c" "COMMON_C" >> ${VARS_FILE}
+src_listvar "common" "*.h" "COMMON_H" >> ${VARS_FILE}
+echo -e "COMMON_SRC = \$(COMMON_C) \$(COMMON_H)\n" >> ${VARS_FILE}
+
+src_listvar "tcti/localtpm" "*.c" "LOCALTPM_C" >> ${VARS_FILE}
+src_listvar "tcti/localtpm" "*.h" "LOCALTPM_H" >> ${VARS_FILE}
+echo -e "LOCALTPM_SRC = \$(LOCALTPM_C) \$(LOCALTPM_H)\n" >> ${VARS_FILE}
+
+src_listvar "test/common/sample" "*.c" "SAMPLE_C" >> ${VARS_FILE}
+src_listvar "test/common/sample" "*.h" "SAMPLE_H" >> ${VARS_FILE}
+echo -e "SAMPLE_SRC = \$(SAMPLE_C) \$(SAMPLE_H)\n" >> ${VARS_FILE}
+
+src_listvar "tcti/tpmsockets" "*.cpp" "TPMSOCKETS_C" >> ${VARS_FILE}
+src_listvar "tcti/tpmsockets" "*.h" "TPMSOCKETS_H" >> ${VARS_FILE}
+echo -e "TPMSOCKETS_SRC = \$(TPMSOCKETS_C) \$(TPMSOCKETS_H)\n" >> ${VARS_FILE}
+
aclocal \
&& autoconf \
&& automake --add-missing