Skip to content

Commit 5d510ec

Browse files
committed
support: allow override of ADAFLAGS, LDFLAGS, library shared object version
1 parent c0a4bda commit 5d510ec

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

support/langkit_support.gpr

+28-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ library project Langkit_Support is
1212
Library_Kind_Param : Library_Kind_Type := external
1313
("LIBRARY_TYPE", external ("LANGKIT_SUPPORT_LIBRARY_TYPE", "static"));
1414

15+
type OS_Kind is ("windows", "unix", "osx");
16+
OS : OS_Kind := External ("LANGKIT_SUPPORT_OS", "windows");
17+
18+
Soversion := External ("LANGKIT_SUPPORT_SOVERSION", "1");
19+
20+
Adaflags := External_As_List ("ADAFLAGS", " ");
21+
Ldflags := External_As_List ("LDFLAGS", " ");
22+
1523
for Languages use ("Ada");
1624
for Source_Dirs use (".");
1725
for Object_Dir use "obj/" & Build_Mode;
@@ -70,20 +78,35 @@ library project Langkit_Support is
7078

7179
for Library_Dir use "lib/" & Library_Kind_Param & "/" & Build_Mode;
7280

81+
So_Ext := "";
82+
case OS is
83+
when "windows" => So_Ext := "dll";
84+
when "osx" => So_Ext := "dylib";
85+
when "unix" => So_Ext := "so";
86+
end case;
87+
88+
case Library_Kind_Param is
89+
when "relocatable" =>
90+
for Library_version use "lib" & project'Library_Name & "." & So_Ext
91+
& "." & Soversion;
92+
for Leading_Library_Options use Ldflags;
93+
when "static" | "static-pic" =>
94+
null;
95+
end case;
96+
7397
Common_Ada_Cargs := ("-gnatwa", "-gnatyg", "-fPIC");
7498

7599
package Compiler is
100+
Mode_Args := ();
76101
case Build_Mode is
77102
when "dev" =>
78-
for Default_Switches ("Ada") use
79-
Common_Ada_Cargs & ("-g", "-O0", "-gnatwe", "-gnata");
80-
103+
Mode_Args := ("-g", "-O0", "-gnatwe", "-gnata");
81104
when "prod" =>
82105
-- Debug information is useful even with optimization for
83106
-- profiling, for instance.
84-
for Default_Switches ("Ada") use
85-
Common_Ada_Cargs & ("-g", "-Ofast");
107+
Mode_Args := ("-g", "-Ofast");
86108
end case;
109+
for Default_Switches ("Ada") use Common_Ada_Cargs & Mode_Args & Adaflags;
87110
end Compiler;
88111

89112
end Langkit_Support;

0 commit comments

Comments
 (0)