6 AC_DEFUN([PGAC_PATH_PERL],
7 [PGAC_PATH_PROGS(PERL, perl)
8 AC_ARG_VAR(PERL, [Perl program])dnl
11 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']`
12 AC_MSG_NOTICE([using perl $pgac_perl_version])
13 if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
14 $AWK '{ if ([$]1 == 5 && ([$]2 >= 14)) exit 1; else exit 0;}'
17 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
18 *** Perl version 5.14 or later is required, but this is $pgac_perl_version.])
22 if test -z "$PERL"; then
23 AC_MSG_ERROR([Perl not found])
28 # PGAC_CHECK_PERL_CONFIG(NAME)
29 # ----------------------------
30 AC_DEFUN([PGAC_CHECK_PERL_CONFIG],
31 [AC_REQUIRE([PGAC_PATH_PERL])
32 AC_MSG_CHECKING([for Perl $1])
33 perl_$1=`$PERL -MConfig -e 'print $Config{$1}'`
34 test "$PORTNAME" = "win32" && perl_$1=`echo $perl_$1 | sed 's,\\\\,/,g'`
36 AC_MSG_RESULT([$perl_$1])])
39 # PGAC_CHECK_PERL_CONFIGS(NAMES)
40 # ------------------------------
41 AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
42 [m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
45 # PGAC_CHECK_PERL_EMBED_CCFLAGS
46 # -----------------------------
47 # We selectively extract stuff from $Config{ccflags}. For debugging purposes,
48 # let's have the configure output report the raw ccflags value as well as the
49 # set of flags we chose to adopt. We don't really need anything except -D
50 # switches, and other sorts of compiler switches can actively break things if
51 # Perl was compiled with a different compiler. Moreover, although Perl likes
52 # to put stuff like -D_LARGEFILE_SOURCE and -D_FILE_OFFSET_BITS=64 here, it
53 # would be fatal to try to compile PL/Perl to a different libc ABI than core
54 # Postgres uses. The available information says that most symbols that affect
55 # Perl's own ABI begin with letters, so it's almost sufficient to adopt -D
56 # switches for symbols not beginning with underscore.
58 # Some exceptions are the Windows-specific -D_USE_32BIT_TIME_T and
59 # -D__MINGW_USE_VC2005_COMPAT. To be exact, Windows offers several 32-bit ABIs.
60 # Perl is sensitive to sizeof(time_t), one of the ABI dimensions. PostgreSQL
61 # doesn't support building with pre-MSVC-2005 compilers, but it does support
62 # linking to Perl built with such a compiler. MSVC-built Perl 5.13.4 and
63 # later report -D_USE_32BIT_TIME_T in $Config{ccflags} if applicable, but
64 # MinGW-built Perl never reports -D_USE_32BIT_TIME_T despite typically needing
67 # Consequently, we don't support using MinGW to link to MSVC-built Perl. As
68 # of 2017, all supported ActivePerl and Strawberry Perl are MinGW-built. If
69 # that changes or an MSVC-built Perl distribution becomes prominent, we can
70 # revisit this limitation.
71 AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
72 [AC_REQUIRE([PGAC_PATH_PERL])
73 AC_MSG_CHECKING([for CFLAGS recommended by Perl])
74 perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']`
75 AC_MSG_RESULT([$perl_ccflags])
76 AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
77 perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']`
78 AC_SUBST(perl_embed_ccflags)dnl
79 AC_MSG_RESULT([$perl_embed_ccflags])
80 ])# PGAC_CHECK_PERL_EMBED_CCFLAGS
83 # PGAC_CHECK_PERL_EMBED_LDFLAGS
84 # -----------------------------
85 # We are after Embed's ldopts, but without the subset mentioned in
86 # Config's ccdlflags and ldflags. (Those are the choices of those who
87 # built the Perl installation, which are not necessarily appropriate
88 # for building PostgreSQL.)
89 AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
90 [AC_REQUIRE([PGAC_PATH_PERL])
91 AC_MSG_CHECKING(for flags to link embedded Perl)
92 if test "$PORTNAME" = "win32" ; then
93 perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
94 if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
95 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
97 perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
98 if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
99 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
103 pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
104 pgac_tmp2=`$PERL -MConfig -e 'print "$Config{ccdlflags} $Config{ldflags}"'`
105 perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%"`
107 AC_SUBST(perl_embed_ldflags)dnl
108 if test -z "$perl_embed_ldflags" ; then
110 AC_MSG_ERROR([could not determine flags for linking embedded Perl.
111 This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not
114 AC_MSG_RESULT([$perl_embed_ldflags])
116 ])# PGAC_CHECK_PERL_EMBED_LDFLAGS