From: Reto Buerki <reet@codelabs.ch>
Date: Mon, 26 Mar 2012 18:24:21 +0200
Subject: Build dynamic/static libs in separate Obj/Lib dirs

This avoids position-independent code (PIC) in the static libraries.

Closes: #663672

Conflicts:

	Makefile
---
 Makefile               |   14 ++++++++------
 d_bus_ada_common.gpr   |    5 ++++-
 d_bus_ada_lib.gpr      |    8 ++++----
 d_bus_ada_lib_thin.gpr |    8 ++++----
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index d7033a3..602d2a2 100644
--- a/Makefile
+++ b/Makefile
@@ -44,17 +44,19 @@ install_lib: build_lib
 	install -d $(PREFIX)/lib/gnat
 	install -m 644 $(SRCDIR)/*.ad[bs] $(PREFIX)/include/dbus-ada
 	install -m 644 $(THINDIR)/*.ad[bs] $(PREFIX)/include/dbus-ada/thin
-	install -m 444 $(LIBDIR)/*.ali $(PREFIX)/lib/dbus-ada
-	install -m 444 $(LIBDIR)/thin/*.ali $(PREFIX)/lib/dbus-ada/thin
+	install -m 444 $(LIBDIR)/$(LIBRARY_KIND)/*.ali $(PREFIX)/lib/dbus-ada
+	install -m 444 $(LIBDIR)/thin/$(LIBRARY_KIND)/*.ali \
+		$(PREFIX)/lib/dbus-ada/thin
 	install -m 644 $(GPR_FILES) $(PREFIX)/lib/gnat
 
 install_static:
-	install -m 444 $(LIBDIR)/libdbusada.a $(PREFIX)/lib/dbus-ada
-	install -m 444 $(LIBDIR)/thin/libdbusada-thin.a $(PREFIX)/lib/dbus-ada/thin
+	install -m 444 $(LIBDIR)/$(LIBRARY_KIND)/libdbusada.a $(PREFIX)/lib/dbus-ada
+	install -m 444 $(LIBDIR)/thin/$(LIBRARY_KIND)/libdbusada-thin.a $(PREFIX)/lib/dbus-ada/thin
 
 install_dynamic:
-	install -m 444 $(LIBDIR)/$(SO_LIBRARY) $(PREFIX)/lib/dbus-ada
-	install -m 444 $(LIBDIR)/thin/$(SO_LIBRARY_THIN) $(PREFIX)/lib/dbus-ada/thin
+	install -m 444 $(LIBDIR)/$(LIBRARY_KIND)/$(SO_LIBRARY) $(PREFIX)/lib/dbus-ada
+	install -m 444 $(LIBDIR)/thin/$(LIBRARY_KIND)/$(SO_LIBRARY_THIN) \
+		$(PREFIX)/lib/dbus-ada/thin
 	cd $(PREFIX)/lib/dbus-ada && \
 	ln -sf $(SO_LIBRARY) libdbusada.so && \
 	ln -sf $(SO_LIBRARY) libdbusada.so.$(MAJOR)
diff --git a/d_bus_ada_common.gpr b/d_bus_ada_common.gpr
index 21ac3e1..b6f8a21 100644
--- a/d_bus_ada_common.gpr
+++ b/d_bus_ada_common.gpr
@@ -1,7 +1,7 @@
 --
 --  D_Bus/Ada - An Ada binding to D-Bus
 --
---  Copyright (C) 2011  Reto Buerki <reet@codelabs.ch>
+--  Copyright (C) 2011, 2012  Reto Buerki <reet@codelabs.ch>
 --
 --  This program is free software; you can redistribute it and/or
 --  modify it under the terms of the GNU General Public License
@@ -32,6 +32,9 @@ project D_Bus_Ada_Common is
 
    Version := external ("VERSION", "unknown");
 
+   type Lib_Type is ("static", "dynamic");
+   Libtype : Lib_Type := external ("LIBRARY_KIND", "static");
+
    Compiler_Switches := ("-gnatygAdISuxo",
                          "-gnatVa",
                          "-gnat05",
diff --git a/d_bus_ada_lib.gpr b/d_bus_ada_lib.gpr
index 8f82f1e..317db91 100644
--- a/d_bus_ada_lib.gpr
+++ b/d_bus_ada_lib.gpr
@@ -1,7 +1,7 @@
 --
 --  D_Bus/Ada - An Ada binding to D-Bus
 --
---  Copyright (C) 2011  Reto Buerki <reet@codelabs.ch>
+--  Copyright (C) 2011, 2012  Reto Buerki <reet@codelabs.ch>
 --
 --  This program is free software; you can redistribute it and/or
 --  modify it under the terms of the GNU General Public License
@@ -32,10 +32,10 @@ with "d_bus_ada_lib_thin";
 project D_Bus_Ada_Lib is
 
    for Source_Dirs use ("src");
-   for Object_Dir use "obj/lib";
+   for Object_Dir use "obj/lib/" & D_Bus_Ada_Common.Libtype;
    for Library_Name use "dbusada";
-   for Library_Dir use "lib";
-   for Library_Kind use external ("LIBRARY_KIND", "dynamic");
+   for Library_Dir use "lib/" & D_Bus_Ada_Common.Libtype;
+   for Library_Kind use D_Bus_Ada_Common.Libtype;
    for Library_Version use "libdbusada.so." & D_Bus_Ada_Common.Version;
    for Library_Options use D_Bus_Ada_Common.Linker_Switches;
 
diff --git a/d_bus_ada_lib_thin.gpr b/d_bus_ada_lib_thin.gpr
index 7198b73..8d4aed5 100644
--- a/d_bus_ada_lib_thin.gpr
+++ b/d_bus_ada_lib_thin.gpr
@@ -1,7 +1,7 @@
 --
 --  D_Bus/Ada - An Ada binding to D-Bus
 --
---  Copyright (C) 2011  Reto Buerki <reet@codelabs.ch>
+--  Copyright (C) 2011, 2012  Reto Buerki <reet@codelabs.ch>
 --
 --  This program is free software; you can redistribute it and/or
 --  modify it under the terms of the GNU General Public License
@@ -31,10 +31,10 @@ with "d_bus_ada_common";
 project D_Bus_Ada_Lib_Thin is
 
    for Source_Dirs use ("thin");
-   for Object_Dir use "obj/thin";
+   for Object_Dir use "obj/thin/" & D_Bus_Ada_Common.Libtype;
    for Library_Name use "dbusada-thin";
-   for Library_Dir use "lib/thin";
-   for Library_Kind use external ("LIBRARY_KIND", "dynamic");
+   for Library_Dir use "lib/thin/" & D_Bus_Ada_Common.Libtype;
+   for Library_Kind use D_Bus_Ada_Common.Libtype;
    for Library_Version use "libdbusada-thin.so." & D_Bus_Ada_Common.Version;
 
    Compiler_Switches := ("-gnat05",
