diff --git a/require-ess/tools/driver.makefile b/require-ess/tools/driver.makefile index b734aaf1c4135597fa5b0ca96ce5a0aa71bd2f7c..b025a71a7059f3b788587e00e198b76516cc07ff 100644 --- a/require-ess/tools/driver.makefile +++ b/require-ess/tools/driver.makefile @@ -258,6 +258,12 @@ CFGS = ${CONFIGS} CFGS += ${CONFIGS_${EPICSVERSION}} export CFGS +INSTALL_LICENSE = ${MODULE_LOCATION}/doc +# Find all license files to distribute with binaries +LICENSES = $(shell find -not -path '*/.*' -type f -iname LICENSE) +LICENSES += $(shell find -not -path '*/.*' -type f -iname Copyright) +export LICENSES + # Filter architectures to build using EXCLUDE_ARCHS and ARCH_FILTER. ALL_ARCHS = ${EPICS_HOST_ARCH} ${CROSS_COMPILER_TARGET_ARCHS} BUILD_ARCHS = $(filter-out $(addprefix %,${EXCLUDE_ARCHS}),$(filter-out $(addsuffix %,${EXCLUDE_ARCHS}),\ @@ -309,6 +315,7 @@ debug:: @echo "LIBVERSION = ${LIBVERSION}" @echo "E3_SITEMODS_PATH = ${E3_SITEMODS_PATH}" @echo "EPICS_MODULES = ${EPICS_MODULES}" + @echo "LICENSES = ${LICENSES}" # Create e.g. build-$(T_A) rules for each architecture, so that we can just do # build: build-arch1 build-arch2 @@ -349,6 +356,20 @@ build:: ${COMMON_DIR}/${METAFILE} install:: ${INSTALL_META} +# The licenses should be installed after everything +define license_install = +$1: $2 + @echo "Installing license file $$^" + $$(INSTALL) -d -m444 $$^ $$(@D) + +install:: $1 + +endef +# Creates a target for every license file to be installed. Some modules have +# more than one license file that needs distribution. For them we add the +# previous directory so we have them separate by projects inside /doc. +$(foreach d, $(LICENSES), $(eval $(call license_install, $(INSTALL_LICENSE)/$(filter-out ., $(lastword $(subst /, , $(dir $(d))))/$(notdir $(d))), $(d)))) + else # T_A ifeq ($(filter O.%,$(notdir ${CURDIR})),)