1#-------------------------------------------------------------------------
2#
3# Makefile for the PL/pgSQL procedural language
4#
5# src/pl/plpgsql/src/Makefile
6#
7#-------------------------------------------------------------------------
8
9subdir = src/pl/plpgsql/src
10top_builddir = ../../../..
11include $(top_builddir)/src/Makefile.global
12
13PGFILEDESC = "PL/pgSQL - procedural language"
14
15# Shared library parameters
16NAME= plpgsql
17
18override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
19SHLIB_LINK = $(filter -lintl, $(LIBS))
20rpath =
21
22OBJS = \
23	$(WIN32RES) \
24	pl_comp.o \
25	pl_exec.o \
26	pl_funcs.o \
27	pl_gram.o \
28	pl_handler.o \
29	pl_scanner.o
30
31DATA = plpgsql.control plpgsql--1.0.sql
32
33REGRESS_OPTS = --dbname=$(PL_TESTDB)
34
35REGRESS = plpgsql_array plpgsql_call plpgsql_control plpgsql_copy plpgsql_domain \
36	plpgsql_record plpgsql_cache plpgsql_simple plpgsql_transaction \
37	plpgsql_trap plpgsql_trigger plpgsql_varprops
38
39# where to find gen_keywordlist.pl and subsidiary files
40TOOLSDIR = $(top_srcdir)/src/tools
41GEN_KEYWORDLIST = $(PERL) -I $(TOOLSDIR) $(TOOLSDIR)/gen_keywordlist.pl
42GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
43
44# Test input and expected files.  These are created by pg_regress itself, so we
45# don't have a rule to create them.  We do need rules to clean them however.
46input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
47output_files := $(patsubst $(srcdir)/output/%.source,expected/%.out, $(wildcard $(srcdir)/output/*.source))
48
49all: all-lib
50
51# Shared library stuff
52include $(top_srcdir)/src/Makefile.shlib
53
54
55install: all install-lib install-data install-headers
56
57installdirs: installdirs-lib
58	$(MKDIR_P) '$(DESTDIR)$(datadir)/extension'
59	$(MKDIR_P) '$(DESTDIR)$(includedir_server)'
60
61uninstall: uninstall-lib uninstall-data uninstall-headers
62
63install-data: installdirs
64	$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
65
66# The plpgsql.h header file is needed by instrumentation plugins
67install-headers: installdirs
68	$(INSTALL_DATA) '$(srcdir)/plpgsql.h' '$(DESTDIR)$(includedir_server)'
69
70uninstall-data:
71	rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
72
73uninstall-headers:
74	rm -f '$(DESTDIR)$(includedir_server)/plpgsql.h'
75
76.PHONY: install-data install-headers uninstall-data uninstall-headers
77
78
79# Force these dependencies to be known even without dependency info built:
80pl_gram.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o pl_scanner.o: plpgsql.h pl_gram.h plerrcodes.h
81pl_scanner.o: pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
82
83# See notes in src/backend/parser/Makefile about the following two rules
84pl_gram.h: pl_gram.c
85	touch $@
86
87pl_gram.c: BISONFLAGS += -d
88
89# generate plerrcodes.h from src/backend/utils/errcodes.txt
90plerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-plerrcodes.pl
91	$(PERL) $(srcdir)/generate-plerrcodes.pl $< > $@
92
93# generate keyword headers for the scanner
94pl_reserved_kwlist_d.h: pl_reserved_kwlist.h $(GEN_KEYWORDLIST_DEPS)
95	$(GEN_KEYWORDLIST) --varname ReservedPLKeywords $<
96
97pl_unreserved_kwlist_d.h: pl_unreserved_kwlist.h $(GEN_KEYWORDLIST_DEPS)
98	$(GEN_KEYWORDLIST) --varname UnreservedPLKeywords $<
99
100
101check: submake
102	$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
103
104installcheck: submake
105	$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
106
107.PHONY: submake
108submake:
109	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
110
111
112distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
113
114# pl_gram.c, pl_gram.h, plerrcodes.h, pl_reserved_kwlist_d.h, and
115# pl_unreserved_kwlist_d.h are in the distribution tarball, so they
116# are not cleaned here.
117clean distclean: clean-lib
118	rm -f $(OBJS)
119	rm -f $(output_files) $(input_files)
120	rm -rf $(pg_regress_clean_files)
121
122maintainer-clean: distclean
123	rm -f pl_gram.c pl_gram.h plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
124