From c6ec000582a049526e1c23b115abe5c1beab066b Mon Sep 17 00:00:00 2001
From: Kirill Smelkov <kirr@nexedi.com>
Date: Wed, 28 Oct 2015 12:12:29 +0300
Subject: [PATCH] component/postgresql: Factor out common build stuff to
 postgresql-common

Currently we have recipes to build both postgresql 9.1 and 9.2 (see
9f1f0759 "provide both postgres 9.1 and 9.2") which mostly duplicate
each other with minor difference that 9.1 is built with perl and 9.2
without (perl added to 9.1 in dbbd9a96 "Include Perl in Postgres").

To reduce the duplication let's move common compilation bits to common
section.

NOTE I've tried to add perl to postgresql 9.2 as well and got the
following compilation error:

    ld: .../perl/libs-c/libperl.a(op.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    .../parts/perl/libs-c/libperl.a: could not read symbols: Bad value

which happens because libperl.a is not compiled with fPIC.

For now we don't need perl in postgresql92 and this is not handled, and
we just deduplicate building recipes without any actual change for
resulting commands how the software is built.
---
 component/postgresql/buildout.cfg | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/component/postgresql/buildout.cfg b/component/postgresql/buildout.cfg
index 2362001d6..cfacc686c 100644
--- a/component/postgresql/buildout.cfg
+++ b/component/postgresql/buildout.cfg
@@ -12,21 +12,26 @@ parts = postgresql
 <= postgresql92
 
 
-[postgresql91]
+[postgresql-common]
 recipe = slapos.recipe.cmmi
-url = http://ftp.postgresql.org/pub/source/v9.1.13/postgresql-9.1.13.tar.bz2
-md5sum = f50e201b4ef7e0581bf32a1a32c9f14c
-configure-options = --with-openssl --with-perl
+configure-options = --with-openssl
 environment =
   CPPFLAGS=-I${zlib:location}/include -I${readline:location}/include -I${openssl:location}/include -I${ncurses:location}/lib
   LDFLAGS=-L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib -L${readline:location}/lib -Wl,-rpath=${readline:location}/lib -L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -L${ncurses:location}/lib -Wl,-rpath=${ncurses:location}/lib -L${perl:location}/libs-c -Wl,-rpath=${perl:location}/libs-c
 
 
+[postgresql91]
+<= postgresql-common
+url = http://ftp.postgresql.org/pub/source/v9.1.13/postgresql-9.1.13.tar.bz2
+md5sum = f50e201b4ef7e0581bf32a1a32c9f14c
+configure-options += --with-perl
+
+
 [postgresql92]
-recipe = slapos.recipe.cmmi
+<= postgresql-common
 url = http://ftp.postgresql.org/pub/source/v9.2.8/postgresql-9.2.8.tar.bz2
 md5sum = c5c65a9b45ee53ead0b659be21ca1b97
-configure-options = --with-openssl
-environment =
-  CPPFLAGS=-I${zlib:location}/include -I${readline:location}/include -I${openssl:location}/include -I${ncurses:location}/lib
-  LDFLAGS=-L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib -L${readline:location}/lib -Wl,-rpath=${readline:location}/lib -L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -L${ncurses:location}/lib -Wl,-rpath=${ncurses:location}/lib -L${perl:location}/libs-c -Wl,-rpath=${perl:location}/libs-c
+# ld: .../perl/libs-c/libperl.a(op.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
+# .../parts/perl/libs-c/libperl.a: could not read symbols: Bad value
+# (because libperl.a is not compiled with fPIC)
+# -> no --with-perl
-- 
2.30.9