]> granicus.if.org Git - postgresql/blob - src/pl/plpython/Makefile
0fb120461cdca15f49c73011fc3d6ef75121870e
[postgresql] / src / pl / plpython / Makefile
1 # $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.30 2008/10/01 22:38:56 petere Exp $
2
3 subdir = src/pl/plpython
4 top_builddir = ../../..
5 include $(top_builddir)/src/Makefile.global
6
7
8 # On some platforms we can only build PL/Python if libpython is a
9 # shared library.  Since there is no official way to determine this
10 # (at least not in pre-2.3 Python), we see if there is a file that is
11 # named like a shared library.
12 ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
13 shared_libpython = yes
14 endif
15
16 # Windows needs to convert backslashed paths to normal slashes,
17 # and we have to remove -lpython from the link since we are building our own
18 ifeq ($(PORTNAME), win32)
19 shared_libpython = yes
20 python_includespec := $(subst \,/,$(python_includespec))
21 override python_libspec =
22 endif
23
24 # Darwin (OS X) has its own ideas about how to do this.
25 ifeq ($(PORTNAME), darwin)
26 shared_libpython = yes
27 override python_libspec = -framework Python
28 override python_additional_libs =
29 endif
30
31 # If we don't have a shared library and the platform doesn't allow it
32 # to work without, we have to skip it.
33 ifneq (,$(findstring yes, $(shared_libpython)$(allow_nonpic_in_shlib)))
34
35 override CPPFLAGS := -I$(srcdir) $(python_includespec) $(CPPFLAGS)
36
37 rpathdir = $(python_libdir)
38
39 NAME = plpython
40 OBJS = plpython.o
41
42
43 # Python on win32 ships with import libraries only for Microsoft Visual C++,
44 # which are not compatible with mingw gcc. Therefore we need to build a
45 # new import library to link with.
46 ifeq ($(PORTNAME), win32)
47 pytverstr=$(subst .,,${python_version})
48 OBJS += libpython${pytverstr}.a
49 libpython${pytverstr}.a: python${pytverstr}.def
50         dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib  libpython${pytverstr}.a
51 WD=$(subst \,/,$(WINDIR))
52 python${pytverstr}.def: $(WD)/system32/python${pytverstr}.dll
53         pexports $(WD)/system32/python${pytverstr}.dll > python${pytverstr}.def
54 endif
55
56
57 SHLIB_LINK = $(python_libspec) $(python_additional_libs)
58
59 REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpythonu
60 REGRESS = plpython_schema plpython_populate plpython_function plpython_test plpython_error plpython_drop
61 # where to find psql for running the tests
62 PSQLDIR = $(bindir)
63
64 include $(top_srcdir)/src/Makefile.shlib
65
66
67 all: all-lib
68
69 install: all installdirs install-lib
70
71 installdirs: installdirs-lib
72
73 uninstall: uninstall-lib
74
75 installcheck: submake
76         $(top_builddir)/src/test/regress/pg_regress --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
77
78 .PHONY: submake
79 submake:
80         $(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
81
82 clean distclean maintainer-clean: clean-lib
83         rm -f $(OBJS)
84         rm -rf results
85         rm -f regression.diffs regression.out
86 ifeq ($(PORTNAME), win32)
87         rm -f python${pytverstr}.def
88 endif
89
90 else # can't build
91
92 all:
93         @echo ""; \
94          echo "*** Cannot build PL/Python because libpython is not a shared library." ; \
95          echo "*** You might have to rebuild your Python installation.  Refer to"; \
96          echo "*** the documentation for details."; \
97          echo ""
98
99 endif # can't build