Cleanup of build scripting
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Sun, 16 Apr 2023 14:46:06 +0000 (00:46 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Sun, 16 Apr 2023 14:46:06 +0000 (00:46 +1000)
Makefile
lsplib.mk [new file with mode: 0644]
manpage.mk [new file with mode: 0644]

index 1c3e94c4473edd3801da0cf73c2c57af97005496..c9f3ceff5d8d9705aca66e1bddeed7aad9f4104b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,21 @@
+# 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}
diff --git a/lsplib.mk b/lsplib.mk
new file mode 100644 (file)
index 0000000..c1871cb
--- /dev/null
+++ b/lsplib.mk
@@ -0,0 +1,14 @@
+# 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)))
diff --git a/manpage.mk b/manpage.mk
new file mode 100644 (file)
index 0000000..071f31f
--- /dev/null
@@ -0,0 +1,2 @@
+%.8: %.8.adoc
+       asciidoctor -b manpage $<