74ca47
From fffbb3d39a2ea12a2b3a72c729e76c1e69a19d8f Mon Sep 17 00:00:00 2001
74ca47
From: Mark Reynolds <mreynolds@redhat.com>
74ca47
Date: Mon, 27 Mar 2017 14:33:17 -0400
74ca47
Subject: [PATCH] Ticket 49177 - rpm would not create valid pkgconfig files
74ca47
74ca47
    Bug Description:  pkgconfig from the rpm was not valid.
74ca47
74ca47
    Fix Description:  Resolve an issue in the way we handle the file
74ca47
    substiution to resolve this issue.
74ca47
74ca47
    https://pagure.io/389-ds-base/issue/49177
74ca47
---
74ca47
 Makefile.am                | 10 ++--------
74ca47
 configure.ac               |  3 +++
74ca47
 m4/mozldap.m4              |  4 ++++
74ca47
 m4/openldap.m4             |  4 ++++
74ca47
 src/pkgconfig/dirsrv.pc.in |  4 ++++
74ca47
 5 files changed, 17 insertions(+), 8 deletions(-)
74ca47
74ca47
diff --git a/Makefile.am b/Makefile.am
74ca47
index 4a4b2d3..982dd28 100644
74ca47
--- a/Makefile.am
74ca47
+++ b/Makefile.am
74ca47
@@ -110,14 +110,12 @@ if OPENLDAP
74ca47
 # shared lib _fini for one will stomp on the other, and the program will crash
74ca47
 LDAPSDK_LINK_NOTHR = @openldap_lib@ -lldap@ol_libver@ @ldap_lib_ldif@ -llber@ol_libver@
74ca47
 LDAPSDK_LINK = @openldap_lib@ -lldap_r@ol_libver@ @ldap_lib_ldif@ -llber@ol_libver@
74ca47
-ldaplib = openldap
74ca47
-ldaplib_defs = -DUSE_OPENLDAP
74ca47
 else
74ca47
 LDAPSDK_LINK = @ldapsdk_lib@ -lssldap60 -lprldap60 -lldap60 -lldif60
74ca47
 LDAPSDK_LINK_NOTHR = $(LDAPSDK_LINK)
74ca47
-ldaplib = mozldap
74ca47
-ldaplib_defs =
74ca47
 endif
74ca47
+ldaplib = @ldaplib@
74ca47
+ldaplib_defs = @ldaplib_defs@
74ca47
 
74ca47
 DB_LINK = @db_lib@ -ldb-@db_libver@
74ca47
 SASL_LINK = @sasl_lib@ -lsasl2
74ca47
@@ -2237,10 +2235,6 @@ else
74ca47
 	$(fixupcmd) $^ | sed -n -e 's/@preamble@//' -e '/^#/{p;d;}' -e '/^$$/{p;d;}' -e 's/^\([^=]*\)\(=.*\)$$/\1\2 ; export \1/ ; p' > $@
74ca47
 endif
74ca47
 
74ca47
-%/$(PACKAGE_NAME).pc: %/dirsrv.pc.in
74ca47
-	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
74ca47
-	$(fixupcmd) $^ > $@
74ca47
-
74ca47
 %/$(PACKAGE_NAME)-snmp: %/ldap-agent-initscript.in
74ca47
 	if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
74ca47
 	$(fixupcmd) $^ > $@
74ca47
diff --git a/configure.ac b/configure.ac
74ca47
index 4e3e9fb..3f2aa75 100644
74ca47
--- a/configure.ac
74ca47
+++ b/configure.ac
74ca47
@@ -785,6 +785,8 @@ AC_SUBST(openldap_inc)
74ca47
 AC_SUBST(openldap_lib)
74ca47
 AC_SUBST(openldap_libdir)
74ca47
 AC_SUBST(openldap_bindir)
74ca47
+AC_SUBST(ldaplib)
74ca47
+AC_SUBST(ldaplib_defs)
74ca47
 AC_SUBST(ldaptool_bindir)
74ca47
 AC_SUBST(ldaptool_opts)
74ca47
 AC_SUBST(plainldif_opts)
74ca47
@@ -853,6 +855,7 @@ if test "$GCC" != yes ; then
74ca47
 fi
