ax_perl_ext.m4 extension: PERL_EXT_PREFIX

Thomas Klausner <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.archive-maintainers
Message-ID <[email protected]>
Hi!

For a local project I've extended ax_perl_ext.m4 to report back the
perl installation prefix as PERL_EXT_PREFIX.

I use it like this:

configure.ac:
PERL_RELATIVE_INSTALL_DIR=`echo ${PERL_EXT_LIB} | sed "s,${PERL_EXT_PREFIX},,"`

Makefile.am:
perlmodulepmdir=$(prefix)$(PERL_RELATIVE_INSTALL_DIR)/FOO
perlmodulepm_DATA=BAR.pm
perlmodulesodir=$(prefix)$(PERL_RELATIVE_INSTALL_DIR)/auto/FOO/BAR
perlmoduleso_LTLIBRARIES = BAR.la

This way I can install the perl files into DESTDIR for packaging.

Of course, if $(prefix) != $(PERL_EXT_PREFIX) in the final
installation place, it won't work.

Cheers,
 Thomas
ax_perl_ext.m4.diff (text/plain, 2.2 KB)
--- ax_perl_ext.m4.orig	2014-02-13 10:50:08.000000000 +0100
+++ ax_perl_ext.m4	2014-02-13 10:56:56.000000000 +0100
@@ -9,11 +9,12 @@
 # DESCRIPTION
 #
 #   Fetches the linker flags and C compiler flags for compiling and linking
-#   Perl binary extensions.  The macro substitutes PERL_EXT_INC,
+#   Perl binary extensions.  The macro substitutes PERL_EXT_PREFIX, PERL_EXT_INC,
 #   PERL_EXT_LIB, PERL_EXT_CPPFLAGS, PERL_EXT_LDFLAGS and PERL_EXT_DLEXT
 #   variables if Perl executable was found.  It also checks the same
 #   variables before trying to retrieve them from the Perl configuration.
 #
+#     PERL_EXT_PREFIX: top-level perl installation path (--prefix)
 #     PERL_EXT_INC: XS include directory
 #     PERL_EXT_LIB: Perl extensions destination directory
 #     PERL_EXT_CPPFLAGS: C preprocessor flags to compile extensions
@@ -30,17 +31,16 @@
 # LICENSE
 #
 #   Copyright (c) 2011 Stanislav Sedov <[email protected]>
+#   Copyright (c) 2014 Thomas Klausner <[email protected]>
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions are
 #   met:
 #
 #   1. Redistributions of source code must retain the above copyright
-#
 #      notice, this list of conditions and the following disclaimer.
 #
 #   2. Redistributions in binary form must reproduce the above copyright
-#
 #      notice, this list of conditions and the following disclaimer in the
 #      documentation and/or other materials provided with the distribution.
 #
@@ -68,6 +68,17 @@
         if test -n "$PERL" ; then
 
                 #
+                # Check for Perl prefix.
+                #
+                AC_ARG_VAR(PERL_EXT_PREFIX, [Perl PREFIX])
+                AC_MSG_CHECKING([for Perl prefix])
+                if test -z "$PERL_EXT_PREFIX" ; then
+                        [PERL_EXT_PREFIX=`$PERL -MConfig -e 'print $Config{prefix};'`];
+                fi
+                AC_MSG_RESULT([$PERL_EXT_PREFIX])
+                AC_SUBST(PERL_EXT_PREFIX)
+
+                #
                 # Check for Perl extensions include path.
                 #
                 AC_ARG_VAR(PERL_EXT_INC, [Directory to include XS headers from])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.