File: compiler_options.patch

package info (click to toggle)
libflorist 2016-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,204 kB
  • ctags: 291
  • sloc: ada: 11,902; ansic: 7,195; makefile: 155; sh: 19
file content (169 lines) | stat: -rw-r--r-- 5,932 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
Description: make build more flexible
 Ensure least-surprise behaviour when CFLAGS CPPFLAGS LDFLAGS LIBS
 are set by usual means: either via the environment, as ./configure
 arguments, or as make arguments.
 Implicit Make rules handle this, adapt florist.gpr to do so.
 .
 Add a similar ADAFLAGS variable.
 .
 Allow override of Library_Version (via GPRBUILD_FLAGS).
 .
 Allow to build both relocatable and static libraries in a row.
 Distinct lib and obj directories are required.
 A LIBRARY_TYPE_OPTION make variable is convenient because it avoids a new
 ./configure run.
 These ideas may easily be extended to BUILD_TYPE THREADS and RTS.
 .
 Allow GPRBUILD_FLAGS to override default gprbuild command line.
 PROJECT_FLAGS has a distinct purpose, and may be set separately.
Author: Ludovic Brenta <lbrenta@debian.org>
Author: Nicolas Boulenguez <nicolas@debian.org>

--- a/configure.in
+++ b/configure.in
@@ -13,6 +13,8 @@
 
 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])
--- a/Makefile.in
+++ b/Makefile.in
@@ -7,7 +7,6 @@
 
 VERSION=Florist-2016 (20160515)
 GNATPREPFLAGS = -c -r
-GCCFLAGS = -O2
 TARGET=@host_alias@
 
 ifneq ($(TARGET),)
@@ -20,18 +19,23 @@
 endif
 
 # configure substitutions
+ADAFLAGS                                := @ADAFLAGS@
+CFLAGS                                  := @CFLAGS@
+CPPFLAGS                                := @CPPFLAGS@
+LDFLAGS                                 := @LDFLAGS@
+LIBRARY_TYPE_OPTION                     := @LIBRARY_TYPE_OPTION@
 CC = @CC@
 LIBS = @LIBS@
 SIGNALS_GENERATED = @SIGNALS_GENERATED@
 PREFIX = @prefix@
 
-PROJECT_FLAGS = @LIBRARY_TYPE_OPTION@ @BUILD_TYPE_OPTION@ @THREADS_OPTION@ @RTS_OPTION@ $(TARGET_OPTION)
+PROJECT_FLAGS = $(LIBRARY_TYPE_OPTION) @BUILD_TYPE_OPTION@ @THREADS_OPTION@ @RTS_OPTION@ $(TARGET_OPTION)
 # Scenario variables and RTS selection must be passed consistently to
 # project-aware tools gprbuild, gprinstall, and gprclean.
 
 GNATPREP = $(TARGET_PREFIX)gnatprep
 GPRBUILD = gprbuild
-GPRBUILD_FLAGS = $(GCCFLAGS) $(PROJECT_FLAGS)
+GPRBUILD_FLAGS =
 
 GENDIR = gensrc
 GENDIR_ON_TARGET=$(GENDIR)
@@ -100,13 +104,18 @@
 # it might be fixable by hand-editing config.h or pconfig.h.
 # 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)
+c-posix: confsrc/config.h \
+         confsrc/pconfig.h
+c-posix: CPPFLAGS += -DVERSION="\"$(VERSION)\"" \
+                     -DLIBS="\"$(LIBS)\"" \
+                     -DGENDIR="\"$(GENDIR_ON_TARGET)\""
+c-posix: LDLIBS += $(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)
+c-posix-signals: CPPFLAGS += -DGENDIR="\"$(GENDIR_ON_TARGET)\""
+c-posix-signals: LDLIBS += $(LIBS)
 #
 # generate Ada source files using "c-posix" program
 #
@@ -127,13 +136,11 @@
 # particular OS using the "gnatprep" program.
 # The sources for these end in ".gpb" and ".gps".
 #
-.SUFFIXES: .gps .gpb .ads .adb .o .c
+.SUFFIXES: .gps .gpb .ads .adb
 $(GENDIR)/%.ads: libsrc/%.gps gnatprep.config
 	mkdir -p `dirname $@` && $(GNATPREP) $< $@ gnatprep.config $(GNATPREPFLAGS)
 $(GENDIR)/%.adb: libsrc/%.gpb gnatprep.config
 	mkdir -p `dirname $@` && $(GNATPREP) $< $@ gnatprep.config $(GNATPREPFLAGS)
-.c.o:
-	$(CC) -c $(GCCFLAGS) $<
 
 #
 # ------------------------------------
@@ -143,7 +150,9 @@
 force:
 
 floristlib: $(GENERATED) force
-	$(GPRBUILD) -p $(GPRBUILD_FLAGS) -Pflorist
+	$(GPRBUILD) -P florist $(PROJECT_FLAGS) \
+	  $(foreach v,ADAFLAGS CFLAGS CPPFLAGS LDFLAGS LIBS,"-X$(v)=$($(v))") \
+	  -p $(GPRBUILD_FLAGS)
 #
 # -----------------------------------
 # Maintenance targets
--- a/florist.gpr
+++ b/florist.gpr
@@ -15,22 +15,27 @@
           for Source_Dirs use Common_Source_Dirs & Threads_Source_Dirs;
    end case;
 
-   for Object_Dir   use "obj";
-   for Library_Dir  use "lib";
-
-   Version := "1";
+   Version := External ("SOVERSION", "1");
    for Library_version use "libflorist.so." & Version;
 
    type Library_Type_Type is ("relocatable", "static");
    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;
+
+   for Leading_Library_Options use External_As_List ("LDFLAGS", " ");
+   for Library_Options use External_As_List ("LIBS", " ");
+
    type Build_Type is ("Debug", "Production");
    Build : Build_Type := External ("Build", "Production");
-
    package Compiler is
-      GNAT_Flags := ("-O2", "-gnatpg");
+      --  Select -O2 in the absence of user settings.
+      Adaflags := ("-O2") & External_As_List ("ADAFLAGS", " ");
 
+      --  Let -gnatg override user settings.
+      GNAT_Flags := ("-gnatp") & Adaflags & ("-gnatg");
       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;
@@ -38,10 +43,13 @@
 
       case Build is
          when "Debug" =>
-            for Default_Switches ("Ada") use ("-O2", "-gnatwae", "-gnatyg");
+            for Default_Switches ("Ada") use ("-gnatwae", "-gnatyg") & Adaflags;
          when "Production" =>
-            for Default_Switches ("Ada") use ("-O2", "-gnatp");
+            for Default_Switches ("Ada") use ("-gnatp") & Adaflags;
       end case;
+
+      for Default_Switches ("C") use External_As_List ("CFLAGS", " ")
+        & External_As_List ("CPPFLAGS", " ");
    end Compiler;
 
 end Florist;