diff options
Diffstat (limited to 'comfignat.mk')
-rw-r--r-- | comfignat.mk | 54 |
1 files changed, 39 insertions, 15 deletions
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. |