Rombobjörn

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL17
-rw-r--r--build_system_log.gpr28
-rw-r--r--comfignat.gpr.gp20
-rw-r--r--comfignat.mk54
-rw-r--r--system_log.gpr.gp2
5 files changed, 90 insertions, 31 deletions
diff --git a/INSTALL b/INSTALL
index f247cc4..2aa149b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -118,12 +118,21 @@ invoke Gnatprep. You may need to define them if you run Gnatprep manually.
above will be used if the symbols are undefined.
-Build Tools and Options
------------------------
+Building a Shared or Static Library
+-----------------------------------
+
+System_Log can be built either as a shared library or as a static library.
+The Make variable library_type controls which kind of library is built. The
+valid values are "dynamic", "static", and "relocatable" which is an alias for
+"dynamic". The default is to build a shared library, that is "dynamic".
+
+
+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
@@ -168,7 +177,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/build_system_log.gpr b/build_system_log.gpr
index b907fd5..ff2af50 100644
--- a/build_system_log.gpr
+++ b/build_system_log.gpr
@@ -10,19 +10,29 @@ with "comfignat.gpr";
library project Build_System_Log is
+ for Library_Name use "adasyslog";
+ for Library_Kind use Comfignat.Library_Type;
+ for Object_Dir use Comfignat.Objdir;
+ for Library_Src_Dir use Comfignat.Stage_Includedir & "/adasyslog";
+ for Library_Dir use Comfignat.Stage_Libdir;
+ for Library_ALI_Dir use Comfignat.Stage_Alidir & "/adasyslog";
+
+ -- When building a shared library we want Library_Interface to make the
+ -- library elaborate itself automatically. For a static library we need to
+ -- avoid Library_Interface so that GNAT will automatically make a using
+ -- program handle elaboration of the library.
+ -- Library_Version sets the soname, which only shared libraries have.
-- An attempt to use a two-part version number at the end of the soname
-- caused Gnatmake and GPRbuild to include only the major version number,
-- so for compatibility the soname is libadasyslog.so.1 until an ABI change
-- is made, if that ever happens.
-
- for Library_Name use "adasyslog";
- for Library_Kind use "dynamic";
- for Library_Version use "libadasyslog.so.1";
- for Library_Interface use ("System_Log");
- for Object_Dir use Comfignat.Objdir;
- for Library_Src_Dir use Comfignat.Stage_Includedir & "/adasyslog";
- for Library_Dir use Comfignat.Stage_Libdir;
- for Library_ALI_Dir use Comfignat.Stage_Alidir & "/adasyslog";
+ case Comfignat.Library_Type is
+ when "dynamic" | "relocatable" =>
+ for Library_Version use "libadasyslog.so.1";
+ for Library_Interface use ("System_Log");
+ when "static" =>
+ null;
+ end case;
package Compiler is
for Default_Switches ("Ada") use ("-gnato");
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.
diff --git a/system_log.gpr.gp b/system_log.gpr.gp
index 7bb2c6d..1962134 100644
--- a/system_log.gpr.gp
+++ b/system_log.gpr.gp
@@ -12,7 +12,7 @@ with $Directories_GPR;
library project System_Log is
for Library_Name use "adasyslog";
- for Library_Kind use "dynamic";
+ for Library_Kind use $Library_Type;
for Source_Dirs use ($Includedir & "/adasyslog");
for Library_Dir use $Libdir;
for Library_ALI_Dir use $Alidir & "/adasyslog";