1#-------------------------------------------------------------------------
2#
3# Makefile for the pl/tcl procedural language
4#
5# src/pl/tcl/Makefile
6#
7#-------------------------------------------------------------------------
8
9subdir = src/pl/tcl
10top_builddir = ../../..
11include $(top_builddir)/src/Makefile.global
12
13
14override CPPFLAGS := -I. -I$(srcdir) $(TCL_INCLUDE_SPEC) $(CPPFLAGS)
15
16# On Windows, we don't link directly with the Tcl library; see below
17ifneq ($(PORTNAME), win32)
18SHLIB_LINK = $(TCL_LIB_SPEC) $(TCL_LIBS) -lc
19endif
20
21PGFILEDESC = "PL/Tcl - procedural language"
22
23NAME = pltcl
24
25OBJS = pltcl.o $(WIN32RES)
26
27DATA = pltcl.control pltcl--1.0.sql pltcl--unpackaged--1.0.sql \
28       pltclu.control pltclu--1.0.sql pltclu--unpackaged--1.0.sql
29
30REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=pltcl
31REGRESS = pltcl_setup pltcl_queries pltcl_unicode
32
33# Tcl on win32 ships with import libraries only for Microsoft Visual C++,
34# which are not compatible with mingw gcc. Therefore we need to build a
35# new import library to link with.
36ifeq ($(PORTNAME), win32)
37
38tclwithver = $(subst -l,,$(filter -l%, $(TCL_LIB_SPEC)))
39TCLDLL = $(dir $(TCLSH))/$(tclwithver).dll
40
41OBJS += lib$(tclwithver).a
42
43lib$(tclwithver).a: $(tclwithver).def
44	dlltool --dllname $(tclwithver).dll --def $(tclwithver).def --output-lib lib$(tclwithver).a
45
46$(tclwithver).def: $(TCLDLL)
47	pexports $^ > $@
48
49endif # win32
50
51
52include $(top_srcdir)/src/Makefile.shlib
53
54
55all: all-lib
56	$(MAKE) -C modules $@
57
58# Force this dependency to be known even without dependency info built:
59pltcl.o: pltclerrcodes.h
60
61# generate pltclerrcodes.h from src/backend/utils/errcodes.txt
62pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrcodes.pl
63	$(PERL) $(srcdir)/generate-pltclerrcodes.pl $< > $@
64
65distprep: pltclerrcodes.h
66
67install: all install-lib install-data
68	$(MAKE) -C modules $@
69
70installdirs: installdirs-lib
71	$(MKDIR_P) '$(DESTDIR)$(datadir)/extension'
72	$(MAKE) -C modules $@
73
74uninstall: uninstall-lib uninstall-data
75	$(MAKE) -C modules $@
76
77install-data: installdirs
78	$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
79
80uninstall-data:
81	rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
82
83.PHONY: install-data uninstall-data
84
85
86check: submake
87	$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
88
89installcheck: submake
90	$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
91
92.PHONY: submake
93submake:
94	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
95
96# pltclerrcodes.h is in the distribution tarball, so don't clean it here.
97clean distclean: clean-lib
98	rm -f $(OBJS)
99	rm -rf $(pg_regress_clean_files)
100ifeq ($(PORTNAME), win32)
101	rm -f $(tclwithver).def
102endif
103	$(MAKE) -C modules $@
104
105maintainer-clean: distclean
106	rm -f pltclerrcodes.h
107