]> granicus.if.org Git - postgresql/blob - src/Makefile.global.in
Fix typos in comments.
[postgresql] / src / Makefile.global.in
1 # -*-makefile-*-
2 # src/Makefile.global.in
3 # @configure_input@
4
5 #------------------------------------------------------------------------------
6 # All PostgreSQL makefiles include this file and use the variables it sets,
7 # which in turn are put here by the configure script. There is no need for
8 # users to edit this file -- if it turns out to be necessary then that's a
9 # bug.
10 #
11 # A makefile that includes this file needs to set the variable `subdir' to
12 # the relative path from the top to itself and `top_builddir' to the relative
13 # path from itself to the top before including this file. (The "top" is the
14 # parent directory of the directory this file is in.)
15 #------------------------------------------------------------------------------
16
17
18 ##########################################################################
19 #
20 # Meta configuration
21
22 standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check installcheck init-po update-po
23 # these targets should recurse even into subdirectories not being built:
24 standard_always_targets = distprep clean distclean maintainer-clean
25
26 .PHONY: $(standard_targets) install-strip html man installcheck-parallel maintainer-check
27
28 # make `all' the default target
29 all:
30
31 # Delete target files if the command fails after it has
32 # started to update the file.
33 .DELETE_ON_ERROR:
34
35 # Never delete any intermediate files automatically.
36 .SECONDARY:
37
38 # PostgreSQL version number
39 VERSION = @PACKAGE_VERSION@
40 MAJORVERSION = @PG_MAJORVERSION@
41 VERSION_NUM = @PG_VERSION_NUM@
42
43 # Set top_srcdir, srcdir, and VPATH.
44 ifdef PGXS
45 top_srcdir = $(top_builddir)
46
47 # If VPATH is set or Makefile is not in current directory we are building
48 # the extension with VPATH so we set the variable here.
49 ifdef VPATH
50 srcdir = $(VPATH)
51 else
52 ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
53 srcdir = .
54 VPATH =
55 else
56 srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
57 VPATH = $(srcdir)
58 endif
59 endif
60 else # not PGXS
61 vpath_build = @vpath_build@
62 abs_top_builddir = @abs_top_builddir@
63 abs_top_srcdir = @abs_top_srcdir@
64
65 ifneq ($(vpath_build),yes)
66 top_srcdir = $(top_builddir)
67 srcdir = .
68 else # vpath_build = yes
69 top_srcdir = $(abs_top_srcdir)
70 srcdir = $(top_srcdir)/$(subdir)
71 VPATH = $(srcdir)
72 endif
73 endif # not PGXS
74
75 vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
76
77 # Saved arguments from configure
78 configure_args = @configure_args@
79
80
81 ##########################################################################
82 #
83 # Installation directories
84 #
85 # These are set by the equivalent --xxxdir configure options.  We
86 # append "postgresql" to some of them, if the string does not already
87 # contain "pgsql" or "postgres", in order to avoid directory clutter.
88 #
89 # In a PGXS build, we cannot use the values inserted into Makefile.global
90 # by configure, since the installation tree may have been relocated.
91 # Instead get the path values from pg_config.
92
93 ifndef PGXS
94
95 # Note that prefix, exec_prefix, and datarootdir aren't defined in a PGXS build;
96 # makefiles may only use the derived variables such as bindir.
97
98 prefix := @prefix@
99 exec_prefix := @exec_prefix@
100 datarootdir := @datarootdir@
101
102 bindir := @bindir@
103
104 datadir := @datadir@
105 ifeq "$(findstring pgsql, $(datadir))" ""
106 ifeq "$(findstring postgres, $(datadir))" ""
107 override datadir := $(datadir)/postgresql
108 endif
109 endif
110
111 sysconfdir := @sysconfdir@
112 ifeq "$(findstring pgsql, $(sysconfdir))" ""
113 ifeq "$(findstring postgres, $(sysconfdir))" ""
114 override sysconfdir := $(sysconfdir)/postgresql
115 endif
116 endif
117
118 libdir := @libdir@
119
120 pkglibdir = $(libdir)
121 ifeq "$(findstring pgsql, $(pkglibdir))" ""
122 ifeq "$(findstring postgres, $(pkglibdir))" ""
123 override pkglibdir := $(pkglibdir)/postgresql
124 endif
125 endif
126
127 includedir := @includedir@
128
129 pkgincludedir = $(includedir)
130 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
131 ifeq "$(findstring postgres, $(pkgincludedir))" ""
132 override pkgincludedir := $(pkgincludedir)/postgresql
133 endif
134 endif
135
136 mandir := @mandir@
137
138 docdir := @docdir@
139 ifeq "$(findstring pgsql, $(docdir))" ""
140 ifeq "$(findstring postgres, $(docdir))" ""
141 override docdir := $(docdir)/postgresql
142 endif
143 endif
144
145 htmldir := @htmldir@
146
147 localedir := @localedir@
148
149 else # PGXS case
150
151 # Extension makefiles should set PG_CONFIG, but older ones might not
152 ifndef PG_CONFIG
153 PG_CONFIG = pg_config
154 endif
155
156 bindir := $(shell $(PG_CONFIG) --bindir)
157 datadir := $(shell $(PG_CONFIG) --sharedir)
158 sysconfdir := $(shell $(PG_CONFIG) --sysconfdir)
159 libdir := $(shell $(PG_CONFIG) --libdir)
160 pkglibdir := $(shell $(PG_CONFIG) --pkglibdir)
161 includedir := $(shell $(PG_CONFIG) --includedir)
162 pkgincludedir := $(shell $(PG_CONFIG) --pkgincludedir)
163 mandir := $(shell $(PG_CONFIG) --mandir)
164 docdir := $(shell $(PG_CONFIG) --docdir)
165 localedir := $(shell $(PG_CONFIG) --localedir)
166
167 endif # PGXS
168
169 # These derived path variables aren't separately configurable.
170
171 includedir_server = $(pkgincludedir)/server
172 includedir_internal = $(pkgincludedir)/internal
173 pgxsdir = $(pkglibdir)/pgxs
174
175
176 ##########################################################################
177 #
178 # Features
179 #
180 # Records the choice of the various --enable-xxx and --with-xxx options.
181
182 with_perl       = @with_perl@
183 with_python     = @with_python@
184 with_tcl        = @with_tcl@
185 with_openssl    = @with_openssl@
186 with_selinux    = @with_selinux@
187 with_systemd    = @with_systemd@
188 with_libxml     = @with_libxml@
189 with_libxslt    = @with_libxslt@
190 with_system_tzdata = @with_system_tzdata@
191 with_uuid       = @with_uuid@
192 with_zlib       = @with_zlib@
193 enable_rpath    = @enable_rpath@
194 enable_nls      = @enable_nls@
195 enable_debug    = @enable_debug@
196 enable_dtrace   = @enable_dtrace@
197 enable_coverage = @enable_coverage@
198 enable_tap_tests        = @enable_tap_tests@
199 enable_thread_safety    = @enable_thread_safety@
200 enable_strong_random    = @enable_strong_random@
201
202 python_includespec      = @python_includespec@
203 python_libdir           = @python_libdir@
204 python_libspec          = @python_libspec@
205 python_additional_libs  = @python_additional_libs@
206 python_majorversion     = @python_majorversion@
207 python_version          = @python_version@
208
209 krb_srvtab = @krb_srvtab@
210
211 TCLSH                   = @TCLSH@
212 TCL_LIBS                = @TCL_LIBS@
213 TCL_LIB_SPEC            = @TCL_LIB_SPEC@
214 TCL_INCLUDE_SPEC        = @TCL_INCLUDE_SPEC@
215 TCL_SHARED_BUILD        = @TCL_SHARED_BUILD@
216 TCL_SHLIB_LD_LIBS       = @TCL_SHLIB_LD_LIBS@
217
218 PTHREAD_CFLAGS          = @PTHREAD_CFLAGS@
219 PTHREAD_LIBS            = @PTHREAD_LIBS@
220
221
222 ##########################################################################
223 #
224 # Programs and flags
225
226 # Compilers
227
228 CPP = @CPP@
229 CPPFLAGS = @CPPFLAGS@
230
231 ifdef PGXS
232 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
233 else # not PGXS
234 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
235 ifdef VPATH
236 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
237 endif
238 endif # not PGXS
239
240 CC = @CC@
241 GCC = @GCC@
242 SUN_STUDIO_CC = @SUN_STUDIO_CC@
243 CFLAGS = @CFLAGS@
244 CFLAGS_VECTOR = @CFLAGS_VECTOR@
245 CFLAGS_SSE42 = @CFLAGS_SSE42@
246
247 # Kind-of compilers
248
249 BISON = @BISON@
250 BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
251 FLEX = @FLEX@
252 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
253 DTRACE = @DTRACE@
254 DTRACEFLAGS = @DTRACEFLAGS@
255 ZIC = @ZIC@
256
257 # Linking
258
259 AR = @AR@
260 DLLTOOL = @DLLTOOL@
261 DLLWRAP = @DLLWRAP@
262 LIBS = @LIBS@
263 LDAP_LIBS_FE = @LDAP_LIBS_FE@
264 LDAP_LIBS_BE = @LDAP_LIBS_BE@
265 UUID_LIBS = @UUID_LIBS@
266 UUID_EXTRA_OBJS = @UUID_EXTRA_OBJS@
267 LD = @LD@
268 with_gnu_ld = @with_gnu_ld@
269
270 # We want -L for libpgport.a and libpgcommon.a to be first in LDFLAGS.  We
271 # also need LDFLAGS to be a "recursively expanded" variable, else adjustments
272 # to rpathdir don't work right.  So we must NOT do LDFLAGS := something,
273 # meaning this has to be done first and elsewhere we must only do LDFLAGS +=
274 # something.
275 ifdef PGXS
276   LDFLAGS = -L$(libdir)
277 else
278   LDFLAGS = -L$(top_builddir)/src/port -L$(top_builddir)/src/common
279 endif
280 LDFLAGS += @LDFLAGS@
281
282 LDFLAGS_EX = @LDFLAGS_EX@
283 # LDFLAGS_SL might have already been assigned by calling makefile
284 LDFLAGS_SL += @LDFLAGS_SL@
285 LDREL = -r
286 LDOUT = -o
287 RANLIB = @RANLIB@
288 WINDRES = @WINDRES@
289 X = @EXEEXT@
290
291 # Perl
292
293 ifneq (@PERL@,)
294     # quoted to protect pathname with spaces
295     PERL                = '@PERL@'
296 else
297     PERL                = $(missing) perl
298 endif
299 perl_archlibexp         = @perl_archlibexp@
300 perl_privlibexp         = @perl_privlibexp@
301 perl_embed_ldflags      = @perl_embed_ldflags@
302
303 # Miscellaneous
304
305 AWK     = @AWK@
306 LN_S    = @LN_S@
307 MSGFMT  = @MSGFMT@
308 MSGFMT_FLAGS = @MSGFMT_FLAGS@
309 MSGMERGE = @MSGMERGE@
310 PYTHON  = @PYTHON@
311 TAR     = @TAR@
312 XGETTEXT = @XGETTEXT@
313
314 GZIP    = gzip
315 BZIP2   = bzip2
316
317 # Testing
318
319 check: temp-install
320
321 .PHONY: temp-install
322 temp-install:
323 ifndef NO_TEMP_INSTALL
324 ifneq ($(abs_top_builddir),)
325 ifeq ($(MAKELEVEL),0)
326         rm -rf '$(abs_top_builddir)'/tmp_install
327         $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
328         $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
329 endif
330         $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install >>'$(abs_top_builddir)'/tmp_install/log/install.log || exit; done)
331 endif
332 endif
333
334 PROVE = @PROVE@
335 # There are common routines in src/test/perl, and some test suites have
336 # extra perl modules in their own directory.
337 PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/ -I $(srcdir)
338 PROVE_FLAGS = --verbose
339
340 # prepend to path if already set, else just set it
341 define add_to_path
342 $(1)="$(if $($(1)),$(2):$$$(1),$(2))"
343 endef
344
345 # platform-specific environment variable to set shared library path
346 define ld_library_path_var
347 $(if $(filter $(PORTNAME),darwin),DYLD_LIBRARY_PATH,$(if $(filter $(PORTNAME),aix),LIBPATH,$(if $(filter $(PORTNAME),hpux),SHLIB_PATH,LD_LIBRARY_PATH)))
348 endef
349
350 define with_temp_install
351 PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" $(call add_to_path,$(ld_library_path_var),$(abs_top_builddir)/tmp_install$(libdir))
352 endef
353
354 ifeq ($(enable_tap_tests),yes)
355
356 define prove_installcheck
357 rm -rf $(CURDIR)/tmp_check/log
358 cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
359 endef
360
361 define prove_check
362 rm -rf $(CURDIR)/tmp_check/log
363 cd $(srcdir) && TESTDIR='$(CURDIR)' $(with_temp_install) PGPORT='6$(DEF_PGPORT)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
364 endef
365
366 else
367 prove_installcheck = @echo "TAP tests not enabled"
368 prove_check = $(prove_installcheck)
369 endif
370
371 # Installation.
372
373 install_bin = @install_bin@
374 install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c
375 INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh)))
376
377 INSTALL_SCRIPT_MODE     = 755
378 INSTALL_DATA_MODE       = 644
379 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
380 INSTALL_SCRIPT  = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
381 INSTALL_DATA    = $(INSTALL) -m $(INSTALL_DATA_MODE)
382 INSTALL_STLIB   = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
383 INSTALL_SHLIB   = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
384 # Override in Makefile.port if necessary
385 INSTALL_SHLIB_OPTS = -m 755
386
387 MKDIR_P = @MKDIR_P@
388
389 missing         = $(SHELL) $(top_srcdir)/config/missing
390
391 STRIP           = @STRIP@
392 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
393 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
394
395 # Documentation
396
397 have_docbook    = @have_docbook@
398 COLLATEINDEX    = @COLLATEINDEX@
399 DBTOEPUB        = @DBTOEPUB@
400 DOCBOOKSTYLE    = @DOCBOOKSTYLE@
401 JADE                    = @JADE@
402 NSGMLS                  = @NSGMLS@
403 OSX                             = @OSX@
404 XMLLINT                 = @XMLLINT@
405 XSLTPROC                = @XSLTPROC@
406
407 # Code coverage
408
409 GCOV = @GCOV@
410 LCOV = @LCOV@
411 GENHTML = @GENHTML@
412
413 ifeq ($(enable_coverage),yes)
414 # ccache loses .gcno files
415 export CCACHE_DISABLE = 1
416 endif
417
418 # Feature settings
419
420 DEF_PGPORT = @default_port@
421 WANTED_LANGUAGES = @WANTED_LANGUAGES@
422
423
424 ##########################################################################
425 #
426 # Additional platform-specific settings
427 #
428
429 # Name of the "template"
430 PORTNAME= @PORTNAME@
431
432 build_os = @build_os@
433
434 host_tuple = @host@
435 host_os = @host_os@
436 host_cpu = @host_cpu@
437
438 # Make HAVE_IPV6 available for initdb script creation
439 HAVE_IPV6= @HAVE_IPV6@
440
441 # This is mainly for use on FreeBSD, where we have both a.out and elf
442 # systems now.  May be applicable to other systems to?
443 ELF_SYSTEM= @ELF_SYS@
444
445 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
446 WIN32_STACK_RLIMIT=4194304
447
448 # Set if we have a working win32 crashdump header
449 have_win32_dbghelp = @have_win32_dbghelp@
450
451 # Pull in platform-specific magic
452 include $(top_builddir)/src/Makefile.port
453
454 # Set up rpath if enabled.  By default it will point to our libdir,
455 # but individual Makefiles can force other rpath paths if needed.
456 rpathdir = $(libdir)
457
458 ifeq ($(enable_rpath), yes)
459 LDFLAGS += $(rpath)
460 endif
461
462
463 ##########################################################################
464 #
465 # Some variables needed to find some client interfaces
466
467 ifdef PGXS
468 # some contribs assumes headers and libs are in the source tree...
469 libpq_srcdir = $(includedir)
470 libpq_builddir = $(libdir)
471 else
472 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
473 libpq_builddir = $(top_builddir)/src/interfaces/libpq
474 endif
475
476 # This macro is for use by libraries linking to libpq.  (Because libpgport
477 # isn't created with the same link flags as libpq, it can't be used.)
478 libpq = -L$(libpq_builddir) -lpq
479
480 # This macro is for use by client executables (not libraries) that use libpq.
481 # We force clients to pull symbols from the non-shared libraries libpgport
482 # and libpgcommon rather than pulling some libpgport symbols from libpq just
483 # because libpq uses those functions too.  This makes applications less
484 # dependent on changes in libpq's usage of pgport.  To do this we link to
485 # pgport before libpq.  This does cause duplicate -lpgport's to appear
486 # on client link lines.
487 ifdef PGXS
488 libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq)
489 else
490 libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)
491 endif
492
493 # Cygwin seems to need ldap libraries to be mentioned here, too
494 ifeq ($(PORTNAME),cygwin)
495 libpq_pgport += $(LDAP_LIBS_FE)
496 endif
497
498
499 ##########################################################################
500 #
501 # Commonly used submake targets
502
503 submake-libpq:
504         $(MAKE) -C $(libpq_builddir) all
505
506 submake-libpgport:
507         $(MAKE) -C $(top_builddir)/src/port all
508         $(MAKE) -C $(top_builddir)/src/common all
509
510 submake-libpgfeutils:
511         $(MAKE) -C $(top_builddir)/src/port all
512         $(MAKE) -C $(top_builddir)/src/common all
513         $(MAKE) -C $(top_builddir)/src/fe_utils all
514
515 submake-generated-headers:
516         $(MAKE) -C $(top_builddir)/src/backend generated-headers
517
518 .PHONY: submake-libpq submake-libpgport submake-libpgfeutils submake-generated-headers
519
520
521 ##########################################################################
522 #
523 # Testing support
524
525 PL_TESTDB = pl_regression
526 CONTRIB_TESTDB = contrib_regression
527 ifneq ($(MODULE_big),)
528   CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULE_big)
529 else
530   ifneq ($(MODULES),)
531     CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULES)
532   else
533     CONTRIB_TESTDB_MODULE = contrib_regression
534   endif
535 endif
536
537 ifdef NO_LOCALE
538 NOLOCALE += --no-locale
539 endif
540
541 # file with extra config for temp build
542 TEMP_CONF =
543 ifdef TEMP_CONFIG
544 TEMP_CONF += --temp-config=$(TEMP_CONFIG)
545 endif
546
547 pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
548
549 pg_regress_check = $(with_temp_install) $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --temp-instance=./tmp_check $(TEMP_CONF) --bindir= $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
550 pg_regress_installcheck = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --bindir='$(bindir)' $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
551
552 pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ log/
553
554 pg_isolation_regress_check = $(with_temp_install) $(top_builddir)/src/test/isolation/pg_isolation_regress --inputdir=$(srcdir) --temp-instance=./tmp_check $(TEMP_CONF) --bindir= $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
555 pg_isolation_regress_installcheck = $(top_builddir)/src/test/isolation/pg_isolation_regress --inputdir=$(srcdir) $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
556
557 ##########################################################################
558 #
559 # Customization
560 #
561 # This includes your local customizations if Makefile.custom exists
562 # in the source directory.  This file doesn't exist in the original
563 # distribution so that it doesn't get overwritten when you upgrade.
564 #
565 # NOTE:  Makefile.custom is from the pre-Autoconf days of PostgreSQL.
566 # You are liable to shoot yourself in the foot if you use it without
567 # knowing exactly what you're doing.  The preferred (and more
568 # reliable) method is to communicate what you want to do to the
569 # configure script, and leave the makefiles alone.
570
571 -include $(top_srcdir)/src/Makefile.custom
572
573 ifneq ($(CUSTOM_INSTALL),)
574 INSTALL= $(CUSTOM_INSTALL)
575 endif
576
577 ifneq ($(CUSTOM_CC),)
578   CC= $(CUSTOM_CC)
579 endif
580
581 ifneq ($(CUSTOM_COPT),)
582   COPT= $(CUSTOM_COPT)
583 endif
584
585 ifdef COPT
586    CFLAGS += $(COPT)
587    LDFLAGS += $(COPT)
588 endif
589
590 ifdef PROFILE
591    CFLAGS += $(PROFILE)
592    LDFLAGS += $(PROFILE)
593 endif
594
595
596 ##########################################################################
597 #
598 # substitute implementations of C library routines (see src/port/)
599 # note we already included -L.../src/port in LDFLAGS above
600
601 LIBOBJS = @LIBOBJS@
602
603 # files needed for the chosen CRC-32C implementation
604 PG_CRC32C_OBJS = @PG_CRC32C_OBJS@
605
606 LIBS := -lpgcommon -lpgport $(LIBS)
607
608 # to make ws2_32.lib the last library
609 ifeq ($(PORTNAME),win32)
610 LIBS += -lws2_32
611 endif
612
613 # Not really standard libc functions, used by the backend.
614 TAS         = @TAS@
615
616
617 ##########################################################################
618 #
619 # Global targets and rules
620
621 %.c: %.l
622 ifdef FLEX
623         $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
624         @$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
625 else
626         @$(missing) flex $< '$@'
627 endif
628
629 %.c: %.y
630         $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
631 ifdef BISON
632         $(BISON) $(BISONFLAGS) -o $@ $<
633 else
634         @$(missing) bison $< $@
635 endif
636
637 %.i: %.c
638         $(CPP) $(CPPFLAGS) -o $@ $<
639
640 %.gz: %
641         $(GZIP) --best -c $< >$@
642
643 %.bz2: %
644         $(BZIP2) -c $< >$@
645
646 # Direct builds of foo.c -> foo are disabled to avoid generating
647 # *.dSYM junk on Macs.  All builds should normally go through the
648 # foo.c -> foo.o -> foo steps.  This also ensures that dependency
649 # tracking (see below) is used.
650 %: %.c
651
652 ifndef PGXS
653
654 # Remake Makefile.global from Makefile.global.in if the latter
655 # changed. In order to trigger this rule, the including file must
656 # write `include $(top_builddir)/src/Makefile.global', not some
657 # shortcut thereof.
658 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
659         cd $(top_builddir) && ./config.status src/Makefile.global
660
661 # Remake pg_config.h from pg_config.h.in if the latter changed.
662 # config.status will not change the timestamp on pg_config.h if it
663 # doesn't change, so as to avoid recompiling the entire tree
664 # unnecessarily. Therefore we make config.status update a timestamp file
665 # stamp-h every time it runs, so that we don't trigger this rule every time.
666 # (We do trigger the null rule for stamp-h to pg_config.h every time; so it's
667 # important for that rule to be empty!)
668 #
669 # Of course you need to turn on dependency tracking to get any
670 # dependencies on pg_config.h.
671 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
672
673 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
674         cd $(top_builddir) && ./config.status src/include/pg_config.h
675
676 # Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
677 $(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
678
679 $(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
680         cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
681
682 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
683 # logic as above.
684 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
685
686  $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
687         cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
688
689 # When configure changes, rerun configure with the same options as
690 # last time. To change configure, you need to run autoconf manually.
691 $(top_builddir)/config.status: $(top_srcdir)/configure
692         cd $(top_builddir) && ./config.status --recheck
693
694 endif # not PGXS
695
696
697 install-strip:
698 # install-strip always uses install-sh, so that strip options can be
699 # passed.
700         $(MAKE) use_install_sh=yes \
701             INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
702             INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
703             INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
704             INSTALL_STRIP_FLAG=-s \
705             install
706
707
708 ##########################################################################
709 #
710 # Recursive make support
711 # ----------------------
712 # Instead of recursing through subdirectories with a for loop or
713 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
714 # allows parallel make across directories and lets make -k and -q work
715 # correctly.
716
717 # We need the $(eval) function and order-only prerequisites, which are
718 # available in GNU make 3.80.  That also happens to be the version
719 # where the .VARIABLES variable was introduced, so this is a simple check.
720 ifndef .VARIABLES
721 $(error GNU make 3.80 or newer is required.  You are using version $(MAKE_VERSION))
722 endif
723
724 # This function is only for internal use below.  It should be called
725 # using $(eval).  It will set up a target so that it recurses into
726 # a given subdirectory.  Note that to avoid a nasty bug in make 3.80,
727 # this function has to avoid using any complicated constructs (like
728 # multiple targets on a line) and also not contain any lines that expand
729 # to more than about 200 bytes.  This is why we make it apply to just one
730 # subdirectory at a time, rather than to a list of subdirectories.
731 # $1: target name, e.g., all
732 # $2: subdir name
733 # $3: target to run in subdir, usually same as $1
734 define _create_recursive_target
735 .PHONY: $(1)-$(2)-recurse
736 $(1): $(1)-$(2)-recurse
737 $(1)-$(2)-recurse: $(if $(filter check, $(3)), temp-install)
738         $$(MAKE) -C $(2) $(3)
739 endef
740 # Note that the use of $$ on the last line above is important; we want
741 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
742 # to create the rule.  This is necessary to get make -q working.
743
744 # Call this function in a makefile that needs to recurse into subdirectories.
745 # In the normal case all arguments can be defaulted.
746 # $1: targets to make recursive (defaults to list of standard targets)
747 # $2: list of subdirs (defaults to SUBDIRS variable)
748 # $3: target to run in subdir (defaults to current element of $1)
749 recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if $2,$2,$(SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target))))))
750
751 # If a makefile's list of SUBDIRS varies depending on configuration, then
752 # any subdirectories excluded from SUBDIRS should instead be added to
753 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
754 # This ensures that distprep, distclean, etc will apply to all subdirectories.
755 # In the normal case all arguments will be defaulted.
756 # $1: targets to make recursive (defaults to standard_always_targets)
757 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
758 # $3: target to run in subdir (defaults to current element of $1)
759 recurse_always = $(foreach target,$(if $1,$1,$(standard_always_targets)),$(foreach subdir,$(if $2,$2,$(ALWAYS_SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target))))))
760
761
762 ##########################################################################
763 #
764 # Automatic dependency generation
765 # -------------------------------
766 # When we configure with --enable-depend then we override the default
767 # compilation rule with the magic below. While or after creating the
768 # actual output file we also create a dependency list for the .c file.
769 # Next time we invoke make we will have top-notch information about
770 # whether this file needs to be updated. The dependency files are kept
771 # in the .deps subdirectory of each directory.
772
773 autodepend = @autodepend@
774
775 ifeq ($(autodepend), yes)
776
777 ifndef COMPILE.c
778 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
779 endif
780
781 DEPDIR = .deps
782
783 ifeq ($(GCC), yes)
784
785 # GCC allows us to create object and dependency file in one invocation.
786 %.o : %.c
787         @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
788         $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
789
790 endif # GCC
791
792 # Include all the dependency files generated for the current
793 # directory. Note that make would complain if include was called with
794 # no arguments.
795 Po_files := $(wildcard $(DEPDIR)/*.Po)
796 ifneq (,$(Po_files))
797 include $(Po_files)
798 endif
799
800 # hook for clean-up
801 clean distclean maintainer-clean: clean-deps
802
803 .PHONY: clean-deps
804 clean-deps:
805         @rm -rf $(DEPDIR)
806
807 endif # autodepend
808
809
810 ##########################################################################
811 #
812 # Native language support
813
814 ifeq ($(enable_nls), yes)
815 ifneq (,$(wildcard $(srcdir)/nls.mk))
816
817 include $(top_srcdir)/src/nls-global.mk
818
819 endif # nls.mk
820 endif # enable_nls
821
822
823 ##########################################################################
824 #
825 # Coverage
826
827 # Explanation of involved files:
828 #   foo.c       source file
829 #   foo.o       object file
830 #   foo.gcno    gcov graph (a.k.a. "notes") file, created at compile time
831 #               (by gcc -ftest-coverage)
832 #   foo.gcda    gcov data file, created when the program is run (for
833 #               programs compiled with gcc -fprofile-arcs)
834 #   foo.c.gcov  gcov output file with coverage information, created by
835 #               gcov from foo.gcda (by "make coverage")
836 #   foo.c.gcov.out  stdout captured when foo.c.gcov is created, mildly
837 #               interesting
838 #   lcov.info   lcov tracefile, built from gcda files in one directory,
839 #               later collected by "make coverage-html"
840
841 ifeq ($(enable_coverage), yes)
842
843 # There is a strange interaction between lcov and existing .gcov
844 # output files.  Hence the rm command and the ordering dependency.
845
846 gcda_files := $(wildcard *.gcda)
847
848 lcov.info: $(gcda_files)
849         rm -f *.gcov
850         $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV))
851
852 %.c.gcov: %.gcda | lcov.info
853         $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
854
855 coverage: $(gcda_files:.gcda=.c.gcov) lcov.info
856
857 .PHONY: coverage-html
858 coverage-html: coverage
859         rm -rf coverage
860         mkdir coverage
861         $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) `find . -name lcov.info -print`
862
863
864 # hook for clean-up
865 clean distclean maintainer-clean: clean-coverage
866
867 .PHONY: clean-coverage
868 clean-coverage:
869         rm -rf coverage
870         rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out
871
872
873 # User-callable target to reset counts between test runs
874 coverage-clean:
875         rm -f `find . -name '*.gcda' -print`
876
877 endif # enable_coverage