]> granicus.if.org Git - postgresql/blob - src/test/regress/GNUmakefile
Make pg_regress.c get paths from pg_config_paths.h, instead of -D
[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.61 2006/07/20 01:16:57 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 = '-DHOST_TUPLE="$(host_tuple)"' \
39         '-DMAKEPROG="$(MAKE)"' \
40         '-DSHELLPROG="$(SHELL)"'
41
42 ##
43 ## Prepare for tests
44 ##
45
46 # Build regression test driver
47
48 all: submake-libpgport pg_regress$(X)
49
50 pg_regress$(X): pg_regress.o
51         $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@
52
53 # dependencies ensure that path changes propagate
54 pg_regress.o: pg_regress.c $(top_builddir)/src/port/pg_config_paths.h
55         $(CC) $(CFLAGS) $(CPPFLAGS) -I$(top_builddir)/src/port $(EXTRADEFS) -c -o $@ $<
56
57 $(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global
58         $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
59
60 install: pg_regress$(X)
61         $(INSTALL_PROGRAM) pg_regress$(X) '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
62
63 uninstall:
64         rm -f '$(DESTDIR)$(pgxsdir)/$(subdir)/pg_regress$(X)'
65
66
67 # Build dynamically-loaded object file for CREATE FUNCTION ... LANGUAGE C.
68
69 NAME = regress
70 SO_MAJOR_VERSION= 0
71 SO_MINOR_VERSION= 0
72 OBJS = regress.o
73 SHLIB_LINK = $(BE_DLLLIBS)
74
75 include $(top_srcdir)/src/Makefile.shlib
76
77 all: $(NAME)$(DLSUFFIX)
78
79 $(NAME)$(DLSUFFIX): $(shlib)
80         rm -f $(NAME)$(DLSUFFIX)
81         $(LN_S) $(shlib) $(NAME)$(DLSUFFIX)
82
83 # Build test input and expected files
84
85 file_list := copy create_function_1 create_function_2 misc constraints tablespace
86 input_files  := $(foreach file, $(file_list), sql/$(file).sql)
87 output_files := $(foreach file, $(file_list), expected/$(file).out)
88
89 all: $(input_files) $(output_files)
90
91 ifneq ($(PORTNAME),win32)
92 abs_srcdir := $(shell cd $(srcdir) && pwd)
93 abs_builddir := $(shell pwd)
94 else
95 abs_srcdir := $(shell cd $(srcdir) && pwd -W)
96 abs_builddir := $(shell pwd -W)
97 endif
98
99 testtablespace := $(abs_builddir)/testtablespace
100
101
102 define sed-command
103 sed -e 's,@abs_srcdir@,$(abs_srcdir),g' \
104     -e 's,@abs_builddir@,$(abs_builddir),g' \
105     -e 's,@testtablespace@,$(testtablespace),g' \
106     -e 's/@DLSUFFIX@/$(DLSUFFIX)/g' $< >$@
107 endef
108
109 $(input_files): sql/%.sql: input/%.source
110         $(sed-command)
111
112 $(output_files): expected/%.out: output/%.source
113         $(sed-command)
114
115 # When doing a VPATH build, copy over the remaining .sql and .out
116 # files so that the driver script can find them.  We have to use an
117 # absolute path for the targets, because otherwise make will try to
118 # locate the missing files using VPATH, and will find them in
119 # $(srcdir), but the point here is that we want to copy them from
120 # $(srcdir) to the build directory.
121
122 ifdef VPATH
123 remaining_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out) $(srcdir)/resultmap
124 remaining_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(remaining_files_src))
125
126 all: $(remaining_files_build)
127 $(remaining_files_build): $(abs_builddir)/%: $(srcdir)/%
128         ln -s $< $@
129 endif
130
131
132 # And finally some extra C modules...
133
134 all: all-spi
135
136 .PHONY: all-spi
137 all-spi:
138         $(MAKE) -C $(contribdir)/spi refint$(DLSUFFIX) autoinc$(DLSUFFIX)
139
140
141 ##
142 ## Run tests
143 ##
144
145 check: all
146         -rm -rf ./testtablespace
147         mkdir ./testtablespace
148         ./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)
149
150 installcheck: all
151         -rm -rf ./testtablespace
152         mkdir ./testtablespace
153         ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE)
154
155 installcheck-parallel: all
156         -rm -rf ./testtablespace
157         mkdir ./testtablespace
158         ./pg_regress --schedule=$(srcdir)/parallel_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(MAXCONNOPT) $(NOLOCALE)
159
160
161 # old interfaces follow...
162
163 runcheck: check
164 runtest: installcheck
165 runtest-parallel: installcheck-parallel
166
167 bigtest:
168         ./pg_regress --schedule=$(srcdir)/serial_schedule --multibyte=$(MULTIBYTE) --load-language=plpgsql $(NOLOCALE) numeric_big 
169
170 bigcheck:
171         ./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
172
173
174 ##
175 ## Clean up
176 ##
177
178 clean distclean maintainer-clean: clean-lib
179 # things built by `all' target
180         rm -f $(NAME)$(DLSUFFIX) $(OBJS)
181         $(MAKE) -C $(contribdir)/spi clean
182         rm -f $(output_files) $(input_files) pg_regress.o pg_regress$(X)
183 # things created by various check targets
184         rm -rf testtablespace
185         rm -rf results tmp_check log
186         rm -f regression.diffs regression.out regress.out run_check.out
187 ifeq ($(PORTNAME), cygwin)
188         rm -f regress.def
189 endif
190 ifdef VPATH
191         rm -f $(remaining_files_build)
192 endif