Bug 252249

Summary: Need pkgconfig file for -devel package
Product: [Retired] 389 Reporter: Rich Megginson <rmeggins>
Component: Server - PluginsAssignee: Nathan Kinder <nkinder>
Status: CLOSED CURRENTRELEASE QA Contact: Chandrasekar Kannan <ckannan>
Severity: low Docs Contact:
Priority: high    
Version: 1.1.0betaCC: amsharma, benl, jgalipea, ssorce
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-16 16:24:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 639035, 656390    
Attachments:
Description Flags
Patch
nhosoi: review+
Revised Patch
nhosoi: review+
Revised Patch nkinder: review?, rmeggins: review+

Description Rich Megginson 2007-08-14 21:41:48 UTC
One problem is that openldap will install /usr/include/slapi-plugin.h which
plugin writers will find and be confused by.  We need to provide the standard
include/lib directives for plugins to use.

Comment 5 Rich Megginson 2009-04-09 17:05:30 UTC
We should also add the sample code to the -devel package

Comment 7 Rich Megginson 2011-01-04 17:20:36 UTC
*** Bug 659776 has been marked as a duplicate of this bug. ***

Comment 8 Nathan Kinder 2011-01-21 19:13:11 UTC
Created attachment 474667 [details]
Patch

Comment 9 Rich Megginson 2011-01-21 20:09:12 UTC
ipa needs the ability to determine if slapi uses mozldap or openldap and, if so, what compiler switches to add (e.g. -DUSE_OPENLDAP=1)

Comment 10 Nathan Kinder 2011-01-21 21:57:40 UTC
(In reply to comment #9)
> ipa needs the ability to determine if slapi uses mozldap or openldap and, if
> so, what compiler switches to add (e.g. -DUSE_OPENLDAP=1)

Would it be OK to just add "-DUSE_OPENLDAP=1" to cflags if the openldap client libraries are used?

Comment 11 Rich Megginson 2011-01-21 22:09:23 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > ipa needs the ability to determine if slapi uses mozldap or openldap and, if
> > so, what compiler switches to add (e.g. -DUSE_OPENLDAP=1)
> 
> Would it be OK to just add "-DUSE_OPENLDAP=1" to cflags if the openldap client
> libraries are used?

I think so - Simo?

Comment 12 Simo Sorce 2011-01-21 22:21:50 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > ipa needs the ability to determine if slapi uses mozldap or openldap and, if
> > > so, what compiler switches to add (e.g. -DUSE_OPENLDAP=1)
> > 
> > Would it be OK to just add "-DUSE_OPENLDAP=1" to cflags if the openldap client
> > libraries are used?
> 
> I think so - Simo?

It would probably be better to return the right include path in cflags and the right libraries in lflags, this way plugin writers do not even need to do their own checks for these libs. They will just pick the pkgflags values.

Comment 13 Nathan Kinder 2011-01-21 22:46:41 UTC
One problem with simply returning the compiler include flags and linker flags is that the mozldap and openldap APIs are not 100% compatible.  I think it is better to expose a custom variable via our pkgconfig file to define which ldap library we are using.  This way a plug-in that needs to know which ldap client library was used by the server can get that information and use whatever define they want internally.  I'm thinking something like this:

    # pkg-config --variable=ldaplib dirsrv
    openldap

    OR

    # pkg-config --variable=ldaplib dirsrv
    mozldap

Comment 14 Rich Megginson 2011-01-21 22:54:05 UTC
If you need to know which sdk to use outside of C code, you would need something like that.  But I don't think it is needed.  As long as plugin writers know that they can use

#if defined(USE_OPENLDAP)
... use openldap specific api ...
#else
... use mozldap specific api ...
#endif

and as long as pkg-config --cflags dirsrv returns "... -DUSE_OPENLDAP=1 ..." I think that will suffice.

Comment 15 Nathan Kinder 2011-01-24 18:19:32 UTC
Created attachment 475007 [details]
Revised Patch

This patch is a revised version of the previous patch.  This adds "-DUSE_OPENLDAP" to cflags in addition to adding a variable named "ldaplib" to the pkg-config file that will be set to either "mozldap" or "openldap" depending on which library is used by dirsrv.

Comment 16 Rich Megginson 2011-01-24 18:48:01 UTC
Comment on attachment 475007 [details]
Revised Patch

This line is incorrect:
+Cflags: @ldaplib_defs@ -I@serverincdir@/slapi-plugin.h

Should just be the path, not the path and filename.

Comment 17 Nathan Kinder 2011-01-24 19:11:24 UTC
(In reply to comment #16)
> Comment on attachment 475007 [details]
> Revised Patch
> 
> This line is incorrect:
> +Cflags: @ldaplib_defs@ -I@serverincdir@/slapi-plugin.h
> 
> Should just be the path, not the path and filename.

Good catch.  New patch coming.

Comment 18 Nathan Kinder 2011-01-24 19:12:24 UTC
Created attachment 475025 [details]
Revised Patch

This fixes the include flag to not contain the header filename.  Thanks to Rich for catching this issue!

Comment 19 Nathan Kinder 2011-01-24 20:52:00 UTC
Pushed patch to master.  Thanks to Rich for his review!

Counting objects: 12, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 2.31 KiB, done.
Total 7 (delta 5), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   9f1160c..c9839b3  master -> master

Comment 20 Amita Sharma 2011-05-25 13:16:18 UTC
Hi Rich/Nathan,

Request you to please add the verification steps.

Thanks,
Amita

Comment 21 Nathan Kinder 2011-05-25 15:19:01 UTC
(In reply to comment #20)
> Hi Rich/Nathan,
> 
> Request you to please add the verification steps.
> 
> Thanks,
> Amita

Install the 389-ds-base-devel pacakge, then attempt to run the following command:

  pkg-config --libs dirsrv

If this returns something similar to the following, you can consider it verified:

  -L/usr/lib64/dirsrv -lslapd

Comment 22 Amita Sharma 2011-05-27 08:57:44 UTC
Installed:
  389-ds-base-devel.x86_64 0:1.2.8.2-1.el6                                                                                                                   

Dependency Installed:
  389-ds-base-libs.x86_64 0:1.2.8.2-1.el6          cyrus-sasl-devel.x86_64 0:2.1.23-8.el6           nspr-devel.x86_64 0:4.8.7-1.el6                        
  nss-devel.x86_64 0:3.12.9-9.el6                  nss-softokn-devel.x86_64 0:3.12.9-3.el6          nss-softokn-freebl-devel.x86_64 0:3.12.9-3.el6         
  nss-util-devel.x86_64 0:3.12.9-1.el6             openldap-devel.x86_64 0:2.4.23-15.el6            pkgconfig.x86_64 1:0.23-9.1.el6                        
  svrcore.x86_64 0:4.0.4-5.1.el6                   svrcore-devel.x86_64 0:4.0.4-5.1.el6            

Complete!
[root@rhel6 yum.repos.d]# pkg-config --libs dirsrv
-L/usr/lib64/dirsrv -lslapd  
[root@rhel6 yum.repos.d]# 
[root@rhel6 yum.repos.d]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.1 (Santiago)

Comment 23 Rich Megginson 2014-06-16 13:38:34 UTC
should be marked CLOSED