Discussion:
Variable expansin in AC_PREFIX_DEFAULT
Joakim Jalap
2017-03-22 08:20:01 UTC
Permalink
Hello autoconf gurus!

I am trying to write some autotools support for installing a latex
package. On CTAN I found some autoconf macros (which I had to modify a
bit) which I use to find for example latex(1) and pdflatex(1). So far so
good. This CTAN package also has a macro to find the path to the tex
installation, AC_TEXMF_PATH. This finds the correct path for me at
/usr/share/texmf-dist. Now I want to put this as the default prefix so
that configure will "do the right thing" by default, but this is where I
fail.

This is my configure.ac:
----------------------------------------
AC_INIT([package], [0.1], [blah])
AC_PREREQ([2.60])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])

AC_PROG_INSTALL
AC_PROG_LATEX
AC_PROG_KPSEWHICH
AC_PROG_PDFLATEX
AC_TEXMF_PATH

AC_PREFIX_DEFAULT([$texmfpath])
AC_MSG_NOTICE([$texmfpath])

AC_CONFIG_FILES(Makefile)
AC_OUTPUT
----------------------------------------
AC_TEXMF_PATH exports `texmfpath' and does AC_SUBST on it. (You can find
all the macros here: https://www.ctan.org/tex-archive/support/autoconf)

The problem is with the AC_PREFIX_DEFAULT. It sets the default prefix to
empty. But the AC_MSG_NOTICE macro on the line below prints the correct
path! So somehow $texmfpath is expanded to the correct value by
AC_MSG_NOTICE, but it is expanded to nothing on the line above. If I do
AC_PREFIX_DEFAULT(["some_path"]) then the default prefix is correctly
set to "some_path".

Is it not possible to set the default prefix in this way? What other
good ways are there to set the default prefix to something discovered at
configure time?

I'm not subscribed to the list so if somebody answers, please keep me on
cc :)

Regards,

Joakim
Eric Blake
2017-03-22 13:38:42 UTC
Permalink
Post by Joakim Jalap
Hello autoconf gurus!
I am trying to write some autotools support for installing a latex
package. On CTAN I found some autoconf macros (which I had to modify a
bit) which I use to find for example latex(1) and pdflatex(1). So far so
good. This CTAN package also has a macro to find the path to the tex
installation, AC_TEXMF_PATH. This finds the correct path for me at
It's poor practice to name a macro in the AC_ namespace if it is not
actually owned by autoconf; you may want to choose a different namespace
to make it obvious where the macro originates from.
Post by Joakim Jalap
/usr/share/texmf-dist. Now I want to put this as the default prefix so
that configure will "do the right thing" by default, but this is where I
fail.
----------------------------------------
AC_INIT([package], [0.1], [blah])
AC_PREREQ([2.60])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_INSTALL
AC_PROG_LATEX
AC_PROG_KPSEWHICH
AC_PROG_PDFLATEX
AC_TEXMF_PATH
AC_PREFIX_DEFAULT([$texmfpath])
AC_MSG_NOTICE([$texmfpath])
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
----------------------------------------
AC_TEXMF_PATH exports `texmfpath' and does AC_SUBST on it. (You can find
all the macros here: https://www.ctan.org/tex-archive/support/autoconf)
The problem is with the AC_PREFIX_DEFAULT. It sets the default prefix to
empty. But the AC_MSG_NOTICE macro on the line below prints the correct
path! So somehow $texmfpath is expanded to the correct value by
AC_MSG_NOTICE, but it is expanded to nothing on the line above. If I do
AC_PREFIX_DEFAULT(["some_path"]) then the default prefix is correctly
set to "some_path".
Indeed, thanks to the magic of m4 diversions, AC_PREFIX_DEFAULT expands
to code that appears very early in configure, and using a shell variable
that early in the run is tricky; while AC_MSG_NOTICE expands to code
that runs at the place where the macro was used.
Post by Joakim Jalap
Is it not possible to set the default prefix in this way? What other
good ways are there to set the default prefix to something discovered at
configure time?
Is AC_PREFIX_PROGRAM any better for your use case?
Post by Joakim Jalap
I'm not subscribed to the list so if somebody answers, please keep me on
cc :)
That's GNU list policy anyways.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Joakim Jalap
2017-03-22 15:54:56 UTC
Permalink
Post by Eric Blake
Post by Joakim Jalap
Hello autoconf gurus!
I am trying to write some autotools support for installing a latex
package. On CTAN I found some autoconf macros (which I had to modify a
bit) which I use to find for example latex(1) and pdflatex(1). So far so
good. This CTAN package also has a macro to find the path to the tex
installation, AC_TEXMF_PATH. This finds the correct path for me at
It's poor practice to name a macro in the AC_ namespace if it is not
actually owned by autoconf; you may want to choose a different namespace
to make it obvious where the macro originates from.
Well I didn't choose it. That's the way it was in CTAN. But point taken.
Post by Eric Blake
Indeed, thanks to the magic of m4 diversions, AC_PREFIX_DEFAULT expands
to code that appears very early in configure, and using a shell variable
that early in the run is tricky; while AC_MSG_NOTICE expands to code
that runs at the place where the macro was used.
Well that's a shame. But I found another way anyway. See below.
Post by Eric Blake
Is AC_PREFIX_PROGRAM any better for your use case?
Not really. I'm not installing any programs, only data. But I found a
solution: I can use the 'kpsewhich' program to find the correct texmf
directory. So now I do

AC_PREFIX_DEFAULT([`pksewhich --var-value TEXMFHOME`])

and it works!

Thanks for your time!

-- Joakim

Loading...