mirror of https://git.codelabs.ch/alog.git
Select dynamic library if SO version is set
This prevents any inconsistency on the command line between ALOG_VERSION (or its default value) and LIBRARY_KIND (or its default value). Require an explicit ALOG_VERSION in gprbuild command line. The default was dynamic in Makefile and static in projects, leading to some confusion. For example, debian/rules was setting VERSION for tests. Split build_lib_[dynamic|static] Makefile targets as done for install. Rename the project version internal variable after the external one, and move it from common project to the only project it affects.
This commit is contained in:
parent
814d0283ae
commit
04f9385318
14
Makefile
14
Makefile
|
@ -59,12 +59,14 @@ all: build_lib
|
|||
tests: build_tests
|
||||
@$(OBJECTDIR)/test_runner
|
||||
|
||||
build_lib:
|
||||
@gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION="$(VERSION)" \
|
||||
-XLIBRARY_KIND="$(LIBRARY_KIND)"
|
||||
build_lib: build_lib_$(LIBRARY_KIND)
|
||||
build_lib_dynamic:
|
||||
@gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION="$(VERSION)"
|
||||
build_lib_static:
|
||||
@gprbuild $(GMAKE_OPTS) -Palog -XALOG_VERSION=
|
||||
|
||||
build_tests:
|
||||
@gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests"
|
||||
@gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="tests" -XALOG_VERSION=
|
||||
|
||||
build_all: build_lib build_tests
|
||||
|
||||
|
@ -104,7 +106,7 @@ install_tests: build_tests
|
|||
cov:
|
||||
@mkdir -p $(COVDIR)
|
||||
@rm -f $(OBJECTDIR)/cov/*.gcda
|
||||
@gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="coverage"
|
||||
@gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="coverage" -XALOG_VERSION=
|
||||
@$(OBJECTDIR)/cov/test_runner || true
|
||||
@lcov -c -d $(OBJECTDIR)/cov/ -o $(OBJECTDIR)/cov/alog_tmp.info
|
||||
@lcov -e $(OBJECTDIR)/cov/alog_tmp.info "$(PWD)/src/*.adb" \
|
||||
|
@ -113,7 +115,7 @@ cov:
|
|||
|
||||
prof:
|
||||
@rm -f $(OBJECTDIR)/callgrind.*
|
||||
gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling"
|
||||
gprbuild $(GMAKE_OPTS) -Palog_tests -XALOG_BUILD="profiling" -XALOG_VERSION=
|
||||
valgrind -q --tool=callgrind \
|
||||
--callgrind-out-file=$(OBJECTDIR)/callgrind.out.%p $(OBJECTDIR)/profiler
|
||||
callgrind_annotate $(OBJECTDIR)/callgrind.* > $(OBJECTDIR)/profile.txt
|
||||
|
|
21
alog.gpr
21
alog.gpr
|
@ -24,21 +24,26 @@ with "alog_common";
|
|||
|
||||
library project Alog is
|
||||
|
||||
Alog_Version := External ("ALOG_VERSION");
|
||||
-- Require an explicit setting for ALOG_VERSION.
|
||||
-- Build a static library when it is empty,
|
||||
-- else a relocatable library with the given shared object version.
|
||||
|
||||
for Languages use Alog_Common.Languages;
|
||||
for Source_Dirs use ("src");
|
||||
for Object_Dir use "obj/lib/" & Alog_Common.Libtype;
|
||||
for Library_Name use "alog";
|
||||
for Library_Dir use "lib/" & Alog_Common.Libtype;
|
||||
for Library_Kind use Alog_Common.Libtype;
|
||||
|
||||
case Alog_Common.Libtype is
|
||||
when "static" =>
|
||||
null;
|
||||
when "dynamic" =>
|
||||
for Library_Version use "libalog.so." & Alog_Common.Version;
|
||||
case Alog_Version is
|
||||
when "" =>
|
||||
for Library_Kind use "static";
|
||||
when others =>
|
||||
for Library_Kind use "dynamic";
|
||||
for Library_Version use "libalog.so." & Alog_Version;
|
||||
-- Start with LDFLAGS as it may contain options like --as-needed.
|
||||
for Leading_Library_Options use Alog_Common.Ldflags;
|
||||
end case;
|
||||
for Object_Dir use "obj/lib/" & project'Library_Kind;
|
||||
for Library_Dir use "lib/" & project'Library_Kind;
|
||||
|
||||
package Compiler extends Alog_Common.Compiler is
|
||||
for Default_Switches ("Ada") use
|
||||
|
|
|
@ -24,11 +24,6 @@ abstract project Alog_Common is
|
|||
|
||||
for Source_Dirs use ();
|
||||
|
||||
Version := external ("ALOG_VERSION", "0.1");
|
||||
|
||||
type Lib_Type is ("static", "dynamic");
|
||||
Libtype : Lib_Type := external ("LIBRARY_KIND", "static");
|
||||
|
||||
Adaflags := External_As_List ("ADAFLAGS", " ");
|
||||
Cflags := External_As_List ("CFLAGS", " ");
|
||||
Cppflags := External_As_List ("CPPFLAGS", " ");
|
||||
|
|
|
@ -24,7 +24,7 @@ all: build_examples
|
|||
|
||||
# C compilations may happen if the library is updated.
|
||||
build_examples:
|
||||
@gprbuild -p -Palog_examples \
|
||||
@gprbuild -p -Palog_examples -XALOG_VERSION= \
|
||||
$(foreach v,ADAFLAGS CFLAGS CPPFLAGS LDFLAGS,"-X$(v)=$($(v))")
|
||||
|
||||
clean:
|
||||
|
|
Loading…
Reference in New Issue