aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/perl5/Makefile.PL
blob: 6c217d9e6274db27ff816abce998d83ad4172a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#-------------------------------------------------------
#
# $Id: Makefile.PL,v 1.18 2001/08/26 22:28:04 petere Exp $
#
# Copyright (c) 1997, 1998  Edmund Mergl
#
#-------------------------------------------------------

use ExtUtils::MakeMaker;
use Config;
use strict;

my $srcdir=$ENV{SRCDIR};

my %opts;

%opts = (
    NAME         => 'Pg',
    VERSION_FROM => "Pg.pm",
    OBJECT       => "Pg\$(OBJ_EXT)",
# explicit mappings required for VPATH builds
    PM           => { "$srcdir/Pg.pm" => '$(INST_LIBDIR)/Pg.pm' },
    MAN3PODS     => { "$srcdir/Pg.pm" => '$(INST_MAN3DIR)/Pg.$(MAN3EXT)' },
);


if (! -d $ENV{POSTGRES_LIB} || ! -d $ENV{POSTGRES_INCLUDE}) {

    # Check that we actually are inside the Postgres source tree
    if (! -d "../libpq") {
	die
"To install Pg separately from the Postgres distribution, you must
set environment variables POSTGRES_LIB and POSTGRES_INCLUDE to point
to where Postgres is installed (often /usr/local/pgsql/{lib,include}).\n";
    }

} else {

    # Setup for standalone installation when Postgres already is installed.

    %opts = (
        %opts,
        INC          => "-I$ENV{POSTGRES_INCLUDE}",
        LIBS         => ["-L$ENV{POSTGRES_LIB} -lpq"],
    );
}


WriteMakefile(%opts);



# Put the proper runpath into the shared object.

sub MY::dynamic_lib {
    package MY;
    my $inherited= shift->SUPER::dynamic_lib(@_);

    my $pglibdir = $ENV{PGLIBDIR};
    return $inherited if $pglibdir eq '';

    # Remove any misguided attempts to set the runpath.
    $inherited =~ s/LD_RUN_PATH=\"\$\(LD_RUN_PATH\)\" //g;
    $inherited =~ s/-R\S*//g;
    $inherited =~ s/-rpath\S*//g;

    my $rpath;
    # Note that this could be different from what Makefile.port has
    # because a different compiler/linker could be used.
    SWITCH: for ($Config::Config{'osname'}) {
	/hpux/      and $rpath = "+b $pglibdir", last;
	/freebsd/   and $rpath = "-R$pglibdir", last;
	/irix/      and $rpath = "-R$pglibdir", last;
	/linux/     and $rpath = "-Wl,-rpath,$pglibdir", last;
	/netbsd/    and $rpath = "-R$pglibdir", last;
	/openbsd/   and $rpath = "-R$pglibdir", last;
	/solaris/   and $rpath = "-R$pglibdir", last;
	/svr5/      and $rpath = "-R$pglibdir", last;
    }

    $inherited=~ s,OTHERLDFLAGS =,OTHERLDFLAGS = $rpath , if defined $rpath;
    $inherited;
}



# 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) $< > $@
';
} 

# Delete this rule.  We can use the above one.
sub MY::xs_o {
    '';
}


# This rule tries to rebuild the Makefile from Makefile.PL.  We can do
# that better ourselves.
sub MY::makefile {
    '';
}