aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plperl/Makefile.PL
blob: e3d9600e7236f64b8c90442f299f43970e73f4a9 (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
108
109
110
111
112
113
114
115
use DynaLoader;
use Config;
use ExtUtils::Embed;

#
# massage the ld options
#
my $ldopts = ldopts();
chomp($ldopts);

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

}

open(MAKEFILE, ">Makefile");

print MAKEFILE <<_STATIC_;
#-------------------------------------------------------------------------
#
# Makefile
#    Makefile for the plperl shared object
#
# AUTOGENERATED Makefile.pl
#

#
# Tell make where the postgresql sources live
#
SRCDIR= ../../../src
include \$(SRCDIR)/Makefile.global


# use the same compiler as perl did
CC= $Config{cc}

# get the compiler options that perl wants.
CFLAGS+= @{[ccopts()]}
# including the ones for dynamic loading
CFLAGS+= $Config{cccdlflags}

# add the includes for postgreSQL
CFLAGS+= -I\$(LIBPQDIR) -I\$(SRCDIR)/include

# For fmgr.h
CFLAGS+= -I\$(SRCDIR)/backend


# add the postgreSQL libraries
LDADD+= -L\$(LIBPQDIR) -lpq

LDFLAGS+= $Config{lddlflags} \\
	$ldopts \\
	-lperl

#
# DLOBJS is the dynamically-loaded object file.
#
DLOBJS= plperl\$(DLSUFFIX)

INFILES= \$(DLOBJS) 

SHLIB_EXTRA_LIBS+= $opcode

#
# plus exports files
#
ifdef EXPSUFF
INFILES+= \$(DLOBJS:.o=\$(EXPSUFF))
endif

%.so: %.o
	\$(CC) -o \$@ \$< \$(LDFLAGS) \$(SHLIB_EXTRA_LIBS) \$(LDADD)


#
# Build the shared lib
#
all:	 plperl

plperl : plperl.o
	\$(CC) -o plperl.so plperl.o \$(SHLIB_EXTRA_LIBS) \$(LDADD) \$(LDFLAGS)

%.o : %.c
	\$(CC) -c \$(CFLAGS) \$<


#
# Clean 
#
clean:
	rm -f \$(INFILES) *.o
	rm -rf .libs
	rm -f Makefile

dep depend:

_STATIC_