[Top][All Lists]

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

(long) handling perl modules in mixed language source packages

From: Alan D. Salewski
Subject: (long) handling perl modules in mixed language source packages
Date: Thu, 28 Aug 2003 15:27:58 -0400
User-agent: Mutt/1.3.28i

Hello All,

>From the googling I've done, it seems that it is generally recommended
that perl module packages be handled via MakeMaker rather than
automake/autoconf. However, I have a mixed-language project that
requires handling of perl modules along with other items that I would
ordinarily handle with automake, so I came up with the following

[ I am working with ancient versions of automake and autoconf (1.4-p5
and 2.13, respectively) ]

By default, I install perl modules beneath $libdir/$PACKAGE. This is the
default because it repects the '--prefix=DIR' option specified by the

I provide the user with two configure options, '--enable-perlsysdirs'
and '--with-perldir=DIR'.

Using '--enable-perlsysdirs' changes the default behavior to install
perl modules beneath Perl's 'installsitelib' directory, as determined by
running a variation of:

    $ perl -V:install.* | grep installsitelib

This has the benefit of putting the modules where perl is already
looking, but cannot be made the default because it causes the
installation to ignore the value of the '--prefix=DIR' arg for perl
modules; obviously, this violates the principle of least surprise and
could conceivably hose a system.

The '--with-perldir=DIR' option allows the user to explicitly set the
directory beneath which the perl modules will be installed.

Note that it does not make sense to specify both the
'--enable-perlsysdirs' option and the '--with-perldir=DIR' options at
the same time; nevertheless, if both options are specified, the
'--enable-perlsysdirs' option is effectively ignored because the
'--with-perldir=DIR' option is more specific.

The only real downside I see to this scheme is that it requires the user
to specify the '--enable-perlsysdirs' if he wants CPAN-module-like
behavior of just installing the modules where perl will find them.

I created the macro 'ads_PERL_INSTALLSITELIB' for use in my
file, and a helper macro 'ads_PERL_DIR_PREFIX' to provide part of the
implementation. The macros are included at the end of this message.

I would very much appreciate critiques of the above, both of the general
approach and the macro code itself.


dnl DO NOT put this macro directly in your '' (unless you know
dnl exactly what you're doing. This macro exists only to allow the
dnl 'ads_PERL_INSTALLSITELIB' macro to depend upon it and allow the user
dnl to manually specify where to drop the perl libraries.
dnl This macro provides for two 'configure' options:
dnl     --with-perldir=DIR
dnl     --enable-perlsysdirs
dnl In practice, it only makes sense to specify one option or the other,
dnl but if both are specified correctly, then '--enable-perlsysdirs' is
dnl effectively ignored (since '--with-perldir=DIR' is more specific).
dnl This macro sets up two shell variables:
dnl     $PERLDIR, which will contain either be empty or contain a
dnl               directory name at the end of the macro
dnl     $using_perlsysdirs, which will be either "yes" or "no" at
dnl               the end of the macro
dnl This macro sets up the automake conditional 'USING_PERLSYSDIRS' for
dnl use in files
dnl This macro also expands PERLDIR as an automake variable; this is
dnl probably a bug. Code that needs the base of the perl tree should
dnl use PERL_INSTALLSITELIB instead.


     changequote(<<, >>)dnl
<<  --with-perldir=DIR      where to install perl modules 
     changequote([, ])dnl
    [ # AC_ARG_WITH: option if given
    AC_MSG_CHECKING(for override perl site lib dir)
    if test -z "$withval" || \
       test "$withval" = "yes" || \
       test "$withval" = "no"; then
        # user specified --with-perldir w/o giving an '=DIR' arg
        AC_MSG_ERROR(no directory specified)
        AC_MSG_RESULT([yes: ${withval}])
        dnl FIXME: warn the user if dir not in @INC?
    [ # AC_ARG_WITH: option if not given
    AC_MSG_CHECKING(for override perl site lib dir)
    ])dnl end of AC_ARG_WITH() macro

    dnl The way this works is as follows: if the user explicitly set
    dnl the PERLDIR above, then --enable-perlsysdirs will be ignored
    dnl because --enable-perlsysdirs exists only to change the default
    dnl perl module installation directory; in this case we'll explicity
    dnl set using_perlsysdirs to "no".

     changequote(<<, >>)dnl
<<  --enable-perlsysdirs    install perl modules into perl system 
     changequote([, ])dnl
    [ # AC_ARG_ENABLE: option if given
    AC_MSG_CHECKING(whether perl modules should be installed into perl system 

    if test ! -z "$PERLDIR"; then
        # user explicitly set PERLDIR using '--with-perldir', so we'll ignore
        # the '--enable-perlsysdirs' option
        AC_MSG_RESULT([no (overridden by --with-perldir option)])
        case "${enableval}" in
            yes) using_perlsysdirs="yes"
            no)  using_perlsysdirs="no"
            *)   AC_MSG_ERROR(bad value \"${enableval}\" for 
    [ # AC_ARG_ENABLE: option if not given. By default we'll set up the
      # installation junk to respect the user's --prefix arg and not try
      # to install the perl modules into the perl 'installsitelib' dir.
    AC_MSG_CHECKING(whether perl modules should be installed into perl system 

    ])dnl end AC_ARG_ENABLE(perlsysdirs) macro

    dnl register a conditional for use in files

    AM_CONDITIONAL(USING_PERLSYSDIRS, test x$using_perlsysdirs = x$yes)

    dnl AL.DEBUG: make me require something that defines PERL (fullpath),
    if test ! -z "${PERLDIR}"; then
        if test "x${using_perlsysdirs}" = "xno"; then
            dnl only show this checking message if user did not specify
            dnl '--with-perldir' option /and/ the user has not specified
            dnl the '--enable-perlsysdirs' option. This is the default
            dnl because it respects the '--prefix' option if specified
            dnl by the user.
            AC_MSG_CHECKING(for where to install perl modules)
            dnl only show this checking message if user did not specify
            dnl '--with-perldir' option /and/ the user has specified the
            dnl --enable-perlsysdirs option

            AC_MSG_CHECKING(for perl site lib dir)
            PERL_INSTALLSITELIB=`$PERL '-V:install.*' | \
                                 $GREP 'installsitelib' | \
                                 $SED -e "s/^installsitelib=[']\(.*\)[']\$/\1/"`
            if test "${PERL_INSTALLSITELIB}" = "undef" || test 
                tmp_valid_opts="`printf "\t"`"`$PERL -le 'print join $/."\t", 
    Perl\'s installsitelib is not defined, and this is the preferred
    location in which to install the perl libraries included with ${PACKAGE}.
    Of course, you may specify that the perl libraries be installed anywhere
    perl will find them (anywhere in the @INC array), but you must explicitely
    request where, as this is non-standard. You may specify where to place them
    by using the \'--with-perldir=DIR\' option to \'configure\'. All of the
    following are in @INC:

a l a n   d.   s a l e w s k i             address@hidden
     We envision an extraordinarily powerful 32-bit approach.
Generated from WWW Marketing Phrase gizmo:

reply via email to

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