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