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