[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best practice for user decided unusual library paths ?

From: Johan Persson
Subject: Best practice for user decided unusual library paths ?
Date: Mon, 10 Jan 2011 22:05:46 +0100
User-agent: RoundCube Webmail/0.2

I have a package which uses a specific library that most user have
installed in the "usual" places so this works fine. 

However after having reports that some user have the library in
not-so-common places (like /opt/local) i decided to add a "--with-package"
switch so the user can add the root-directory for this alternative place.
However, I believe that my solution (while it works) is very "ugly" and
there must be a "best practice" for how to do this in a "proper" way.

What I did was adding the extra flag and some variables for use with
automake in (in this case the library was as in
(ignore the non-formatted help text)

    [--with-libpcre   Specify parent directory for the PCRE library and

if test ! -z ${with_libpcre}; then
header file for PCRE library])
    AM_CONDITIONAL(need_pcrelib_special, test 1 = 1 )
    AM_CONDITIONAL(need_pcrelib_special, test 1 = 0 )

I added the defines above to be able to include the correct header in the
source files as in:

#include <pcre.h>

and then some automake conditionals to be able to add a test in my template

if need_pcrelib_special
myprogram_LDADD += ${PCRELIB}

This looks pretty ugly to me and I can't help thinking there must be a
cleaner way to do this? 
How do others solve this particular issue? (it must be a fairly common
thing to want to do, I guess)

(Two things I particularly don't like are the fact that the library is
hard coded to the *.so name and the #include handling.)

A point to notice here might be that I don't want to add a generic -I and
-L flags to the compiler options so it searches in the extra directory
since the user may have generic version of the library in the normal places
so those places should never be searched. 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]