Adding a custom installation directory option to Autoconf-generated configure scripts
Asked Answered
V

3

7

configure scripts always include something like the following in the help message:

...
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root
                          [DATAROOTDIR/doc/gedit-line-ending-style-plugin]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
...

What I would like to do is add "plugindir", to this section, as in:

...
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]
  --plugindir=DIR         Gedit plugin files [LIBDIR/gedit-2/plugins]
...

so that users would be able to pass in --plugindir=... to the configure script.

How can I do this?

Vinita answered 21/8, 2010 at 19:57 Comment(1)
Possible duplicate of Make install, but not to default directories?Parisi
L
0

If I'm correct those paths are set in the share/autoconf/autoconf/general.m4 file. The list is hardcoded so it is difficult to insert things in the list. You can add extra help information using the macro AS_HELP_STRING. There are some examples that add a plugindir, for example in gstreamer, gimp, but those don't have a configurable plugin directory.

Leid answered 21/8, 2010 at 20:35 Comment(4)
Interesting. Line 1058 of my /usr/share/autoconf/autoconf/general.m4 file is responsible for the "Fine tuning of the installation directories:" line. It does not, however, appear that I can easily add to the "installation directories" section of the configure script help text without modifying general.m4. But, at least I now know.Vinita
I am not sure which approach of gstreamer and xine you are referring to. But, what I did was adapted a line from general.m4, adding AC_SUBST([plugindir], ['${libdir}/gedit-2/plugins']) to my configure.ac. Then, I specify targets that I want to install to the "plugindir" in the plugin_DATA variable in a Makefile.am. It's not as user-configurable as I was originally going for, but it works well: code.google.com/p/gedit-line-ending-style-plugin/source/browse/…Vinita
Neither gstreamer nor xine do what the OP was asking. Both set the plugin path without any way for the user to specify. The only way I can see to allow the user to specify a plugin path at configure time is to abuse AC_ARG_WITH, which puts the documentation under "optional packages" rather than "fine tuning of the installation directories."Winton
general.m4 is an internal file of autoconf, don't mess with it. The link is dead. But from what I see, everybody uses AC_ARG_WITH. Adding an argument without "with" or "enable" is impossible without modifying Autoconf.Ensphere
D
4

Put the following lines in configure.ac, near the beginning:

AC_ARG_WITH([pkgconfigdir],
  [AS_HELP_STRING([--with-pkgconfigdir=DIR], [pkgconfig files])],
  [pkgconfigdir=$withval],
  [pkgconfigdir="\${libdir}/pkgconfig"])
AC_SUBST([pkgconfigdir], [$pkgconfigdir])

Then, in Makefile.am, you can refer to the directory like this:

pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = mylibrary.pc
Durbar answered 7/2, 2015 at 23:23 Comment(1)
The second argument is not needed. pkgconfigdir = @pkgconfigdir@ is not needed. It's nice to specify the default in the help. You can use single quotes instead of escaping $.Ensphere
L
0

If I'm correct those paths are set in the share/autoconf/autoconf/general.m4 file. The list is hardcoded so it is difficult to insert things in the list. You can add extra help information using the macro AS_HELP_STRING. There are some examples that add a plugindir, for example in gstreamer, gimp, but those don't have a configurable plugin directory.

Leid answered 21/8, 2010 at 20:35 Comment(4)
Interesting. Line 1058 of my /usr/share/autoconf/autoconf/general.m4 file is responsible for the "Fine tuning of the installation directories:" line. It does not, however, appear that I can easily add to the "installation directories" section of the configure script help text without modifying general.m4. But, at least I now know.Vinita
I am not sure which approach of gstreamer and xine you are referring to. But, what I did was adapted a line from general.m4, adding AC_SUBST([plugindir], ['${libdir}/gedit-2/plugins']) to my configure.ac. Then, I specify targets that I want to install to the "plugindir" in the plugin_DATA variable in a Makefile.am. It's not as user-configurable as I was originally going for, but it works well: code.google.com/p/gedit-line-ending-style-plugin/source/browse/…Vinita
Neither gstreamer nor xine do what the OP was asking. Both set the plugin path without any way for the user to specify. The only way I can see to allow the user to specify a plugin path at configure time is to abuse AC_ARG_WITH, which puts the documentation under "optional packages" rather than "fine tuning of the installation directories."Winton
general.m4 is an internal file of autoconf, don't mess with it. The link is dead. But from what I see, everybody uses AC_ARG_WITH. Adding an argument without "with" or "enable" is impossible without modifying Autoconf.Ensphere
R
0

I think you are on the right track with AC_SUBST.

Additionally, I think you can modify or extend the --help output of configure with AS_HELP_STRING.

See: http://www.gnu.org/s/hello/manual/autoconf/Pretty-Help-Strings.html

Rebecarebecca answered 28/9, 2011 at 12:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.