]> granicus.if.org Git - postgresql/blob - src/test/regress/GNUmakefile
Rewrite pg_regress as a C program instead of a shell script.
[postgresql] / src / test / regress / GNUmakefile
1 #-------------------------------------------------------------------------
2 #
3 # GNUmakefile--
4 #    Makefile for src/test/regress (the regression tests)
5 #
6 # Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
7 # Portions Copyright (c) 1994, Regents of the University of California
8 #
9 # $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.58 2006/07/19 02:37:00 tgl Exp $
10 #
11 #-------------------------------------------------------------------------
12
13 subdir = src/test/regress
14 top_builddir = ../../..
15 include $(top_builddir)/src/Makefile.global
16
17 contribdir := $(top_builddir)/contrib
18
19 # port number for temp-installation test postmaster
20 TEMP_PORT = 5$(DEF_PGPORT)
21
22 # default encoding
23 MULTIBYTE = SQL_ASCII
24
25 # maximum simultaneous connections for parallel tests
26 MAXCONNOPT :=
27 ifdef MAX_CONNECTIONS
28 MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS)
29 endif
30
31 # locale
32 NOLOCALE :=
33 ifdef NO_LOCALE
34 NOLOCALE += --no-locale
35 endif
36
37 # stuff to pass into build of pg_regress
38 EXTRADEFS = '-DPGBINDIR="$(bindir)"' \
39         '-DLIBDIR="$(libdir)"' \
40         '-DPGSHAREDIR="$(datadir)"' \
41         '-DHOST_TUPLE="$(host_tuple)"' \
42         '-DMAKEPROG="$(MAKE)"'
43
44 ##
45 ## Prepare for tests
46 ##
47
48 # Build regression test driver
49
50 all: submake-libpgport pg_regress$(X)
51
52 pg_regress$(X): pg_regress.o
53         $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@
54
55 # depend on Makefile.global to ensure that symbol changes propagate
56 pg_regress.o: pg_regress.c $(top_builddir)/src/Makefile.global
57         $(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRADEFS) -c -o $@ $<
58
59 install: pg_regress$(X)
60         $(INSTALL_PROGRAM) pg_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
61
62 uninstall:
63         rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
64
65
66 # Build dynamically-loaded object file for CREATE FUNCTION ... LANGUAGE C.
67
68 NAME = regress
69 SO_MAJOR_VERSION= 0
70 SO_MINOR_VERSION= 0
71 OBJS = regress.o
72 SHLIB_LINK = $(BE_DLLLIBS)
73
74 include $(top_srcdir)/src/Makefile.shlib
75
76 all: $(NAME)$(DLSUFFIX)
77
78 $(NAME)$(DLSUFFIX): $(shlib)
79         rm -f $(NAME)$(DLSUFFIX)
80         $(LN_S) $(shlib) $(NAME)$(DLSUFFIX)
81
82 # Build test input and expected files
83
84 file_list := copy create_function_1 create_function_2 misc constraints tablespace
85 input_files  := $(foreach file, $(file_list), sql/$(file).sql)
86 output_files := $(foreach file, $(file_list), expected/$(file).out)
87
88 all: $(input_files) $(output_files)
89
90 ifneq ($(PORTNAME),win32)
91 abs_srcdir := $(shell cd $(srcdir) && pwd)
92 abs_builddir := $(shell pwd)
93 else
94 abs_srcdir := $(shell cd $(srcdir) && pwd -W)
95 abs_builddir := $(shell pwd -W)
96 endif
97
98 testtablespace := $(abs_builddir)/testtablespace
99
100
101 define sed-command
102 sed -e 's,@abs_srcdir@,$(abs_srcdir),g' \
103     -e 's,@abs_builddir@,$(abs_builddir),g' \
104     -e 's,@testtablespace@,$(testtablespace),g' \
105     -e 's/@DLSUFFIX@/$(DLSUFFIX)/g' $< >$@
106 endef
107
108 $(input_files): sql/%.sql: input/%.source
109         $(sed-command)
110
111 $(output_files): expected/%.out: output/%.source
112         $(sed-command)
113
114 # When doing a VPATH build, copy over the remaining .sql and .out
115 # files so that the driver script can find them.  We have to use an
116 # absolute path for the targets, because otherwise make will try to
117 # locate the missing files using VPATH, and will find them in
118 # $(srcdir), but the point here is that we want to copy them from
119 # $(srcdir) to the build directory.
120
121 ifdef VPATH
122 remaining_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out) $(srcdir)/resultmap
123 remaining_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(remaining_files_src))
124
125 all: $(remaining_files_build)
126 $(remaining_files_build): $(abs_builddir)/%: $(srcdir)/%
127         ln -s $< $@
128 endif
129
130
131 # And finally some extra C modules...
132
133 all: all-spi
134
135 .PHONY: all-spi
136 all-spi:
137         $(MAKE) -C $(contribdir)/spi refint$(DLSUFFIX) autoinc$(DLSUFFIX)
138
139
140 ##
141 ## Run tests
142 ##
143
144 check: all
145         -rm -rf ./testtablespace
146         mkdir ./testtablespace
147         ./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
148
149 installcheck: all
150         -rm -rf ./testtablespace
151         mkdir ./testtablespace
152         ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
153
154 installcheck-parallel: all
155         -rm -rf ./testtablespace
156         mkdir ./testtablespace
157         ./pg_regress --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
158
159
160 # old interfaces follow...
161
162 runcheck: check
163 runtest: installcheck
164 runtest-parallel: installcheck-parallel
165
166 bigtest:
167         ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big 
168
169 bigcheck:
170         ./pg_regress --temp-install=./tmp_check --top-builddir=$(top_builddir) --temp-port=$(TEMP_PORT) --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE) numeric_big
171
172
173 ##
174 ## Clean up
175 ##
176
177 clean distclean maintainer-clean: clean-lib
178 # things built by `all' target
179         rm -f $(NAME)$(DLSUFFIX) $(OBJS)
180         $(MAKE) -C $(contribdir)/spi clean
181         rm -f $(output_files) $(input_files) pg_regress.o pg_regress$(X)
182 # things created by various check targets
183         rm -rf testtablespace
184         rm -rf results tmp_check log
185         rm -f regression.diffs regression.out regress.out run_check.out
186 ifeq ($(PORTNAME), cygwin)
187         rm -f regress.def
188 endif
189 ifdef VPATH
190         rm -f $(remaining_files_build)
191 endif