]> granicus.if.org Git - postgresql/blob - src/Makefile.global.in
Clean up CREATE DATABASE processing to make it more robust and get rid
[postgresql] / src / Makefile.global.in
1 # -*-makefile-*-
2 # $PostgreSQL: pgsql/src/Makefile.global.in,v 1.219 2005/08/02 19:02:31 tgl Exp $
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 .PHONY: all install install-strip installdirs uninstall clean distclean maintainer-clean distprep check installcheck maintainer-check
22 .SILENT: installdirs
23
24 # make `all' the default target
25 all:
26
27 # Delete target files if the command fails after it has
28 # started to update the file.
29 .DELETE_ON_ERROR:
30
31 # PostgreSQL version number
32 VERSION = @PACKAGE_VERSION@
33
34 # Support for VPATH builds
35 vpath_build = @vpath_build@
36 abs_top_srcdir = @abs_top_srcdir@
37
38 ifneq ($(vpath_build),yes)
39 top_srcdir = $(top_builddir)
40 srcdir = .
41 else # vpath_build = yes
42 top_srcdir = $(abs_top_srcdir)
43 srcdir = $(top_srcdir)/$(subdir)
44 VPATH = $(srcdir)
45 endif
46
47 # Saved arguments from configure
48 configure_args = @configure_args@
49
50
51 ##########################################################################
52 #
53 # Installation directories
54 #
55 # These are set by the equivalent --xxxdir configure options.  We
56 # append "postgresql" to some of them, if the string does not already
57 # contain "pgsql" or "postgres", in order to avoid directory clutter.
58
59 prefix := @prefix@
60 exec_prefix := @exec_prefix@
61
62 bindir := @bindir@
63 sbindir := @sbindir@
64
65 libexecdir := @libexecdir@
66 ifeq "$(findstring pgsql, $(libexecdir))" ""
67 ifeq "$(findstring postgres, $(libexecdir))" ""
68 override libexecdir := $(libexecdir)/postgresql
69 endif
70 endif
71
72 datadir := @datadir@
73 ifeq "$(findstring pgsql, $(datadir))" ""
74 ifeq "$(findstring postgres, $(datadir))" ""
75 override datadir := $(datadir)/postgresql
76 endif
77 endif
78
79 sysconfdir := @sysconfdir@
80 ifeq "$(findstring pgsql, $(sysconfdir))" ""
81 ifeq "$(findstring postgres, $(sysconfdir))" ""
82 override sysconfdir := $(sysconfdir)/postgresql
83 endif
84 endif
85
86 libdir := @libdir@
87 pkglibdir = $(libdir)
88 ifeq "$(findstring pgsql, $(pkglibdir))" ""
89 ifeq "$(findstring postgres, $(pkglibdir))" ""
90 override pkglibdir := $(pkglibdir)/postgresql
91 endif
92 endif
93
94 includedir := @includedir@
95 pkgincludedir = $(includedir)
96 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
97 ifeq "$(findstring postgres, $(pkgincludedir))" ""
98 override pkgincludedir := $(pkgincludedir)/postgresql
99 endif
100 endif
101 includedir_server = $(pkgincludedir)/server
102 includedir_internal = $(pkgincludedir)/internal
103
104 mandir := @mandir@
105 sqlmansect_dummy = l
106
107 docdir := @docdir@
108 # docdir can be an empty string to signify --without-docdir
109 ifneq (,$(docdir))
110 ifeq "$(findstring pgsql, $(docdir))" ""
111 ifeq "$(findstring postgres, $(docdir))" ""
112 override docdir := $(docdir)/postgresql
113 endif
114 endif
115 endif
116
117 localedir := @localedir@
118
119 pgxsdir = $(pkglibdir)/pgxs
120
121
122 ##########################################################################
123 #
124 # Features
125 #
126 # Records the choice of the various --enable-xxx and --with-xxx options.
127
128 with_perl       = @with_perl@
129 with_python     = @with_python@
130 with_tcl        = @with_tcl@
131 with_openssl    = @with_openssl@
132 with_zlib       = @with_zlib@
133 enable_shared   = @enable_shared@
134 enable_rpath    = @enable_rpath@
135 enable_nls      = @enable_nls@
136 enable_debug    = @enable_debug@
137 enable_thread_safety    = @enable_thread_safety@
138
139 python_includespec      = @python_includespec@
140 python_libdir           = @python_libdir@
141 python_libspec          = @python_libspec@
142 python_additional_libs  = @python_additional_libs@
143 python_configdir        = @python_configdir@
144 python_version          = @python_version@
145
146 krb_srvtab = @krb_srvtab@
147
148 TCLSH                   = @TCLSH@
149 TCL_LIB_FILE            = @TCL_LIB_FILE@
150 TCL_LIBS                = @TCL_LIBS@
151 TCL_LIB_SPEC            = @TCL_LIB_SPEC@
152 TCL_INCLUDE_SPEC        = @TCL_INCLUDE_SPEC@
153 TCL_SHARED_BUILD        = @TCL_SHARED_BUILD@
154 TCL_SHLIB_LD_LIBS       = @TCL_SHLIB_LD_LIBS@
155
156 PTHREAD_CFLAGS          = @PTHREAD_CFLAGS@
157 PTHREAD_LIBS            = @PTHREAD_LIBS@
158
159 have_docbook    = @have_docbook@
160 DOCBOOKSTYLE    = @DOCBOOKSTYLE@
161 COLLATEINDEX    = @COLLATEINDEX@
162
163
164 ##########################################################################
165 #
166 # Programs and flags
167
168 # Compilers
169
170 CPP = @CPP@
171 CPPFLAGS = @CPPFLAGS@
172
173 ifdef PGXS
174 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
175 else # not PGXS
176 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
177 ifdef VPATH
178 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
179 endif
180 endif # not PGXS
181
182 CC = @CC@
183 GCC = @GCC@
184 CFLAGS = @CFLAGS@
185
186 # Kind-of compilers
187
188 YACC = @YACC@
189 YFLAGS = @YFLAGS@
190 FLEX = @FLEX@
191 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
192
193 # Linking
194
195 LIBS = @LIBS@
196 LD = @LD@
197 with_gnu_ld = @with_gnu_ld@
198 ld_R_works = @ld_R_works@
199 LDFLAGS = @LDFLAGS@
200 LDFLAGS_SL = @LDFLAGS_SL@
201 LDREL = -r
202 LDOUT = -o
203 RANLIB = @RANLIB@
204 LORDER = @LORDER@
205 X = @EXEEXT@
206
207 # Perl 
208
209 # quoted for pathname with spaces
210 PERL                    = "@PERL@"
211 perl_archlibexp         = @perl_archlibexp@
212 perl_privlibexp         = @perl_privlibexp@
213 perl_useshrplib         = @perl_useshrplib@
214 perl_embed_ldflags      = @perl_embed_ldflags@
215
216 # Miscellaneous
217
218 AWK     = @AWK@
219 LN_S    = @LN_S@
220 MSGFMT  = @MSGFMT@
221 MSGMERGE = @MSGMERGE@
222 PYTHON  = @PYTHON@
223 TAR     = @TAR@
224 XGETTEXT = @XGETTEXT@
225
226 GZIP    = gzip
227 BZIP2   = bzip2
228
229 PL_TESTDB = pl_regression
230 CONTRIB_TESTDB = contrib_regression
231
232 # Installation.
233
234 INSTALL = $(SHELL) $(top_srcdir)/config/install-sh -c
235
236 INSTALL_SCRIPT_MODE     = 755
237 INSTALL_DATA_MODE       = 644
238 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
239 INSTALL_SCRIPT  = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
240 INSTALL_DATA    = $(INSTALL) -m $(INSTALL_DATA_MODE)
241 INSTALL_STLIB   = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
242 INSTALL_SHLIB   = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
243 # Override in Makefile.port if necessary
244 INSTALL_SHLIB_OPTS = -m 755
245
246 mkinstalldirs   = $(SHELL) $(top_srcdir)/config/mkinstalldirs
247 missing         = $(SHELL) $(top_srcdir)/config/missing
248
249 STRIP           = @STRIP@
250 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
251 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
252
253 # Documentation
254
255 JADE    = @JADE@
256 NSGMLS  = @NSGMLS@
257 SGMLSPL = @SGMLSPL@
258
259 # Feature settings
260
261 DEF_PGPORT = @default_port@
262 WANTED_LANGUAGES = @WANTED_LANGUAGES@
263
264
265 ##########################################################################
266 #
267 # Additional platform-specific settings
268 #
269
270 # Name of the "template"
271 PORTNAME= @PORTNAME@
272
273 host_tuple = @host@
274 host_os = @host_os@
275 host_cpu = @host_cpu@
276
277 # Make HAVE_IPV6 available for initdb script creation
278 HAVE_IPV6= @HAVE_IPV6@
279
280 # The HP-UX port makefile, for one, needs access to this symbol
281 HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
282
283 # This is mainly for use on FreeBSD, where we have both a.out and elf
284 # systems now.  May be applicable to other systems to?
285 ELF_SYSTEM= @ELF_SYS@
286
287 # Pull in platform-specific magic
288 include $(top_builddir)/src/Makefile.port
289
290 # Set up rpath if enabled.  By default it will point to our libdir,
291 # but individual Makefiles can force other rpath paths if needed.
292 rpathdir = $(libdir)
293
294 ifeq ($(enable_rpath), yes)
295 LDFLAGS += $(rpath)
296 endif
297
298
299 ##########################################################################
300 #
301 # Some variables needed to find some client interfaces
302
303 ifdef PGXS
304 # some contribs assumes headers and libs are in the source tree...
305 libpq_srcdir = $(includedir)
306 libpq_builddir = $(libdir)
307 else
308 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
309 libpq_builddir = $(top_builddir)/src/interfaces/libpq
310 endif
311
312 # This is for use for libraries linking to libpq.  Because libpqport
313 # isn't created with the same link flags as libpq, it can't be used.
314 libpq = -L$(libpq_builddir) -lpq
315   
316 # If doing static linking, shared library dependency can't be
317 # used so we specify pthread libs for every usage of libpq
318 ifeq ($(enable_shared), no)
319 libpq += $(PTHREAD_LIBS)
320 else
321 # AIX libraries do not remember their required libs so we have to force
322 # thread dependent libraires in the link
323 ifeq ($(PORTNAME), aix)
324 libpq += $(PTHREAD_LIBS)
325 endif
326 endif
327
328 # Force clients to pull symbols from the non-shared library libpgport 
329 # rather than pulling some libpgport symbols from libpq just because 
330 # libpq uses those functions too.  This makes applications less 
331 # dependent on changes in libpq's usage of pgport.  To do this we link to
332 # pgport before libpq.  This does cause duplicate -lpgport's to appear
333 # on client link lines.
334 ifdef PGXS
335 libpq_pgport = -L$(libdir) -lpgport $(libpq)
336 else
337 libpq_pgport = -L$(top_builddir)/src/port -lpgport $(libpq)
338 endif
339
340
341 submake-libpq:
342         $(MAKE) -C $(libpq_builddir) all
343
344 submake-libpgport:
345         $(MAKE) -C $(top_builddir)/src/port all
346
347 .PHONY: submake-libpq submake-libpgport
348
349
350 ##########################################################################
351 #
352 # Customization
353 #
354 # This includes your local customizations if Makefile.custom exists
355 # in the source directory.  This file doesn't exist in the original
356 # distribution so that it doesn't get overwritten when you upgrade.
357 #
358 # NOTE:  Makefile.custom is from the pre-Autoconf days of PostgreSQL.
359 # You are liable to shoot yourself in the foot if you use it without
360 # knowing exactly what you're doing.  The preferred (and more
361 # reliable) method is to communicate what you want to do to the
362 # configure script, and leave the makefiles alone.
363
364 -include $(top_srcdir)/src/Makefile.custom
365
366 ifneq ($(CUSTOM_INSTALL),)
367 INSTALL= $(CUSTOM_INSTALL)
368 endif
369
370 ifneq ($(CUSTOM_CC),)
371   CC= $(CUSTOM_CC)
372 endif
373
374 ifneq ($(CUSTOM_COPT),)
375   COPT= $(CUSTOM_COPT)
376 endif
377
378 ifdef COPT
379    CFLAGS += $(COPT)
380    LDFLAGS += $(COPT)
381 endif
382
383 ifdef PROFILE
384    CFLAGS += $(PROFILE)
385    LDFLAGS += $(PROFILE)
386 endif
387
388
389 ##########################################################################
390 #
391 # substitute implementations of C library routines (see src/port/)
392
393 LIBOBJS = @LIBOBJS@ copydir.o dirmod.o exec.o noblock.o path.o pipe.o pgsleep.o pgstrcasecmp.o sprompt.o thread.o
394
395 LIBS := -lpgport $(LIBS)
396 # add location of libpgport.a to LDFLAGS
397 ifdef PGXS
398 override LDFLAGS := -L$(libdir) $(LDFLAGS)
399 else
400 override LDFLAGS := -L$(top_builddir)/src/port $(LDFLAGS)
401 endif
402
403 # to make ws2_32.lib the last library, and always link with shfolder,
404 # so SHGetFolderName isn't picked up from shell32.dll
405 ifeq ($(PORTNAME),win32)
406 LIBS += -lws2_32 -lshfolder
407 endif
408
409 # Not really standard libc functions, used by the backend.
410 TAS         = @TAS@
411
412
413 ##########################################################################
414 #
415 # Global targets and rules
416
417 %.gz: %
418         $(GZIP) -f --best $<
419
420 %.bz2: %
421         $(BZIP2) -f $<
422
423 ifeq ($(PORTNAME),win32)
424 # Build rules to add versioninfo resources to win32 binaries
425 WIN32RES += win32ver.o
426 ifeq ($(PGFILESHLIB),1)
427 PGFTYPE=VFT_DLL
428 else
429 PGFTYPE=VFT_APP
430 endif
431 ifneq (,$(PGAPPICON))
432 PGICOSTR=$(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
433 endif
434 win32ver.rc: $(top_builddir)/src/port/win32ver.rc
435         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
436 win32ver.o: $(top_builddir)/src/port/win32ver.rc
437         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
438         windres -i win32ver.rc -o win32ver.o --include-dir=$(top_builddir)/src/include
439         rm -f win32ver.rc
440 endif
441
442 ifndef PGXS
443
444 # Remake Makefile.global from Makefile.global.in if the latter
445 # changed. In order to trigger this rule, the including file must
446 # write `include $(top_builddir)/src/Makefile.global', not some
447 # shortcut thereof.
448 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
449         cd $(top_builddir) && ./config.status src/Makefile.global
450
451 # Remake pg_config.h from pg_config.h.in if the latter changed.
452 # config.status will not change the timestamp on pg_config.h if it
453 # doesn't change, so as to avoid recompiling the entire tree
454 # unnecessarily. Therefore we make config.status update a timestamp file
455 # stamp-h everytime it runs, so that we don't trigger this rule everytime.
456 # (We do trigger the null rule for stamp-h to pg_config.h everytime; so it's
457 # important for that rule to be null!)
458 #
459 # Of course you need to turn on dependency tracking to get any
460 # dependencies on pg_config.h.
461 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h
462
463 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
464         cd $(top_builddir) && ./config.status src/include/pg_config.h
465
466 # When configure changes, rerun configure with the same options as
467 # last time. To change configure, you need to run autoconf manually.
468 $(top_builddir)/config.status: $(top_srcdir)/configure
469         cd $(top_builddir) && ./config.status --recheck
470
471 endif # not PGXS
472
473
474 install-strip:
475         @$(MAKE) INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
476             INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
477             INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
478             INSTALL_STRIP_FLAG=-s \
479             install
480
481
482 ##########################################################################
483 #
484 # Automatic dependency generation
485 # -------------------------------
486 # When we configure with --enable-depend then we override the default
487 # compilation rule with the magic below. While or after creating the
488 # actual output file we also create a dependency list for the .c file.
489 # Next time we invoke make we will have top-notch information about
490 # whether this file needs to be updated. The dependency files are kept
491 # in the .deps subdirectory of each directory.
492 #
493 # The sed command is necessary to post-process the dependency file:
494 # Each dependency file becomes a target of its own, without
495 # dependencies or commands. This is because if you happen to remove a
496 # file that is a dependency (say, you rename a header file) the
497 # dependency would point to a non-existing file and make would fail.
498 # But if the file is listed as a target of its own, without
499 # prerequisites and commands, and doesn't exist then make will
500 # consider it updated. (That in turn also has the nice side effect
501 # that make will update all files that depended on the now removed
502 # file.)
503
504 autodepend = @autodepend@
505
506 ifeq ($(autodepend), yes)
507
508 ifndef COMPILE.c
509 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
510 endif
511
512 DEPDIR = .deps
513 df = $(DEPDIR)/$(*F)
514
515 # This converts a .d file in the current directory to a .P file in the .deps
516 # subdirectory, with the dummy targets as explained above.
517 define postprocess-depend
518 @if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi
519 @cp $*.d $(df).P
520 @sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
521      -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P
522 @rm -f $*.d
523 endef
524
525 ifeq ($(GCC), yes)
526
527 # GCC allows us to create object and dependency file in one invocation.
528 %.o : %.c
529         $(COMPILE.c) -o $@ $< -MMD
530         $(postprocess-depend)
531
532 endif # GCC
533
534 # Include all the dependency files generated for the current
535 # directory. List /dev/null as dummy because if the wildcard expands
536 # to nothing then make would complain.
537 -include $(wildcard $(DEPDIR)/*.P) /dev/null
538
539 # hook for clean-up
540 clean distclean maintainer-clean: clean-deps
541
542 .PHONY: clean-deps
543 clean-deps:
544         @rm -rf $(DEPDIR) *.d
545
546 endif # autodepend
547
548
549 ##########################################################################
550 #
551 # Native language support
552
553 ifeq ($(enable_nls), yes)
554 ifneq (,$(wildcard $(srcdir)/nls.mk))
555
556 include $(top_srcdir)/src/nls-global.mk
557
558 endif # nls.mk
559 endif # enable_nls