Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I configure Autotools files for libexec installs?

375 views
Skip to first unread message

Lew Pitcher

unread,
May 31, 2015, 12:51:00 PM5/31/15
to
I have a home-grown app that I'd like to package up with GNU autotools
(automake/autoconf/libtool).

My specific dilemma is that I have a number of shell scripts that the app
invokes, and I'd like these scripts to end up installed in the
<prefix>/libexec/<project> directory.

I've read through the documentation on each command, the "Autotools book", and
the config files from various example (both real and contrived)
installations. From what I can find out, my target directory is named by the
autotools @libexecdir@ (for <prefix>/libexec) or (possibly) the @pkglibexec@
variable.

What I want to do is write my Makefile.in (or Makefile.am) to invoke the GNU
install program, so that the ultimate Makefile will "install" the scripts in
the appropriate directory

For instance, given a package libexec directory path
of /usr/local/libexec/mypackage, my final Makefile should look something like

install: example.exit
echo install -o root -g bin -m 755 -d /usr/local/libexec/mypackage
echo install -o root -g bin -m 755 -t /usr/local/libexec/mypackage $?

I have tried all sorts of solutions, primarily focussing on the relevant
Makefile.in (after I abandoned automake and Makefile.am as being so poorly
documented as to be unusable in this situation). Various attempts have looked
like

INSTALLDIR = ${exec_prefix}/libexec

install: example.exit
echo install -o root -g bin -m 755 -d ${INSTALLDIR}/mypackage
echo install -o root -g bin -m 755 -t ${INSTALLDIR}/mypackage $?

and

INSTALLDIR = @libexec@

install: example.exit
echo install -o root -g bin -m 755 -d ${INSTALLDIR}/mypackage
echo install -o root -g bin -m 755 -t ${INSTALLDIR}/mypackage $?
and

install: example.exit
echo install -o root -g bin -m 755 -d @libexec@/mypackage
echo install -o root -g bin -m 755 -t @libexec@/mypackage $?

but none have resulted in a Makefile that would actually install the file into
the intended directory. Usually the @libexec@ just expands into a
literal '${exec_prefix}/libexec' path, without expanding the ${exec_prefix}.
Even the explicit '${exec_prefix}/libexec' just "expands"
into '${prefix}/libexec', still leaving the path unusable.

Do I actually have to hand-expand the @libexec@ path manually in my Makefile,
or is there some way to get autoconf to process my Makefile.in to properly
and *completely* expand the variable when generating the target Makefile?

Any advice?
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

Lew Pitcher

unread,
May 31, 2015, 12:55:03 PM5/31/15
to
On Sunday May 31 2015 12:50, in comp.os.linux.development.apps, "Lew Pitcher"
<lew.p...@digitalfreehold.ca> wrote:

> I have a home-grown app that I'd like to package up with GNU autotools
> (automake/autoconf/libtool).
>
> My specific dilemma is that I have a number of shell scripts that the app
> invokes, and I'd like these scripts to end up installed in the
> <prefix>/libexec/<project> directory.
>
> I've read through the documentation on each command, the "Autotools book",
> and the config files from various example (both real and contrived)
> installations. From what I can find out, my target directory is named by the
> autotools @libexecdir@ (for <prefix>/libexec) or (possibly) the @pkglibexec@
> variable.
>
> What I want to do is write my Makefile.in (or Makefile.am) to invoke the GNU
> install program, so that the ultimate Makefile will "install" the scripts in
> the appropriate directory
>
> For instance, given a package libexec directory path
> of /usr/local/libexec/mypackage, my final Makefile should look something
> like

Please ignore the <echo> values; that's left over from my last round of
debugging

> install: example.exit
> echo install -o root -g bin -m 755 -d /usr/local/libexec/mypackage
> echo install -o root -g bin -m 755 -t /usr/local/libexec/mypackage
> $?

Please read the above as

install: example.exit
install -o root -g bin -m 755 -d /usr/local/libexec/mypackage
install -o root -g bin -m 755 -t /usr/local/libexec/mypackage
$?

