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