Rombobjörn

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comfignat.gpr.gp11
-rw-r--r--comfignat.mk404
2 files changed, 256 insertions, 159 deletions
diff --git a/comfignat.gpr.gp b/comfignat.gpr.gp
index b27e460..b9ea446 100644
--- a/comfignat.gpr.gp
+++ b/comfignat.gpr.gp
@@ -1,5 +1,5 @@
-- Comfignat configuration variables for GNAT project files
--- Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
+-- Copyright 2013 - 2015 B. Persson, Bjorn@Rombobeorn.se
--
-- This material is provided as is, with absolutely no warranty expressed
-- or implied. Any use is at your own risk.
@@ -11,7 +11,7 @@
-- modified is included with the above copyright notice.
--- This file is part of Comfignat 1.2 – common, convenient, command-line-
+-- This file is part of Comfignat 1.4 – common, convenient, command-line-
-- controlled compile-time configuration of software built with the GNAT tools.
-- For information about Comfignat, see http://www.Rombobeorn.se/Comfignat/.
@@ -84,7 +84,7 @@ abstract project Comfignat is
-- Programs that can be run from a command prompt are in Bindir. This is
-- usually the same directory that the program itself is in, so this
- -- variable is probably useful only to programs in Libexecdir.
+ -- variable is probably useful only to programs under Libexecdir.
#if Bindir'Defined then
Bindir := $Bindir;
#else
@@ -272,8 +272,9 @@ abstract project Comfignat is
Stage_Bindir := Stagedir & Bindir;
#end if;
- -- Programs that are only to be run by other programs, not by users, shall
- -- be installed under Stage_Libexecdir.
+ -- Programs that are only intended to be run by other programs, not by
+ -- users, shall be installed under an application-specific subdirectory of
+ -- Stage_Libexecdir.
#if Stage_Libexecdir'Defined then
Stage_Libexecdir := $Stage_Libexecdir;
#else
diff --git a/comfignat.mk b/comfignat.mk
index a4742c4..f9f2038 100644
--- a/comfignat.mk
+++ b/comfignat.mk
@@ -1,5 +1,5 @@
# Comfignat makefile foundation for configuring and building GNAT projects
-# Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
+# Copyright 2013 - 2015 B. Persson, Bjorn@Rombobeorn.se
#
# This material is provided as is, with absolutely no warranty expressed
# or implied. Any use is at your own risk.
@@ -11,7 +11,7 @@
# modified is included with the above copyright notice.
-# This file is part of Comfignat 1.2 – common, convenient, command-line-
+# This file is part of Comfignat 1.4 – common, convenient, command-line-
# controlled compile-time configuration of software built with the GNAT tools.
# For information about Comfignat, see http://www.Rombobeorn.se/Comfignat/.
@@ -34,6 +34,69 @@
#
+# First of all, define some functions and constants for processing directory
+# variables:
+#
+
+nil =
+inert_space = _Comfignat_magic_protective_space_character_substitute_
+inert_tab = _Comfignat_magic_protective_tab_character_substitute_
+inert_percent = _Comfignat_magic_protective_percent_character_substitute_
+mung_string = ${subst %,${inert_percent},${subst ${nil} ,${inert_tab},${subst ${nil} ,${inert_space},${1}}}}
+unmung_string = ${subst ${inert_percent},%,${subst ${inert_tab}, ,${subst ${inert_space}, ,${1}}}}
+# mung_string and unmung_string are used to prevent Make from interpreting
+# space and percent characters in strings.
+
+relativize = ${if ${filter ${2}%,${1}}, \
+ ${3}${1:${2}%=%}, \
+ ${call relativize,${1},${dir ${2:%/=%}},${3}../}}
+# relativize is the recursive algorithm that converts an absolute pathname into
+# a relative one.
+# Parameters:
+# 1: an absolute pathname to convert to relative
+# 2: the absolute base pathname, being shortened until it's a prefix of 1
+# 3: a growing series of "../" to lead the relative pathname with
+# If 2 is a prefix of 1, then return 3 concatenated with the part of 1 that
+# differs from 2. Otherwise delete the last element of 2, add one level of
+# "../" to 3, and repeat.
+# Within relativize all pathnames have one trailing slash so that only whole
+# directory names will match. Otherwise "/usr/lib" could match "/usr/lib64" for
+# example.
+
+prepare_pathname = ${subst //,/,${abspath ${call mung_string,${1}}}/}
+# prepare_pathname prepares a pathname for use as a parameter to relativize.
+# · Protect space and percent characters from interpretation by Make.
+# · Normalize the pathname, eliminating ".", ".." and "//".
+# · Append a slash.
+# · If the input was "/", then it is now "//". Change that back to "/".
+
+relative_to = \
+ ${or ${call unmung_string \
+ ,${patsubst %/,%,${call relativize \
+ ,${call prepare_pathname,${1}} \
+ ,${call prepare_pathname,${2}},}}},.}
+# relative_to converts an absolute pathname into a relative one. What it
+# actually does is to prepare the input to relativize and fix up its output.
+# Parameters:
+# 1: an absolute pathname to convert to relative
+# 2: the absolute base pathname that 1 shall be made relative to
+# Processing:
+# · Prepare the two input pathnames with prepare_pathname.
+# · Call relativize with the prepared pathnames for parameters 1 and 2, and
+# an empty string for 3.
+# · Strip the result of surrounding spaces and the trailing slash.
+# · Reverse the protection of space and percent characters.
+# · If the result is an empty string, then return "." instead.
+
+Make_pathname = ${call relative_to,${${1}},${CURDIR}}
+# Make_pathname takes the name of a variable whose value is an absolute
+# pathname, and converts that pathname into the right form for usage in Make
+# targets, prerequisites and functions, which means that it is made relative
+# to the current working directory to prevent spaces in parent directories'
+# names from breaking Make.
+
+
+#
# Program-name variables and the usual options variables are picked up from the
# environment or the command line:
#
@@ -118,15 +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.
-
-ifneq (${Comfignat_overriding_absolute_builddir},)
- # This process is a sub-Make and must use the same builddir as its parent.
- # This assignment must be done before builddir is used in VPATH and in the
- # pathname of the configuration file.
- override builddir := ${Comfignat_overriding_absolute_builddir}
-endif
+# 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.
@@ -138,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
@@ -169,6 +231,29 @@ stage_miscdocdir = ${stagedir}${miscdocdir}
# These are the directories where different kinds of files to be installed are
# written during the build.
+Make_srcdir = ${call Make_pathname,srcdir}
+Make_builddir = ${call Make_pathname,builddir}
+Make_objdir = ${call Make_pathname,objdir}
+Make_stagedir = ${call Make_pathname,stagedir}
+Make_bindir = ${call Make_pathname,stage_bindir}
+Make_libexecdir = ${call Make_pathname,stage_libexecdir}
+Make_datadir = ${call Make_pathname,stage_datadir}
+Make_sysconfdir = ${call Make_pathname,stage_sysconfdir}
+Make_statedir = ${call Make_pathname,stage_statedir}
+Make_cachedir = ${call Make_pathname,stage_cachedir}
+Make_logdir = ${call Make_pathname,stage_logdir}
+Make_includedir = ${call Make_pathname,stage_includedir}
+Make_archincludedir = ${call Make_pathname,stage_archincludedir}
+Make_libdir = ${call Make_pathname,stage_libdir}
+Make_alidir = ${call Make_pathname,stage_alidir}
+Make_gprdir = ${call Make_pathname,stage_gprdir}
+Make_localedir = ${call Make_pathname,stage_localedir}
+Make_mandir = ${call Make_pathname,stage_mandir}
+Make_infodir = ${call Make_pathname,stage_infodir}
+Make_miscdocdir = ${call Make_pathname,stage_miscdocdir}
+# These variables are for use in Make targets, prerequisites and other places
+# where Make expects space-separated lists.
+
preprocess_file = "${GNATPREP}" ${firstword ${filter %.gp,$^}} $@ \
${options_preprocessing} ${Gnatprep_arguments} \
${if ${filter ${notdir $@},${notdir ${usage_GPRs}}}, \
@@ -178,16 +263,74 @@ preprocess_file = "${GNATPREP}" ${firstword ${filter %.gp,$^}} $@ \
# preprocess_file is a command for use in recipes. It runs the first .gp file
# among the rule's prerequisites through Gnatprep to produce the target. If the
# target is a usage project, then the usage-relevant directory variables are
-# conveyed to it as Gnatprep symbols. Otherwise srcdir is conveyed.
+# conveyed to it as Gnatprep symbols. Otherwise srcdir is conveyed, as it's
+# needed by preprocessed build projects.
build_GPR = "${GNAT_BUILDER}" -P ${firstword ${filter %.gpr,$^}} \
- -aP${srcdir} -aP${builddir} -p \
+ ${addprefix -aP,${VPATH}} -p \
${options_building} ${builder_arguments} ${GNATFLAGS}
# build_GPR is a command for use in recipes. It performs a build controlled by
# the first project file among the rule's prerequisites.
#
+# Adjust the build directory variables, and load the configuration:
+#
+
+# Ensure that builddir is an absolute pathname and is inherited by sub-Makes:
+
+ifneq (${Comfignat_overriding_absolute_builddir},)
+ override builddir := ${Comfignat_overriding_absolute_builddir}
+else ifeq (${origin builddir},command line)
+ override builddir := ${abspath ${builddir}}
+endif
+export Comfignat_overriding_absolute_builddir := ${builddir}
+
+# Read the configuration file if there is one:
+
+configuration = ${Make_builddir}/comfignat_configuration.mk
+
+-include ${configuration}
+
+# Ensure that objdir and stagedir are absolute pathnames and are inherited by
+# sub-Makes:
+
+ifneq (${Comfignat_overriding_absolute_objdir},)
+ override objdir := ${Comfignat_overriding_absolute_objdir}
+else ifeq (${origin objdir},command line)
+ override objdir := ${abspath ${objdir}}
+ export Comfignat_overriding_absolute_objdir := ${objdir}
+ objdir_is_overridden = true
+endif
+
+ifneq (${Comfignat_overriding_absolute_stagedir},)
+ override stagedir := ${Comfignat_overriding_absolute_stagedir}
+else ifeq (${origin stagedir},command line)
+ override stagedir := ${abspath ${stagedir}}
+ export Comfignat_overriding_absolute_stagedir := ${stagedir}
+ stagedir_is_overridden = true
+endif
+
+# builddir, objdir and stagedir need to be absolute in project files, because a
+# pathname relative to a project file can be wrong when a separate build
+# directory is used and project files are both in srcdir and in builddir.
+# objdir and stagedir also need to be absolute in the configuration file
+# because the working directory might change between Make invocations.
+# Sub-Makes must use the same builddir, objdir and stagedir as the parent, so
+# the absolute pathnames are conveyed to child processes in environment
+# variables that won't normally be overridden and are unlikely to be defined by
+# accident.
+# The correction of builddir in sub-Makes must happen before builddir is used
+# in VPATH and in the pathname of the configuration file.
+# The inclusion of the configuration file must happen after MAKEFILE_LIST has
+# been used to define srcdir.
+# The changes to objdir and stagedir must be done after the configuration file
+# is read because otherwise the configuration would override the command line.
+# Once modified the variables are no longer of command line origin, so they are
+# marked as overridden so that "make configure" will save them.
+
+
+#
# Containing makefiles should assign or append to these variables as needed:
#
@@ -207,7 +350,7 @@ endif
ifneq (${origin preprocessed_files},file)
preprocessed_files = \
${filter-out ${notdir ${usage_GPRs}}, \
- ${basename ${notdir ${wildcard ${srcdir}/*.gp}}}}
+ ${basename ${notdir ${wildcard ${Make_srcdir}/*.gp}}}}
endif
# preprocessed_files is a list of files to be produced in the preprocessing
# step at the beginning of the build. Containing makefiles may override it or
@@ -241,9 +384,13 @@ endif
# default values for optional arguments should be set in the options variables
# instead.
-VPATH += ${srcdir} ${builddir}
+VPATH += ${filter-out .,${Make_srcdir} ${Make_builddir}}
# VPATH is a list of directories that Make should search for prerequisites.
+# If VPATH has been defined as simply expanded before this file was included,
+# then Make_srcdir and Make_builddir will be expanded now, so everything that's
+# involved in their values must be defined before this point.
+
configuration_variables += \
GNATPREP GNAT_BUILDER \
GNATPREPFLAGS GNAT_BUILDER_FLAGS ADAFLAGS CPPFLAGS CFLAGS CXXFLAGS FFLAGS \
@@ -257,6 +404,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
@@ -264,60 +412,12 @@ configuration_variables += \
#
-# Read the configuration file if there is one:
-#
-
-configuration = ${builddir}/comfignat_configuration.mk
-
--include ${configuration}
-
-
-#
-# Ensure that builddir, objdir and stagedir are absolute pathnames:
-#
-
-ifeq (${origin builddir},command line)
- override builddir := ${abspath ${builddir}}
-endif
-export Comfignat_overriding_absolute_builddir := ${builddir}
-
-ifneq (${Comfignat_overriding_absolute_objdir},)
- override objdir := ${Comfignat_overriding_absolute_objdir}
-else ifeq (${origin objdir},command line)
- override objdir := ${abspath ${objdir}}
- export Comfignat_overriding_absolute_objdir := ${objdir}
- objdir_is_overridden = true
-endif
-
-ifneq (${Comfignat_overriding_absolute_stagedir},)
- override stagedir := ${Comfignat_overriding_absolute_stagedir}
-else ifeq (${origin stagedir},command line)
- override stagedir := ${abspath ${stagedir}}
- export Comfignat_overriding_absolute_stagedir := ${stagedir}
- stagedir_is_overridden = true
-endif
-
-# These pathnames need to be absolute in project files, because a pathname
-# relative to a project file can be wrong when a separate build directory is
-# used and project files are both in srcdir and in builddir. objdir and
-# stagedir also need to be absolute in the configuration file because the
-# working directory might change between Make invocations.
-# Sub-Makes must use the same builddir, objdir and stagedir as the parent, so
-# the absolute pathnames are conveyed to child processes in environment
-# variables that won't normally be overridden and are unlikely to be defined by
-# accident.
-# The changes to objdir and stagedir must be done after the configuration file
-# is read because otherwise the configuration would override the command line.
-# Once modified the variables are no longer of command line origin, so they are
-# marked as overridden so that "make configure" will save them.
-
-
-#
# Compute symbol definitions for Gnatprep and external variable assignments for
# build projects:
#
-# First define some functions and constants for processing directory variables.
+# For this some more functions and constants for processing directory variables
+# are needed.
usage_directory_variables = includedir archincludedir libdir alidir
# These are the usage-relevant directory variables. They are needed in usage
@@ -325,77 +425,36 @@ usage_directory_variables = includedir archincludedir libdir alidir
builder_directory_variables = bindir libexecdir ${usage_directory_variables}
# These are the builder-relevant directory variables. They control where the
-# GNAT tools write files to be installed.
+# GNAT tools write files to be installed. These are the variables that
+# Comfignat-compatible directories projects must provide.
usage_relevant = ${filter ${usage_directory_variables},${1}}
# usage_relevant returns a list of the words in the input list that are usage-
# relevant directory variables. If given a single variable name, it returns
# that name if the variable is usage-relevant, or an empty string if it isn't.
-nil =
-inert_space = _Comfignat_magic_protective_space_character_substitute_
-inert_percent = _Comfignat_magic_protective_percent_character_substitute_
-mung_string = ${subst %,${inert_percent},${subst ${nil} ,${inert_space},${1}}}
-unmung_string = ${subst ${inert_percent},%,${subst ${inert_space}, ,${1}}}
-# mung_string and unmung_string are used to prevent Make from interpreting
-# space and percent characters in strings.
+checked_boolean = ${or ${and ${filter 1,${words ${${1}}}}, \
+ ${filter true false,${${1}}}}, \
+ ${error ${1} must be "true" or "false"}}
+# checked_boolean takes the name of a variable and checks that its value is a
+# single word, and that that word is either "true" or "false". If so it returns
+# the value; otherwise it complains and stops the execution.
-relativize = ${if ${filter ${2}%,${1}}, \
- ${3}${1:${2}%=%}, \
- ${call relativize,${1},${dir ${2:%/=%}},${3}../}}
-# relativize is the recursive algorithm that converts an absolute pathname into
-# a relative one.
-# Parameters:
-# 1: an absolute pathname to convert to relative
-# 2: the absolute base pathname, being shortened until it's a prefix of 1
-# 3: a growing series of "../" to lead the relative pathname with
-# If 2 is a prefix of 1, then return 3 concatenated with the part of 1 that
-# differs from 2. Otherwise delete the last element of 2, add one level of
-# "../" to 3, and repeat.
-# Within relativize all pathnames have one trailing slash so that only whole
-# directory names will match. Otherwise "/usr/lib" could match "/usr/lib64" for
-# example.
+checked_true = ${filter true,${call checked_boolean,${1}}}
+# checked_true takes the name of a variable and checks that it has a boolean
+# value. It then returns an empty string for "false" or a non-empty string for
+# "true".
-prepare_pathname = ${subst //,/,${abspath ${call mung_string,${1}}}/}
-# prepare_pathname prepares a pathname for use as a parameter to relativize.
-# · Protect space and percent characters from interpretation by Make.
-# · Normalize the pathname, eliminating ".", ".." and "//".
-# · Append a slash.
-# · If the input was "/", then it is now "//". Change that back to "/".
-
-relative_to = \
- ${or ${call unmung_string \
- ,${patsubst %/,%,${call relativize \
- ,${call prepare_pathname,${1}} \
- ,${call prepare_pathname,${2}},}}},.}
-# relative_to converts an absolute pathname into a relative one. What it
-# actually does is to prepare the input to relativize and fix up its output.
-# Parameters:
-# 1: an absolute pathname to convert to relative
-# 2: the absolute base pathname that 1 shall be made relative to
-# Processing:
-# · Prepare the two input pathnames with prepare_pathname.
-# · Call relativize with the prepared pathnames for parameters 1 and 2, and
-# an empty string for 3.
-# · Strip the result of surrounding spaces and the trailing slash.
-# · Reverse the protection of space and percent characters.
-# · If the result is an empty string, then return "." instead.
-
-maybe_relative_to = \
- ${if ${or ${filter-out 1,${words ${relocatable_package}}}, \
- ${filter-out true false,${relocatable_package}}}, \
- ${error relocatable_package must be "true" or "false"} \
- ,${if ${filter true,${relocatable_package}} \
- ,${call relative_to,${1},${2}},${1}}}
+maybe_relative_to = ${if ${call checked_true,relocatable_package} \
+ ,${call relative_to,${1},${2}},${1}}
# maybe_relative_to converts an absolute pathname into a relative one if a
# relocatable package is desired.
# Parameters:
# 1: an absolute pathname to maybe convert to relative
# 2: the absolute base pathname that 1 may be made relative to
-# First check that the value of relocatable_package is a single word and that
-# that word is either "true" or "false". Complain and stop if that isn't so.
-# Then, if relocatable_package is "true", let relative_to convert the pathname,
+# If relocatable_package is "true", then let relative_to convert the pathname,
# otherwise return parameter 1 unchanged.
+# It is checked that relocatable_package has a boolean value.
embed_pathname = ${call maybe_relative_to,${${1}},${if ${filter bindir,${1}} \
,${libexecdir},${bindir}}}
@@ -415,11 +474,10 @@ define convey_builder_directory_variable
all_directories += '-Dstage_${1}="${stage_${1}}"'
usage_directories += ${if ${call usage_relevant,${1}}, \
'-D${1}="${call usage_pathname,${1}}"'}
-
endef
# convey_builder_directory_variable takes the name of a builder-relevant
# directory variable and returns Make code that conveys that variable to
-# project files. The code snippet ends with a line break.
+# project files.
# · Append a symbol definition to all_directories to convey the variable to
# comfignat.gpr in the right form for inclusion in a program.
# · Also convey to comfignat.gpr the corresponding pathname under the
@@ -433,11 +491,10 @@ define use_directories_project_variable
all_directories += '-D${1}=${directories_project}.${1}'
usage_directories += ${if ${call usage_relevant,${1}}, \
'-D${1}=${directories_project}.${1}'}
-
endef
# use_directories_project_variable takes the name of a builder-relevant
# directory variable and returns Make code that makes project files get that
-# variable from a directories project. The code snippet ends with a line break.
+# variable from a directories project.
# · Append a symbol definition to all_directories for comfignat.gpr.
# · If the variable is also usage-relevant, then append a symbol definition
# to usage_directories for usage projects.
@@ -480,12 +537,12 @@ all_directories += '-DLockdir="${lockdir}"'
# pathnames.
# Set the builder-relevant directory variables.
-${eval ${foreach var,${builder_directory_variables}, \
- ${if ${or ${findstring command line,${origin ${var}}}, \
- ${filter true,${${var}_is_configured}}, \
- ${filter 0,${words ${dirgpr}}}}, \
- ${call convey_builder_directory_variable,${var}}, \
- ${call use_directories_project_variable,${var}}}}}
+${foreach var,${builder_directory_variables}, \
+ ${if ${or ${findstring command line,${origin ${var}}}, \
+ ${filter true,${${var}_is_configured}}, \
+ ${filter 0,${words ${dirgpr}}}}, \
+ ${eval ${call convey_builder_directory_variable,${var}}}, \
+ ${eval ${call use_directories_project_variable,${var}}}}}
# For each builder-relevant directory variable, check whether its value in
# project files should be taken from the corresponding Make variable or from a
# directories project, and construct symbol definitions accordingly.
@@ -498,15 +555,13 @@ ${eval ${foreach var,${builder_directory_variables}, \
option_values = \
${foreach option,${options}, \
- ${if ${and ${filter-out environment,${origin ${option}}}, \
- ${filter 1,${words ${${option}}}}, \
- ${filter true false,${${option}}}}, \
- ${option}=${${option}}, \
- ${error ${option} must be "true" or "false"}}}
-# For each variable listed in options, check that it didn't come from the
-# environment (to prevent accidents), that its value is a single word, and that
-# that word is either "true" or "false". If so, output a name/value pair;
-# otherwise complain and stop.
+ ${if ${filter-out undefined environment,${origin ${option}}}, \
+ ${option}=${call checked_boolean,${option}}, \
+ ${error ${option} has no default value and must be set to \
+ "true" or "false" on the command line}}}
+# For each variable listed in options, check that it exists, that it didn't
+# come from the environment (to prevent accidents), and that it has a boolean
+# value. If so, output a name/value pair; otherwise complain and stop.
# Convey boolean options to Gnatprep.
options_preprocessing = ${addprefix -D,${option_values}}
@@ -530,8 +585,8 @@ build_targets = ${addsuffix .phony_target,${build_GPRs}}
# A phony target is defined for each build project, and the job of determining
# whether the project needs rebuilding is delegated to the builder.
-staged_usage_GPRs = ${addprefix ${stage_gprdir}/,${usage_GPRs}}
-preprocessed_files_in_builddir = ${addprefix ${builddir}/,${preprocessed_files}}
+staged_usage_GPRs = ${addprefix ${Make_gprdir}/,${usage_GPRs}}
+preprocessed_files_in_builddir = ${addprefix ${Make_builddir}/,${preprocessed_files}}
# When usage projects are preprocessed they are written to stage_gprdir. Other
# preprocessed files are assumed to be needed during the build and are written
# to builddir.
@@ -543,6 +598,7 @@ preprocessed_files_in_builddir = ${addprefix ${builddir}/,${preprocessed_files}}
.SECONDEXPANSION:
+.PHONY: Comfignat_default_goal
Comfignat_default_goal: build
# How to make directories:
@@ -551,11 +607,11 @@ Comfignat_default_goal: build
.PRECIOUS: %/
# This rule appears to work around a bug that was fixed in GNU Make 3.82:
-${stage_gprdir}/:
+${Make_gprdir}/:
mkdir -p $@
# How to initialize a build directory with a delegating makefile:
-${builddir}/Makefile: | ${builddir}/
+${Make_builddir}/Makefile: | ${Make_builddir}/
@echo 'Writing $@.'
@( echo 'Comfignat_default_goal: force ; ${delegation_command}'; \
echo '%: force ; ${delegation_command} $$@'; \
@@ -570,7 +626,8 @@ ${builddir}/Makefile: | ${builddir}/
# the match-anything rule to update the makefile.
# How to save configured variables:
-configure:: ${builddir}/Makefile
+.PHONY: configure
+configure:: ${Make_builddir}/Makefile
@echo "Writing ${configuration}."
@( ${foreach var,${configuration_variables}, \
${if ${or ${findstring command line,${origin ${var}}}, \
@@ -605,6 +662,7 @@ configure:: ${builddir}/Makefile
# V_is_weakly_configured=false".
# How to show the values of configured variables:
+.PHONY: show_configuration
show_configuration::
@${foreach var,${configuration_variables}, \
${if ${filter true,${${var}_is_configured}}, \
@@ -614,21 +672,22 @@ show_configuration::
true
# How to preprocess the project Comfignat:
-${builddir}/comfignat.gpr: comfignat.gpr.gp | ${builddir}/
+${Make_builddir}/comfignat.gpr: comfignat.gpr.gp | ${Make_builddir}/
"${GNATPREP}" $< $@ -DInvoked_By_Makefile ${all_directories} ${GNATPREPFLAGS}
# How to preprocess files that are needed during the build:
-${builddir}/%: %.gp | ${builddir}/
+${Make_builddir}/%: %.gp | ${Make_builddir}/
${preprocess_file}
# How to preprocess usage projects:
-${stage_gprdir}/%: %.gp | ${stage_gprdir}/
+${Make_gprdir}/%: %.gp | ${Make_gprdir}/
${preprocess_file}
# How to stage usage projects that don't need preprocessing:
-${stage_gprdir}/%: % | ${stage_gprdir}/
+${Make_gprdir}/%: % | ${Make_gprdir}/
cp -p $< $@
+.PHONY: preprocess
preprocess: $${preprocessed_files_in_builddir}
# How to build a project:
@@ -638,33 +697,70 @@ preprocess: $${preprocessed_files_in_builddir}
# requires that all preprocessing of files that are needed during the build is
# done before any project is built.
+.PHONY: base
base: $${build_targets}
# This builds the projects listed in build_GPRs, plus any additional
# prerequisites that the containing makefile might add.
+.PHONY: build
build: base $${staged_usage_GPRs}
# This is the default build. Additional targets that should be built by default
# may be added as prerequisites.
+.PHONY: all
all: build
# Optional targets may be added as prerequisites of "all".
-${stagedir}:
+${Make_stagedir}:
@${MAKE} build
# "make install" straight out of a source package triggers a build, but if
# 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: ${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::
rm -Rf "${objdir}" "${stagedir}" ${preprocessed_files_in_builddir}
+.PHONY: unconfigure
unconfigure::
rm -f "${configuration}"
+.PHONY: distclean
distclean: clean unconfigure