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