6 AC_DEFUN([PGAC_PATH_PERL],
7 [PGAC_PATH_PROGS(PERL, perl)
10 pgac_perl_version=`$PERL -v 2>/dev/null | sed -n ['s/This is perl.*v[a-z ]*\([0-9]\.[0-9][0-9.]*\).*$/\1/p']`
11 AC_MSG_NOTICE([using perl $pgac_perl_version])
12 if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
13 $AWK '{ if ([$]1 == 5 && [$]2 >= 8) exit 1; else exit 0;}'
16 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
17 *** Perl version 5.8 or later is required, but this is $pgac_perl_version.])
22 if test -z "$PERL"; then
24 *** Without Perl you will not be able to build PostgreSQL from Git.
25 *** You can obtain Perl from any CPAN mirror site.
26 *** (If you are using the official distribution of PostgreSQL then you do not
27 *** need to worry about this, because the Perl output is pre-generated.)])
32 # PGAC_CHECK_PERL_CONFIG(NAME)
33 # ----------------------------
34 AC_DEFUN([PGAC_CHECK_PERL_CONFIG],
35 [AC_REQUIRE([PGAC_PATH_PERL])
36 AC_MSG_CHECKING([for Perl $1])
37 perl_$1=`$PERL -MConfig -e 'print $Config{$1}'`
38 test "$PORTNAME" = "win32" && perl_$1=`echo $perl_$1 | sed 's,\\\\,/,g'`
40 AC_MSG_RESULT([$perl_$1])])
43 # PGAC_CHECK_PERL_CONFIGS(NAMES)
44 # ------------------------------
45 AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
46 [m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
49 # PGAC_CHECK_PERL_EMBED_CCFLAGS
50 # -----------------------------
51 # We selectively extract stuff from $Config{ccflags}. We don't really need
52 # anything except -D switches, and other sorts of compiler switches can
53 # actively break things if Perl was compiled with a different compiler.
54 # Moreover, although Perl likes to put stuff like -D_LARGEFILE_SOURCE and
55 # -D_FILE_OFFSET_BITS=64 here, it would be fatal to try to compile PL/Perl
56 # to a different libc ABI than core Postgres uses. The available information
57 # says that all the symbols that affect Perl's own ABI begin with letters,
58 # so it should be sufficient to adopt -D switches for symbols not beginning
59 # with underscore. An exception is that we need to let through
60 # -D_USE_32BIT_TIME_T if it's present. (We probably could restrict that to
61 # only get through on Windows, but for the moment we let it through always.)
62 # For debugging purposes, let's have the configure output report the raw
63 # ccflags value as well as the set of flags we chose to adopt.
64 AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
65 [AC_REQUIRE([PGAC_PATH_PERL])
66 AC_MSG_CHECKING([for CFLAGS recommended by Perl])
67 perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']`
68 AC_MSG_RESULT([$perl_ccflags])
69 AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
70 perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']`
71 AC_SUBST(perl_embed_ccflags)dnl
72 AC_MSG_RESULT([$perl_embed_ccflags])
73 ])# PGAC_CHECK_PERL_EMBED_CCFLAGS
76 # PGAC_CHECK_PERL_EMBED_LDFLAGS
77 # -----------------------------
78 # We are after Embed's ldopts, but without the subset mentioned in
79 # Config's ccdlflags; and also without any -arch flags, which recent
80 # Apple releases put in unhelpfully. (If you want a multiarch build
81 # you'd better be specifying it in more places than plperl's final link.)
82 AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
83 [AC_REQUIRE([PGAC_PATH_PERL])
84 AC_MSG_CHECKING(for flags to link embedded Perl)
85 if test "$PORTNAME" = "win32" ; then
86 perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
87 if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
88 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
90 perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
91 if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
92 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
96 pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
97 pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
98 perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
100 AC_SUBST(perl_embed_ldflags)dnl
101 if test -z "$perl_embed_ldflags" ; then
103 AC_MSG_ERROR([could not determine flags for linking embedded Perl.
104 This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not
107 AC_MSG_RESULT([$perl_embed_ldflags])
109 ])# PGAC_CHECK_PERL_EMBED_LDFLAGS