Rombobjörn

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Persson <bjorn@rombobjörn.se>2013-11-04 09:06:24 +0100
committerBjörn Persson <bjorn@rombobjörn.se>2013-11-04 09:06:24 +0100
commit59d62720ed2874a342b1c3fc4624d8a60cfc5fa4 (patch)
treebbe5dc5597f64e85d411b53a68bedaa61c0a6f82
parent0e758f47deba535e53d5caa515df0d3ffafcc4d0 (diff)
Made explicitly set directory variables override a directories project.
-rw-r--r--INSTALL24
-rw-r--r--comfignat.mk161
-rwxr-xr-xmanual.en.html5
3 files changed, 114 insertions, 76 deletions
diff --git a/INSTALL b/INSTALL
index 982d5a7..4a33eb2 100644
--- a/INSTALL
+++ b/INSTALL
@@ -55,7 +55,9 @@ are relevant during the build:
GNAT project file that defines directory variables for use by other project
files. Multiarch support requires a directories project that can refer to
different directories depending on the target architecture. A directories
- project overrides some but not all of the directory variables listed below.
+ project overrides the default values of some of the directory variables
+ listed below, but if one of those variables is set explicitly, then it
+ overrides the directories project.
relocatable_package
If relocatable_package is true and no directories project is provided, then
@@ -73,13 +75,13 @@ are relevant during the build:
other architecture-specific files. Default: <prefix>
bindir
- The directory for programs that can be run from a command prompt, used only
- if no directories project is provided. Default: <exec_prefix>/bin
+ The directory for programs that can be run from a command prompt; may be
+ provided by a directories project. Default: <exec_prefix>/bin
libexecdir
The top-level directory for programs that are intended to be run by other
- programs rather than by users, used only if no directories project is
- provided. Default: <exec_prefix>/libexec
+ programs rather than by users; may be provided by a directories project.
+ Default: <exec_prefix>/libexec
datarootdir
The root of the directory tree for read-only architecture-independent data
@@ -124,22 +126,22 @@ are relevant during the build:
includedir
The top-level directory for source files to be used in the compilation of
- software using libraries, used only if no directories project is provided.
+ software using libraries; may be provided by a directories project.
Default: <prefix>/include
archincludedir
Like includedir but for architecture-specific source files, in case this
- library must install such files. Default: <includedir>
+ library must install such files; may be provided by a directories project.
+ Default: <includedir>
libdir
The directory for binary libraries to be used by other software, and the
- top-level directory for other architecture-specific files, used for
- libraries only if no directories project is provided.
- Default: <exec_prefix>/lib
+ top-level directory for other architecture-specific files; may be provided
+ by a directories project. Default: <exec_prefix>/lib
alidir
The parent of the library-specific directory for Ada library information
- files for this library, used only if no directories project is provided.
+ files for this library; may be provided by a directories project.
Default: <libdir>
gprdir
diff --git a/comfignat.mk b/comfignat.mk
index 9bc4f7b..f2a9955 100644
--- a/comfignat.mk
+++ b/comfignat.mk
@@ -317,6 +317,21 @@ endif
# build projects:
#
+# First define some functions and constants for processing directory variables.
+
+usage_directory_variables = includedir archincludedir libdir alidir
+# These are the usage-relevant directory variables. They are needed in usage
+# projects after installation.
+
+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.
+
+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_
@@ -382,33 +397,81 @@ maybe_relative_to = \
# Then, if relocatable_package is "true", let relative_to convert the pathname,
# otherwise return parameter 1 unchanged.
-embed_pathname = ${call maybe_relative_to,${1},${bindir}}
-# embed_pathname converts an absolute pathname into the right form for
-# inclusion in a program, which means that it is made relative to bindir if a
+embed_pathname = ${call maybe_relative_to,${${1}},${if ${filter bindir,${1}} \
+ ,${libexecdir},${bindir}}}
+# embed_pathname takes the name of a variable whose value is an absolute
+# pathname, and converts that pathname into the right form for inclusion in a
+# program, which means that bindir is made relative to libexecdir and other
+# variables are made relative to bindir if a relocatable package is desired.
+
+usage_pathname = ${call maybe_relative_to,${${1}},${gprdir}}
+# usage_pathname takes the name of a variable whose value is an absolute
+# pathname, and converts that pathname into the right form for inclusion in a
+# usage project, which means that it is made relative to gprdir if a
# relocatable package is desired.
-usage_pathname = ${call maybe_relative_to,${1},${gprdir}}
-# usage_pathname converts an absolute pathname into the right form for
-# inclusion in a usage project, which means that it is made relative to gprdir
-# if a relocatable package is desired.
+define convey_builder_directory_variable
+ all_directories += '-D${1}="${call embed_pathname,${1}}"'
+ 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.
+# · 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
+# staging directory, which wouldn't be derived correctly from a relative
+# pathname.
+# · If the variable is also usage-relevant, then append a symbol definition
+# to usage_directories to convey it to usage projects in the form that
+# usage projects need.
+
+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.
+# · 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.
+
+# Now that all those functions are defined, compute the symbol definitions for
+# the directory variables.
# Convey builddir, objdir and stagedir to comfignat.gpr.
all_directories = '-DBuilddir="${builddir}"' '-DObjdir="${objdir}"' \
'-DStagedir="${stagedir}"'
+usage_directories =
+
+# Make project files import the directories project if one has been provided.
+ifneq (${dirgpr},)
+ directories_project := ${basename ${notdir ${call mung_string,${dirgpr}}}}
+ all_directories += '-DDirectories_GPR="${dirgpr}"'
+ all_directories += '-DDirectories_Project=${directories_project}'
+ usage_directories += '-DDirectories_GPR="${dirgpr}"'
+endif
+
# Convey the builder-irrelevant directory variables, making them available to
# build projects for inclusion in binaries. Make most of the pathnames relative
# if a relocatable package is desired.
-all_directories += '-DDatadir="${call embed_pathname,${datadir}}"'
-all_directories += '-DSysconfdir="${call embed_pathname,${sysconfdir}}"'
-all_directories += '-DStatedir="${call embed_pathname,${statedir}}"'
-all_directories += '-DCachedir="${call embed_pathname,${cachedir}}"'
-all_directories += '-DLogdir="${call embed_pathname,${logdir}}"'
-all_directories += '-DGPRdir="${call embed_pathname,${gprdir}}"'
-all_directories += '-DLocaledir="${call embed_pathname,${localedir}}"'
-all_directories += '-DMandir="${call embed_pathname,${mandir}}"'
-all_directories += '-DInfodir="${call embed_pathname,${infodir}}"'
-all_directories += '-DMiscdocdir="${call embed_pathname,${miscdocdir}}"'
+all_directories += '-DDatadir="${call embed_pathname,datadir}"'
+all_directories += '-DSysconfdir="${call embed_pathname,sysconfdir}"'
+all_directories += '-DStatedir="${call embed_pathname,statedir}"'
+all_directories += '-DCachedir="${call embed_pathname,cachedir}"'
+all_directories += '-DLogdir="${call embed_pathname,logdir}"'
+all_directories += '-DGPRdir="${call embed_pathname,gprdir}"'
+all_directories += '-DLocaledir="${call embed_pathname,localedir}"'
+all_directories += '-DMandir="${call embed_pathname,mandir}"'
+all_directories += '-DInfodir="${call embed_pathname,infodir}"'
+all_directories += '-DMiscdocdir="${call embed_pathname,miscdocdir}"'
all_directories += '-DRunstatedir="${runstatedir}"'
all_directories += '-DLockdir="${lockdir}"'
# runstatedir and lockdir belong to the operating system and are used for
@@ -416,54 +479,22 @@ all_directories += '-DLockdir="${lockdir}"'
# to have its own runstatedir. Therefore these variables are always absolute
# pathnames.
-ifeq (${dirgpr},)
-
- # No directories project was provided, so convey even the builder-relevant
- # directory variables to comfignat.gpr, and convey the usage-relevant ones
- # to usage projects in the form that usage projects need.
-
- all_directories += '-DBindir="${call maybe_relative_to,${bindir},${libexecdir}}"'
- all_directories += '-DLibexecdir="${call embed_pathname,${libexecdir}}"'
- all_directories += '-DIncludedir="${call embed_pathname,${includedir}}"'
- all_directories += '-DArchincludedir="${call embed_pathname,${archincludedir}}"'
- all_directories += '-DLibdir="${call embed_pathname,${libdir}}"'
- all_directories += '-DAlidir="${call embed_pathname,${alidir}}"'
-
- all_directories += '-DStage_Bindir="${stage_bindir}"'
- all_directories += '-DStage_Libexecdir="${stage_libexecdir}"'
- all_directories += '-DStage_Includedir="${stage_includedir}"'
- all_directories += '-DStage_Archincludedir="${stage_archincludedir}"'
- all_directories += '-DStage_Libdir="${stage_libdir}"'
- all_directories += '-DStage_Alidir="${stage_alidir}"'
-
- usage_directories = '-DIncludedir="${call usage_pathname,${includedir}}"' \
- '-DArchincludedir="${call usage_pathname,${archincludedir}}"' \
- '-DLibdir="${call usage_pathname,${libdir}}"' \
- '-DAlidir="${call usage_pathname,${alidir}}"'
-
-else
-
- # A directories project is used, so make project files take the builder-
- # relevant directory variables from there.
-
- directories_project := ${basename ${notdir ${call mung_string,${dirgpr}}}}
-
- all_directories += '-DDirectories_GPR="${dirgpr}"'
- all_directories += '-DDirectories_Project=${directories_project}'
- all_directories += '-DBindir=${directories_project}.Bindir'
- all_directories += '-DLibexecdir=${directories_project}.Libexecdir'
- all_directories += '-DIncludedir=${directories_project}.Includedir'
- all_directories += '-DArchincludedir=${directories_project}.Archincludedir'
- all_directories += '-DLibdir=${directories_project}.Libdir'
- all_directories += '-DAlidir=${directories_project}.Alidir'
-
- usage_directories = '-DDirectories_GPR="${dirgpr}"' \
- '-DIncludedir=${directories_project}.Includedir' \
- '-DArchincludedir=${directories_project}.Archincludedir' \
- '-DLibdir=${directories_project}.Libdir' \
- '-DAlidir=${directories_project}.Alidir'
-
-endif
+# 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}}}}}
+# 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.
+# If a variable is of command line origin or marked as configured, or if dirgpr
+# is empty (that is, no directories project has been provided), then convey the
+# variable to project files. Otherwise make project files use the variable that
+# the directories project provides.
+
+# And now process any boolean options.
option_values = \
${foreach option,${options}, \
diff --git a/manual.en.html b/manual.en.html
index c219442..bfbc04c 100755
--- a/manual.en.html
+++ b/manual.en.html
@@ -642,6 +642,11 @@ and testing, and delete parts that don't apply to your project.</p>
<h3 id="news_1.2">Noteworthy Changes in Version 1.2</h3>
<ul>
+<li><p>The interaction between directory variables and directories projects was
+corrected so that a directories project overrides the default values of some
+directory variables, but an explicitly set Make variable overrides the
+corresponding variable in the directories project.</p></li>
+
<li><p>The directory variables <var>alidir</var> and <var>archincludedir</var>
were added.</p></li>