[Top][All Lists]

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

Re: Best & most portable way to add *paths to headers* & *libraries*???

From: Alexandre Duret-Lutz
Subject: Re: Best & most portable way to add *paths to headers* & *libraries*???
Date: Sat, 19 Apr 2003 00:39:54 +0200
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 (gnu/linux)

>>>   <address@hidden> writes:

 > If I want to add some /paths to include files/,
 > I should just add my -I's to with
 > this line right??...

 > INCLUDES=-I/path1 -I/path2 -I/path3

`automake -Wall' will tell you to prefer AM_CPPFLAGS

It's also more portable to put a space between each -I and its argument.

 > If I want to link with some /libraries/,
 > I should just add my -l's to with
 > this line right?

 > myprogram_LDADD=-lsomelib1 -lsomeotherlib2 -lsomelibagain3

 > My main question is this.... For portability, one would
 > eventually want to check for *existence* of these
 > files and their *location*.  This implies I would
 > have to replace my hardwired stuff above with
 > *variables* I suppose....

 > If I do such checks in Autoconf in the future, will
 > it make necessary changes to Makefile by itself???
 > i.e. will I still need a line in with
 > some variable still???

AC_CHECK_LIB and friends will automatically prepend found
libraries to the LIBS variable, which is used when linking *all*
programs.  You don't have to do anything in your for
this to work.

However, sometimes you don't want to link all found libraries with
all programs.  One way to do that is to use the ACTION-IF-FOUND
argument of AC_CHECK_LIB do define a variable, then AC_SUBST
this variable to make it available to the Makefile, and use
it in

AC_CHECK_LIB([foo], [fun], [LIBFOO="-lfoo"])

yourprogram_LDADD = $(LIBFOO)

The same applies to -L and -I settings.
Alexandre Duret-Lutz

reply via email to

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