Rombobjörn

summaryrefslogtreecommitdiff
path: root/comfignat.mk
diff options
context:
space:
mode:
authorBjörn Persson <Bjorn@Rombobjörn.se>2014-02-23 15:28:49 +0100
committerBjörn Persson <Bjorn@Rombobjörn.se>2014-02-23 15:28:49 +0100
commit553cfcce4259cb2a0d622110ad52811d9ab357b6 (patch)
treeb29560a4611223c11d6c4619180dc53fac7905d3 /comfignat.mk
parentb9d89b95bbb1a89842cd9a285390a265157c6779 (diff)
multi-step installation
· Added pre- and post-installation hooks to the installation phase. · No attempt to install staged files is made if the build doesn't stage any files.
Diffstat (limited to 'comfignat.mk')
-rw-r--r--comfignat.mk48
1 files changed, 43 insertions, 5 deletions
diff --git a/comfignat.mk b/comfignat.mk
index be030f0..37af018 100644
--- a/comfignat.mk
+++ b/comfignat.mk
@@ -181,8 +181,8 @@ objdir = ${builddir}/obj
stagedir = ${builddir}/stage
# builddir is the build directory, which may be separate from the source tree.
# Intermediate files produced during the build are kept in objdir. Files to be
-# installed are written under stagedir, and then copied to their destination in
-# the installation step.
+# installed are written under stagedir in the build phase, and then copied to
+# their destination in the installation phase.
# Containing makefiles should avoid modifying the directory variables. Users
# should be able to rely on these defaults.
@@ -194,6 +194,12 @@ install_cp_flags = ${if ${DESTDIR},--preserve=timestamps}
# directly to the target system, because that would change the timestamps of
# existing directories.
+do_preinstall = ${if ${DESTDIR},false,true}
+do_postinstall = ${if ${DESTDIR},false,true}
+# Any pre- and post-installation commands that the containing makefile may
+# specify are executed when installation is done directly to the target system,
+# but not when installation is done to a staging directory, because such
+# commands need to be run on the target system, not on a build server.
#
# Containing makefiles may use these variables in their rules, but nothing
@@ -397,6 +403,7 @@ configuration_variables += \
localedir mandir infodir miscdocdir \
objdir stagedir \
install_cp_flags \
+ do_preinstall do_postinstall \
${options}
# configuration_variables is a list of variables that can be saved in the
# persistent configuration with "make configure". Containing makefiles may
@@ -710,11 +717,42 @@ ${make_stagedir}:
# something has been built then "make install" doesn't rebuild anything, just
# copies the built files to their destination.
+.PHONY: preinstall
+preinstall:
+# A recipe may be added to "preinstall" with commands that need to be run
+# before the files are installed when installation is done directly to the
+# target system, but should be skipped when installation is done to a staging
+# directory.
+
# How to install what has been built and staged:
-install: ${make_stagedir}
- mkdir -p "${DESTDIR}/"
- cp -RPf ${install_cp_flags} "${stagedir}"/* "${DESTDIR}/"
+.PHONY: install_stage
+install_stage: ${make_stagedir} ${if ${call checked_true,do_preinstall},preinstall}
+ if [ "`echo "${stagedir}"/*`" != "${stagedir}/*" ]; then \
+ mkdir -p "${DESTDIR}/"; \
+ cp -RPf ${install_cp_flags} "${stagedir}"/* "${DESTDIR}/"; \
+ fi
+# If stagedir doesn't exist, then the rule to make it by running the build is
+# invoked. If stagedir then exists and contains some files (the asterisk gets
+# expanded) then those files are copied recursively to DESTDIR or to the
+# filesystem root.
+
+.PHONY: install_files
+install_files: install_stage
+# A recipe may be added to "install_files" if any files have to be written,
+# deleted or moved after the staged directory tree has been installed. This
+# should be used only for workarounds. It's better to stage all the files
+# correctly under stagedir in the build phase.
+
+.PHONY: postinstall
+postinstall: install_files
+# A recipe may be added to "postinstall" with commands that need to be run
+# after the files are installed when installation is done directly to the
+# target system, but should be skipped when installation is done to a staging
+# directory. This will typically be commands that modify existing files on the
+# target system.
+
.PHONY: install
+install: install_files ${if ${call checked_true,do_postinstall},postinstall}
.PHONY: clean
clean::