aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plperl/Makefile.PL
blob: 565e8bbd2888db797e913ab7895431169b3f5e66 (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
use ExtUtils::MakeMaker;
use ExtUtils::Embed;
use DynaLoader;
use Config;

#
# Can't build a shared plperl unless libperl is shared too.
# (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.)
#
if ($Config{'useshrplib'} ne 'true') {
	open(OUT, ">Makefile") or die "Can't write Makefile: $!\n";
	print OUT <<'EndOfMakefile';
# Dummy Makefile for use when we can't build plperl

all install:
	@echo "Cannot build plperl because libperl is not a shared library; skipping it."

clean distclean:
	rm -f Makefile

.DEFAULT dep depend:

EndOfMakefile
	close(OUT);
	exit(0);
}


#
# get the location of the Opcode module
#
my $opcode = '';
{

	$modname = 'Opcode';

	my $dir;
	foreach (@INC) {
		if (-d "$_/auto/$modname") {
			$dir = "$_/auto/$modname";
			last;
		}
	}

	if (defined $dir) {
		$opcode = DynaLoader::dl_findfile("-L$dir", $modname);
	}

}

my $perllib = "-L$Config{archlibexp}/CORE -lperl";

WriteMakefile( 'NAME' => 'plperl', 
	dynamic_lib => { 'OTHERLDFLAGS' => "$opcode $perllib" } ,
	INC => '-I$(SRCDIR)/include -I$(SRCDIR)/backend $(PGSQL_INCLUDES)',
	XS => { 'SPI.xs' => 'SPI.c' },
	OBJECT => 'plperl.o eloglvl.o SPI.o',
	);

sub MY::post_initialize { 

q[
SRCDIR=../../../src
include $(SRCDIR)/Makefile.global
];

}

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 {

q[
install :: all
	cp $(INST_DYNAMIC) $(LIBDIR)
];

}