# -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.235 2007/04/15 12:48:23 adunstan Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.254 2009/06/23 03:46:00 tgl Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
#
# Meta configuration
-.PHONY: all install install-strip installdirs uninstall clean distclean maintainer-clean distprep check installcheck maintainer-check
+.PHONY: all install install-strip installdirs uninstall clean distclean maintainer-clean distprep check installcheck maintainer-check coverage
.SILENT: installdirs
# make `all' the default target
# PostgreSQL version number
VERSION = @PACKAGE_VERSION@
+MAJORVERSION = @PG_MAJORVERSION@
# Support for VPATH builds
vpath_build = @vpath_build@
ifndef PGXS
-# Note that prefix and exec_prefix aren't defined in a PGXS build;
+# Note that prefix, exec_prefix, and datarootdir aren't defined in a PGXS build;
# makefiles may only use the derived variables such as bindir.
prefix := @prefix@
exec_prefix := @exec_prefix@
+datarootdir := @datarootdir@
bindir := @bindir@
mandir := @mandir@
docdir := @docdir@
-# docdir can be an empty string to signify --without-docdir
-ifneq (,$(docdir))
ifeq "$(findstring pgsql, $(docdir))" ""
ifeq "$(findstring postgres, $(docdir))" ""
override docdir := $(docdir)/postgresql
endif
endif
-endif
+
+htmldir := @htmldir@
localedir := @localedir@
else # PGXS case
+# Extension makefiles should set PG_CONFIG, but older ones might not
+ifndef PG_CONFIG
PG_CONFIG = pg_config
+endif
bindir := $(shell $(PG_CONFIG) --bindir)
datadir := $(shell $(PG_CONFIG) --sharedir)
includedir_internal = $(pkgincludedir)/internal
pgxsdir = $(pkglibdir)/pgxs
-sqlmansect_dummy = l
-
##########################################################################
#
with_python = @with_python@
with_tcl = @with_tcl@
with_openssl = @with_openssl@
+with_ossp_uuid = @with_ossp_uuid@
with_libxml = @with_libxml@
with_libxslt = @with_libxslt@
+with_system_tzdata = @with_system_tzdata@
with_zlib = @with_zlib@
enable_shared = @enable_shared@
enable_rpath = @enable_rpath@
enable_nls = @enable_nls@
enable_debug = @enable_debug@
enable_dtrace = @enable_dtrace@
+enable_coverage = @enable_coverage@
enable_thread_safety = @enable_thread_safety@
python_includespec = @python_includespec@
have_docbook = @have_docbook@
DOCBOOKSTYLE = @DOCBOOKSTYLE@
COLLATEINDEX = @COLLATEINDEX@
+DOCBOOK2MAN = @DOCBOOK2MAN@
##########################################################################
CC = @CC@
GCC = @GCC@
+SUN_STUDIO_CC = @SUN_STUDIO_CC@
CFLAGS = @CFLAGS@
# Kind-of compilers
-YACC = @YACC@
-YFLAGS = @YFLAGS@
+BISON = @BISON@
+BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
FLEX = @FLEX@
FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
DTRACE = @DTRACE@
DTRACEFLAGS = @DTRACEFLAGS@
+ZIC = @ZIC@
# Linking
+AR = @AR@
+DLLTOOL = @DLLTOOL@
+DLLWRAP = @DLLWRAP@
LIBS = @LIBS@
LDAP_LIBS_FE = @LDAP_LIBS_FE@
LDAP_LIBS_BE = @LDAP_LIBS_BE@
+OSSP_UUID_LIBS = @OSSP_UUID_LIBS@
LD = @LD@
with_gnu_ld = @with_gnu_ld@
ld_R_works = @ld_R_works@
LDREL = -r
LDOUT = -o
RANLIB = @RANLIB@
+WINDRES = @WINDRES@
X = @EXEEXT@
# Perl
-# quoted for pathname with spaces
-PERL = "@PERL@"
+ifneq (@PERL@,)
+ # quoted to protect pathname with spaces
+ PERL = "@PERL@"
+else
+ PERL = $(missing) perl
+endif
perl_archlibexp = @perl_archlibexp@
perl_privlibexp = @perl_privlibexp@
perl_useshrplib = @perl_useshrplib@
NSGMLS = @NSGMLS@
SGMLSPL = @SGMLSPL@
+# Code coverage
+
+GCOV = @GCOV@
+LCOV = @LCOV@
+GENHTML = @GENHTML@
+
+ifeq ($(enable_coverage),yes)
+# ccache loses .gcno files
+export CCACHE_DISABLE = 1
+endif
+
# Feature settings
DEF_PGPORT = @default_port@
# Name of the "template"
PORTNAME= @PORTNAME@
+build_os = @build_os@
+
host_tuple = @host@
host_os = @host_os@
host_cpu = @host_cpu@
#
# substitute implementations of C library routines (see src/port/)
-LIBOBJS = @LIBOBJS@ copydir.o dirmod.o exec.o noblock.o path.o pipe.o pgsleep.o pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o thread.o
+LIBOBJS = @LIBOBJS@
LIBS := -lpgport $(LIBS)
# add location of libpgport.a to LDFLAGS
#
# Global targets and rules
+%.i: %.c
+ $(CPP) $(CPPFLAGS) -o $@ $<
+
%.gz: %
$(GZIP) -f --best $<
%.bz2: %
$(BZIP2) -f $<
-ifeq ($(PORTNAME),win32)
-# Build rules to add versioninfo resources to win32 binaries
-WIN32RES += win32ver.o
-ifeq ($(PGFILESHLIB),1)
-PGFTYPE=VFT_DLL
-else
-PGFTYPE=VFT_APP
-endif
-ifneq (,$(PGAPPICON))
-PGICOSTR=$(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
-endif
-win32ver.rc: $(top_builddir)/src/port/win32ver.rc
- sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0 *$$;\1,'`date '+%y%j' | sed 's/^0*//'`';' $(top_builddir)/src/port/win32ver.rc > win32ver.rc
-win32ver.o: $(top_builddir)/src/port/win32ver.rc
- sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0 *$$;\1,'`date '+%y%j' | sed 's/^0*//'`';' $(top_builddir)/src/port/win32ver.rc > win32ver.rc
- windres -i win32ver.rc -o win32ver.o --include-dir=$(top_builddir)/src/include
- rm -f win32ver.rc
-endif
-
ifndef PGXS
# Remake Makefile.global from Makefile.global.in if the latter
$(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
cd $(top_builddir) && ./config.status src/include/pg_config.h
-# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed. Values in it can
-# only change if pg_config.h has changed, so include this file to its dependencies.
-$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/include/pg_config.h $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
+# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
+# logic as above.
+$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h
+
+ $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
# When configure changes, rerun configure with the same options as
endif # nls.mk
endif # enable_nls
+
+
+##########################################################################
+#
+# Coverage
+
+# Explanation of involved files:
+# foo.c source file
+# foo.o object file
+# foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
+# (by gcc -ftest-coverage)
+# foo.gcda gcov data file, created when the program is run (for
+# programs compiled with gcc -fprofile-arcs)
+# foo.c.gcov gcov output file with coverage information, created by
+# gcov from foo.gcda (by "make coverage")
+# foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
+# interesting
+# lcov.info lcov tracefile, built from gcda files in one directory,
+# later collected by "make coverage-html"
+
+ifeq ($(enable_coverage), yes)
+
+# There is a strange interaction between lcov and existing .gcov
+# output files. Hence the rm command and the ordering dependency.
+
+gcda_files := $(wildcard *.gcda)
+
+lcov.info: $(gcda_files)
+ rm -f *.gcov
+ $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS))
+
+%.c.gcov: %.gcda | lcov.info
+ $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
+
+
+# hook for clean-up
+clean distclean maintainer-clean: clean-coverage
+
+.PHONY: clean-coverage
+clean-coverage:
+ rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out
+
+
+# User-callable target to reset counts between test runs
+coverage-clean:
+ rm -f `find . -name '*.gcda' -print`
+
+endif # enable_coverage