Package: libxmlezout / 1.06.1-12

adapt_makefile.patch Patch series | 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
Description: allow Makefile user to override some settings
 Allow user to select:
 - gprbuild instead of gnatmake, which is dropping project support
 - additional options for gprbuild, the compiler, the linker
 - the SO name of the shared library
Author:Xavier Grave <xavier.grave@csnsm.in2p3.fr>
Author: Nicolas Boulenguez <nicolas@debian.org>

--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,27 +1,30 @@
 CPUS := $(shell getconf _NPROCESSORS_ONLN)
 INSTALL := $(HOME)
+BUILDER                        := gnatmake
+BUILDER_OPTIONS                :=
+ADAFLAGS                       :=
+LDFLAGS                        :=
+SONAME                         := libxmlezout.so
 
-all:shared_library static_library
+all: dynamic_library static_library
 
-.PHONY:shared_library static_library
-shared_library:
-	gnatmake -p -j$(CPUS) -Pbuild_xmlezout_lib.gpr \
-        -XLIBRARY_KIND=dynamic -XSONAME=libxmlezout.so -XOBJ_DIR=obj-shared
+.PHONY: all dynamic_library static_library clean install
 
-static_library:
-	gnatmake -p -j$(CPUS) -Pbuild_xmlezout_lib.gpr \
-        -XLIBRARY_KIND=static -XOBJ_DIR=obj-static
+dynamic_library static_library: %_library:
+	$(BUILDER) -p -j$(CPUS) $(BUILDER_OPTIONS) -Pbuild_xmlezout_lib.gpr \
+	  -XLIBRARY_KIND=$* \
+	  $(foreach v,ADAFLAGS LDFLAGS SONAME,"-X$(v)=$($(v))")
 
 clean:
-	rm -Rf obj-shared obj-static lib
+	rm -fr obj-dynamic obj-static lib
 	rm -f *~
 
 install:all
 	mkdir -p $(INSTALL)/lib/xmlezout
 	mkdir -p $(INSTALL)/include/xmlezout
 	cp -f xmlezout.gpr $(INSTALL)/include/xmlezout.gpr
-	cp -f lib/libxmlezout.a lib/libxmlezout.so $(INSTALL)/lib/xmlezout/
-	cd $(INSTALL)/lib;ln -s xmlezout/libxmlezout.so;cd -
+	cp -f lib/libxmlezout.a lib/$(SONAME) $(INSTALL)/lib/xmlezout/
+	cd $(INSTALL)/lib;ln -s xmlezout/$(SONAME);cd -
 	cp -f obj-shared/*.ali $(INSTALL)/lib/xmlezout/
 	chmod uog-w $(INSTALL)/lib/xmlezout/*.ali
 	cp -f mckae*.ad[sb] $(INSTALL)/include/xmlezout
--- a/build_xmlezout_lib.gpr
+++ b/build_xmlezout_lib.gpr
@@ -1,13 +1,28 @@
-project build_xmlezout_lib is
+library project build_xmlezout_lib is
+
+   type Library_Kind is ("dynamic", "static");
+   Kind : Library_Kind := External ("LIBRARY_KIND");
+
+   Adaflags := External_As_List ("ADAFLAGS", " ");
+   Ldflags  := External_As_List ("LDFLAGS", " ");
+   Soname   := External ("SONAME");
+
    for Library_Name use "xmlezout";
-   for Library_Kind use External ("LIBRARY_KIND");
+   for Library_Kind use Kind;
    for Library_Dir use "lib";
-   for Library_ALI_Dir use External ("OBJ_DIR") & "/ali";
-   for Library_Version use External ("SONAME");
-   for Object_Dir use External ("OBJ_DIR");
+   for Object_Dir use "obj-" & Kind;
+   for Library_ALI_Dir use Project'Object_dir & "/ali";
    for Source_Dirs use (".");
    for Excluded_Source_Files use ("tmeztf.adb");
 
+   case Kind is
+      when "dynamic" =>
+         for Library_Version use Soname;
+         for Leading_Library_Options use Ldflags;
+      when "static" =>
+         null;
+   end case;
+
    package Compiler is
       for Default_Switches ("Ada") use
         ("-gnat05",  --  Ada 2005 mode
@@ -15,7 +30,8 @@
          "-gnatf",   --  Full compiler error messages
          "-gnaty",   --  Enable style checks
          "-gnatwa",  --  Enable all warnings
-         "-gnatwe"); --  Warning as errors
+         "-gnatwe")  --  Warning as errors
+        & Adaflags;
    end Compiler;
 
    package Binder is