Rombobjörn

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Persson <Bjorn@Rombobjörn.se>2016-02-20 23:31:07 +0100
committerBjörn Persson <Bjorn@Rombobjörn.se>2016-02-20 23:31:07 +0100
commit3ac552858d7d4564f20c743633f072a7917e9531 (patch)
treeef9e7cb72ffba0e3cff7695258632e61d0e8748c
parent951821861bd9b0b474b0c8d4ae667cc21efb0f55 (diff)
Updated Comfignat to version 1.5.HEADmaster
-rw-r--r--INSTALL8
-rw-r--r--comfignat.gpr.gp20
-rw-r--r--comfignat.mk54
3 files changed, 61 insertions, 21 deletions
diff --git a/INSTALL b/INSTALL
index 10a7c94..aa257d7 100644
--- a/INSTALL
+++ b/INSTALL
@@ -137,12 +137,12 @@ thread wrapper is disabled by default. To enable it, set the variable
wrap_threads to "true" on the Make or Gnatprep command line.
-Build Tools and Options
------------------------
+Build Tools and their Arguments
+-------------------------------
The following variables, which may be set in the environment or on the Make
command line, control which programs are invoked to do the build and which
-options are passed to them:
+arguments are passed to them:
GNATPREP
The command for invoking Gnatprep, in case you want to use a nondefault
@@ -189,7 +189,7 @@ options are passed to them:
Copyright of This File
----------------------
-Copyright 2013 B. Persson, Bjorn@Rombobeorn.se
+Copyright 2013 - 2016 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.
diff --git a/comfignat.gpr.gp b/comfignat.gpr.gp
index b9ea446..e024f90 100644
--- a/comfignat.gpr.gp
+++ b/comfignat.gpr.gp
@@ -1,5 +1,5 @@
-- Comfignat configuration variables for GNAT project files
--- Copyright 2013 - 2015 B. Persson, Bjorn@Rombobeorn.se
+-- Copyright 2013 - 2016 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.4 – common, convenient, command-line-
+-- This file is part of Comfignat 1.5 – 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/.
@@ -313,4 +313,20 @@ abstract project Comfignat is
Stage_Alidir := Stagedir & Alidir;
#end if;
+
+ --
+ -- Other configuration than directories:
+ --
+
+ -- If a library can be built as either shared or static, then Library_Type
+ -- shall be used to set the attribute Library_Kind. It can be overridden on
+ -- the builder command line, which makes it possible to write a makefile
+ -- that builds both a shared and a static library.
+ type Library_Kind is ("dynamic", "relocatable", "static");
+ #if Library_Type'Defined then
+ Library_Type : Library_Kind := external("LIBRARY_TYPE", $Library_Type);
+ #else
+ Library_Type : Library_Kind := external("LIBRARY_TYPE", "dynamic");
+ #end if;
+
end Comfignat;
diff --git a/comfignat.mk b/comfignat.mk
index f9f2038..b71efb2 100644
--- a/comfignat.mk
+++ b/comfignat.mk
@@ -1,5 +1,5 @@
# Comfignat makefile foundation for configuring and building GNAT projects
-# Copyright 2013 - 2015 B. Persson, Bjorn@Rombobeorn.se
+# Copyright 2013 - 2016 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.4 – common, convenient, command-line-
+# This file is part of Comfignat 1.5 – 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/.
@@ -148,6 +148,10 @@ relocatable_package = false
# breaking the project files.
# dirgpr takes precedence over relocatable_package.
+library_type = dynamic
+# If a library can be built as either shared or static, then library_type shall
+# be used to set the attribute Library_Kind in the project files.
+
prefix = /usr/local
exec_prefix = ${prefix}
datarootdir = ${prefix}/share
@@ -212,6 +216,16 @@ srcdir := ${abspath ${dir ${lastword ${MAKEFILE_LIST}}}}
# as the directory part of the last pathname in MAKEFILE_LIST – which is this
# file since there is no include directive above this point.
+srcsubdir := ${abspath ${dir ${firstword ${MAKEFILE_LIST}}}}
+# Unlike other directory variables, srcsubdir varies between Make invocations
+# when there are several Comfignat-using makefiles in subdirectories in the
+# source tree. Its value is the directory of the makefile that the current Make
+# process was invoked with. This will often be the same as CURDIR, but not for
+# the main makefile when it's invoked from a delegating makefile in a separate
+# build directory, as CURDIR is then the build directory.
+# (dir must be called before abspath in case a parent directory name contains
+# spaces, because dir operates on a space-separated list.)
+
stage_bindir = ${stagedir}${bindir}
stage_libexecdir = ${stagedir}${libexecdir}
stage_datadir = ${stagedir}${datadir}
@@ -232,6 +246,7 @@ stage_miscdocdir = ${stagedir}${miscdocdir}
# written during the build.
Make_srcdir = ${call Make_pathname,srcdir}
+Make_srcsubdir = ${call Make_pathname,srcsubdir}
Make_builddir = ${call Make_pathname,builddir}
Make_objdir = ${call Make_pathname,objdir}
Make_stagedir = ${call Make_pathname,stagedir}
@@ -257,14 +272,14 @@ Make_miscdocdir = ${call Make_pathname,stage_miscdocdir}
preprocess_file = "${GNATPREP}" ${firstword ${filter %.gp,$^}} $@ \
${options_preprocessing} ${Gnatprep_arguments} \
${if ${filter ${notdir $@},${notdir ${usage_GPRs}}}, \
- ${usage_directories}, \
+ ${usage_directories} '-DLibrary_Type="${library_type}"', \
'-DSrcdir="${srcdir}"'} \
${GNATPREPFLAGS}
# 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, as it's
-# needed by preprocessed build projects.
+# target is a usage project, then the usage-relevant variables are 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,$^}} \
${addprefix -aP,${VPATH}} -p \
@@ -350,7 +365,7 @@ endif
ifneq (${origin preprocessed_files},file)
preprocessed_files = \
${filter-out ${notdir ${usage_GPRs}}, \
- ${basename ${notdir ${wildcard ${Make_srcdir}/*.gp}}}}
+ ${basename ${notdir ${wildcard ${Make_srcsubdir}/*.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
@@ -396,7 +411,7 @@ configuration_variables += \
GNATPREPFLAGS GNAT_BUILDER_FLAGS ADAFLAGS CPPFLAGS CFLAGS CXXFLAGS FFLAGS \
GNATBINDFLAGS GNATLINKFLAGS LDFLAGS GNATFLAGS \
DESTDIR \
- dirgpr relocatable_package \
+ dirgpr relocatable_package library_type \
prefix exec_prefix datarootdir localstatedir \
bindir libexecdir \
datadir sysconfdir statedir cachedir logdir runstatedir lockdir \
@@ -574,12 +589,20 @@ options_building = ${addprefix -X,${option_values}}
# Some other data that the rules below need:
#
-main_makefile := ${firstword ${MAKEFILE_LIST}}
-delegation_command = @$${MAKE} --file=${abspath ${main_makefile}} \
- --include-dir=${abspath ${dir ${main_makefile}}}
+delegation_command = @\$${MAKE} \
+ '--file=${abspath ${firstword ${MAKEFILE_LIST}}}' \
+ '--include-dir=${srcsubdir}'
# delegation_command is the Make command line that delegating makefiles in
# separate build directories use to delegate commands to the main makefile. The
# first pathname in MAKEFILE_LIST is the main makefile.
+# The --file parameter remembers the main makefile that was used to write the
+# delegating makefile.
+# The --include-dir parameter allows the main makefile to find comfignat.mk
+# relative to its own location.
+# The working directory is not changed, so that any relative pathnames passed
+# in will be resolved relative to the build directory. (Note that sub-Makes in
+# subdirectories can still change the working directory).
+
build_targets = ${addsuffix .phony_target,${build_GPRs}}
# A phony target is defined for each build project, and the job of determining
@@ -613,8 +636,8 @@ ${Make_gprdir}/:
# How to initialize a build directory with a delegating makefile:
${Make_builddir}/Makefile: | ${Make_builddir}/
@echo 'Writing $@.'
- @( echo 'Comfignat_default_goal: force ; ${delegation_command}'; \
- echo '%: force ; ${delegation_command} $$@'; \
+ @( echo "Comfignat_default_goal: force ; ${delegation_command}"; \
+ echo "%: force ; ${delegation_command} "'$$@'; \
echo 'force: ;'; \
echo 'Makefile: ;' \
) > $@
@@ -673,7 +696,8 @@ show_configuration::
# How to preprocess the project Comfignat:
${Make_builddir}/comfignat.gpr: comfignat.gpr.gp | ${Make_builddir}/
- "${GNATPREP}" $< $@ -DInvoked_By_Makefile ${all_directories} ${GNATPREPFLAGS}
+ "${GNATPREP}" $< $@ -DInvoked_By_Makefile ${all_directories} \
+ '-DLibrary_Type="${library_type}"' ${GNATPREPFLAGS}
# How to preprocess files that are needed during the build:
${Make_builddir}/%: %.gp | ${Make_builddir}/
@@ -698,7 +722,7 @@ preprocess: $${preprocessed_files_in_builddir}
# done before any project is built.
.PHONY: base
-base: $${build_targets}
+base: $${build_targets} preprocess
# This builds the projects listed in build_GPRs, plus any additional
# prerequisites that the containing makefile might add.