> I have tried all sorts of solutions, primarily focussing on the relevant
> Makefile.in (after I abandoned automake and Makefile.am as being so poorly
> documented as to be unusable in this situation). Various attempts have
> looked like

Similarly, the echo's are leftovers from prior debugging attempts

> INSTALLDIR = ${exec_prefix}/libexec
>
> install: example.exit
> echo install -o root -g bin -m 755 -d ${INSTALLDIR}/mypackage
> echo install -o root -g bin -m 755 -t ${INSTALLDIR}/mypackage $?

Please read as
INSTALLDIR = ${exec_prefix}/libexec

install: example.exit
install -o root -g bin -m 755 -d ${INSTALLDIR}/mypackage
install -o root -g bin -m 755 -t ${INSTALLDIR}/mypackage $?

> and
>
> INSTALLDIR = @libexec@
>
> install: example.exit
> echo install -o root -g bin -m 755 -d ${INSTALLDIR}/mypackage
> echo install -o root -g bin -m 755 -t ${INSTALLDIR}/mypackage $?

Please read as
INSTALLDIR = @libexec@

install: example.exit
install -o root -g bin -m 755 -d ${INSTALLDIR}/mypackage
install -o root -g bin -m 755 -t ${INSTALLDIR}/mypackage $?

> and
>
> install: example.exit
> echo install -o root -g bin -m 755 -d @libexec@/mypackage
> echo install -o root -g bin -m 755 -t @libexec@/mypackage $?

Please read as
install: example.exit
install -o root -g bin -m 755 -d @libexec@/mypackage

Lew Pitcher

unread,
May 31, 2015, 1:12:11 PM5/31/15
to
On Sunday May 31 2015 12:55, in comp.os.linux.development.apps, "Lew Pitcher"
<lew.p...@digitalfreehold.ca> wrote:

> On Sunday May 31 2015 12:50, in comp.os.linux.development.apps, "Lew
> Pitcher" <lew.p...@digitalfreehold.ca> wrote:
>
>> I have a home-grown app that I'd like to package up with GNU autotools
>> (automake/autoconf/libtool).
>>
>> My specific dilemma is that I have a number of shell scripts that the app
>> invokes, and I'd like these scripts to end up installed in the
>> <prefix>/libexec/<project> directory.
>>
>> I've read through the documentation on each command, the "Autotools book",
>> and the config files from various example (both real and contrived)
>> installations. From what I can find out, my target directory is named by
>> the autotools @libexecdir@ (for <prefix>/libexec) or (possibly) the
>> @pkglibexec@ variable.
>>
>> What I want to do is write my Makefile.in (or Makefile.am) to invoke the
>> GNU install program, so that the ultimate Makefile will "install" the
>> scripts in the appropriate directory
[snip]
>> Do I actually have to hand-expand the @libexec@ path manually in my
>> Makefile, or is there some way to get autoconf to process my Makefile.in to
>> properly and *completely* expand the variable when generating the target
>> Makefile?
>>
>> Any advice?

Here's the relevant part of the Makefile.in from my last test run, where I try
a number of variations, all in one makefile:

install: example.exit
echo install -o root -g bin -m 755 -d @libexecdir@/rmonitor
echo install -o root -g bin -m 755 -t @libexecdir@/rmonitor $?
echo install -o root -g bin -m 755 -d @prefix@/libexec/rmonitor
echo install -o root -g bin -m 755 -t @prefix@/libexec/rmonitor $?
echo
echo install -o root -g bin -m 755 -d ${libexecdir}/rmonitor
echo install -o root -g bin -m 755 -t ${libexecdir}/rmonitor $?
echo install -o root -g bin -m 755 -d ${exec_prefix}/libexec/rmonitor
echo install -o root -g bin -m 755 -t ${exec_prefix}/rmonitor $?
echo install -o root -g bin -m 755 -d ${prefix}/libexec/rmonitor
echo install -o root -g bin -m 755 -t ${prefix}/rmonitor $?


and, here's the resulting Makefile, after ./configure (defaulting all options)