74ca47
 
74ca47
 # Build our pkgconfig files
74ca47
+# This currently conflicts with %.in: rule in Makefile.am, which should be removed eventually.
74ca47
 AC_CONFIG_FILES([src/pkgconfig/dirsrv.pc src/pkgconfig/nunc-stans.pc src/pkgconfig/libsds.pc])
74ca47
 
74ca47
 AC_CONFIG_FILES([Makefile rpm/389-ds-base.spec  ])
74ca47
diff --git a/m4/mozldap.m4 b/m4/mozldap.m4
74ca47
index 4352151..8084ed8 100644
74ca47
--- a/m4/mozldap.m4
74ca47
+++ b/m4/mozldap.m4
74ca47
@@ -15,6 +15,8 @@ AC_ARG_WITH(ldapsdk, AS_HELP_STRING([--with-ldapsdk@<:@=PATH@:>@],[Mozilla LDAP
74ca47
   if test "$withval" = yes
74ca47
   then
74ca47
     AC_MSG_RESULT(yes)
74ca47
+    ldaplib="mozldap"
74ca47
+    ldaplib_defs=""
74ca47
   elif test "$withval" = no
74ca47
   then
74ca47
     AC_MSG_RESULT(no)
74ca47
@@ -22,6 +24,8 @@ AC_ARG_WITH(ldapsdk, AS_HELP_STRING([--with-ldapsdk@<:@=PATH@:>@],[Mozilla LDAP
74ca47
   then
74ca47
     AC_MSG_RESULT([using $withval])
74ca47
     LDAPSDKDIR=$withval
74ca47
+    ldaplib="mozldap"
74ca47
+    ldaplib_defs=""
74ca47
     ldapsdk_inc="-I$LDAPSDKDIR/include"
74ca47
     ldapsdk_lib="-L$LDAPSDKDIR/lib"
74ca47
     ldapsdk_libdir="$LDAPSDKDIR/lib"
74ca47
diff --git a/m4/openldap.m4 b/m4/openldap.m4
74ca47
index 417bf43..f45637c 100644
74ca47
--- a/m4/openldap.m4
74ca47
+++ b/m4/openldap.m4
74ca47
@@ -15,6 +15,8 @@ AC_ARG_WITH(openldap, AS_HELP_STRING([--with-openldap@<:@=PATH@:>@],[Use OpenLDA
74ca47
   if test "$withval" = yes
74ca47
   then
74ca47
     AC_MSG_RESULT([using system OpenLDAP])
74ca47
+    ldaplib="openldap"
74ca47
+    ldaplib_defs="-DUSE_OPENLDAP"
74ca47
   elif test "$withval" = no
74ca47
   then
74ca47
     AC_MSG_RESULT(no)
74ca47
@@ -22,6 +24,8 @@ AC_ARG_WITH(openldap, AS_HELP_STRING([--with-openldap@<:@=PATH@:>@],[Use OpenLDA
74ca47
   then
74ca47
     AC_MSG_RESULT([using $withval])
74ca47
     OPENLDAPDIR=$withval
74ca47
+    ldaplib="openldap"
74ca47
+    ldaplib_defs="-DUSE_OPENLDAP"
74ca47
     openldap_incdir="$OPENLDAPDIR/include"
74ca47
     openldap_inc="-I$openldap_incdir"
74ca47
     openldap_lib="-L$OPENLDAPDIR/lib"
74ca47
diff --git a/src/pkgconfig/dirsrv.pc.in b/src/pkgconfig/dirsrv.pc.in
74ca47
index 4140031..df433cf 100644
74ca47
--- a/src/pkgconfig/dirsrv.pc.in
74ca47
+++ b/src/pkgconfig/dirsrv.pc.in
74ca47
@@ -1,3 +1,7 @@
74ca47
+prefix=@prefix@
74ca47
+exec_prefix=@exec_prefix@
74ca47
+libdir=@libdir@
74ca47
+includedir=@includedir@
74ca47
 ldaplib=@ldaplib@
74ca47
 
74ca47
 Name: dirsrv
74ca47
-- 
74ca47
2.9.3
74ca47