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