install: example.exit
echo install -o root -g bin -m 755 -d ${exec_prefix}/libexec/rmonitor
echo install -o root -g bin -m 755 -t ${exec_prefix}/libexec/rmonitor $?
echo install -o root -g bin -m 755 -d /usr/local/libexec/rmonitor
echo install -o root -g bin -m 755 -t /usr/local/libexec/rmonitor $?
echo
echo install -o root -g bin -m 755 -d ${libexecdir}/rmonitor
echo install -o root -g bin -m 755 -t ${libexecdir}/rmonitor $?
echo install -o root -g bin -m 755 -d ${exec_prefix}/libexec/rmonitor
echo install -o root -g bin -m 755 -t ${exec_prefix}/rmonitor $?
echo install -o root -g bin -m 755 -d ${prefix}/libexec/rmonitor
echo install -o root -g bin -m 755 -t ${prefix}/rmonitor $?

The /only/ Makefile.in pattern that got the install directory completely
correct was the one where I /forced/ the issue, and manually specified the
install directory as @prefix@/libexec.

This seems counter to how autotools should work to me; I don't want rules that
depend on hardcoded paths - if the end-installer wants to run
./configure --libexecdir=/some/obscure/path
then, my Makefile.in shouldn't override that to assume @prefix@/libexec.

Richard Kettlewell

unread,
May 31, 2015, 1:21:01 PM5/31/15
to
Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
[...]
> but none have resulted in a Makefile that would actually install the
> file into the intended directory. Usually the @libexec@ just expands
> into a literal '${exec_prefix}/libexec' path, without expanding the
> ${exec_prefix}. Even the explicit '${exec_prefix}/libexec' just
> "expands" into '${prefix}/libexec', still leaving the path unusable.

You need definitions for exec_prefix and prefix as well. Example:

$ cat configure.ac
AC_INIT([whatever], [0.0], [what...@example.com])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
$ cat Makefile.in
prefix=@prefix@
exec_prefix=@exec_prefix@
libbexecdir=@libexecdir@
$ autoconf
$ ./configure
configure: creating ./config.status
config.status: creating Makefile
$ cat Makefile
prefix=/usr/local
exec_prefix=${prefix}
libbexecdir=${exec_prefix}/libexec

The idea is that setting just prefix is enough to redirect everything
else.

You mentioned Automake, which normally sorts thist stuff out for you,
but I guess you’re not actually using it.

--
http://www.greenend.org.uk/rjk/

Lew Pitcher

unread,
May 31, 2015, 1:31:48 PM5/31/15
to
On Sunday May 31 2015 13:20, in comp.os.linux.development.apps, "Richard
I tried automake, but the use documentation was even more spotty than
autoconf's documentation. For instance, the "Autotools book" discusses the
automake "Easy Primaries", which seem to include high-level rules for
compilation and installation of programs into <somepath>/bin , the
compilation and installation of libraries into <somepath>/bin and for the
movement of manual pages into <somepath>/man. But is says nothing else. And
the rest of the documentation regarding automake says even less.

The info page for these tools talks a lot about how they work, but not how to
use them. And the man page just points to the info page.

So, I abandon automake as complicating the issue, and just concentrate on
autoconf for now.

Lew Pitcher

unread,
May 31, 2015, 1:32:34 PM5/31/15
to
On Sunday May 31 2015 13:20, in comp.os.linux.development.apps, "Richard
Kettlewell" <r...@greenend.org.uk> wrote:

That's what I needed to see.

Thank you. I'll give it a try.

Lew Pitcher

unread,
May 31, 2015, 1:56:08 PM5/31/15
to
On Sunday May 31 2015 13:20, in comp.os.linux.development.apps, "Richard
Kettlewell" <r...@greenend.org.uk> wrote:

That's got it. Thanks.

I tried it, and get the results I hoped for.
I guess that, for the other Makefile.in files, I'll have to do something
similar. Do you know of a guide to the expansion rules for the standard
macros (eg. @libexecdir@ -> @exec_prefix@/libexec, @exec_prefix@ -> @prefix@,
etc.)? I guess that I dig through config.log for the expansions, and
retro-fit them into my Makefile.in, if necessary.
0 new messages