On Fri, Aug 29, 2003 at 09:32:32AM +0200, Schleicher Ralph (LLI) spake thus: > Alan D. Salewski writes: > > > 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. > > I would merge the two options into a single one: > --without-perl-libdir AKA --with-perl-libdir=no uses $pkglibdir (the default). > --with-perl-libdir AKA --with-perl-libdir=yes uses 'perl -V:installsitelibperl'. > --with-perl-libdir=DIR uses DIR as is. > > -- > Ralph Thanks for the suggestions, Ralph. Your way makes much better sense: your 'configure' option name is better and your interface (one option rather than two) is easier to understand. I've rearranged the original code to implement the whole thing as you suggested, and it turns out that the code is easier to understand, as well. I'm now down to one macro, 'ads_PERL_LIBDIR', which I've included at the end of this message. I'm trying to make this macro useful for anyone who needs to configure and install perl modules, so I've also added a bunch of documentation. Any comments or criticisms on this new macro would be greatly appreciated. One thing I noticed while making my changes for this version is that the $pkglibdir shell variable is not available within the configure script; it is only available in the generated Makefile.in files. In my original message, I was building the equivalent of $pkglibdir by hand because I did not think to use the $pkglibdir var directly (so I did not come across this). Ralph's reply indicated the use of $pkglibdir so I read up on it a bit and learned that it provides the same thing I was doing, only as an automake provided facility. Still, you'll notice in the 'ads_PERL_LIBDIR' macro that I need to build the variable "by hand" in the same way that automake does in the Makefile.in output. I would have thought that $pkglibdir was available within 'configure' just as $mandir, $bindir, etc. are. Am I missing something here? I'm also considering making an equivalent macro for installing architecture-specific perl modules (Perl's 'installsitearch'). If I do, and anyone is interested, I'll send it to the list once I have something. -Al P.S. I've included my 'ads_PROG_PERL.m4' file after the 'ads_PERL_LIBDIR.m4' file because the latter requires something to define $PERL as a path to the perl interpreter. This is included as a convenience for anyone who might want to use 'ads_PERL_LIBDIR' without writing their own test. ---------------------------8<-----ads_PERL_LIBDIR.m4--start dnl -*-m4-*- ## ## $Id: ads_PERL_LIBDIR.m4,v 1.3 2003/08/29 20:35:52 al Exp $ ## dnl This macro provides for a new 'configure' option: dnl --with-perl-libdir=DIR dnl dnl which provides the following semantics: dnl dnl --without-perl-libdir AKA --with-perl-libdir=no uses $pkglibdir (the default). dnl --with-perl-libdir AKA --with-perl-libdir=yes uses 'perl -V:installsitelib'. dnl --with-perl-libdir=DIR uses specified DIR dnl dnl This macro provides "autoconfiscated" software packages with a means dnl of installing Perl library modules in a way that is consistent with dnl other packages that use the GNU autotools, yet also allows perl modules dnl to be installed like CPAN modules. dnl dnl Dependencies: dnl ------------ dnl This macro expects that the shell variables $SED and $PERL are dnl set and that their values are the paths to the 'sed' and 'perl' dnl executables. dnl dnl The macro provides the 'PERL_LIBDIR' automake variable to indicate where dnl perl library modules should be installed. It also provides the automake dnl conditional 'USING_PERL_INSTALLSITELIB'. See below for details. dnl dnl The default behavior of this macro is to set up PERL_LIBDIR to install dnl perl modules in $pkglibdir; this is to make it consistent with other dnl automake macros in that the '--prefix=DIR' configure option is respected. dnl The downside to this default behavior is that Perl scripts that need to dnl access the installed modules may need to take special measures (add dnl a 'use lib' pragma or manipulate @INC directly) to be able to find the dnl modules; see the 'USING_PERL_INSTALLSITELIB' automake conditional below dnl for one tool that may be used to handle this condition at configure time. dnl The default behavior is what you get when the '--with-perl-libdir' option dnl is not passed to configure, or when it is passed in the following forms: dnl --with-perl-libdir=no dnl --without-perl-libdir dnl dnl When specified as dnl --with-perl-libdir dnl or dnl --with-perl-libdir=yes dnl the macro will determine where to install the perl modules by asking the dnl perl interpreter where it will look for installed site libraries. This is dnl how CPAN user's expect to be able to install Perl modules (that is, the dnl installation procedure ask the existing Perl installation where it will dnl be able to find installed modules, and then installs the modules dnl accordingly), and would be the default behavior except for the fact that dnl it ignores the '--prefix=DIR' configure option (when setting PERL_LIBDIR), dnl and could therefore be destructive if the user was not expecting that. dnl Packages that use this macro may wish to recommend this form of dnl '--with-perl-libdir' to user's in a README or INSTALL file. This dnl installation method is accomplished by extracting the directory path from dnl the output of the command: dnl $ perl -V:installsitelib dnl dnl The third and final way to use the '--with-perl-libdir' configure option dnl is like this: dnl --with-perl-libdir=DIR dnl When run this way, PERL_LIBDIR simply gets set to the value of DIR. dnl dnl dnl To use this macro, simply put the following in your configure.in: dnl ads_PERL_LIBDIR dnl dnl This macro sets up the shell variable: dnl dnl $PERL_LIBDIR, which will contain a directory name at the dnl end of the macro dnl dnl This macro sets up the automake var @PERL_LIBDIR@ with the value in the dnl $PERL_LIBDIR shell variable. This automake var is provided for use in dnl Makefile.am files. dnl dnl This macro also sets up the automake conditional 'USING_PERL_INSTALLSITELIB' dnl to indicate whether or not the value of PERL_LIBIDR was set using the value dnl returned from the perl interpreter for 'installsitelib'. dnl dnl dnl CREDITS dnl * This macro was written by Alan D. Salewski <salewski AT worldnet.att.net>, dnl using code extracted from earlier efforts. dnl dnl * The name and semantics of the '--with-perl-libdir' configure option are dnl an immense improvement over the original effort; these were suggested dnl by Ralph Schleicher <ralph.schleicher AT lli.liebherr.com> dnl AC_DEFUN(ads_PERL_LIBDIR, [ AC_ARG_WITH(perl-libdir, changequote(<<, >>)dnl << --with-perl-libdir[=ARG] where to install perl modules [ARG=no, uses \$pgklibdir]>>dnl changequote([, ])dnl , [ # AC_ARG_WITH: option if given AC_MSG_CHECKING(for where to install perl modules) # each condition sets 'using_perlsysdirs' to either "yes" or "no", and # sets 'PERL_LIBDIR' to a non-empty DIR value if test "$withval" = "no"; then # --with-perl-libdir=no AKA --without-perl-libdir uses $pkglibdir (dflt) using_perlsysdirs="no" # note that we're constructing pkglibdir as automake would, but not # using the shell variable directly; this is because automake (at least # as of 1.4-p5) only defines '$pkglibdir' in the generated Makefile.in # files, but not in 'configure.in'. We need it defined in configure # in order for the assignment to PERL_LIBDIR to work. PERL_LIBDIR=${libdir}/${PACKAGE} AC_MSG_RESULT(\$pkglibdir: ${libdir}/${PACKAGE}) elif test -z "$withval" || \ test "$withval" = "yes"; then # --with-perl-libdir AKA --with-perl-libdir=yes uses 'perl -V:installsitelib' using_perlsysdirs="yes" AC_MSG_RESULT(Perl's "installsitelib") AC_MSG_CHECKING(for perl installsitelib dir) PERL_LIBDIR=`$PERL '-V:installsitelib*' | \ $SED -e "s/^installsitelib=[']\(.*\)[']\$/\1/"` if test "${PERL_LIBDIR}" = "undef" || \ test "${PERL_LIBDIR}X" = "X"; then tmp_valid_opts="`printf "\t"`"`$PERL -le 'print join $/."\t", @INC'` AC_MSG_ERROR([ 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-perl-libdir=DIR\' option to \'configure\'. All of the following are in @INC: $tmp_valid_opts ]) fi AC_MSG_RESULT($PERL_LIBDIR) else # --with-perl-libdir=DIR, use user-specified directory using_perlsysdirs="no" PERL_LIBDIR="${withval}" AC_MSG_RESULT(specified dir: $withval) dnl DEBUG: FIXME: warn the user if dir not in @INC? fi ], [ # AC_ARG_WITH: option if not given, same as --without-perl-libdir AC_MSG_CHECKING(for where to install perl modules) # note that we're constructing pkglibdir as automake would, but not # using the shell variable directly; this is because automake (at least # as of 1.4-p5) only defines '$pkglibdir' in the generated Makefile.in # files, but not in 'configure.in'. We need it defined in configure # in order for the assignment to PERL_LIBDIR to work. PERL_LIBDIR=${libdir}/${PACKAGE} AC_MSG_RESULT(\$pkglibdir: ${libdir}/${PACKAGE}) ])dnl end of AC_ARG_WITH(perl-libdir) macro AC_SUBST(PERL_LIBDIR) dnl register a conditional for use in Makefile.am files AM_CONDITIONAL(USING_PERL_INSTALLSITELIB, test x$using_perlsysdirs = x$yes) ]) ---------------------------8<-----ads_PERL_LIBDIR.m4----end ---------------------------8<-----ads_PROG_PERL.m4----start dnl -*- m4 -*- ## ## $Id: ads_PROG_PERL.m4,v 1.1 2003/08/29 21:04:59 al Exp $ ## dnl ads_PROG_PERL([required_perl_version]) dnl dnl This macro tests for the existence of a perl interpreter on the dnl target system. By default, it looks for perl version 5.005 or dnl newer; you can change the default version by passing in the dnl optional 'required_perl_version' argument, setting it to the perl dnl version you want. The format of the 'required_perl_version' argument dnl string is anything that you could legitimately use in a perl dnl script, but see below for a note on the format of the perl version dnl argument and compatibility with older perl interpreters. dnl dnl If no perl interpreter of the the required minimum version is found, dnl then we bomb out with an error message. dnl dnl To use this macro, just drop it in your configure.in file as dnl indicated in the examples below. Then use @PERL@ in any of your dnl files that will be processed by automake; the @PERL@ variable dnl will be expanded to the full path of the perl interpreter. dnl dnl Examples: dnl ads_PROG_PERL (looks for 5.005, the default) dnl ads_PROG_PERL() (same effect as previous) dnl ads_PROG_PERL([5.006]) (looks for 5.6.0, preferred way) dnl ads_PROG_PERL([5.6.0]) (looks for 5.6.0, don't do this) dnl dnl Note that care should be taken to make the required perl version dnl backward compatible, as explained here: dnl http://www.perldoc.com/perl5.8.0/pod/func/require.html dnl That is why the '5.006' form is preferred over '5.6.0', even though dnl both are for perl version 5.6.0 dnl dnl CREDITS dnl * This macro was written by Alan D. Salewksi <salewski AT worldnet.att.net> AC_DEFUN(ads_PROG_PERL, [ req_perl_version="$1" if test -z "$req_perl_version"; then req_perl_version="5.005" fi AC_PATH_PROG(PERL, perl) if test -z "$PERL"; then AC_MSG_ERROR([perl not found]) fi $PERL -e "require ${req_perl_version};" || { AC_MSG_ERROR([perl $req_perl_version or newer is required]) } ]) ---------------------------8<-----ads_PROG_PERL.m4------end -- a l a n d. s a l e w s k i salewski@xxxxxxxxxxxxxxxx -------------------------------------------------------------------- We have masterminded a decidedly ubiquitous multimedia toolset. -------------------------------------------------------------------- Generated from WWW Marketing Phrase gizmo: www.lyra.org/phrase.cgi