]> granicus.if.org Git - postgresql/blob - configure.in
Stamp 9.4.24.
[postgresql] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl configure.in
3 dnl
4 dnl Developers, please strive to achieve this order:
5 dnl
6 dnl 0. Initialization and options processing
7 dnl 1. Programs
8 dnl 2. Libraries
9 dnl 3. Header files
10 dnl 4. Types
11 dnl 5. Structures
12 dnl 6. Compiler characteristics
13 dnl 7. Functions, global variables
14 dnl 8. System services
15 dnl
16 dnl Read the Autoconf manual for details.
17 dnl
18 m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
19
20 AC_INIT([PostgreSQL], [9.4.24], [pgsql-bugs@postgresql.org])
21
22 m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
23 Untested combinations of 'autoconf' and PostgreSQL versions are not
24 recommended.  You can remove the check from 'configure.in' but it is then
25 your responsibility whether the result works or not.])])
26 AC_COPYRIGHT([Copyright (c) 1996-2014, PostgreSQL Global Development Group])
27 AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
28 AC_CONFIG_AUX_DIR(config)
29 AC_PREFIX_DEFAULT(/usr/local/pgsql)
30 AC_SUBST(configure_args, [$ac_configure_args])
31
32 [PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\.[0-9][0-9]*\)'`]
33 AC_SUBST(PG_MAJORVERSION)
34 AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major version as a string])
35
36 PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
37              [PG_VERSION="$PACKAGE_VERSION$withval"],
38              [PG_VERSION="$PACKAGE_VERSION"])
39 AC_DEFINE_UNQUOTED(PG_VERSION, "$PG_VERSION", [PostgreSQL version as a string])
40
41 AC_CANONICAL_HOST
42
43 template=
44 AC_MSG_CHECKING([which template to use])
45
46 PGAC_ARG_REQ(with, template, [NAME], [override operating system template],
47 [
48   case $withval in
49     list)   echo; ls "$srcdir/src/template"; exit;;
50     *)      if test -f "$srcdir/src/template/$with_template" ; then
51               template=$withval
52             else
53               AC_MSG_ERROR(['$withval' is not a valid template name. Use 'list' for a list.])
54             fi;;
55   esac
56 ],
57 [
58 # --with-template not given
59
60 case $host_os in
61      aix*) template=aix ;;
62   cygwin*) template=cygwin ;;
63   darwin*) template=darwin ;;
64 dragonfly*) template=netbsd ;;
65  freebsd*) template=freebsd ;;
66     hpux*) template=hpux ;;
67  linux*|gnu*|k*bsd*-gnu)
68            template=linux ;;
69    mingw*) template=win32 ;;
70   netbsd*) template=netbsd ;;
71  openbsd*) template=openbsd ;;
72      osf*) template=osf ;;
73      sco*) template=sco ;;
74  solaris*) template=solaris ;;
75    sysv5*) template=unixware ;;
76 esac
77
78   if test x"$template" = x"" ; then
79     AC_MSG_ERROR([[
80 *******************************************************************
81 PostgreSQL has apparently not been ported to your platform yet.
82 To try a manual configuration, look into the src/template directory
83 for a similar platform and use the '--with-template=' option.
84
85 Please also contact <pgsql-bugs@postgresql.org> to see about
86 rectifying this.  Include the above 'checking host system type...'
87 line.
88 *******************************************************************
89 ]])
90   fi
91
92 ])
93
94 AC_MSG_RESULT([$template])
95
96 PORTNAME=$template
97 AC_SUBST(PORTNAME)
98
99 # Initialize default assumption that we do not need separate assembly code
100 # for TAS (test-and-set).  This can be overridden by the template file
101 # when it's executed.
102 need_tas=no
103 tas_file=dummy.s
104
105
106
107 ##
108 ## Command line options
109 ##
110
111 #
112 # Add non-standard directories to the include path
113 #
114 PGAC_ARG_REQ(with, includes, [DIRS], [look for additional header files in DIRS])
115
116
117 #
118 # Add non-standard directories to the library search path
119 #
120 PGAC_ARG_REQ(with, libraries, [DIRS], [look for additional libraries in DIRS],
121              [LIBRARY_DIRS=$withval])
122
123 PGAC_ARG_REQ(with, libs,      [DIRS], [alternative spelling of --with-libraries],
124              [LIBRARY_DIRS=$withval])
125
126
127 #
128 # 64-bit integer date/time storage: enabled by default.
129 #
130 AC_MSG_CHECKING([whether to build with 64-bit integer date/time support])
131 PGAC_ARG_BOOL(enable, integer-datetimes, yes, [disable 64-bit integer date/time support],
132               [AC_DEFINE([USE_INTEGER_DATETIMES], 1,
133                          [Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes)])])
134 AC_MSG_RESULT([$enable_integer_datetimes])
135
136
137 #
138 # NLS
139 #
140 AC_MSG_CHECKING([whether NLS is wanted])
141 PGAC_ARG_OPTARG(enable, nls,
142                 [LANGUAGES], [enable Native Language Support],
143                 [],
144                 [WANTED_LANGUAGES=$enableval],
145                 [AC_DEFINE(ENABLE_NLS, 1,
146                            [Define to 1 if you want National Language Support. (--enable-nls)])])
147 AC_MSG_RESULT([$enable_nls])
148 AC_SUBST(enable_nls)
149 AC_SUBST(WANTED_LANGUAGES)
150
151 #
152 # Default port number (--with-pgport), default 5432
153 #
154 AC_MSG_CHECKING([for default port number])
155 PGAC_ARG_REQ(with, pgport, [PORTNUM], [set default port number [5432]],
156              [default_port=$withval],
157              [default_port=5432])
158 AC_MSG_RESULT([$default_port])
159 # Need both of these because some places want an integer and some a string
160 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port},
161 [Define to the default TCP port number on which the server listens and
162 to which clients will try to connect.  This can be overridden at run-time,
163 but it's convenient if your clients have the right default compiled in.
164 (--with-pgport=PORTNUM)])
165 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
166                    [Define to the default TCP port number as a string constant.])
167 AC_SUBST(default_port)
168
169 #
170 # '-rpath'-like feature can be disabled
171 #
172 PGAC_ARG_BOOL(enable, rpath, yes,
173               [do not embed shared library search path in executables])
174 AC_SUBST(enable_rpath)
175
176 #
177 # Spinlocks
178 #
179 PGAC_ARG_BOOL(enable, spinlocks, yes,
180               [do not use spinlocks])
181
182 #
183 # --enable-debug adds -g to compiler flags
184 #
185 PGAC_ARG_BOOL(enable, debug, no,
186               [build with debugging symbols (-g)])
187 AC_SUBST(enable_debug)
188
189 #
190 # --enable-profiling enables gcc profiling
191 #
192 PGAC_ARG_BOOL(enable, profiling, no,
193               [build with profiling enabled ])
194
195 #
196 # --enable-coverage enables generation of code coverage metrics with gcov
197 #
198 PGAC_ARG_BOOL(enable, coverage, no,
199               [build with coverage testing instrumentation],
200 [AC_CHECK_PROGS(GCOV, gcov)
201 if test -z "$GCOV"; then
202   AC_MSG_ERROR([gcov not found])
203 fi
204 AC_CHECK_PROGS(LCOV, lcov)
205 if test -z "$LCOV"; then
206   AC_MSG_ERROR([lcov not found])
207 fi
208 AC_CHECK_PROGS(GENHTML, genhtml)
209 if test -z "$GENHTML"; then
210   AC_MSG_ERROR([genhtml not found])
211 fi])
212 AC_SUBST(enable_coverage)
213
214 #
215 # DTrace
216 #
217 PGAC_ARG_BOOL(enable, dtrace, no,
218               [build with DTrace support],
219 [AC_CHECK_PROGS(DTRACE, dtrace)
220 if test -z "$DTRACE"; then
221   AC_MSG_ERROR([dtrace not found])
222 fi
223 AC_SUBST(DTRACEFLAGS)])
224 AC_SUBST(enable_dtrace)
225
226 #
227 # TAP tests
228 #
229 PGAC_ARG_BOOL(enable, tap-tests, no,
230               [enable TAP tests (requires Perl and IPC::Run)])
231 AC_SUBST(enable_tap_tests)
232
233 #
234 # Block size
235 #
236 AC_MSG_CHECKING([for block size])
237 PGAC_ARG_REQ(with, blocksize, [BLOCKSIZE], [set table block size in kB [8]],
238              [blocksize=$withval],
239              [blocksize=8])
240 case ${blocksize} in
241   1) BLCKSZ=1024;;
242   2) BLCKSZ=2048;;
243   4) BLCKSZ=4096;;
244   8) BLCKSZ=8192;;
245  16) BLCKSZ=16384;;
246  32) BLCKSZ=32768;;
247   *) AC_MSG_ERROR([Invalid block size. Allowed values are 1,2,4,8,16,32.])
248 esac
249 AC_MSG_RESULT([${blocksize}kB])
250
251 AC_DEFINE_UNQUOTED([BLCKSZ], ${BLCKSZ}, [
252  Size of a disk block --- this also limits the size of a tuple.  You
253  can set it bigger if you need bigger tuples (although TOAST should
254  reduce the need to have large tuples, since fields can be spread
255  across multiple tuples).
256
257  BLCKSZ must be a power of 2.  The maximum possible value of BLCKSZ
258  is currently 2^15 (32768).  This is determined by the 15-bit widths
259  of the lp_off and lp_len fields in ItemIdData (see
260  include/storage/itemid.h).
261
262  Changing BLCKSZ requires an initdb.
263 ])
264
265 #
266 # Relation segment size
267 #
268 AC_MSG_CHECKING([for segment size])
269 PGAC_ARG_REQ(with, segsize, [SEGSIZE], [set table segment size in GB [1]],
270              [segsize=$withval],
271              [segsize=1])
272 # this expression is set up to avoid unnecessary integer overflow
273 # blocksize is already guaranteed to be a factor of 1024
274 RELSEG_SIZE=`expr '(' 1024 / ${blocksize} ')' '*' ${segsize} '*' 1024`
275 test $? -eq 0 || exit 1
276 AC_MSG_RESULT([${segsize}GB])
277
278 AC_DEFINE_UNQUOTED([RELSEG_SIZE], ${RELSEG_SIZE}, [
279  RELSEG_SIZE is the maximum number of blocks allowed in one disk file.
280  Thus, the maximum size of a single file is RELSEG_SIZE * BLCKSZ;
281  relations bigger than that are divided into multiple files.
282
283  RELSEG_SIZE * BLCKSZ must be less than your OS' limit on file size.
284  This is often 2 GB or 4GB in a 32-bit operating system, unless you
285  have large file support enabled.  By default, we make the limit 1 GB
286  to avoid any possible integer-overflow problems within the OS.
287  A limit smaller than necessary only means we divide a large
288  relation into more chunks than necessary, so it seems best to err
289  in the direction of a small limit.
290
291  A power-of-2 value is recommended to save a few cycles in md.c,
292  but is not absolutely required.
293
294  Changing RELSEG_SIZE requires an initdb.
295 ])
296
297 #
298 # WAL block size
299 #
300 AC_MSG_CHECKING([for WAL block size])
301 PGAC_ARG_REQ(with, wal-blocksize, [BLOCKSIZE], [set WAL block size in kB [8]],
302              [wal_blocksize=$withval],
303              [wal_blocksize=8])
304 case ${wal_blocksize} in
305   1) XLOG_BLCKSZ=1024;;
306   2) XLOG_BLCKSZ=2048;;
307   4) XLOG_BLCKSZ=4096;;
308   8) XLOG_BLCKSZ=8192;;
309  16) XLOG_BLCKSZ=16384;;
310  32) XLOG_BLCKSZ=32768;;
311  64) XLOG_BLCKSZ=65536;;
312   *) AC_MSG_ERROR([Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64.])
313 esac
314 AC_MSG_RESULT([${wal_blocksize}kB])
315
316 AC_DEFINE_UNQUOTED([XLOG_BLCKSZ], ${XLOG_BLCKSZ}, [
317  Size of a WAL file block.  This need have no particular relation to BLCKSZ.
318  XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
319  XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
320  buffers, else direct I/O may fail.
321
322  Changing XLOG_BLCKSZ requires an initdb.
323 ])
324
325 #
326 # WAL segment size
327 #
328 AC_MSG_CHECKING([for WAL segment size])
329 PGAC_ARG_REQ(with, wal-segsize, [SEGSIZE], [set WAL segment size in MB [16]],
330              [wal_segsize=$withval],
331              [wal_segsize=16])
332 case ${wal_segsize} in
333   1) ;;
334   2) ;;
335   4) ;;
336   8) ;;
337  16) ;;
338  32) ;;
339  64) ;;
340   *) AC_MSG_ERROR([Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64.])
341 esac
342 AC_MSG_RESULT([${wal_segsize}MB])
343
344 AC_DEFINE_UNQUOTED([XLOG_SEG_SIZE], [(${wal_segsize} * 1024 * 1024)], [
345  XLOG_SEG_SIZE is the size of a single WAL file.  This must be a power of 2
346  and larger than XLOG_BLCKSZ (preferably, a great deal larger than
347  XLOG_BLCKSZ).
348
349  Changing XLOG_SEG_SIZE requires an initdb.
350 ])
351
352 #
353 # C compiler
354 #
355
356 # For historical reasons you can also use --with-CC to specify the C compiler
357 # to use, although the standard way to do this is to set the CC environment
358 # variable.
359 PGAC_ARG_REQ(with, CC, [CMD], [set compiler (deprecated)], [CC=$with_CC])
360
361 case $template in
362   aix) pgac_cc_list="gcc xlc";;
363     *) pgac_cc_list="gcc cc";;
364 esac
365
366 AC_PROG_CC([$pgac_cc_list])
367
368 # Check if it's Intel's compiler, which (usually) pretends to be gcc,
369 # but has idiosyncrasies of its own.  We assume icc will define
370 # __INTEL_COMPILER regardless of CFLAGS.
371 AC_TRY_COMPILE([], [@%:@ifndef __INTEL_COMPILER
372 choke me
373 @%:@endif], [ICC=[yes]], [ICC=[no]])
374
375 # Check if it's Sun Studio compiler. We assume that
376 # __SUNPRO_C will be defined for Sun Studio compilers
377 AC_TRY_COMPILE([], [@%:@ifndef __SUNPRO_C
378 choke me
379 @%:@endif], [SUN_STUDIO_CC=yes], [SUN_STUDIO_CC=no])
380
381 AC_SUBST(SUN_STUDIO_CC)
382
383 unset CFLAGS
384
385 #
386 # Read the template
387 #
388 . "$srcdir/src/template/$template" || exit
389
390 # CFLAGS are selected so:
391 # If the user specifies something in the environment, that is used.
392 # else:  If the template file set something, that is used.
393 # else:  If coverage was enabled, don't set anything.
394 # else:  If the compiler is GCC, then we use -O2.
395 # else:  If the compiler is something else, then we use -O, unless debugging.
396
397 if test "$ac_env_CFLAGS_set" = set; then
398   CFLAGS=$ac_env_CFLAGS_value
399 elif test "${CFLAGS+set}" = set; then
400   : # (keep what template set)
401 elif test "$enable_coverage" = yes; then
402   : # no optimization by default
403 elif test "$GCC" = yes; then
404   CFLAGS="-O2"
405 else
406   # if the user selected debug mode, don't use -O
407   if test "$enable_debug" != yes; then
408     CFLAGS="-O"
409   fi
410 fi
411
412 # CFLAGS we determined above will be added back at the end
413 user_CFLAGS=$CFLAGS
414 CFLAGS=""
415
416 # set CFLAGS_VECTOR from the environment, if available
417 if test "$ac_env_CFLAGS_VECTOR_set" = set; then
418   CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
419 fi
420
421 # Some versions of GCC support some additional useful warning flags.
422 # Check whether they are supported, and add them to CFLAGS if so.
423 # ICC pretends to be GCC but it's lying; it doesn't support these flags,
424 # but has its own.  Also check other compiler-specific flags here.
425
426 if test "$GCC" = yes -a "$ICC" = no; then
427   CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
428   # These work in some but not all gcc versions
429   PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
430   PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
431   PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
432   # This was included in -Wall/-Wformat in older GCC versions
433   PGAC_PROG_CC_CFLAGS_OPT([-Wformat-security])
434   # Disable strict-aliasing rules; needed for gcc 3.3+
435   PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
436   # Disable optimizations that assume no overflow; needed for gcc 4.3+
437   PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
438   # Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
439   PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
440   # Optimization flags for specific files that benefit from vectorization
441   PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
442   PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
443   # We want to suppress clang's unhelpful unused-command-line-argument warnings
444   # but gcc won't complain about unrecognized -Wno-foo switches, so we have to
445   # test for the positive form and if that works, add the negative form
446   NOT_THE_CFLAGS=""
447   PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
448   if test -n "$NOT_THE_CFLAGS"; then
449     CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
450   fi
451   # Similarly disable useless truncation warnings from gcc 8+
452   NOT_THE_CFLAGS=""
453   PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])
454   if test -n "$NOT_THE_CFLAGS"; then
455     CFLAGS="$CFLAGS -Wno-format-truncation"
456   fi
457   NOT_THE_CFLAGS=""
458   PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation])
459   if test -n "$NOT_THE_CFLAGS"; then
460     CFLAGS="$CFLAGS -Wno-stringop-truncation"
461   fi
462 elif test "$ICC" = yes; then
463   # Intel's compiler has a bug/misoptimization in checking for
464   # division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
465   PGAC_PROG_CC_CFLAGS_OPT([-mp1])
466   # Make sure strict aliasing is off (though this is said to be the default)
467   PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
468 elif test "$PORTNAME" = "aix"; then
469   # AIX's xlc has to have strict aliasing turned off too
470   PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias])
471   PGAC_PROG_CC_CFLAGS_OPT([-qlonglong])
472 elif test "$PORTNAME" = "hpux"; then
473   # On some versions of HP-UX, libm functions do not set errno by default.
474   # Fix that by using +Olibmerrno if the compiler recognizes it.
475   PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno])
476 fi
477
478 AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
479
480 # supply -g if --enable-debug
481 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
482   CFLAGS="$CFLAGS -g"
483 fi
484
485 # enable code coverage if --enable-coverage
486 if test "$enable_coverage" = yes; then
487   if test "$GCC" = yes; then
488     CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
489   else
490     AC_MSG_ERROR([--enable-coverage is supported only when using GCC])
491   fi
492 fi
493
494 # enable profiling if --enable-profiling
495 if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
496   if test "$GCC" = yes; then
497     AC_DEFINE([PROFILE_PID_DIR], 1,
498            [Define to 1 to allow profiling output to be saved separately for each process.])
499     CFLAGS="$CFLAGS -pg $PLATFORM_PROFILE_FLAGS"
500   else
501     AC_MSG_ERROR([--enable-profiling is supported only when using GCC])
502   fi
503 fi
504
505 # We already have this in Makefile.win32, but configure needs it too
506 if test "$PORTNAME" = "win32"; then
507   CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
508 fi
509
510 # Now that we're done automatically adding stuff to CFLAGS, put back the
511 # user-specified flags (if any) at the end.  This lets users override
512 # the automatic additions.
513 CFLAGS="$CFLAGS $user_CFLAGS"
514
515 # Check if the compiler still works with the final flag settings
516 AC_MSG_CHECKING([whether the C compiler still works])
517 AC_TRY_LINK([], [return 0;],
518   [AC_MSG_RESULT(yes)],
519   [AC_MSG_RESULT(no)
520    AC_MSG_ERROR([cannot proceed])])
521
522 # Defend against gcc -ffast-math
523 if test "$GCC" = yes; then
524 AC_TRY_COMPILE([], [@%:@ifdef __FAST_MATH__
525 choke me
526 @%:@endif], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
527 fi
528
529 # Defend against clang being used on x86-32 without SSE2 enabled.  As current
530 # versions of clang do not understand -fexcess-precision=standard, the use of
531 # x87 floating point operations leads to problems like isinf possibly returning
532 # false for a value that is infinite when converted from the 80bit register to
533 # the 8byte memory representation.
534 #
535 # Only perform the test if the compiler doesn't understand
536 # -fexcess-precision=standard, that way a potentially fixed compiler will work
537 # automatically.
538 if test "$pgac_cv_prog_cc_cflags__fexcess_precision_standard" = no; then
539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
540 @%:@if defined(__clang__) && defined(__i386__) && !defined(__SSE2_MATH__)
541 choke me
542 @%:@endif
543 ])], [],
544 [AC_MSG_ERROR([Compiling PostgreSQL with clang, on 32bit x86, requires SSE2 support. Use -msse2 or use gcc.])])
545 fi
546
547 AC_PROG_CPP
548 AC_SUBST(GCC)
549
550
551 #
552 # Set up TAS assembly code if needed; the template file has now had its
553 # chance to request this.
554 #
555 AC_CONFIG_LINKS([src/backend/port/tas.s:src/backend/port/tas/${tas_file}])
556
557 if test "$need_tas" = yes ; then
558   TAS=tas.o
559 else
560   TAS=""
561 fi
562 AC_SUBST(TAS)
563
564
565 #
566 # Automatic dependency tracking
567 #
568 PGAC_ARG_BOOL(enable, depend, no, [turn on automatic dependency tracking],
569               [autodepend=yes])
570 AC_SUBST(autodepend)
571
572
573 #
574 # Enable assert checks
575 #
576 PGAC_ARG_BOOL(enable, cassert, no, [enable assertion checks (for debugging)],
577               [AC_DEFINE([USE_ASSERT_CHECKING], 1,
578                          [Define to 1 to build with assertion checks. (--enable-cassert)])])
579
580
581 #
582 # Include directories
583 #
584 ac_save_IFS=$IFS
585 IFS="${IFS}${PATH_SEPARATOR}"
586 # SRCH_INC comes from the template file
587 for dir in $with_includes $SRCH_INC; do
588   if test -d "$dir"; then
589     INCLUDES="$INCLUDES -I$dir"
590   else
591     AC_MSG_WARN([*** Include directory $dir does not exist.])
592   fi
593 done
594 IFS=$ac_save_IFS
595 AC_SUBST(INCLUDES)
596
597
598 #
599 # Library directories
600 #
601 ac_save_IFS=$IFS
602 IFS="${IFS}${PATH_SEPARATOR}"
603 # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
604 for dir in $LIBRARY_DIRS $SRCH_LIB; do
605   if test -d "$dir"; then
606     LIBDIRS="$LIBDIRS -L$dir"
607   else
608     AC_MSG_WARN([*** Library directory $dir does not exist.])
609   fi
610 done
611 IFS=$ac_save_IFS
612
613 #
614 # Enable thread-safe client libraries
615 #
616 AC_MSG_CHECKING([allow thread-safe client libraries])
617 PGAC_ARG_BOOL(enable, thread-safety, yes, [disable thread-safety in client libraries])
618 if test "$enable_thread_safety" = yes; then
619   AC_DEFINE([ENABLE_THREAD_SAFETY], 1,
620           [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])
621 fi
622 AC_MSG_RESULT([$enable_thread_safety])
623 AC_SUBST(enable_thread_safety)
624
625 #
626 # Optionally build Tcl modules (PL/Tcl)
627 #
628 AC_MSG_CHECKING([whether to build with Tcl])
629 PGAC_ARG_BOOL(with, tcl, no, [build Tcl modules (PL/Tcl)])
630 AC_MSG_RESULT([$with_tcl])
631 AC_SUBST([with_tcl])
632
633 # We see if the path to the Tcl/Tk configuration scripts is specified.
634 # This will override the use of tclsh to find the paths to search.
635
636 PGAC_ARG_REQ(with, tclconfig, [DIR], [tclConfig.sh is in DIR])
637
638 #
639 # Optionally build Perl modules (PL/Perl)
640 #
641 AC_MSG_CHECKING([whether to build Perl modules])
642 PGAC_ARG_BOOL(with, perl, no, [build Perl modules (PL/Perl)])
643 AC_MSG_RESULT([$with_perl])
644 AC_SUBST(with_perl)
645
646 #
647 # Optionally build Python modules (PL/Python)
648 #
649 AC_MSG_CHECKING([whether to build Python modules])
650 PGAC_ARG_BOOL(with, python, no, [build Python modules (PL/Python)])
651 AC_MSG_RESULT([$with_python])
652 AC_SUBST(with_python)
653
654 #
655 # GSSAPI
656 #
657 AC_MSG_CHECKING([whether to build with GSSAPI support])
658 PGAC_ARG_BOOL(with, gssapi, no, [build with GSSAPI support],
659 [
660   AC_DEFINE(ENABLE_GSS, 1, [Define to build with GSSAPI support. (--with-gssapi)])
661   krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
662 ])
663 AC_MSG_RESULT([$with_gssapi])
664
665
666 AC_SUBST(krb_srvtab)
667
668
669 #
670 # Kerberos configuration parameters
671 #
672 PGAC_ARG_REQ(with, krb-srvnam,
673              [NAME], [default service principal name in Kerberos (GSSAPI) [postgres]],
674              [],
675              [with_krb_srvnam="postgres"])
676 AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
677                    [Define to the name of the default PostgreSQL service principal in Kerberos (GSSAPI). (--with-krb-srvnam=NAME)])
678
679
680 #
681 # PAM
682 #
683 AC_MSG_CHECKING([whether to build with PAM support])
684 PGAC_ARG_BOOL(with, pam, no,
685               [build with PAM support],
686               [AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])])
687 AC_MSG_RESULT([$with_pam])
688
689
690 #
691 # LDAP
692 #
693 AC_MSG_CHECKING([whether to build with LDAP support])
694 PGAC_ARG_BOOL(with, ldap, no,
695               [build with LDAP support],
696               [AC_DEFINE([USE_LDAP], 1, [Define to 1 to build with LDAP support. (--with-ldap)])])
697 AC_MSG_RESULT([$with_ldap])
698
699
700 #
701 # Bonjour
702 #
703 AC_MSG_CHECKING([whether to build with Bonjour support])
704 PGAC_ARG_BOOL(with, bonjour, no,
705               [build with Bonjour support],
706               [AC_DEFINE([USE_BONJOUR], 1, [Define to 1 to build with Bonjour support. (--with-bonjour)])])
707 AC_MSG_RESULT([$with_bonjour])
708
709
710 #
711 # OpenSSL
712 #
713 AC_MSG_CHECKING([whether to build with OpenSSL support])
714 PGAC_ARG_BOOL(with, openssl, no, [build with OpenSSL support],
715               [AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support. (--with-openssl)])])
716 AC_MSG_RESULT([$with_openssl])
717 AC_SUBST(with_openssl)
718
719 #
720 # SELinux
721 #
722 AC_MSG_CHECKING([whether to build with SELinux support])
723 PGAC_ARG_BOOL(with, selinux, no, [build with SELinux support])
724 AC_SUBST(with_selinux)
725 AC_MSG_RESULT([$with_selinux])
726
727 #
728 # Readline
729 #
730 PGAC_ARG_BOOL(with, readline, yes,
731               [do not use GNU Readline nor BSD Libedit for editing])
732 # readline on MinGW has problems with backslashes in psql and other bugs.
733 # This is particularly a problem with non-US code pages.
734 # Therefore disable its use until we understand the cause. 2004-07-20
735 if test "$PORTNAME" = "win32"; then
736   if test "$with_readline" = yes; then
737     AC_MSG_WARN([*** Readline does not work on MinGW --- disabling])
738     with_readline=no
739   fi
740 fi
741
742
743 #
744 # Prefer libedit
745 #
746 PGAC_ARG_BOOL(with, libedit-preferred, no,
747               [prefer BSD Libedit over GNU Readline])
748
749
750 #
751 # UUID library
752 #
753 # There are at least three UUID libraries in common use: the FreeBSD/NetBSD
754 # library, the e2fsprogs libuuid (now part of util-linux-ng), and the OSSP
755 # UUID library.  More than one of these might be present on a given platform,
756 # so we make the user say which one she wants.
757 #
758 PGAC_ARG_REQ(with, uuid, [LIB], [build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)])
759 if test x"$with_uuid" = x"" ; then
760   with_uuid=no
761 fi
762 PGAC_ARG_BOOL(with, ossp-uuid, no, [obsolete spelling of --with-uuid=ossp])
763 if test "$with_ossp_uuid" = yes ; then
764   with_uuid=ossp
765 fi
766
767 if test "$with_uuid" = bsd ; then
768   AC_DEFINE([HAVE_UUID_BSD], 1, [Define to 1 if you have BSD UUID support.])
769   UUID_EXTRA_OBJS="md5.o sha1.o"
770 elif test "$with_uuid" = e2fs ; then
771   AC_DEFINE([HAVE_UUID_E2FS], 1, [Define to 1 if you have E2FS UUID support.])
772   UUID_EXTRA_OBJS="md5.o sha1.o"
773 elif test "$with_uuid" = ossp ; then
774   AC_DEFINE([HAVE_UUID_OSSP], 1, [Define to 1 if you have OSSP UUID support.])
775   UUID_EXTRA_OBJS=""
776 elif test "$with_uuid" = no ; then
777   UUID_EXTRA_OBJS=""
778 else
779   AC_MSG_ERROR([--with-uuid must specify one of bsd, e2fs, or ossp])
780 fi
781 AC_SUBST(with_uuid)
782 AC_SUBST(UUID_EXTRA_OBJS)
783
784
785 #
786 # XML
787 #
788 PGAC_ARG_BOOL(with, libxml, no, [build with XML support],
789               [AC_DEFINE([USE_LIBXML], 1, [Define to 1 to build with XML support. (--with-libxml)])])
790
791 if test "$with_libxml" = yes ; then
792   AC_CHECK_PROGS(XML2_CONFIG, xml2-config)
793   if test -n "$XML2_CONFIG"; then
794     for pgac_option in `$XML2_CONFIG --cflags`; do
795       case $pgac_option in
796         -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
797       esac
798     done
799     for pgac_option in `$XML2_CONFIG --libs`; do
800       case $pgac_option in
801         -L*) LDFLAGS="$LDFLAGS $pgac_option";;
802       esac
803     done
804   fi
805 fi
806
807 AC_SUBST(with_libxml)
808
809 #
810 # XSLT
811 #
812 PGAC_ARG_BOOL(with, libxslt, no, [use XSLT support when building contrib/xml2],
813               [AC_DEFINE([USE_LIBXSLT], 1, [Define to 1 to use XSLT support when building contrib/xml2. (--with-libxslt)])])
814
815
816 AC_SUBST(with_libxslt)
817
818 #
819 # tzdata
820 #
821 PGAC_ARG_REQ(with, system-tzdata,
822              [DIR], [use system time zone data in DIR])
823 AC_SUBST(with_system_tzdata)
824
825 #
826 # Zlib
827 #
828 PGAC_ARG_BOOL(with, zlib, yes,
829               [do not use Zlib])
830 AC_SUBST(with_zlib)
831
832 #
833 # Elf
834 #
835
836 # Assume system is ELF if it predefines __ELF__ as 1,
837 # otherwise believe host_os based default.
838 case $host_os in
839     freebsd1*|freebsd2*) elf=no;;
840     freebsd3*|freebsd4*) elf=yes;;
841 esac
842
843 AC_EGREP_CPP(yes,
844 [#if __ELF__
845   yes
846 #endif
847 ],
848 [ELF_SYS=true],
849 [if test "X$elf" = "Xyes" ; then
850   ELF_SYS=true
851 else
852   ELF_SYS=
853 fi])
854 AC_SUBST(ELF_SYS)
855
856 #
857 # Assignments
858 #
859
860 CPPFLAGS="$CPPFLAGS $INCLUDES"
861 LDFLAGS="$LDFLAGS $LIBDIRS"
862
863 AC_ARG_VAR(LDFLAGS_EX, [extra linker flags for linking executables only])
864 AC_ARG_VAR(LDFLAGS_SL, [extra linker flags for linking shared libraries only])
865
866 PGAC_PROG_LD
867 AC_SUBST(LD)
868 AC_SUBST(with_gnu_ld)
869 case $host_os in sysv5*)
870   AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
871   [
872     pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,-R/usr/lib"
873     AC_TRY_LINK([], [], [pgac_cv_prog_ld_R=yes], [pgac_cv_prog_ld_R=no])
874     LDFLAGS=$pgac_save_LDFLAGS
875   ])
876   ld_R_works=$pgac_cv_prog_ld_R
877   AC_SUBST(ld_R_works)
878 esac
879 AC_PROG_RANLIB
880 PGAC_CHECK_STRIP
881 AC_CHECK_TOOL(AR, ar, ar)
882 if test "$PORTNAME" = "win32"; then
883   AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool)
884   AC_CHECK_TOOL(DLLWRAP, dllwrap, dllwrap)
885   AC_CHECK_TOOL(WINDRES, windres, windres)
886 fi
887
888 AC_PROG_INSTALL
889 # When Autoconf chooses install-sh as install program it tries to generate
890 # a relative path to it in each makefile where it substitutes it. This clashes
891 # with our Makefile.global concept. This workaround helps.
892 case $INSTALL in
893   *install-sh*) install_bin='';;
894   *) install_bin=$INSTALL;;
895 esac
896 AC_SUBST(install_bin)
897
898 AC_PATH_PROG(TAR, tar)
899 AC_PROG_LN_S
900 AC_PROG_AWK
901 AC_PROG_MKDIR_P
902 # When Autoconf chooses install-sh as mkdir -p program it tries to generate
903 # a relative path to it in each makefile where it substitutes it. This clashes
904 # with our Makefile.global concept. This workaround helps.
905 case $MKDIR_P in
906   *install-sh*) MKDIR_P='\${SHELL} \${top_srcdir}/config/install-sh -c -d';;
907 esac
908
909 PGAC_PATH_BISON
910 PGAC_PATH_FLEX
911
912 PGAC_PATH_PERL
913 if test "$with_perl" = yes; then
914   if test -z "$PERL"; then
915     AC_MSG_ERROR([Perl not found])
916   fi
917   PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
918   # On most platforms, archlibexp is also where the Perl include files live ...
919   perl_includespec="-I$perl_archlibexp/CORE"
920   # ... but on newer macOS versions, we must use -iwithsysroot to look
921   # under $PG_SYSROOT
922   if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
923     if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
924       perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
925     fi
926   fi
927   AC_SUBST(perl_includespec)dnl
928   PGAC_CHECK_PERL_EMBED_CCFLAGS
929   PGAC_CHECK_PERL_EMBED_LDFLAGS
930 fi
931
932 if test "$with_python" = yes; then
933   PGAC_PATH_PYTHON
934   PGAC_CHECK_PYTHON_EMBED_SETUP
935 fi
936
937 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
938   AC_PATH_PROG(ZIC, zic)
939   if test -z "$ZIC"; then
940     AC_MSG_ERROR([
941 When cross-compiling, either use the option --with-system-tzdata to use
942 existing time-zone data, or set the environment variable ZIC to a zic
943 program to use during the build.])
944   fi
945 fi
946
947 #
948 # Pthreads
949 #
950 # For each platform, we need to know about any special compile and link
951 # libraries, and whether the normal C function names are thread-safe.
952 # See the comment at the top of src/port/thread.c for more information.
953 # WIN32 doesn't need the pthread tests;  it always uses threads
954 #
955 # These tests are run before the library-tests, because linking with the
956 # other libraries can pull in the pthread functions as a side-effect.  We
957 # want to use the -pthread or similar flags directly, and not rely on
958 # the side-effects of linking with some other library.
959 #
960 # note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER
961 # invocation below is the first one in the script, and autoconf generates
962 # additional code for that, which must not be inside the if-block. AS_IF
963 # knows how to do that.
964 AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"],
965 [ # then
966 AX_PTHREAD      # set thread flags
967
968 # Some platforms use these, so just define them.  They can't hurt if they
969 # are not supported.  For example, on Solaris -D_POSIX_PTHREAD_SEMANTICS
970 # enables 5-arg getpwuid_r, among other things.
971 PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
972
973 # Check for *_r functions
974 _CFLAGS="$CFLAGS"
975 _LIBS="$LIBS"
976 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
977 LIBS="$LIBS $PTHREAD_LIBS"
978
979 AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
980 pthread.h not found;  use --disable-thread-safety to disable thread safety])])
981
982 AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
983
984 # Do test here with the proper thread flags
985 PGAC_FUNC_GETPWUID_R_5ARG
986 PGAC_FUNC_STRERROR_R_INT
987
988 CFLAGS="$_CFLAGS"
989 LIBS="$_LIBS"
990
991 ], [ # else
992 # do not use values from template file
993 PTHREAD_CFLAGS=
994 PTHREAD_LIBS=
995 ]) # fi
996
997 AC_SUBST(PTHREAD_CFLAGS)
998 AC_SUBST(PTHREAD_LIBS)
999
1000
1001 ##
1002 ## Libraries
1003 ##
1004 ## Most libraries are included only if they demonstrably provide a function
1005 ## we need, but libm is an exception: always include it, because there are
1006 ## too many compilers that play cute optimization games that will break
1007 ## probes for standard functions such as pow().
1008 ##
1009
1010 AC_CHECK_LIB(m, main)
1011 AC_SEARCH_LIBS(setproctitle, util)
1012 AC_SEARCH_LIBS(dlopen, dl)
1013 AC_SEARCH_LIBS(socket, [socket wsock32])
1014 AC_SEARCH_LIBS(shl_load, dld)
1015 # We only use libld in port/dynloader/aix.c
1016 case $host_os in
1017      aix*)
1018         AC_SEARCH_LIBS(ldopen, ld)
1019         ;;
1020 esac
1021 AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
1022 AC_SEARCH_LIBS(crypt, crypt)
1023 AC_SEARCH_LIBS(shm_open, rt)
1024 AC_SEARCH_LIBS(shm_unlink, rt)
1025 # Solaris:
1026 AC_SEARCH_LIBS(fdatasync, [rt posix4])
1027 # Required for thread_test.c on Solaris
1028 AC_SEARCH_LIBS(sched_yield, rt)
1029 # Required for thread_test.c on Solaris 2.5:
1030 # Other ports use it too (HP-UX) so test unconditionally
1031 AC_SEARCH_LIBS(gethostbyname_r, nsl)
1032 # Cygwin:
1033 AC_SEARCH_LIBS(shmget, cygipc)
1034
1035 if test "$with_readline" = yes; then
1036   PGAC_CHECK_READLINE
1037   if test x"$pgac_cv_check_readline" = x"no"; then
1038     AC_MSG_ERROR([readline library not found
1039 If you have readline already installed, see config.log for details on the
1040 failure.  It is possible the compiler isn't looking in the proper directory.
1041 Use --without-readline to disable readline support.])
1042   fi
1043 fi
1044
1045 if test "$with_zlib" = yes; then
1046   AC_CHECK_LIB(z, inflate, [],
1047                [AC_MSG_ERROR([zlib library not found
1048 If you have zlib already installed, see config.log for details on the
1049 failure.  It is possible the compiler isn't looking in the proper directory.
1050 Use --without-zlib to disable zlib support.])])
1051 fi
1052
1053 if test "$enable_spinlocks" = yes; then
1054   AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
1055 else
1056   AC_MSG_WARN([
1057 *** Not using spinlocks will cause poor performance.])
1058 fi
1059
1060 if test "$with_gssapi" = yes ; then
1061   if test "$PORTNAME" != "win32"; then
1062     AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
1063                    [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
1064   else
1065     LIBS="$LIBS -lgssapi32"
1066   fi
1067 fi
1068
1069 if test "$with_openssl" = yes ; then
1070   dnl Order matters!
1071   if test "$PORTNAME" != "win32"; then
1072      AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
1073      AC_CHECK_LIB(ssl,    SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
1074   else
1075      AC_SEARCH_LIBS(CRYPTO_new_ex_data, [eay32 crypto], [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
1076      AC_SEARCH_LIBS(SSL_new, [ssleay32 ssl], [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
1077   fi
1078   AC_CHECK_FUNCS([SSL_get_current_compression])
1079   # Functions introduced in OpenSSL 1.1.0. We used to check for
1080   # OPENSSL_VERSION_NUMBER, but that didn't work with 1.1.0, because LibreSSL
1081   # defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
1082   # doesn't have these OpenSSL 1.1.0 functions. So check for individual
1083   # functions.
1084   AC_CHECK_FUNCS([OPENSSL_init_ssl BIO_meth_new ASN1_STRING_get0_data RAND_OpenSSL])
1085   # OpenSSL versions before 1.1.0 required setting callback functions, for
1086   # thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
1087   # function was removed.
1088   AC_CHECK_FUNCS([CRYPTO_lock])
1089 fi
1090
1091 if test "$with_pam" = yes ; then
1092   AC_CHECK_LIB(pam,    pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])])
1093 fi
1094
1095 if test "$with_libxml" = yes ; then
1096   AC_CHECK_LIB(xml2, xmlSaveToBuffer, [], [AC_MSG_ERROR([library 'xml2' (version >= 2.6.23) is required for XML support])])
1097 fi
1098
1099 if test "$with_libxslt" = yes ; then
1100   AC_CHECK_LIB(xslt, xsltCleanupGlobals, [], [AC_MSG_ERROR([library 'xslt' is required for XSLT support])])
1101 fi
1102
1103 # Note: We can test for libldap_r only after we know PTHREAD_LIBS
1104 if test "$with_ldap" = yes ; then
1105   _LIBS="$LIBS"
1106   if test "$PORTNAME" != "win32"; then
1107     AC_CHECK_LIB(ldap, ldap_bind, [],
1108                  [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
1109                  [$EXTRA_LDAP_LIBS])
1110     LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
1111     if test "$enable_thread_safety" = yes; then
1112       # on some platforms ldap_r fails to link without PTHREAD_LIBS
1113       AC_CHECK_LIB(ldap_r, ldap_simple_bind, [],
1114                    [AC_MSG_ERROR([library 'ldap_r' is required for LDAP])],
1115                    [$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
1116       LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
1117     else
1118       LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
1119     fi
1120   else
1121     AC_CHECK_LIB(wldap32, ldap_bind, [], [AC_MSG_ERROR([library 'wldap32' is required for LDAP])])
1122     LDAP_LIBS_FE="-lwldap32"
1123     LDAP_LIBS_BE="-lwldap32"
1124   fi
1125   LIBS="$_LIBS"
1126 fi
1127 AC_SUBST(LDAP_LIBS_FE)
1128 AC_SUBST(LDAP_LIBS_BE)
1129
1130 # for contrib/sepgsql
1131 if test "$with_selinux" = yes; then
1132   AC_CHECK_LIB(selinux, security_compute_create_name, [],
1133                [AC_MSG_ERROR([library 'libselinux', version 2.1.10 or newer, is required for SELinux support])])
1134 fi
1135
1136 # for contrib/uuid-ossp
1137 if test "$with_uuid" = bsd ; then
1138   # On BSD, the UUID functions are in libc
1139   AC_CHECK_FUNC(uuid_to_string,
1140     [UUID_LIBS=""],
1141     [AC_MSG_ERROR([BSD UUID functions are not present])])
1142 elif test "$with_uuid" = e2fs ; then
1143   # On OS X, the UUID functions are in libc
1144   AC_CHECK_FUNC(uuid_generate,
1145     [UUID_LIBS=""],
1146     [AC_CHECK_LIB(uuid, uuid_generate,
1147       [UUID_LIBS="-luuid"],
1148       [AC_MSG_ERROR([library 'uuid' is required for E2FS UUID])])])
1149 elif test "$with_uuid" = ossp ; then
1150   AC_CHECK_LIB(ossp-uuid, uuid_export,
1151     [UUID_LIBS="-lossp-uuid"],
1152     [AC_CHECK_LIB(uuid, uuid_export,
1153       [UUID_LIBS="-luuid"],
1154       [AC_MSG_ERROR([library 'ossp-uuid' or 'uuid' is required for OSSP UUID])])])
1155 fi
1156 AC_SUBST(UUID_LIBS)
1157
1158
1159 ##
1160 ## Header files
1161 ##
1162
1163 dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES
1164 AC_CHECK_HEADERS([crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h poll.h pwd.h sys/ioctl.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/socket.h sys/sockio.h sys/tas.h sys/time.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h])
1165
1166 # On BSD, test for net/if.h will fail unless sys/socket.h
1167 # is included first.
1168 AC_CHECK_HEADERS(net/if.h, [], [],
1169 [AC_INCLUDES_DEFAULT
1170 #ifdef HAVE_SYS_SOCKET_H
1171 #include <sys/socket.h>
1172 #endif
1173 ])
1174
1175 # On OpenBSD, test for sys/ucred.h will fail unless sys/param.h
1176 # is included first.
1177 AC_CHECK_HEADERS(sys/ucred.h, [], [],
1178 [AC_INCLUDES_DEFAULT
1179 #include <sys/param.h>
1180 ])
1181
1182 # At least on IRIX, test for netinet/tcp.h will fail unless
1183 # netinet/in.h is included first.
1184 AC_CHECK_HEADERS(netinet/in.h)
1185 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
1186 [AC_INCLUDES_DEFAULT
1187 #ifdef HAVE_NETINET_IN_H
1188 #include <netinet/in.h>
1189 #endif
1190 ])
1191
1192 if expr x"$pgac_cv_check_readline" : 'x-lreadline' >/dev/null ; then
1193   AC_CHECK_HEADERS(readline/readline.h, [],
1194         [AC_CHECK_HEADERS(readline.h, [],
1195                 [AC_MSG_ERROR([readline header not found
1196 If you have readline already installed, see config.log for details on the
1197 failure.  It is possible the compiler isn't looking in the proper directory.
1198 Use --without-readline to disable readline support.])])])
1199   AC_CHECK_HEADERS(readline/history.h, [],
1200         [AC_CHECK_HEADERS(history.h, [],
1201                 [AC_MSG_ERROR([history header not found
1202 If you have readline already installed, see config.log for details on the
1203 failure.  It is possible the compiler isn't looking in the proper directory.
1204 Use --without-readline to disable readline support.])])])
1205 fi
1206
1207 if expr x"$pgac_cv_check_readline" : 'x-ledit' >/dev/null ; then
1208 # Some installations of libedit usurp /usr/include/readline/, which seems
1209 # bad practice, since in combined installations readline will have its headers
1210 # there.  We might have to resort to AC_EGREP checks to make sure we found
1211 # the proper header...
1212   AC_CHECK_HEADERS(editline/readline.h, [],
1213         [AC_CHECK_HEADERS(readline.h, [],
1214                 [AC_CHECK_HEADERS(readline/readline.h, [],
1215                         [AC_MSG_ERROR([readline header not found
1216 If you have libedit already installed, see config.log for details on the
1217 failure.  It is possible the compiler isn't looking in the proper directory.
1218 Use --without-readline to disable libedit support.])])])])
1219 # Note: in a libedit installation, history.h is sometimes a dummy, and may
1220 # not be there at all.  Hence, don't complain if not found.  We must check
1221 # though, since in yet other versions it is an independent header.
1222   AC_CHECK_HEADERS(editline/history.h, [],
1223         [AC_CHECK_HEADERS(history.h, [],
1224                 [AC_CHECK_HEADERS(readline/history.h)])])
1225 fi
1226
1227 if test "$with_zlib" = yes; then
1228   AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found
1229 If you have zlib already installed, see config.log for details on the
1230 failure.  It is possible the compiler isn't looking in the proper directory.
1231 Use --without-zlib to disable zlib support.])])
1232 fi
1233
1234 if test "$with_gssapi" = yes ; then
1235   AC_CHECK_HEADERS(gssapi/gssapi.h, [],
1236         [AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
1237 fi
1238
1239 if test "$with_openssl" = yes ; then
1240   AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
1241   AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
1242 fi
1243
1244 if test "$with_pam" = yes ; then
1245   AC_CHECK_HEADERS(security/pam_appl.h, [],
1246                    [AC_CHECK_HEADERS(pam/pam_appl.h, [],
1247                                      [AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])])
1248 fi
1249
1250 if test "$with_libxml" = yes ; then
1251   AC_CHECK_HEADER(libxml/parser.h, [], [AC_MSG_ERROR([header file <libxml/parser.h> is required for XML support])])
1252 fi
1253
1254 if test "$with_libxslt" = yes ; then
1255   AC_CHECK_HEADER(libxslt/xslt.h, [], [AC_MSG_ERROR([header file <libxslt/xslt.h> is required for XSLT support])])
1256 fi
1257
1258 # PGAC_LDAP_SAFE
1259 # --------------
1260 # PostgreSQL sometimes loads libldap_r and plain libldap into the same
1261 # process.  Check for OpenLDAP versions known not to tolerate doing so; assume
1262 # non-OpenLDAP implementations are safe.  The dblink test suite exercises the
1263 # hazardous interaction directly.
1264
1265 AC_DEFUN([PGAC_LDAP_SAFE],
1266 [AC_CACHE_CHECK([for compatible LDAP implementation], [pgac_cv_ldap_safe],
1267 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1268 [#include <ldap.h>
1269 #if !defined(LDAP_VENDOR_VERSION) || \
1270      (defined(LDAP_API_FEATURE_X_OPENLDAP) && \
1271       LDAP_VENDOR_VERSION >= 20424 && LDAP_VENDOR_VERSION <= 20431)
1272 choke me
1273 #endif], [])],
1274 [pgac_cv_ldap_safe=yes],
1275 [pgac_cv_ldap_safe=no])])
1276
1277 if test "$pgac_cv_ldap_safe" != yes; then
1278   AC_MSG_WARN([
1279 *** With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, each backend
1280 *** process that loads libpq (via WAL receiver, dblink, or postgres_fdw) and
1281 *** also uses LDAP will crash on exit.])
1282 fi])
1283
1284
1285
1286 if test "$with_ldap" = yes ; then
1287   if test "$PORTNAME" != "win32"; then
1288      AC_CHECK_HEADERS(ldap.h, [],
1289                       [AC_MSG_ERROR([header file <ldap.h> is required for LDAP])])
1290      PGAC_LDAP_SAFE
1291   else
1292      AC_CHECK_HEADERS(winldap.h, [],
1293                       [AC_MSG_ERROR([header file <winldap.h> is required for LDAP])],
1294                       [AC_INCLUDES_DEFAULT
1295 #include <windows.h>
1296                       ])
1297   fi
1298 fi
1299
1300 if test "$with_bonjour" = yes ; then
1301   AC_CHECK_HEADER(dns_sd.h, [], [AC_MSG_ERROR([header file <dns_sd.h> is required for Bonjour])])
1302 dnl At some point we might add something like
1303 dnl AC_SEARCH_LIBS(DNSServiceRegister, dns_sd)
1304 dnl but right now, what that would mainly accomplish is to encourage
1305 dnl people to try to use the avahi implementation, which does not work.
1306 dnl If you want to use Apple's own Bonjour code on another platform,
1307 dnl just add -ldns_sd to LIBS manually.
1308 fi
1309
1310 # for contrib/uuid-ossp
1311 if test "$with_uuid" = bsd ; then
1312   AC_CHECK_HEADERS(uuid.h,
1313     [AC_EGREP_HEADER([uuid_to_string], uuid.h, [],
1314       [AC_MSG_ERROR([header file <uuid.h> does not match BSD UUID library])])],
1315     [AC_MSG_ERROR([header file <uuid.h> is required for BSD UUID])])
1316 elif test "$with_uuid" = e2fs ; then
1317   AC_CHECK_HEADERS(uuid/uuid.h,
1318     [AC_EGREP_HEADER([uuid_generate], uuid/uuid.h, [],
1319       [AC_MSG_ERROR([header file <uuid/uuid.h> does not match E2FS UUID library])])],
1320     [AC_CHECK_HEADERS(uuid.h,
1321       [AC_EGREP_HEADER([uuid_generate], uuid.h, [],
1322         [AC_MSG_ERROR([header file <uuid.h> does not match E2FS UUID library])])],
1323       [AC_MSG_ERROR([header file <uuid/uuid.h> or <uuid.h> is required for E2FS UUID])])])
1324 elif test "$with_uuid" = ossp ; then
1325   AC_CHECK_HEADERS(ossp/uuid.h,
1326     [AC_EGREP_HEADER([uuid_export], ossp/uuid.h, [],
1327       [AC_MSG_ERROR([header file <ossp/uuid.h> does not match OSSP UUID library])])],
1328     [AC_CHECK_HEADERS(uuid.h,
1329       [AC_EGREP_HEADER([uuid_export], uuid.h, [],
1330         [AC_MSG_ERROR([header file <uuid.h> does not match OSSP UUID library])])],
1331       [AC_MSG_ERROR([header file <ossp/uuid.h> or <uuid.h> is required for OSSP UUID])])])
1332 fi
1333
1334 if test "$PORTNAME" = "win32" ; then
1335    AC_CHECK_HEADERS(crtdefs.h)
1336 fi
1337
1338 ##
1339 ## Types, structures, compiler characteristics
1340 ##
1341
1342 m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
1343 AC_C_BIGENDIAN
1344 PGAC_C_INLINE
1345 AC_C_FLEXIBLE_ARRAY_MEMBER
1346 PGAC_C_SIGNED
1347 PGAC_C_FUNCNAME_SUPPORT
1348 PGAC_C_STATIC_ASSERT
1349 PGAC_C_TYPES_COMPATIBLE
1350 PGAC_C_BUILTIN_CONSTANT_P
1351 PGAC_C_BUILTIN_UNREACHABLE
1352 PGAC_C_VA_ARGS
1353 PGAC_STRUCT_TIMEZONE
1354 PGAC_UNION_SEMUN
1355 PGAC_STRUCT_SOCKADDR_UN
1356 PGAC_STRUCT_SOCKADDR_STORAGE
1357 PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
1358 PGAC_STRUCT_ADDRINFO
1359 AC_TYPE_INTPTR_T
1360 AC_TYPE_UINTPTR_T
1361 AC_TYPE_LONG_LONG_INT
1362
1363 PGAC_TYPE_LOCALE_T
1364
1365 AC_CHECK_TYPES([struct cmsgcred], [], [],
1366 [#include <sys/socket.h>
1367 #include <sys/param.h>
1368 #ifdef HAVE_SYS_UCRED_H
1369 #include <sys/ucred.h>
1370 #endif])
1371
1372 AC_CHECK_TYPES([struct option], [], [],
1373 [#ifdef HAVE_GETOPT_H
1374 #include <getopt.h>
1375 #endif])
1376
1377 if test "$with_zlib" = yes; then
1378   # Check that <zlib.h> defines z_streamp (versions before about 1.0.4
1379   # did not).  While we could work around the lack of z_streamp, it
1380   # seems unwise to encourage people to use such old zlib versions...
1381   AC_CHECK_TYPE(z_streamp, [], [AC_MSG_ERROR([zlib version is too old
1382 Use --without-zlib to disable zlib support.])],
1383                 [#include <zlib.h>])
1384 fi
1385
1386 # On PPC, check if assembler supports LWARX instruction's mutex hint bit
1387 case $host_cpu in
1388   ppc*|powerpc*)
1389     AC_MSG_CHECKING([whether assembler supports lwarx hint bit])
1390     AC_TRY_COMPILE([],
1391         [int a = 0; int *p = &a; int r;
1392          __asm__ __volatile__ (" lwarx %0,0,%1,1\n" : "=&r"(r) : "r"(p));],
1393         [pgac_cv_have_ppc_mutex_hint=yes],
1394         [pgac_cv_have_ppc_mutex_hint=no])
1395     AC_MSG_RESULT([$pgac_cv_have_ppc_mutex_hint])
1396     if test x"$pgac_cv_have_ppc_mutex_hint" = xyes ; then
1397         AC_DEFINE(HAVE_PPC_LWARX_MUTEX_HINT, 1, [Define to 1 if the assembler supports PPC's LWARX mutex hint bit.])
1398     fi
1399   ;;
1400 esac
1401
1402 # Check largefile support.  You might think this is a system service not a
1403 # compiler characteristic, but you'd be wrong.  We must check this before
1404 # probing existence of related functions such as fseeko, since the largefile
1405 # defines can affect what is generated for that.
1406 if test "$PORTNAME" != "win32"; then
1407    AC_SYS_LARGEFILE
1408    dnl Autoconf 2.69's AC_SYS_LARGEFILE believes it's a good idea to #define
1409    dnl _DARWIN_USE_64_BIT_INODE, but it isn't: on OS X 10.5 that activates a
1410    dnl bug that causes readdir() to sometimes return EINVAL.  On later OS X
1411    dnl versions where the feature actually works, it's on by default anyway.
1412    AH_VERBATIM([_DARWIN_USE_64_BIT_INODE],[])
1413 fi
1414
1415 # Check for largefile support (must be after AC_SYS_LARGEFILE)
1416 AC_CHECK_SIZEOF([off_t])
1417
1418 # If we don't have largefile support, can't handle segsize >= 2GB.
1419 if test "$ac_cv_sizeof_off_t" -lt 8 -a "$segsize" != "1"; then
1420    AC_MSG_ERROR([Large file support is not enabled. Segment size cannot be larger than 1GB.])
1421 fi
1422
1423
1424 ##
1425 ## Functions, global variables
1426 ##
1427
1428 PGAC_VAR_INT_TIMEZONE
1429 AC_FUNC_ACCEPT_ARGTYPES
1430 PGAC_FUNC_GETTIMEOFDAY_1ARG
1431 PGAC_FUNC_WCSTOMBS_L
1432
1433 # Some versions of libedit contain strlcpy(), setproctitle(), and other
1434 # symbols that that library has no business exposing to the world.  Pending
1435 # acquisition of a clue by those developers, ignore libedit (including its
1436 # possible alias of libreadline) while checking for everything else.
1437 LIBS_including_readline="$LIBS"
1438 LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1439
1440 AC_CHECK_FUNCS(m4_normalize([
1441         cbrt
1442         dlopen
1443         fdatasync
1444         getifaddrs
1445         getpeerucred
1446         getrlimit
1447         mbstowcs_l
1448         memmove
1449         poll
1450         posix_fallocate
1451         pstat
1452         pthread_is_threaded_np
1453         readlink
1454         setproctitle
1455         setsid
1456         shm_open
1457         sigprocmask
1458         symlink
1459         sync_file_range
1460         towlower
1461         uselocale
1462         utime
1463         utimes
1464         wcstombs
1465         wcstombs_l
1466 ]))
1467
1468 AC_REPLACE_FUNCS(fseeko)
1469 case $host_os in
1470         # NetBSD uses a custom fseeko/ftello built on fsetpos/fgetpos
1471         # Mingw uses macros to access Win32 API calls
1472         netbsd*|mingw*)
1473                 AC_DEFINE(HAVE_FSEEKO, 1, [Define to 1 because replacement version used.])
1474                 ac_cv_func_fseeko=yes;;
1475         *)
1476                 AC_FUNC_FSEEKO;;
1477 esac
1478
1479 # posix_fadvise() is a no-op on Solaris, so don't incur function overhead
1480 # by calling it, 2009-04-02
1481 # http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
1482 dnl must use AS_IF here, else AC_REQUIRES inside AC_CHECK_DECLS malfunctions
1483 AS_IF([test "$PORTNAME" != "solaris"], [
1484 AC_CHECK_FUNCS(posix_fadvise)
1485 AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.h>])
1486 ]) # fi
1487
1488 AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
1489 AC_CHECK_DECLS([strlcat, strlcpy])
1490 # This is probably only present on Darwin, but may as well check always
1491 AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>])
1492
1493 HAVE_IPV6=no
1494 AC_CHECK_TYPE([struct sockaddr_in6],
1495         [AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])
1496          HAVE_IPV6=yes],
1497         [],
1498 [$ac_includes_default
1499 #include <netinet/in.h>])
1500 AC_SUBST(HAVE_IPV6)
1501
1502 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
1503 [AC_TRY_LINK(
1504 [#include <machine/vmparam.h>
1505 #include <sys/exec.h>
1506 ],
1507 [PS_STRINGS->ps_nargvstr = 1;
1508 PS_STRINGS->ps_argvstr = "foo";],
1509 [pgac_cv_var_PS_STRINGS=yes],
1510 [pgac_cv_var_PS_STRINGS=no])])
1511 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
1512   AC_DEFINE([HAVE_PS_STRINGS], 1, [Define to 1 if the PS_STRINGS thing exists.])
1513 fi
1514
1515
1516 # We use our snprintf.c emulation if either snprintf() or vsnprintf()
1517 # is missing.  Yes, there are machines that have only one.  We may
1518 # also decide to use snprintf.c if snprintf() is present but does not
1519 # have all the features we need --- see below.
1520
1521 if test "$PORTNAME" = "win32"; then
1522   # Win32 gets snprintf.c built unconditionally.
1523   #
1524   # To properly translate all NLS languages strings, we must support the
1525   # *printf() %$ format, which allows *printf() arguments to be selected
1526   # by position in the translated string.
1527   #
1528   # libintl versions < 0.13 use the native *printf() functions, and Win32
1529   # *printf() doesn't understand %$, so we must use our /port versions,
1530   # which do understand %$. libintl versions >= 0.13 include their own
1531   # *printf versions on Win32.  The libintl 0.13 release note text is:
1532   #
1533   #   C format strings with positions, as they arise when a translator
1534   #   needs to reorder a sentence, are now supported on all platforms.
1535   #   On those few platforms (NetBSD and Woe32) for which the native
1536   #   printf()/fprintf()/... functions don't support such format
1537   #   strings, replacements are provided through <libintl.h>.
1538   #
1539   # We could use libintl >= 0.13's *printf() if we were sure that we had
1540   # a litint >= 0.13 at runtime, but seeing that there is no clean way
1541   # to guarantee that, it is best to just use our own, so we are sure to
1542   # get %$ support. In include/port.h we disable the *printf() macros
1543   # that might have been defined by libintl.
1544   #
1545   # We do this unconditionally whether NLS is used or not so we are sure
1546   # that all Win32 libraries and binaries behave the same.
1547   pgac_need_repl_snprintf=yes
1548 else
1549   pgac_need_repl_snprintf=no
1550   AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
1551   AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
1552 fi
1553
1554
1555 # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
1556 # include/c.h will provide declarations.  Note this is a separate test
1557 # from whether the functions exist in the C library --- there are
1558 # systems that have the functions but don't bother to declare them :-(
1559
1560 AC_CHECK_DECLS([snprintf, vsnprintf])
1561
1562
1563 dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
1564 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
1565 [AC_TRY_LINK([
1566 #include <math.h>
1567 double glob_double;
1568 ],
1569 [return isinf(glob_double) ? 0 : 1;],
1570 [ac_cv_func_isinf=yes],
1571 [ac_cv_func_isinf=no])])
1572
1573 if test $ac_cv_func_isinf = yes ; then
1574   AC_DEFINE(HAVE_ISINF, 1, [Define to 1 if you have isinf().])
1575 else
1576   AC_LIBOBJ(isinf)
1577   # Look for a way to implement a substitute for isinf()
1578   AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
1579 fi
1580
1581 AC_REPLACE_FUNCS([crypt fls getopt getrusage inet_aton mkdtemp random rint srandom strerror strlcat strlcpy])
1582
1583 case $host_os in
1584
1585         # Windows uses a specialised env handler
1586         # and doesn't need a replacement getpeereid because it doesn't use
1587         # Unix sockets.
1588         mingw*)
1589                 AC_DEFINE(HAVE_UNSETENV, 1, [Define to 1 because replacement version used.])
1590                 AC_DEFINE(HAVE_GETPEEREID, 1, [Define to 1 because function not required.])
1591                 ac_cv_func_unsetenv=yes
1592                 ac_cv_func_getpeereid=yes;;
1593         *)
1594                 AC_REPLACE_FUNCS([unsetenv getpeereid])
1595                 ;;
1596 esac
1597
1598 # System's version of getaddrinfo(), if any, may be used only if we found
1599 # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
1600 # (Note: the AC_REPLACE_FUNCS probe fails on Windows, where the available
1601 # versions of getaddrinfo don't follow normal C call protocol.  This is OK
1602 # because we want to use our own getaddrinfo.c on Windows anyway.)
1603 if test x"$ac_cv_type_struct_addrinfo" = xyes ; then
1604   AC_REPLACE_FUNCS([getaddrinfo])
1605 else
1606   AC_LIBOBJ(getaddrinfo)
1607 fi
1608
1609 # Similarly, use system's getopt_long() only if system provides struct option.
1610 if test x"$ac_cv_type_struct_option" = xyes ; then
1611   AC_REPLACE_FUNCS([getopt_long])
1612 else
1613   AC_LIBOBJ(getopt_long)
1614 fi
1615
1616 # On OpenBSD and Solaris, getopt() doesn't do what we want for long options
1617 # (i.e., allow '-' as a flag character), so use our version on those platforms.
1618 if test "$PORTNAME" = "openbsd" -o "$PORTNAME" = "solaris"; then
1619   AC_LIBOBJ(getopt)
1620 fi
1621
1622 # mingw has adopted a GNU-centric interpretation of optind/optreset,
1623 # so always use our version on Windows.
1624 if test "$PORTNAME" = "win32"; then
1625   AC_LIBOBJ(getopt)
1626   AC_LIBOBJ(getopt_long)
1627 fi
1628
1629 # Win32 (really MinGW) support
1630 if test "$PORTNAME" = "win32"; then
1631   AC_CHECK_FUNCS(_configthreadlocale)
1632   AC_REPLACE_FUNCS(gettimeofday)
1633   AC_LIBOBJ(dirmod)
1634   AC_LIBOBJ(kill)
1635   AC_LIBOBJ(open)
1636   AC_LIBOBJ(system)
1637   AC_LIBOBJ(win32env)
1638   AC_LIBOBJ(win32error)
1639   AC_LIBOBJ(win32setlocale)
1640   AC_DEFINE([HAVE_SYMLINK], 1,
1641             [Define to 1 if you have the `symlink' function.])
1642   AC_CHECK_TYPES(MINIDUMP_TYPE, [pgac_minidump_type=yes], [pgac_minidump_type=no], [
1643 #define WIN32_LEAN_AND_MEAN
1644 #include <windows.h>
1645 #include <string.h>
1646 #include <dbghelp.h>])
1647 fi
1648 if test x"$pgac_minidump_type" = x"yes" ; then
1649   AC_SUBST(have_win32_dbghelp,yes)
1650 else
1651   AC_SUBST(have_win32_dbghelp,no)
1652 fi
1653
1654 # Cygwin needs only a bit of that
1655 if test "$PORTNAME" = "cygwin"; then
1656   AC_LIBOBJ(dirmod)
1657 fi
1658
1659 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
1660 dnl (especially on GNU libc)
1661 dnl See also comments in c.h.
1662 AC_CACHE_CHECK([for sigsetjmp], pgac_cv_func_sigsetjmp,
1663 [AC_TRY_LINK([#include <setjmp.h>],
1664             [sigjmp_buf x; sigsetjmp(x, 1);],
1665             [pgac_cv_func_sigsetjmp=yes],
1666             [pgac_cv_func_sigsetjmp=no])])
1667 if test x"$pgac_cv_func_sigsetjmp" = x"yes"; then
1668   AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have sigsetjmp().])
1669 fi
1670
1671 AC_DECL_SYS_SIGLIST
1672
1673 AC_CHECK_FUNC(syslog,
1674               [AC_CHECK_HEADER(syslog.h,
1675                                [AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
1676
1677 AC_CACHE_CHECK([for opterr], pgac_cv_var_int_opterr,
1678 [AC_TRY_LINK([#include <unistd.h>],
1679   [extern int opterr; opterr = 1;],
1680   [pgac_cv_var_int_opterr=yes],
1681   [pgac_cv_var_int_opterr=no])])
1682 if test x"$pgac_cv_var_int_opterr" = x"yes"; then
1683   AC_DEFINE(HAVE_INT_OPTERR, 1, [Define to 1 if you have the global variable 'int opterr'.])
1684 fi
1685
1686 AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
1687 [AC_TRY_LINK([#include <unistd.h>],
1688   [extern int optreset; optreset = 1;],
1689   [pgac_cv_var_int_optreset=yes],
1690   [pgac_cv_var_int_optreset=no])])
1691 if test x"$pgac_cv_var_int_optreset" = x"yes"; then
1692   AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
1693 fi
1694
1695 AC_CHECK_FUNCS([strtoll __strtoll strtoq], [break])
1696 AC_CHECK_FUNCS([strtoull __strtoull strtouq], [break])
1697 # strto[u]ll may exist but not be declared
1698 AC_CHECK_DECLS([strtoll, strtoull])
1699
1700 AC_CACHE_CHECK([for builtin locking functions], pgac_cv_gcc_int_atomics,
1701 [AC_TRY_LINK([],
1702   [int lock = 0;
1703    __sync_lock_test_and_set(&lock, 1);
1704    __sync_lock_release(&lock);],
1705   [pgac_cv_gcc_int_atomics="yes"],
1706   [pgac_cv_gcc_int_atomics="no"])])
1707 if test x"$pgac_cv_gcc_int_atomics" = x"yes"; then
1708   AC_DEFINE(HAVE_GCC_INT_ATOMICS, 1, [Define to 1 if you have __sync_lock_test_and_set(int *) and friends.])
1709 fi
1710
1711 # Lastly, restore full LIBS list and check for readline/libedit symbols
1712 LIBS="$LIBS_including_readline"
1713
1714 if test "$with_readline" = yes; then
1715   PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
1716   AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function rl_reset_screen_size])
1717   AC_CHECK_FUNCS([append_history history_truncate_file])
1718 fi
1719
1720
1721 # This test makes sure that run tests work at all.  Sometimes a shared
1722 # library is found by the linker, but the runtime linker can't find it.
1723 # This check should come after all modifications of compiler or linker
1724 # variables, and before any other run tests.
1725 AC_MSG_CHECKING([test program])
1726 AC_TRY_RUN([int main() { return 0; }],
1727 [AC_MSG_RESULT(ok)],
1728 [AC_MSG_RESULT(failed)
1729 AC_MSG_ERROR([[
1730 Could not execute a simple test program.  This may be a problem
1731 related to locating shared libraries.  Check the file 'config.log'
1732 for the exact reason.]])],
1733 [AC_MSG_RESULT([cross-compiling])])
1734
1735 # --------------------
1736 # Run tests below here
1737 # --------------------
1738
1739 # Force use of our snprintf if system's doesn't do arg control
1740 # See comment above at snprintf test for details.
1741 if test "$enable_nls" = yes -a "$pgac_need_repl_snprintf" = no; then
1742   PGAC_FUNC_SNPRINTF_ARG_CONTROL
1743   if test $pgac_cv_snprintf_arg_control != yes ; then
1744     pgac_need_repl_snprintf=yes
1745   fi
1746 fi
1747
1748
1749 dnl Check to see if we have a working 64-bit integer type.
1750 dnl This breaks down into two steps:
1751 dnl (1) figure out if the compiler has a 64-bit int type with working
1752 dnl arithmetic, and if so
1753 dnl (2) see whether snprintf() can format the type correctly.  (Currently,
1754 dnl snprintf is the only library routine we really need for int8 support.)
1755 dnl It's entirely possible to have a compiler that handles a 64-bit type
1756 dnl when the C library doesn't; this is fairly likely when using gcc on
1757 dnl an older platform, for example.
1758 dnl If there is no native snprintf() or it does not handle the 64-bit type,
1759 dnl we force our own version of snprintf() to be used instead.
1760 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1761
1762 dnl As of Postgres 8.4, we no longer support compilers without a working
1763 dnl 64-bit type.  But we still handle the case of snprintf being broken.
1764
1765 PGAC_TYPE_64BIT_INT([long int])
1766
1767 if test x"$HAVE_LONG_INT_64" = x"yes" ; then
1768   pg_int64_type="long int"
1769 else
1770   PGAC_TYPE_64BIT_INT([long long int])
1771   if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
1772     pg_int64_type="long long int"
1773   else
1774     AC_MSG_ERROR([Cannot find a working 64-bit integer type.])
1775   fi
1776 fi
1777
1778 AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
1779   [Define to the name of a signed 64-bit integer type.])
1780
1781 # If we found "long int" is 64 bits, assume snprintf handles it.  If
1782 # we found we need to use "long long int", better check.  We cope with
1783 # snprintfs that use %lld, %qd, or %I64d as the format.  If none of these
1784 # work, fall back to our own snprintf emulation (which we know uses %lld).
1785
1786 if test "$HAVE_LONG_LONG_INT_64" = yes ; then
1787   if test $pgac_need_repl_snprintf = no; then
1788     PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
1789     if test "$LONG_LONG_INT_FORMAT" = ""; then
1790       # Force usage of our own snprintf, since system snprintf is broken
1791       pgac_need_repl_snprintf=yes
1792       LONG_LONG_INT_FORMAT='%lld'
1793     fi
1794   else
1795     # Here if we previously decided we needed to use our own snprintf
1796     LONG_LONG_INT_FORMAT='%lld'
1797   fi
1798   LONG_LONG_UINT_FORMAT=`echo "$LONG_LONG_INT_FORMAT" | sed 's/d$/u/'`
1799   INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
1800   UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\""
1801 else
1802   # Here if we are not using 'long long int' at all
1803   INT64_FORMAT='"%ld"'
1804   UINT64_FORMAT='"%lu"'
1805 fi
1806
1807 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
1808                    [Define to the appropriate snprintf format for 64-bit ints.])
1809
1810 AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
1811                    [Define to the appropriate snprintf format for unsigned 64-bit ints.])
1812
1813 # Also force use of our snprintf if the system's doesn't support the %z flag.
1814 if test "$pgac_need_repl_snprintf" = no; then
1815   PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
1816   if test "$pgac_cv_snprintf_size_t_support" != yes; then
1817     pgac_need_repl_snprintf=yes
1818   fi
1819 fi
1820
1821 # Now we have checked all the reasons to replace snprintf
1822 if test $pgac_need_repl_snprintf = yes; then
1823   AC_DEFINE(USE_REPL_SNPRINTF, 1, [Use replacement snprintf() functions.])
1824   AC_LIBOBJ(snprintf)
1825 fi
1826
1827 # Check size of void *, size_t (enables tweaks for > 32bit address space)
1828 AC_CHECK_SIZEOF([void *])
1829 AC_CHECK_SIZEOF([size_t])
1830 AC_CHECK_SIZEOF([long])
1831
1832 # Decide whether float4 is passed by value: user-selectable, enabled by default
1833 AC_MSG_CHECKING([whether to build with float4 passed by value])
1834 PGAC_ARG_BOOL(enable, float4-byval, yes, [disable float4 passed by value],
1835               [AC_DEFINE([USE_FLOAT4_BYVAL], 1,
1836                          [Define to 1 if you want float4 values to be passed by value. (--enable-float4-byval)])
1837                float4passbyval=true],
1838               [float4passbyval=false])
1839 AC_MSG_RESULT([$enable_float4_byval])
1840 AC_DEFINE_UNQUOTED([FLOAT4PASSBYVAL], [$float4passbyval], [float4 values are passed by value if 'true', by reference if 'false'])
1841
1842 # Decide whether float8 is passed by value.
1843 # Note: this setting also controls int8 and related types such as timestamp.
1844 # If sizeof(Datum) >= 8, this is user-selectable, enabled by default.
1845 # If not, trying to select it is an error.
1846 AC_MSG_CHECKING([whether to build with float8 passed by value])
1847 if test $ac_cv_sizeof_void_p -ge 8 ; then
1848   PGAC_ARG_BOOL(enable, float8-byval, yes, [disable float8 passed by value])
1849 else
1850   PGAC_ARG_BOOL(enable, float8-byval, no, [disable float8 passed by value])
1851   if test "$enable_float8_byval" = yes ; then
1852     AC_MSG_ERROR([--enable-float8-byval is not supported on 32-bit platforms.])
1853   fi
1854 fi
1855 if test "$enable_float8_byval" = yes ; then
1856   AC_DEFINE([USE_FLOAT8_BYVAL], 1,
1857             [Define to 1 if you want float8, int8, etc values to be passed by value. (--enable-float8-byval)])
1858   float8passbyval=true
1859 else
1860   float8passbyval=false
1861 fi
1862 AC_MSG_RESULT([$enable_float8_byval])
1863 AC_DEFINE_UNQUOTED([FLOAT8PASSBYVAL], [$float8passbyval], [float8, int8, and related values are passed by value if 'true', by reference if 'false'])
1864
1865 # Determine memory alignment requirements for the basic C data types.
1866
1867 AC_CHECK_ALIGNOF(short)
1868 AC_CHECK_ALIGNOF(int)
1869 AC_CHECK_ALIGNOF(long)
1870 if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
1871   AC_CHECK_ALIGNOF(long long int)
1872 fi
1873 AC_CHECK_ALIGNOF(double)
1874
1875 # Compute maximum alignment of any basic type.
1876 # We assume long's alignment is at least as strong as char, short, or int;
1877 # but we must check long long (if it exists) and double.
1878
1879 MAX_ALIGNOF=$ac_cv_alignof_long
1880 if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
1881   MAX_ALIGNOF=$ac_cv_alignof_double
1882 fi
1883 if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ; then
1884   MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
1885 fi
1886 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
1887
1888
1889 # Some platforms predefine the types int8, int16, etc.  Only check
1890 # a (hopefully) representative subset.
1891 AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
1892 [#include <stdio.h>])
1893
1894 # We also check for sig_atomic_t, which *should* be defined per ANSI
1895 # C, but is missing on some old platforms.
1896 AC_CHECK_TYPES(sig_atomic_t, [], [], [#include <signal.h>])
1897
1898
1899 if test "$PORTNAME" != "win32"
1900 then
1901 PGAC_FUNC_POSIX_SIGNALS
1902 if test "$pgac_cv_func_posix_signals" != yes -a "$enable_thread_safety" = yes; then
1903   AC_MSG_ERROR([
1904 Thread-safety requires POSIX signals, which are not supported by this
1905 operating system;  use --disable-thread-safety to disable thread safety.])
1906 fi
1907 fi
1908
1909
1910 # Select semaphore implementation type.
1911 if test "$PORTNAME" != "win32"; then
1912   if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
1913     AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores.])
1914     SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
1915   else
1916     if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
1917       AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores.])
1918       SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
1919     else
1920       AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores.])
1921       SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
1922     fi
1923   fi
1924 else
1925   AC_DEFINE(USE_WIN32_SEMAPHORES, 1, [Define to select Win32-style semaphores.])
1926   SEMA_IMPLEMENTATION="src/backend/port/win32_sema.c"
1927 fi
1928
1929
1930 # Select shared-memory implementation type.
1931 if test "$PORTNAME" != "win32"; then
1932   AC_DEFINE(USE_SYSV_SHARED_MEMORY, 1, [Define to select SysV-style shared memory.])
1933   SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
1934 else
1935   AC_DEFINE(USE_WIN32_SHARED_MEMORY, 1, [Define to select Win32-style shared memory.])
1936   SHMEM_IMPLEMENTATION="src/backend/port/win32_shmem.c"
1937 fi
1938
1939 # Select latch implementation type.
1940 if test "$PORTNAME" != "win32"; then
1941   LATCH_IMPLEMENTATION="src/backend/port/unix_latch.c"
1942 else
1943   LATCH_IMPLEMENTATION="src/backend/port/win32_latch.c"
1944 fi
1945
1946 # If not set in template file, set bytes to use libc memset()
1947 if test x"$MEMSET_LOOP_LIMIT" = x"" ; then
1948   MEMSET_LOOP_LIMIT=1024
1949 fi
1950 AC_DEFINE_UNQUOTED(MEMSET_LOOP_LIMIT, ${MEMSET_LOOP_LIMIT}, [Define bytes to use libc memset().])
1951
1952
1953 if test "$enable_nls" = yes ; then
1954   PGAC_CHECK_GETTEXT
1955 fi
1956
1957 # Check for Tcl configuration script tclConfig.sh
1958 if test "$with_tcl" = yes; then
1959     PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
1960     PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
1961                           [TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
1962     AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
1963     # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
1964     ac_save_CPPFLAGS=$CPPFLAGS
1965     CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
1966     AC_CHECK_HEADER(tcl.h, [], [AC_MSG_ERROR([header file <tcl.h> is required for Tcl])])
1967     CPPFLAGS=$ac_save_CPPFLAGS
1968 fi
1969
1970 # check for <perl.h>
1971 if test "$with_perl" = yes; then
1972   ac_save_CPPFLAGS=$CPPFLAGS
1973   CPPFLAGS="$CPPFLAGS $perl_includespec"
1974   AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
1975                   [#include <EXTERN.h>])
1976   # While we're at it, check that we can link to libperl.
1977   # On most platforms, if perl.h is there then libperl.so will be too, but at
1978   # this writing Debian packages them separately.  There is no known reason to
1979   # waste cycles on separate probes for the Tcl or Python libraries, though.
1980   pgac_save_LIBS=$LIBS
1981   LIBS="$perl_embed_ldflags"
1982   AC_MSG_CHECKING([for libperl])
1983   AC_TRY_LINK([
1984 #include <EXTERN.h>
1985 #include <perl.h>
1986 ],  [perl_alloc();],
1987     [AC_MSG_RESULT(yes)],
1988     [AC_MSG_RESULT(no)
1989      AC_MSG_ERROR([libperl library is required for Perl])])
1990   LIBS=$pgac_save_LIBS
1991   CPPFLAGS=$ac_save_CPPFLAGS
1992 fi
1993
1994 # check for <Python.h>
1995 if test "$with_python" = yes; then
1996   ac_save_CPPFLAGS=$CPPFLAGS
1997   CPPFLAGS="$python_includespec $CPPFLAGS"
1998   AC_CHECK_HEADER(Python.h, [], [AC_MSG_ERROR([header file <Python.h> is required for Python])])
1999   CPPFLAGS=$ac_save_CPPFLAGS
2000 fi
2001
2002 #
2003 # Check for DocBook and tools
2004 #
2005 PGAC_PROG_NSGMLS
2006 PGAC_PROG_JADE
2007 PGAC_CHECK_DOCBOOK(4.2)
2008 PGAC_PATH_DOCBOOK_STYLESHEETS
2009 PGAC_PATH_COLLATEINDEX
2010 AC_CHECK_PROGS(XSLTPROC, xsltproc)
2011 AC_CHECK_PROGS(OSX, [osx sgml2xml sx])
2012
2013 #
2014 # Check for test tools
2015 #
2016 if test "$enable_tap_tests" = yes; then
2017   AC_CHECK_PROGS(PROVE, prove)
2018   if test -z "$PROVE"; then
2019     AC_MSG_ERROR([prove not found])
2020   fi
2021   if test -z "$PERL"; then
2022     AC_MSG_ERROR([Perl not found])
2023   fi
2024 fi
2025
2026 # Thread testing
2027
2028 # We have to run the thread test near the end so we have all our symbols
2029 # defined.  Cross compiling throws a warning.
2030 #
2031 if test "$enable_thread_safety" = yes; then
2032 if test "$PORTNAME" != "win32"
2033 then
2034 AC_MSG_CHECKING([thread safety of required library functions])
2035
2036 _CFLAGS="$CFLAGS"
2037 _LIBS="$LIBS"
2038 CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
2039 LIBS="$LIBS $PTHREAD_LIBS"
2040 AC_TRY_RUN([#include "$srcdir/src/test/thread/thread_test.c"],
2041   [AC_MSG_RESULT(yes)],
2042   [AC_MSG_RESULT(no)
2043   AC_MSG_ERROR([thread test program failed
2044 This platform is not thread-safe.  Check the file 'config.log' or compile
2045 and run src/test/thread/thread_test for the exact reason.
2046 Use --disable-thread-safety to disable thread safety.])],
2047   [AC_MSG_RESULT(maybe)
2048   AC_MSG_WARN([
2049 *** Skipping thread test program because of cross-compile build.
2050 *** Run the program in src/test/thread on the target machine.
2051 ])])
2052 CFLAGS="$_CFLAGS"
2053 LIBS="$_LIBS"
2054 else
2055 AC_MSG_WARN([*** skipping thread test on Win32])
2056 fi
2057 fi
2058
2059 # If compiler will take -Wl,--as-needed (or various platform-specific
2060 # spellings thereof) then add that to LDFLAGS.  This is much easier than
2061 # trying to filter LIBS to the minimum for each executable.
2062 # On (at least) some Red-Hat-derived systems, this switch breaks linking to
2063 # libreadline; therefore we postpone testing it until we know what library
2064 # dependencies readline has.  The test code will try to link with $LIBS.
2065 if test "$with_readline" = yes; then
2066   link_test_func=readline
2067 else
2068   link_test_func=exit
2069 fi
2070
2071 if test "$PORTNAME" = "darwin"; then
2072   PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs], $link_test_func)
2073 elif test "$PORTNAME" = "openbsd"; then
2074   PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-Bdynamic], $link_test_func)
2075 else
2076   PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func)
2077 fi
2078
2079 # Create compiler version string
2080 if test x"$GCC" = x"yes" ; then
2081   cc_string=`${CC} --version | sed q`
2082   case $cc_string in [[A-Za-z]]*) ;; *) cc_string="GCC $cc_string";; esac
2083 elif test x"$SUN_STUDIO_CC" = x"yes" ; then
2084   cc_string=`${CC} -V 2>&1 | sed q`
2085 else
2086   cc_string=$CC
2087 fi
2088
2089 AC_DEFINE_UNQUOTED(PG_VERSION_STR,
2090                    ["PostgreSQL $PG_VERSION on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"],
2091                    [A string containing the version number, platform, and C compiler])
2092
2093 # Supply a numeric version string for use by 3rd party add-ons
2094 # awk -F is a regex on some platforms, and not on others, so make "." a tab
2095 [PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
2096 tr '.' '        ' |
2097 $AWK '{printf "%d%02d%02d", $1, $2, (NF >= 3) ? $3 : 0}'`"]
2098 AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])
2099 AC_SUBST(PG_VERSION_NUM)
2100
2101 # If we are inserting PG_SYSROOT into CPPFLAGS, do so symbolically not
2102 # literally, so that it's possible to override it at build time using
2103 # a command like "make ... PG_SYSROOT=path".  This has to be done after
2104 # we've finished all configure checks that depend on CPPFLAGS.
2105 if test x"$PG_SYSROOT" != x; then
2106   CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
2107 fi
2108 AC_SUBST(PG_SYSROOT)
2109
2110
2111 # Begin output steps
2112
2113 AC_MSG_NOTICE([using compiler=$cc_string])
2114 AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
2115 AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
2116 AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
2117
2118 # prepare build tree if outside source tree
2119 # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
2120 # Note 2: /bin/pwd might be better than shell's built-in at getting
2121 #         a symlink-free name.
2122 if ( test "$srcdir" -ef . ) >/dev/null 2>&1 || test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
2123   vpath_build=no
2124 else
2125   vpath_build=yes
2126   if test "$no_create" != yes; then
2127     _AS_ECHO_N([preparing build tree... ])
2128     pgac_abs_top_srcdir=`cd "$srcdir" && pwd`
2129     $SHELL "$ac_aux_dir/prep_buildtree" "$pgac_abs_top_srcdir" "." \
2130       || AC_MSG_ERROR(failed)
2131     AC_MSG_RESULT(done)
2132   fi
2133 fi
2134 AC_SUBST(vpath_build)
2135
2136
2137 AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
2138
2139 AC_CONFIG_LINKS([
2140   src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c
2141   src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
2142   src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
2143   src/backend/port/pg_latch.c:${LATCH_IMPLEMENTATION}
2144   src/include/dynloader.h:src/backend/port/dynloader/${template}.h
2145   src/include/pg_config_os.h:src/include/port/${template}.h
2146   src/Makefile.port:src/makefiles/Makefile.${template}
2147 ])
2148
2149 if test "$PORTNAME" = "win32"; then
2150 AC_CONFIG_COMMANDS([check_win32_symlinks],[
2151 # Links sometimes fail undetected on Mingw -
2152 # so here we detect it and warn the user
2153 for FILE in $CONFIG_LINKS
2154  do
2155         # test -e works for symlinks in the MinGW console
2156         test -e `expr "$FILE" : '\([[^:]]*\)'` || AC_MSG_WARN([*** link for $FILE -- please fix by hand])
2157  done
2158 ])
2159 fi
2160
2161 AC_CONFIG_HEADERS([src/include/pg_config.h],
2162 [
2163 # Update timestamp for pg_config.h (see Makefile.global)
2164 echo >src/include/stamp-h
2165 ])
2166
2167 AC_CONFIG_HEADERS([src/include/pg_config_ext.h],
2168 [
2169 # Update timestamp for pg_config_ext.h (see Makefile.global)
2170 echo >src/include/stamp-ext-h
2171 ])
2172
2173 AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h],
2174                   [echo >src/interfaces/ecpg/include/stamp-h])
2175
2176 AC_OUTPUT