+# Building archives and the test0 app
+
+PACKNL = ${HOME}/src/borta/packnl/packnl
LSPSRC = lsp-dbus-test.lsp
+ARCHIVES = lsp-misc.a lsp-dbus.a
+DOCS = lsp-dbus.a.8 lsp-misc.a.8
-## Library
-LSPLIB = lsp-dbus.a
+default: test0 docs
-LSP_MISC = foop.lsp misc.lsp
-LSPLIBSRC += $(addprefix lsp-misc/,${LSP_MISC})
+include manpage.mk
+include lsplib.mk
-LSP_DBUS = lsp-dbus-connection.lsp lsp-dbus.lsp lsp-dbus-marshal.lsp
-LSP_DBUS += lsp-dbus-events.lsp
-LSPLIBSRC += $(addprefix lsp-dbus/,${LSP_DBUS})
+.PHONY: docs
+docs: ${DOCS}
-test0: lsp-dbus-test.lsp ${LSPLIB}
- ${HOME}/src/borta/packnl/packnl -w $@ $^ -A ${LSPLIB}
+test0: lsp-dbus-test.lsp ${ARCHIVES}
+ ${PACKNL} -w $@ $< $(addprefix -A ,${ARCHIVES})
-${LSPLIB}: ${LSPLIBSRC}
- ar r $@ $^
+clean:
+ rm -f test0 ${CLEAN}
--- /dev/null
+# This is a Makefile include file for build ar archives as declared in
+# the $(ARCHIVES) variable. Each archive is build by including all
+# .lsp files in the same named subdirectory. E.g. lib-misc.a contains
+# the files lib-misc/*.lsp
+
+# The following defines a Makefile block for archive building
+define archive
+$1: $$(wildcard ${1:.a=}/*.lsp)
+ ar r $$@ $$^
+CLEAN += $1
+endef
+
+# The following command generates the archive building blocks
+$(foreach F,${ARCHIVES},$(eval $(call archive,$F)))