From f5a9cfa9111a6792c5f4e87f1acb4da822a7efc2 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Wed, 3 Nov 2021 15:24:40 +0100 Subject: [PATCH 1/3] florist.gpr: ensure distinct directories for distinct library types The Makefile.in creates a static archive from PIC objects, which is probably not deliberate. --- florist.gpr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/florist.gpr b/florist.gpr index faa6ca4..5b222d8 100644 --- a/florist.gpr +++ b/florist.gpr @@ -15,9 +15,6 @@ library project Florist is for Source_Dirs use Common_Source_Dirs & Threads_Source_Dirs; end case; - for Object_Dir use "obj"; - for Library_Dir use "lib"; - Version := "1"; for Library_version use "libflorist.so." & Version; @@ -25,6 +22,9 @@ library project Florist is Library_Type : Library_Type_Type := external ("LIBRARY_TYPE", "static"); for Library_Kind use Library_Type; + for Object_Dir use "obj/" & Library_Type; + for Library_Dir use "lib/" & Library_Type; + type Build_Type is ("Debug", "Production"); Build : Build_Type := External ("Build", "Production"); From e5babc2b48f5c7c531c99f46215407f0513aaf73 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Wed, 3 Nov 2021 15:28:03 +0100 Subject: [PATCH 2/3] florist.gpr: allow override of the shared object version --- florist.gpr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/florist.gpr b/florist.gpr index 5b222d8..62b49d6 100644 --- a/florist.gpr +++ b/florist.gpr @@ -15,7 +15,7 @@ library project Florist is for Source_Dirs use Common_Source_Dirs & Threads_Source_Dirs; end case; - Version := "1"; + Version := External ("florist_shared_object_version", "1"); for Library_version use "libflorist.so." & Version; type Library_Type_Type is ("relocatable", "static"); From d37db309d182a2e1e1116b895796621007be4862 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Wed, 3 Nov 2021 15:41:59 +0100 Subject: [PATCH 3/3] Allow the user to override build flags CFLAGS CPPFLAGS LDFLAGS LIBS may be set either via the environment, as ./configure arguments, or on the Make command line. Remove the GCCFLAGS variable for clarity. --- Makefile.in | 17 ++++++++++++----- configure.in | 2 ++ florist.gpr | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Makefile.in b/Makefile.in index 0a81ef0..06b9a28 100644 --- a/Makefile.in +++ b/Makefile.in @@ -8,7 +8,10 @@ VERSION=7.3.0w FLORIST_VERSION=$(VERSION) GNATPREPFLAGS = -c -r -GCCFLAGS = -O2 +ADAFLAGS = @ADAFLAGS@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ TARGET=@host_alias@ ifneq ($(TARGET),) @@ -32,13 +35,17 @@ PREFIX = @prefix@ ENABLE_SHARED = @ENABLE_SHARED@ PROJECT_FLAGS = @BUILD_TYPE_OPTION@ @THREADS_OPTION@ @RTS_OPTION@ \ + $(foreach v,ADAFLAGS CFLAGS CPPFLAGS LDFLAGS LIBS\ + ,'-X$(v)=$($(v))') \ $(TARGET_OPTION) # Scenario variables and RTS selection must be passed consistently to # project-aware tools gprbuild, gprinstall, and gprclean. +# *FLAGS usually only influence gprbuild, but stay on the safe side. +# For example gprinstall may copy LIBS into the installed project. GNATPREP = $(TARGET_PREFIX)gnatprep GPRBUILD = gprbuild -GPRBUILD_FLAGS = $(GCCFLAGS) $(PROJECT_FLAGS) +GPRBUILD_FLAGS = $(PROJECT_FLAGS) GENDIR = gensrc GENDIR_ON_TARGET=$(GENDIR) @@ -108,12 +115,12 @@ configure: configure.in aclocal.m4 # If you are unlucky, it will require fixes to c-posix.c. # c-posix: c-posix.c confsrc/config.h confsrc/pconfig.h - $(CC) $(GCCFLAGS) -DVERSION="\"$(VERSION)\"" -DLIBS="\"$(LIBS)\"" -DGENDIR="\"$(GENDIR_ON_TARGET)\"" -o c-posix c-posix.c $(LIBS) + $(CC) -O2 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DVERSION="\"$(VERSION)\"" -DLIBS="\"$(LIBS)\"" -DGENDIR="\"$(GENDIR_ON_TARGET)\"" -o c-posix c-posix.c $(LIBS) # # Program c-posix-signals generates another Ada package spec. # c-posix-signals: c-posix-signals.c - $(CC) $(GCCFLAGS) -DGENDIR="\"$(GENDIR_ON_TARGET)\"" -o c-posix-signals c-posix-signals.c $(LIBS) + $(CC) -O2 $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DGENDIR="\"$(GENDIR_ON_TARGET)\"" -o c-posix-signals c-posix-signals.c $(LIBS) # # generate Ada source files using "c-posix" program # @@ -140,7 +147,7 @@ $(GENDIR)/%.ads: libsrc/%.gps gnatprep.config $(GENDIR)/%.adb: libsrc/%.gpb gnatprep.config mkdir -p `dirname $@` && $(GNATPREP) $< $@ gnatprep.config $(GNATPREPFLAGS) .c.o: - $(CC) -c $(GCCFLAGS) $< + $(CC) -c -O2 $(CFLAGS) $(CPPFLAGS) $< # # ------------------------------------ diff --git a/configure.in b/configure.in index a5d8040..53d469e 100644 --- a/configure.in +++ b/configure.in @@ -13,6 +13,8 @@ AC_PROG_CC rm -f pconfig.h +AC_ARG_VAR(ADAFLAGS,[Debugging and optimization options for the Ada compiler.]) + AC_ARG_ENABLE(threads, AS_HELP_STRING([--disable-threads], [Do not try to build pthread support]),, [use_pthread=yes]) diff --git a/florist.gpr b/florist.gpr index 62b49d6..1bad7f0 100644 --- a/florist.gpr +++ b/florist.gpr @@ -25,6 +25,14 @@ library project Florist is for Object_Dir use "obj/" & Library_Type; for Library_Dir use "lib/" & Library_Type; + case Library_Type is + when "relocatable" => + for Leading_Library_Options use External_As_List ("LDFLAGS", " "); + for Library_Options use External_As_List ("LIBS", " "); + when "static" => + null; + end case; + type Build_Type is ("Debug", "Production"); Build : Build_Type := External ("Build", "Production"); @@ -41,12 +49,20 @@ library project Florist is GNAT_Flags := ("-g", "-O2", "-gnatpg"); end case; + -- Always let ADAFLAGS take priority. + Adaflags := External_As_List ("ADAFLAGS", " "); + Ada_Flags := Ada_Flags & Adaflags; + GNAT_Flags := GNAT_Flags & Adaflags; + for Switches ("posix-signals.adb") use GNAT_Flags; for Switches ("posix-implementation.adb") use GNAT_Flags; for Switches ("posix-supplement_to_ada_io.adb") use GNAT_Flags; for Switches ("posix-unsafe_process_primitives.adb") use GNAT_Flags; for Default_Switches ("Ada") use Ada_Flags; + for Default_Switches ("C") use ("-O2") + & External_As_List ("CFLAGS", " ") + & External_As_List ("CPPFLAGS", " "); end Compiler; end Florist;