1# config/perl.m4 2 3 4# PGAC_PATH_PERL 5# -------------- 6AC_DEFUN([PGAC_PATH_PERL], 7[PGAC_PATH_PROGS(PERL, perl) 8AC_ARG_VAR(PERL, [Perl program])dnl 9 10if test "$PERL"; then 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 >= 8) exit 1; else exit 0;}' 15 then 16 AC_MSG_WARN([ 17*** The installed version of Perl, $PERL, is too old to use with PostgreSQL. 18*** Perl version 5.8 or later is required, but this is $pgac_perl_version.]) 19 PERL="" 20 fi 21fi 22 23if test -z "$PERL"; then 24 AC_MSG_WARN([ 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.)]) 29fi 30])# PGAC_PATH_PERL 31 32 33# PGAC_CHECK_PERL_CONFIG(NAME) 34# ---------------------------- 35AC_DEFUN([PGAC_CHECK_PERL_CONFIG], 36[AC_REQUIRE([PGAC_PATH_PERL]) 37AC_MSG_CHECKING([for Perl $1]) 38perl_$1=`$PERL -MConfig -e 'print $Config{$1}'` 39test "$PORTNAME" = "win32" && perl_$1=`echo $perl_$1 | sed 's,\\\\,/,g'` 40AC_SUBST(perl_$1)dnl 41AC_MSG_RESULT([$perl_$1])]) 42 43 44# PGAC_CHECK_PERL_CONFIGS(NAMES) 45# ------------------------------ 46AC_DEFUN([PGAC_CHECK_PERL_CONFIGS], 47[m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])]) 48 49 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. 69AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS], 70[AC_REQUIRE([PGAC_PATH_PERL]) 71AC_MSG_CHECKING([for CFLAGS recommended by Perl]) 72perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']` 73AC_MSG_RESULT([$perl_ccflags]) 74AC_MSG_CHECKING([for CFLAGS to compile embedded Perl]) 75perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']` 76AC_SUBST(perl_embed_ccflags)dnl 77AC_MSG_RESULT([$perl_embed_ccflags]) 78])# PGAC_CHECK_PERL_EMBED_CCFLAGS 79 80 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 also without any -arch flags, which recent 85# Apple releases put in unhelpfully. (If you want a multiarch build 86# you'd better be specifying it in more places than plperl's final link.) 87AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS], 88[AC_REQUIRE([PGAC_PATH_PERL]) 89AC_MSG_CHECKING(for flags to link embedded Perl) 90if 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" 94 else 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" 98 fi 99 fi 100else 101 pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts` 102 pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'` 103 perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]` 104fi 105AC_SUBST(perl_embed_ldflags)dnl 106if test -z "$perl_embed_ldflags" ; then 107 AC_MSG_RESULT(no) 108 AC_MSG_ERROR([could not determine flags for linking embedded Perl. 109This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not 110installed.]) 111else 112 AC_MSG_RESULT([$perl_embed_ldflags]) 113fi 114])# PGAC_CHECK_PERL_EMBED_LDFLAGS 115