[Pdns-users] Building pdns RPMs using custom LDAP libraries/headers

a b tripivceta at hotmail.com
Fri Mar 22 20:46:14 UTC 2013

> Thanks for your assistance.

You are welcome.

> Until now, I always use a simple:
> $ cat .rpmmacros
> %_topdir %(echo $HOME)/rpmbuild
> which has worked fine in many builds I have, and it works fine when I
> build pdns-server on CentOS 5.

This works because you are redefining the top build directory to be your own account, and because it builds the RPM linked with default libraries in /usr/lib or /usr/lib64, depending on whether one is building on a 32- or 64-bit system (and what the compilers' switches are).

> However, I see your point: I should set (in .rpmmacros) something like:
> %_libdir /usr/local/openldap/lib64

Unfortunately, no. You should configure your .rpmmacros file with at least %prefix as in the earlier example .rpmmacros file.

rpmbuild(1) will then automatically set %_libdir macro to /something/something/lib64 or /something/something/lib depending on whether one is building 32- or 64-bit.

Since the SRPM, by definition, must build without changes on both 32- and 64-bit architectures, %_libdir must not be modified directly; in order to have it correctly set to /usr/local/openldap/lib64, %MY_BASE in the earlier example would have to be set to /usr/local/openldap.

As you can see, this is not necessarily what you want in the long term, because it implies that any and all software would have to end up in /usr/local/openldap.

> Yet, my earlier question remains: Can I set multiple paths, like:
> %_libdir /usr/lib64,/usr/local/openldap/lib64
> ...? Is it supported?

As far as I am aware, no. Also, one is never supposed to pass /usr/lib, /usr/lib64, /lib, or /lib64 to the link editor. These paths are hard coded inside of the link editor binary, and providing them on the link line or anywhere else during compilation has undefined results.

> I don't see any CFLAGS or LDFLAGS specified in the spec file.

What about %_smpflags or %optflags macros, are they referenced anywhere in the .spec file?

> When I build (as an example) Dovecot, I use in the spec file (before
> ./configure):
> export CPPFLAGS="${CPPFLAGS} -I/usr/local/openldap/include"
> export LDFLAGS="${LDFLAGS} -L/usr/local/openldap/lib64 -lldap -llber"
> Should I try the same here?

You can; sometimes that works, sometime it does not. It is a hit-and-miss.

Actually, you could try the following in the .spec file; this assumes %_prefix=/usr/local/openldap in your .rpmmacros, since you wrote that you would rather not change it:

O='$$O'; export O

CPPFLAGS="${CPPFLAGS} -I%{_prefix}/include"; export CPPFLAGS
LDFLAGS="${LDFLAGS} -L%{_libdir} -R${ORIGIN}:${ORIGIN}/../%{_lib}:${ORIGIN}/../../%{_lib}:%{_libdir}"; export LDFLAGS
CFLAGS="${CFLAGS} -Wl,-L%{_libdir},-R${ORIGIN}:${ORIGIN}/../%{_lib}:${ORIGIN}/../../%{_lib}:%{_libdir}"; export CFLAGS
CXXFLAGS="${CXXFLAGS} -Wl,-L%{_libdir},-R${ORIGIN}:${ORIGIN}/../%{_lib}:${ORIGIN}/../../%{_lib}:%{_libdir}"; export CXXFLAGS

%configure ... 		 	   		  

More information about the Pdns-users mailing list