diff --git a/config/perl.m4 b/config/perl.m4 index a7401ccef3..dc134acc22 100644 --- a/config/perl.m4 +++ b/config/perl.m4 @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/config/perl.m4,v 1.1 2001/08/26 22:28:04 petere Exp $ +# $Header: /cvsroot/pgsql/config/perl.m4,v 1.2 2002/05/28 16:57:53 petere Exp $ # PGAC_PATH_PERL @@ -7,21 +7,29 @@ AC_DEFUN([PGAC_PATH_PERL], [AC_PATH_PROG(PERL, perl)]) -# PGAC_CHECK_PERL_DIRS -# --------------------- -AC_DEFUN([PGAC_CHECK_PERL_DIRS], -[ -AC_REQUIRE([PGAC_PATH_PERL]) -AC_MSG_CHECKING([Perl installation directories]) +# PGAC_CHECK_PERL_CONFIG(NAME) +# ---------------------------- +AC_DEFUN([PGAC_CHECK_PERL_CONFIG], +[AC_REQUIRE([PGAC_PATH_PERL]) +AC_MSG_CHECKING([for Perl $1]) +perl_$1=`$PERL -MConfig -e 'print $Config{$1}'` +AC_SUBST(perl_$1)dnl +AC_MSG_RESULT([$perl_$1])]) -# These are the ones we currently need. Others can be added easily. -perl_installsitearch=`$PERL -MConfig -e 'print $Config{installsitearch}'` -perl_installsitelib=`$PERL -MConfig -e 'print $Config{installsitelib}'` -perl_installman3dir=`$PERL -MConfig -e 'print $Config{installman3dir}'` -AC_SUBST(perl_installsitearch)[]dnl -AC_SUBST(perl_installsitelib)[]dnl -AC_SUBST(perl_installman3dir)[]dnl +# PGAC_CHECK_PERL_CONFIGS(NAMES) +# ------------------------------ +AC_DEFUN([PGAC_CHECK_PERL_CONFIGS], +[m4_foreach([pgac_item], [$1], [PGAC_CHECK_PERL_CONFIG(pgac_item)])]) -AC_MSG_RESULT(done) -]) + +# PGAC_CHECK_PERL_EMBED_LDFLAGS +# ----------------------------- +AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS], +[AC_REQUIRE([PGAC_PATH_PERL]) +AC_MSG_CHECKING(for flags to link embedded Perl) +pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts` +pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'` +perl_embed_ldflags=`echo X"$pgac_tmp1" | sed "s/^X//;s%$pgac_tmp2%%"` +AC_SUBST(perl_embed_ldflags)dnl +AC_MSG_RESULT([$perl_embed_ldflags])]) diff --git a/configure b/configure index 28048bde4f..19c0cd9faf 100755 --- a/configure +++ b/configure @@ -4956,19 +4956,44 @@ fi if test "$with_perl" = yes; then - -echo "$as_me:$LINENO: checking Perl installation directories" >&5 -echo $ECHO_N "checking Perl installation directories... $ECHO_C" >&6 - -# These are the ones we currently need. Others can be added easily. +echo "$as_me:$LINENO: checking for Perl installsitearch" >&5 +echo $ECHO_N "checking for Perl installsitearch... $ECHO_C" >&6 perl_installsitearch=`$PERL -MConfig -e 'print $Config{installsitearch}'` -perl_installsitelib=`$PERL -MConfig -e 'print $Config{installsitelib}'` +echo "$as_me:$LINENO: result: $perl_installsitearch" >&5 +echo "${ECHO_T}$perl_installsitearch" >&6 +echo "$as_me:$LINENO: checking for Perl installman3dir" >&5 +echo $ECHO_N "checking for Perl installman3dir... $ECHO_C" >&6 perl_installman3dir=`$PERL -MConfig -e 'print $Config{installman3dir}'` +echo "$as_me:$LINENO: result: $perl_installman3dir" >&5 +echo "${ECHO_T}$perl_installman3dir" >&6 +echo "$as_me:$LINENO: checking for Perl archlibexp" >&5 +echo $ECHO_N "checking for Perl archlibexp... $ECHO_C" >&6 +perl_archlibexp=`$PERL -MConfig -e 'print $Config{archlibexp}'` +echo "$as_me:$LINENO: result: $perl_archlibexp" >&5 +echo "${ECHO_T}$perl_archlibexp" >&6 +echo "$as_me:$LINENO: checking for Perl privlibexp" >&5 +echo $ECHO_N "checking for Perl privlibexp... $ECHO_C" >&6 +perl_privlibexp=`$PERL -MConfig -e 'print $Config{privlibexp}'` +echo "$as_me:$LINENO: result: $perl_privlibexp" >&5 +echo "${ECHO_T}$perl_privlibexp" >&6 +echo "$as_me:$LINENO: checking for Perl useshrplib" >&5 +echo $ECHO_N "checking for Perl useshrplib... $ECHO_C" >&6 +perl_useshrplib=`$PERL -MConfig -e 'print $Config{useshrplib}'` +echo "$as_me:$LINENO: result: $perl_useshrplib" >&5 +echo "${ECHO_T}$perl_useshrplib" >&6 +echo "$as_me:$LINENO: checking for Perl man3ext" >&5 +echo $ECHO_N "checking for Perl man3ext... $ECHO_C" >&6 +perl_man3ext=`$PERL -MConfig -e 'print $Config{man3ext}'` +echo "$as_me:$LINENO: result: $perl_man3ext" >&5 +echo "${ECHO_T}$perl_man3ext" >&6 - -echo "$as_me:$LINENO: result: done" >&5 -echo "${ECHO_T}done" >&6 - +echo "$as_me:$LINENO: checking for flags to link embedded Perl" >&5 +echo $ECHO_N "checking for flags to link embedded Perl... $ECHO_C" >&6 +pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts` +pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'` +perl_embed_ldflags=`echo X"$pgac_tmp1" | sed "s/^X//;s%$pgac_tmp2%%"` +echo "$as_me:$LINENO: result: $perl_embed_ldflags" >&5 +echo "${ECHO_T}$perl_embed_ldflags" >&6 fi if test "$with_python" = yes; then @@ -17414,8 +17439,12 @@ s,@YFLAGS@,$YFLAGS,;t t s,@WISH@,$WISH,;t t s,@PERL@,$PERL,;t t s,@perl_installsitearch@,$perl_installsitearch,;t t -s,@perl_installsitelib@,$perl_installsitelib,;t t s,@perl_installman3dir@,$perl_installman3dir,;t t +s,@perl_archlibexp@,$perl_archlibexp,;t t +s,@perl_privlibexp@,$perl_privlibexp,;t t +s,@perl_useshrplib@,$perl_useshrplib,;t t +s,@perl_man3ext@,$perl_man3ext,;t t +s,@perl_embed_ldflags@,$perl_embed_ldflags,;t t s,@PYTHON@,$PYTHON,;t t s,@python_version@,$python_version,;t t s,@python_prefix@,$python_prefix,;t t diff --git a/configure.in b/configure.in index b07667db3f..0accbce508 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Header: /cvsroot/pgsql/configure.in,v 1.185 2002/05/24 18:10:17 petere Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.186 2002/05/28 16:57:53 petere Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -661,7 +661,9 @@ fi PGAC_PATH_PERL if test "$with_perl" = yes; then - PGAC_CHECK_PERL_DIRS + PGAC_CHECK_PERL_CONFIGS([installsitearch,installman3dir, + archlibexp,privlibexp,useshrplib,man3ext]) + PGAC_CHECK_PERL_EMBED_LDFLAGS fi if test "$with_python" = yes; then diff --git a/src/Makefile.global.in b/src/Makefile.global.in index b6bec695fd..991a42f62b 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.147 2002/05/24 18:10:17 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.148 2002/05/28 16:57:53 petere Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -214,8 +214,12 @@ X = @EXEEXT@ PERL = @PERL@ perl_installsitearch = @perl_installsitearch@ -perl_installsitelib = @perl_installsitelib@ perl_installman3dir = @perl_installman3dir@ +perl_archlibexp = @perl_archlibexp@ +perl_privlibexp = @perl_privlibexp@ +perl_useshrplib = @perl_useshrplib@ +perl_embed_ldflags = @perl_embed_ldflags@ +perl_man3ext = @perl_man3ext@ # Miscellaneous diff --git a/src/interfaces/perl5/GNUmakefile b/src/interfaces/perl5/GNUmakefile index 6920742c59..ede470b299 100644 --- a/src/interfaces/perl5/GNUmakefile +++ b/src/interfaces/perl5/GNUmakefile @@ -1,17 +1,9 @@ -# This file is an interface from the Autoconf world to Perl's -# MakeMaker world, so that the latter behaves (kind of) like the -# former would prefer. Internally, we call Perl to create another -# Makefile according to its own ideas and then invoke the rules from -# that file. -# -# $Header: /cvsroot/pgsql/src/interfaces/perl5/Attic/GNUmakefile,v 1.6 2001/08/26 22:28:04 petere Exp $ +# $Header: /cvsroot/pgsql/src/interfaces/perl5/Attic/GNUmakefile,v 1.7 2002/05/28 16:57:53 petere Exp $ subdir = src/interfaces/perl5 top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -.NOTPARALLEL: - # This would allow a non-root install of the Perl module, but it's not # quite implemented yet. ifeq ($(mysterious_feature),yes) @@ -20,31 +12,49 @@ perl_installsitelib = $(pkglibdir) perl_installman3dir = $(mandir)/man3 endif +override CPPFLAGS := -I$(libpq_srcdir) -I$(top_srcdir)/src/include $(CPPFLAGS) -I$(perl_archlibexp)/CORE +override CFLAGS += $(CFLAGS_SL) +override CPPFLAGS += -DXS_VERSION=\"$(shell sed -n "s/\$$.*::VERSION.*=.*'\(.*\)';/\1/p" $(srcdir)/Pg.pm)\" -all: Makefile libpq-all - $(MAKE) -f $< all VPATH=$(VPATH) +# The code isn't clean with regard to these warnings. +ifeq ($(GCC),yes) +override CFLAGS := $(filter-out -Wall -Wmissing-declarations -Wmissing-prototypes, $(CFLAGS)) +endif -# We need to run Makefile.PL in the source directory because it scans -# the directory for files to build with. If we ran it in the build -# dir it would miss all the files and not build half the stuff! -Makefile: Makefile.PL Pg.pm - abs_builddir=`pwd`; \ - abs_libpq_builddir=`cd $(libpq_builddir) && pwd`; \ - cd $(srcdir) && \ - SRCDIR=$(srcdir) \ - PGLIBDIR=$(libdir) \ - $(PERL) $< \ - INC='-I$(srcdir) -I$(libpq_srcdir) $(filter -I%, $(CPPFLAGS))' \ - LIBS="-L$$abs_libpq_builddir -lpq" \ - INSTALLSITEARCH='$$(DESTDIR)$(perl_installsitearch)' \ - INSTALLSITELIB='$$(DESTDIR)$(perl_installsitelib)' \ - INSTALLMAN3DIR='$$(DESTDIR)$(perl_installman3dir)' \ - MAKEFILE="$$abs_builddir/Makefile" +POD2MAN = pod2man + + +NAME = Pg +OBJS = Pg.o +SO_MAJOR_VERSION = 0 +SO_MINOR_VERSION = 0 +SHLIB_LINK = -L$(libpq_builddir) -lpq + +include $(top_srcdir)/src/Makefile.shlib + + +all: all-lib Pg.pm Pg.bs auto/Pg/autosplit.ix Pg.$(perl_man3ext) + +all-lib: libpq-all .PHONY: libpq-all libpq-all: $(MAKE) -C $(libpq_builddir) all +Pg.c: Pg.xs typemap + $(PERL) $(perl_privlibexp)/ExtUtils/xsubpp -typemap $(perl_privlibexp)/ExtUtils/typemap -typemap $(srcdir)/typemap $(srcdir)/Pg.xs >$@ + +auto/Pg/autosplit.ix: Pg.pm + @$(mkinstalldirs) auto + $(PERL) -MAutoSplit -e 'autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);' $< auto + +Pg.bs: + $(PERL) -MExtUtils::Mkbootstrap -e "Mkbootstrap('Pg', '');" + touch $@ + +Pg.$(perl_man3ext): Pg.pm + $(POD2MAN) $< $@ + # During install, we must guard against the likelihood that we don't # have permissions to install into the Perl module library. It's not @@ -58,38 +68,24 @@ echo "*** `pwd`,"; \ echo "*** become the appropriate user, and enter '$(MAKE) install'."; \ echo ""; } -# We need to massage the packlist after installation to get the -# DESTDIR out of there. install: all installdirs @if test -w $(DESTDIR)$(perl_installsitearch); then \ - $(MAKE) -f Makefile pure_install DESTDIR=$(DESTDIR) && \ - mv $(DESTDIR)$(perl_installsitearch)/auto/Pg/.packlist fake-packlist && \ - sed 's,^$(DESTDIR),,' fake-packlist >$(DESTDIR)$(perl_installsitearch)/auto/Pg/.packlist && \ - rm fake-packlist; \ + $(INSTALL_DATA) Pg.pm $(DESTDIR)$(perl_installsitearch); \ + $(INSTALL_DATA) Pg.bs $(DESTDIR)$(perl_installsitearch)/auto/Pg; \ + $(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(perl_installsitearch)/auto/Pg/Pg$(DLSUFFIX); \ + $(INSTALL_DATA) auto/Pg/autosplit.ix $(DESTDIR)$(perl_installsitearch)/auto/Pg; \ + $(INSTALL_DATA) $(srcdir)/Pg.$(perl_man3ext) $(DESTDIR)$(perl_installman3dir); \ else \ $(install-warning-msg); \ fi -# Try to make the directories ourselves, otherwise the writability -# test above may fail because of mere non-existence. installdirs: - -$(mkinstalldirs) $(DESTDIR)$(perl_installsitearch)/auto/Pg \ - $(DESTDIR)$(perl_installsitelib) \ - $(DESTDIR)$(perl_installman3dir) + -$(mkinstalldirs) $(DESTDIR)$(perl_installsitearch)/auto/Pg $(DESTDIR)$(perl_installman3dir) uninstall: - for file in `cat $(DESTDIR)$(perl_installsitearch)/auto/Pg/.packlist`; do \ - rm -f $(DESTDIR)$$file || exit; \ - done - rm -f $(DESTDIR)$(perl_installsitearch)/auto/Pg/.packlist - -rmdir $(DESTDIR)$(perl_installsitearch)/auto/Pg + rm -f $(addprefix $(DESTDIR)$(perl_installsitearch)/, Pg.pm auto/Pg/Pg.bs auto/Pg/Pg$(DLSUFFIX) auto/Pg/autosplit.ix) $(DESTDIR)$(perl_installman3dir)/Pg.$(perl_man3ext) -clean distclean maintainer-clean: - -[ -f Makefile ] && $(MAKE) -f Makefile clean - rm -f Makefile Makefile.old - @rm -f fake-packlist - - -installcheck test: Makefile - $(MAKE) -f $< test +clean distclean maintainer-clean: clean-lib + rm -f $(OBJS) Pg.c Pg.bs Pg.$(perl_man3ext) + rm -rf auto diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile index 0c37bbe6fc..fa77a7f187 100644 --- a/src/pl/plperl/GNUmakefile +++ b/src/pl/plperl/GNUmakefile @@ -1,24 +1,43 @@ -# $Header: /cvsroot/pgsql/src/pl/plperl/GNUmakefile,v 1.9 2002/02/23 21:49:10 momjian Exp $ +# Makefile for PL/Perl +# $Header: /cvsroot/pgsql/src/pl/plperl/GNUmakefile,v 1.10 2002/05/28 16:57:53 petere Exp $ subdir = src/pl/plperl top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -ifeq ($(allow_nonpic_in_shlib),yes) -makefile_pl_flags = --force +ifeq ($(perl_useshrplib),true) +shared_libperl = yes endif +# If we don't have a shared library and the platform doesn't allow it +# to work without, we have to skip it. +ifneq (,$(findstring yes, $(shared_libperl)$(allow_nonpic_in_shlib))) -all: Makefile - $(MAKE) -f $< all VPATH=$(VPATH) +# The code isn't clean with regard to these warnings. +ifeq ($(GCC),yes) +override CFLAGS := $(filter-out -Wall -Wmissing-declarations -Wmissing-prototypes, $(CFLAGS)) +endif -Makefile: Makefile.PL - plperl_installdir='$$(DESTDIR)$(pkglibdir)' \ - $(PERL) $< $(makefile_pl_flags) LIBS='$(BE_DLLLIBS)' \ - INC='-I$(srcdir) $(filter -I%, $(CPPFLAGS))' +override CPPFLAGS := -I$(srcdir) -I$(perl_archlibexp)/CORE $(CPPFLAGS) + + +NAME = plperl +SO_MAJOR_VERSION = 0 +SO_MINOR_VERSION = 0 + +OBJS = plperl.o eloglvl.o SPI.o +SHLIB_LINK = $(perl_embed_ldflags) $(BE_DLLLIBS) + +include $(top_srcdir)/src/Makefile.shlib + + +all: all-lib + +SPI.c: SPI.xs + $(PERL) $(perl_privlibexp)/ExtUtils/xsubpp -typemap $(perl_privlibexp)/ExtUtils/typemap $< >$@ install: all installdirs - $(MAKE) -f Makefile install DESTDIR='$(DESTDIR)' + $(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/plperl$(DLSUFFIX) installdirs: $(mkinstalldirs) $(DESTDIR)$(pkglibdir) @@ -26,6 +45,16 @@ installdirs: uninstall: rm -f $(DESTDIR)$(pkglibdir)/plperl$(DLSUFFIX) -clean distclean maintainer-clean: - -[ -f Makefile ] && $(MAKE) -f Makefile clean - rm -f Makefile Makefile.old +clean distclean maintainer-clean: clean-lib + rm -f SPI.c $(OBJS) + +else # can't build + +all: + @echo ""; \ + echo "*** Cannot build PL/Perl because libperl is not a shared library."; \ + echo "*** You might have to rebuild your Perl installation. Refer to"; \ + echo "*** the documentation for details."; \ + echo "" + +endif # can't build diff --git a/src/pl/plperl/Makefile.PL b/src/pl/plperl/Makefile.PL deleted file mode 100644 index 83bf1ccc33..0000000000 --- a/src/pl/plperl/Makefile.PL +++ /dev/null @@ -1,98 +0,0 @@ -use ExtUtils::MakeMaker; -use ExtUtils::Embed; -use DynaLoader; -use Config; - -# On some platforms you can't build plperl unless libperl is a shared -# library. (Actually, it would be enough if code in libperl.a is -# compiled to be position-independent, but that is hard to check for -# and seems pretty unlikely anyway.) On some platforms it doesn't -# matter and they can pass in the --force flag to build anyway. -# (Having a shared libperl is still a lot better for efficiency, -# though.) - -if ($Config{'useshrplib'} ne 'true' && $ARGV[0] ne '--force') { - open(OUT, ">Makefile") or die "Can't write Makefile: $!\n"; - print OUT <<'EndOfMakefile'; -# Dummy Makefile for use when we can't build plperl - -all: - @echo ""; \ - echo "*** Cannot build PL/Perl because libperl is not a shared library." ; \ - echo "*** You might have to rebuild your Perl installation. Refer to"; \ - echo "*** the documentation for details."; \ - echo "" - -install: - -clean realclean: - rm -f Makefile - -EndOfMakefile - close(OUT); - exit(0); -} - -my $ldopts=ldopts(); -$ldopts=~s/$Config{ccdlflags}//; - -WriteMakefile( 'NAME' => 'plperl', - dynamic_lib => { 'OTHERLDFLAGS' => $ldopts } , - XS => { 'SPI.xs' => 'SPI.c' }, - OBJECT => 'plperl.o eloglvl.o SPI.o', - ); - - -sub MY::cflags { - package MY; # so that "SUPER" works right - my $inherited = shift->SUPER::cflags(@_); - -# -# Hack for building on HPUX (probably should have a general mechanism -# for system-specific hints, but for now ...) -# The default compiler and flags on this platform is cc -Aa, which -# will reject 'long long' declarations that appear in Postgres headers. -# Need to select -Ae instead. -# - if ($Config::Config{'osname'} eq 'hpux') { - $inherited =~ s/-Aa/-Ae/; - } - - $inherited; -} - -sub MY::install { - -qq[ -install :: all - cp \$(INST_DYNAMIC) $ENV{plperl_installdir} -]; - -} - - -sub MY::xs_o { - ''; -} - -sub MY::makefile { - ''; -} - -# VPATH-aware version of this rule -sub MY::xs_c { - my($self) = shift; - return '' unless $self->needs_linking(); - ' -.xs.c: - $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $< > $@ -'; -} - -# somebody doesn't know how to write make rules... -sub MY::c_o { - package MY; # so that "SUPER" works right - my $inherited = shift->SUPER::c_o(@_); - $inherited =~ s/\$\*\.\S+/\$\