CLISP's interface to PARI is configured with the configure.in
containing AC_LIB_LINKFLAGS([pari])
from lib-link.m4
.
The build process also requires the Makefile
to know where the datadir
of PARI
is located. To this end, Makefile.in
has
prefix = @LIBPARI_PREFIX@
DATADIR = @datadir@
and expects to find $(DATADIR)/pari/pari.desc
(normally
/usr/share/pari/pari.desc
or /usr/local/share/pari/pari.desc
).
This seems to work on Mac OS X where PARI
is installed by homebrew in /usr/local
(and LIBPARI_PREFIX=/usr/local
), but not on Ubuntu, where PARI
is in /usr
, and LIBPARI_PREFIX
is empty.
How do I insert the location of the PARI
's datadir
into the Makefile
?
PS. I also asked this on the autoconf mailing list.
PPS. In response to @BrunoHaible's suggestion, here is the meager attempt at debugging on Linux (where LIBPARI_PREFIX
is empty).
$ bash -x configure 2>&1 | grep found_dir
+ found_dir=
+ eval ac_val=$found_dir
+ eval ac_val=$found_dir
You are trying to use
$(prefix)
in an unintended way. In an Autotools-based build system, the$(prefix)
represents a prefix to the target installation location of the software you're building. By setting it in yourMakefile.in
, you are overriding the prefix thatconfigure
will try to assign. However, since you appear not to have any installation targets anyway, at least at that level, that's probably more an issue of poor form than a cause for malfunction.I'd recommend computing or discovering the needed directory in your configure script, and exporting it to the generated Makefile via its own output variable. Let's take the second part first, since it's simple. In
configure.in
, having in some manner located the wanted data directory and assigned it to a variable, you would make an output variable of that via the
AC_SUBST
macro:Since you are using only Autoconf, not Automake, you would then manually receive that into your Makefile by changing the assignment in your
Makefile.in
:Now, as for locating the data directory in the first place, you have to know what you're trying to implement before you can implement it. From your question and followup comments, it seems to me that you want this:
Use a data directory explicitly specified by the user if there is one. Otherwise,
look for a data directory relative to the location of the shared library. If it's not found there then
(optional) look under the
prefix
specified toconfigure
, or specifically in the specified datadir (both of which may come from the top-levelconfigure
). Finally, if it still has not been found thenlook in some standard locations.
To create a
configure
option by which the user can specify a custom data directory, you would probably use theAC_ARG_WITH
macro, maybe like this:Thanks to @BrunoHaible, we see that although the Gnulib manual does not document it, the macro's internal documentation specifies that if
AC_LIB_LINKFLAGS
locates libpari then it will setLIBPARI_PREFIX
to the library directory prefix. You find that that does work when the--with-libpari
option is used to give it an alternative location to search, so I suggest working with that. You certainly can try to debugAC_LIB_LINKFLAGS
to make it setLIBPARI_PREFIX
in all cases in which the lib is found, but if you don't want to go to that effort then you can work around it (see below).Although the default or specified installation prefix is accessible in
configure
as$prefix
, I would suggest instead going to the specified$datadir
. That is slightly tricky, however, because by default it refers to the prefix indirectly. Thus, you might do this:Finally, you might hardcode a set of prefixes such as
/usr
and/usr/local
.Following on from all the foregoing, then, your
configure.in
might do something like this: