From 5d5c0d0f36262fd61b78790ed5e20010cecd33bc Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Sat, 23 Dec 2023 15:06:19 +0100 Subject: [PATCH 1/2] Allow the user to build a shared library --- lib/gnat/aunit.gpr | 7 +++++-- lib/gnat/aunit_shared.gpr | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/gnat/aunit.gpr b/lib/gnat/aunit.gpr index d07f63d..305c55c 100644 --- a/lib/gnat/aunit.gpr +++ b/lib/gnat/aunit.gpr @@ -18,11 +18,14 @@ project AUnit is for Library_Dir use AUnit_Shared.Library_Dir; Obj_Dir := external ("AUNIT_OBJDIR", "../aunit-obj/" - & AUnit_Shared.Target & "-" & AUnit_Shared.Runtime); + & AUnit_Shared.Target & "-" & AUnit_Shared.Runtime + & "-" & AUnit_Shared.Library_Kind); for Object_Dir use Obj_Dir; for Library_Name use "aunit"; - for Library_Kind use "static"; + for Library_Kind use AUnit_Shared.Library_Kind; + for Library_Version use + external ("AUNIT_LIBRARY_VERSION", "libaunit.so.0.0"); -------------- -- Compiler -- diff --git a/lib/gnat/aunit_shared.gpr b/lib/gnat/aunit_shared.gpr index 43f6f40..1fe5506 100644 --- a/lib/gnat/aunit_shared.gpr +++ b/lib/gnat/aunit_shared.gpr @@ -14,7 +14,9 @@ project AUnit_Shared is Runtime : Runtime_Type := external ("AUNIT_RUNTIME", "full"); - Library_Dir := external ("AUNIT_LIBDIR", "../aunit/" & Target & "-" & Runtime); + Library_Kind := external ("AUNIT_LIBRARY_KIND", "static"); + Library_Dir := external ("AUNIT_LIBDIR", "../aunit/" & Target & "-" & Runtime + & "-" & Library_Kind); for Source_Dirs use (); From 3caf70bd17338f2c5f32c09a761082dc66a80054 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Sat, 23 Dec 2023 15:06:54 +0100 Subject: [PATCH 2/2] Allow the user to set build flags --- lib/gnat/aunit.gpr | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/gnat/aunit.gpr b/lib/gnat/aunit.gpr index 305c55c..4e2b136 100644 --- a/lib/gnat/aunit.gpr +++ b/lib/gnat/aunit.gpr @@ -27,6 +27,13 @@ project AUnit is for Library_Version use external ("AUNIT_LIBRARY_VERSION", "libaunit.so.0.0"); + case AUnit_Shared.Library_Kind is + when "dynamic" | "relocatable" => + -- Put options like --as-needed before the libraries. + for Leading_Library_Options use external_As_List ("LDFLAGS", " "); + when others => + end case; + -------------- -- Compiler -- -------------- @@ -43,6 +50,10 @@ project AUnit is ("-O2", "-gnatp", "-gnatn", "-gnatwa.X"); end case; + -- Allow user flags to override default flags. + for Default_Switches ("ada") use + Compiler'Default_Switches ("ada") & external_As_List ("ADAFLAGS", " "); + for Switches ("aunit.adb") use Compiler'Default_Switches ("ada") & ("-fno-strict-aliasing"); end Compiler;