]> granicus.if.org Git - postgresql/blob - config/perl.m4
Add procedure support to pg_get_functiondef
[postgresql] / config / perl.m4
1 # config/perl.m4
2
3
4 # PGAC_PATH_PERL
5 # --------------
6 AC_DEFUN([PGAC_PATH_PERL],
7 [PGAC_PATH_PROGS(PERL, perl)
8
9 if test "$PERL"; then
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;}'
14   then
15     AC_MSG_WARN([
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.])
18     PERL=""
19   fi
20 fi
21
22 if test -z "$PERL"; then
23   AC_MSG_WARN([
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.)])
28 fi
29 ])# PGAC_PATH_PERL
30
31
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'`
39 AC_SUBST(perl_$1)dnl
40 AC_MSG_RESULT([$perl_$1])])
41
42
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)])])
47
48
49 # PGAC_CHECK_PERL_EMBED_CCFLAGS
50 # -----------------------------
51 # We selectively extract stuff from $Config{ccflags}.  For debugging purposes,
52 # let's have the configure output report the raw ccflags value as well as the
53 # set of flags we chose to adopt.  We don't really need anything except -D
54 # switches, and other sorts of compiler switches can actively break things if
55 # Perl was compiled with a different compiler.  Moreover, although Perl likes
56 # to put stuff like -D_LARGEFILE_SOURCE and -D_FILE_OFFSET_BITS=64 here, it
57 # would be fatal to try to compile PL/Perl to a different libc ABI than core
58 # Postgres uses.  The available information says that most symbols that affect
59 # Perl's own ABI begin with letters, so it's almost sufficient to adopt -D
60 # switches for symbols not beginning with underscore.  Some exceptions are the
61 # Windows-specific -D_USE_32BIT_TIME_T and -D__MINGW_USE_VC2005_COMPAT; see
62 # Mkvcbuild.pm for details.  We absorb the former when Perl reports it.  Perl
63 # never reports the latter, and we don't attempt to deduce when it's needed.
64 # Consequently, we don't support using MinGW to link to MSVC-built Perl.  As
65 # of 2017, all supported ActivePerl and Strawberry Perl are MinGW-built.  If
66 # that changes or an MSVC-built Perl distribution becomes prominent, we can
67 # revisit this limitation.
68 AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
69 [AC_REQUIRE([PGAC_PATH_PERL])
70 AC_MSG_CHECKING([for CFLAGS recommended by Perl])
71 perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']`
72 AC_MSG_RESULT([$perl_ccflags])
73 AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
74 perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']`
75 AC_SUBST(perl_embed_ccflags)dnl
76 AC_MSG_RESULT([$perl_embed_ccflags])
77 ])# PGAC_CHECK_PERL_EMBED_CCFLAGS
78
79
80 # PGAC_CHECK_PERL_EMBED_LDFLAGS
81 # -----------------------------
82 # We are after Embed's ldopts, but without the subset mentioned in
83 # Config's ccdlflags; and also without any -arch flags, which recent
84 # Apple releases put in unhelpfully.  (If you want a multiarch build
85 # you'd better be specifying it in more places than plperl's final link.)
86 AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
87 [AC_REQUIRE([PGAC_PATH_PERL])
88 AC_MSG_CHECKING(for flags to link embedded Perl)
89 if test "$PORTNAME" = "win32" ; then
90         perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
91         if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
92                 perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
93         else
94                 perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
95                 if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
96                         perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
97                 fi
98         fi
99 else
100         pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
101         pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
102         perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
103 fi
104 AC_SUBST(perl_embed_ldflags)dnl
105 if test -z "$perl_embed_ldflags" ; then
106         AC_MSG_RESULT(no)
107         AC_MSG_ERROR([could not determine flags for linking embedded Perl.
108 This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not
109 installed.])
110 else
111         AC_MSG_RESULT([$perl_embed_ldflags])
112 fi
113 ])# PGAC_CHECK_PERL_EMBED_LDFLAGS