Skip to content

Commit

Permalink
Simplify passing of build variables, show them in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
asarhaddon committed Oct 30, 2020
1 parent 68d6128 commit ee3addb
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,45 @@ GPRBUILD_OPTIONS := -j4

# Build flags are commonly found in the environment, but if they are
# set on our Make command line, forward them to GNAT projects.
export ADAFLAGS ?=
export LDFLAGS ?=
ADAFLAGS ?=
LDFLAGS ?=

# For the library, a static archive is built by default but a
# non-empty shared object version selects a relocatable library
export latin_utils_soversion :=
latin_utils_soversion :=

# Directory where dictionnary files are created and searched for.
# This variable is expected to be overridden at build time, with some
# architecture-specific value like $(prefix)/share/whitakers-words).
# At run time, another directory can be selected via the
# WHITAKERS_WORDS_DATADIR environment variable.
datadir := .
# During (re)builds, the tools must read and test the fresh data and
# ignore any previous version already installed in $(datadir).
export WHITAKERS_WORDS_DATADIR := .

generated_sources := src/latin_utils/latin_utils-config.adb

# If a relocatable library has been selected, tell the dynamic loader
# where to find it during tests or generation of the dictionaries.
ifneq (,$(latin_utils_soversion))
export LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)lib/latin_utils-dynamic
maybe_lib_path := \
LD_LIBRARY_PATH=$(if $(LD_LIBRARY_PATH),'$(LD_LIBRARY_PATH)':)lib/latin_utils-dynamic \
$()
endif

generated_sources := src/latin_utils/latin_utils-config.adb

# It is convenient to let gprbuild deal with Ada dependencies, and
# only then let a submake decide which data must be refreshed
# according to the now up-to-date timestamps of the generators.
.PHONY: all
all: commands
$(MAKE) -f Makefile.data.mk
$(maybe_lib_path)WHITAKERS_WORDS_DATADIR=. $(MAKE) -f Makefile.data.mk

# This target is more efficient than separate gprbuild runs because
# the dependency graph is only constructed once.
# It is run either because by an explicit 'commands' target, or
# because a generated file requires it.
.PHONY: commands
commands: $(generated_sources)
$(GPRBUILD) -p $(GPRBUILD_OPTIONS) commands.gpr
$(GPRBUILD) -p $(GPRBUILD_OPTIONS) commands.gpr \
$(foreach v,ADAFLAGS LDFLAGS latin_utils_soversion,-X$(v)='$($(v))')

.PHONY: clean
clean:
Expand All @@ -56,4 +56,4 @@ $(generated_sources): %: %.in Makefile

.PHONY: test
test: all
cd test && ./run-tests.sh
$(maybe_lib_path)test/run-tests.sh

0 comments on commit ee3addb

Please sign in to comment.