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.])
23 if test -z "$PERL"; then
25 *** Without Perl you will not be able to build PostgreSQL from Git.
26 *** You can obtain Perl from any CPAN mirror site.
27 *** (If you are using the official distribution of PostgreSQL then you do not
28 *** need to worry about this, because the Perl output is pre-generated.)])
33 # PGAC_CHECK_PERL_CONFIG(NAME)
34 # ----------------------------
35 AC_DEFUN([PGAC_CHECK_PERL_CONFIG],
36 [AC_REQUIRE([PGAC_PATH_PERL])
37 AC_MSG_CHECKING([for Perl $1])
38 perl_$1=`$PERL -MConfig -e 'print $Config{$1}'`
39 test "$PORTNAME" = "win32" && perl_$1=`echo $perl_$1 | sed 's,\\\\,/,g'`
41 AC_MSG_RESULT([$perl_$1])])
44 # PGAC_CHECK_PERL_CONFIGS(NAMES)
45 # ------------------------------
46 AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
47 [m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])])
50 # PGAC_CHECK_PERL_EMBED_CCFLAGS
51 # -----------------------------
52 # We selectively extract stuff from $Config{ccflags}. For debugging purposes,
53 # let's have the configure output report the raw ccflags value as well as the
54 # set of flags we chose to adopt. We don't really need anything except -D
55 # switches, and other sorts of compiler switches can actively break things if
56 # Perl was compiled with a different compiler. Moreover, although Perl likes
57 # to put stuff like -D_LARGEFILE_SOURCE and -D_FILE_OFFSET_BITS=64 here, it
58 # would be fatal to try to compile PL/Perl to a different libc ABI than core
59 # Postgres uses. The available information says that most symbols that affect
60 # Perl's own ABI begin with letters, so it's almost sufficient to adopt -D
61 # switches for symbols not beginning with underscore. Some exceptions are the
62 # Windows-specific -D_USE_32BIT_TIME_T and -D__MINGW_USE_VC2005_COMPAT; see
63 # Mkvcbuild.pm for details. We absorb the former when Perl reports it. Perl
64 # never reports the latter, and we don't attempt to deduce when it's needed.
65 # Consequently, we don't support using MinGW to link to MSVC-built Perl. As
66 # of 2017, all supported ActivePerl and Strawberry Perl are MinGW-built. If
67 # that changes or an MSVC-built Perl distribution becomes prominent, we can
68 # revisit this limitation.
69 AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
70 [AC_REQUIRE([PGAC_PATH_PERL])
71 AC_MSG_CHECKING([for CFLAGS recommended by Perl])
72 perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']`
73 AC_MSG_RESULT([$perl_ccflags])
74 AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
75 perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']`
76 AC_SUBST(perl_embed_ccflags)dnl
77 AC_MSG_RESULT([$perl_embed_ccflags])
78 ])# PGAC_CHECK_PERL_EMBED_CCFLAGS
81 # PGAC_CHECK_PERL_EMBED_LDFLAGS
82 # -----------------------------
83 # We are after Embed's ldopts, but without the subset mentioned in
84 # Config's ccdlflags and ldflags. (Those are the choices of those who
85 # built the Perl installation, which are not necessarily appropriate
86 # for building PostgreSQL.)
87 AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
88 [AC_REQUIRE([PGAC_PATH_PERL])
89 AC_MSG_CHECKING(for flags to link embedded Perl)
90 if test "$PORTNAME" = "win32" ; then
91 perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
92 if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
93 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
95 perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
96 if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
97 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
101 pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
102 pgac_tmp2=`$PERL -MConfig -e 'print "$Config{ccdlflags} $Config{ldflags}"'`
103 perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%"`
105 AC_SUBST(perl_embed_ldflags)dnl
106 if test -z "$perl_embed_ldflags" ; then
108 AC_MSG_ERROR([could not determine flags for linking embedded Perl.
109 This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not
112 AC_MSG_RESULT([$perl_embed_ldflags])
114 ])# PGAC_CHECK_PERL_EMBED_LDFLAGS