]> granicus.if.org Git - postgresql/blob - configure.in
REINDEX under WAL.
[postgresql] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl Developers, please strive to achieve this order:
4 dnl
5 dnl 0. Initialization and options processing
6 dnl 1. Programs
7 dnl 2. Libraries
8 dnl 3. Header files
9 dnl 4. Types
10 dnl 5. Structures
11 dnl 6. Compiler characteristics
12 dnl 7. Functions, global variables
13 dnl 8. System services
14 dnl
15 dnl Read the Autoconf manual for details.
16
17 dnl The GNU folks apparently haven't heard that some people don't use
18 dnl Texinfo. Use this sorcery to use "docdir" instead of "infodir".
19 define([info], [doc])
20 define([infodir], [docdir])
21 AC_INIT(src/backend/access/common/heaptuple.c)
22 undefine([infodir])
23 undefine([info])
24
25 AC_PREFIX_DEFAULT(/usr/local/pgsql)
26 AC_CONFIG_HEADER(src/include/config.h)
27
28 AC_PREREQ(2.13)
29 AC_CONFIG_AUX_DIR(config)
30
31 VERSION='7.1beta1'
32 AC_SUBST(VERSION)
33 AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION")
34
35 unset CDPATH
36 abs_top_srcdir=`cd $srcdir && pwd`
37 AC_SUBST(abs_top_srcdir)
38 abs_top_builddir=`pwd`
39 AC_SUBST(abs_top_builddir)
40
41 AC_CANONICAL_HOST
42 AC_SUBST(host)
43 AC_SUBST(host_cpu)
44 AC_SUBST(host_os)
45
46 template=
47 AC_MSG_CHECKING([which template to use])
48
49 PGAC_ARG_REQ(with, template, [],
50 [
51   case $withval in
52     list)   echo; ls "$srcdir/src/template"; exit;;
53     *)      if test -f "$srcdir/src/template/$with_template" ; then
54               template=$withval
55             else
56               AC_MSG_ERROR(['$withval' is not a valid template name. Use 'list' for a list.])
57             fi;;
58   esac
59 ],
60 [
61   # --with-template not given
62
63 case $host_os in
64      aix*) template=aix ;;
65     beos*) template=beos ;;
66     bsdi*) template=bsdi ;;
67   cygwin*) template=win ;;
68   darwin*) template=darwin ;;
69     dgux*) template=dgux ;;
70  freebsd*) template=freebsd ;;
71     hpux*) template=hpux ;;
72     irix*) template=irix5 ;;
73    linux*) template=linux ;;
74   netbsd*) template=netbsd ;;
75 nextstep*) template=nextstep ;;
76  openbsd*) template=openbsd ;;
77      osf*) template=osf ;;
78      qnx*) template=qnx4 ;;
79      sco*) template=sco ;;
80  solaris*) template=solaris ;;
81    sunos*) template=sunos4 ;;
82  sysv4.2*)
83         case $host_vendor in
84           univel) template=univel ;;
85         esac ;;
86    sysv4*) template=svr4 ;;
87  sysv5uw*) template=unixware ;;
88   ultrix*) template=ultrix4 ;;
89 esac
90
91   if test x"$template" = x"" ; then
92     AC_MSG_ERROR([[
93 *******************************************************************
94 PostgreSQL has apparently not been ported to your platform yet.
95 To try a manual configuration, look into the src/template directory
96 for a similar platform and use the '--with-template=' option.
97
98 Please also contact <pgsql-ports@postgresql.org> to see about
99 rectifying this.  Include the above 'checking host system type...'
100 line.
101 *******************************************************************
102 ]])
103   fi
104
105 ])
106
107 AC_MSG_RESULT([$template])
108
109 PORTNAME=$template
110 AC_SUBST(PORTNAME)
111
112 AC_LINK_FILES([src/backend/port/dynloader/${template}.c], [src/backend/port/dynloader.c])
113 AC_LINK_FILES([src/backend/port/dynloader/${template}.h], [src/include/dynloader.h])
114 AC_LINK_FILES([src/include/port/${template}.h], [src/include/os.h])
115 AC_LINK_FILES([src/makefiles/Makefile.${template}], [src/Makefile.port])
116
117 # Pick right test-and-set (TAS) code.  Most platforms have inline
118 # assembler code in src/include/storage/s_lock.h, so we just use
119 # a dummy file here.
120 case $host in
121   *-*-hpux*)        need_tas=yes; tas_file=hpux.s ;;
122   sparc-*-solaris*) need_tas=yes; tas_file=solaris_sparc.s ;;
123   i?86-*-solaris)   need_tas=yes; tas_file=solaris_i386.s ;;
124   *)                need_tas=no;  tas_file=dummy.s ;;
125 esac
126 AC_LINK_FILES([src/backend/port/tas/${tas_file}], [src/backend/port/tas.s])
127
128 if test "$need_tas" = yes ; then
129   TAS=tas.o
130 fi
131 AC_SUBST(TAS)
132
133
134
135 ##
136 ## Command line options
137 ##
138
139
140 #
141 # Add non-standard directories to the include path
142 #
143 PGAC_ARG_REQ(with, includes, [  --with-includes=DIRS    look for additional header files in DIRS])
144
145
146 #
147 # Add non-standard directories to the library search path
148 #
149 PGAC_ARG_REQ(with, libraries, [  --with-libraries=DIRS   look for additional libraries in DIRS],
150              [LIBRARY_DIRS=$withval])
151
152 PGAC_ARG_REQ(with, libs,      [  --with-libs=DIRS        alternative spelling of --with-libraries],
153              [LIBRARY_DIRS=$withval])
154
155
156 #
157 # Locale (--enable-locale)
158 #
159 AC_MSG_CHECKING([whether to build with locale support])
160 PGAC_ARG_BOOL(enable, locale, no, [  --enable-locale         enable locale support],
161               [AC_DEFINE([USE_LOCALE], 1,
162                          [Set to 1 if you want LOCALE support (--enable-locale)])])
163 AC_MSG_RESULT([$enable_locale])
164
165
166 #
167 # Character set recode (--enable-recode)
168 #
169 AC_MSG_CHECKING([whether to build with recode support])
170 PGAC_ARG_BOOL(enable, recode, no, [  --enable-recode         enable character set recode support],
171               [AC_DEFINE([CYR_RECODE], 1,
172                          [Set to 1 if you want cyrillic recode support (--enable-recode)])])
173 AC_MSG_RESULT([$enable_recode])
174
175
176 #
177 # Multibyte support
178 #
179 MULTIBYTE=
180 AC_MSG_CHECKING([whether to build with multibyte character support])
181
182 PGAC_ARG_OPTARG(enable, multibyte, [  --enable-multibyte      enable multibyte character support],
183 [MULTIBYTE=SQL_ASCII],
184 [
185   case $enableval in
186     SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
187       MULTIBYTE=$enableval;;
188     *)
189       AC_MSG_ERROR(
190 [argument to --enable-multibyte must be one of:
191   SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
192   UNICODE, MULE_INTERNAL,
193   LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
194   KOI8, WIN, ALT
195 Or do not specify an argument to the option to use the default.]);;
196   esac
197 ],
198 [
199   AC_DEFINE(MULTIBYTE, 1, [Set to 1 if you want to use multibyte characters (--enable-multibyte)])
200   AC_MSG_RESULT([yes, default $MULTIBYTE])
201 ],
202 [AC_MSG_RESULT(no)])
203
204 AC_SUBST(MULTIBYTE)
205
206 #
207 # Unicode conversion (--enable-unicode-conversion)
208 #
209 AC_MSG_CHECKING([whether to build with Unicode conversion support])
210 PGAC_ARG_BOOL(enable, unicode-conversion, no,
211               [  --enable-unicode-conversion  enable unicode conversion support],
212 [if test -z "$MULTIBYTE"; then
213   AC_MSG_ERROR([--enable-unicode-conversion only works with --enable-multibyte])
214 fi
215 AC_DEFINE([UNICODE_CONVERSION], 1,
216           [Set to 1 if you want Unicode conversion support (--enable-unicode-conversion)])])
217 AC_MSG_RESULT([$enable_unicode_conversion])
218
219 #
220 # Default port number (--with-pgport), default 5432
221 #
222 AC_MSG_CHECKING([for default port number])
223 PGAC_ARG_REQ(with, pgport, [  --with-pgport=PORTNUM   change default port number [5432]],
224              [default_port=$withval],
225              [default_port=5432])
226 # Need both of these because backend wants an integer and frontend a string
227 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
228 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
229 AC_MSG_RESULT([$default_port])
230
231
232 #
233 # Maximum number of allowed connections (--with-maxbackends), default 32
234 #
235 AC_MSG_CHECKING([for default soft limit on number of connections])
236 PGAC_ARG_REQ(with, maxbackends, [  --with-maxbackends=N    set default maximum number of connections [32]],
237              [],
238              [with_maxbackends=32])
239 AC_MSG_RESULT([$with_maxbackends])
240 AC_DEFINE_UNQUOTED([DEF_MAXBACKENDS], [$with_maxbackends],
241                    [The default soft limit on the number of concurrent connections, i.e., the default for the postmaster -N switch (--with-maxbackends)])
242
243
244 #
245 # Option to disable shared libraries
246 #
247 PGAC_ARG_BOOL(enable, shared, yes,
248               [  --disable-shared        do not build shared libraries])
249 AC_SUBST(enable_shared)
250
251 #
252 # '-rpath'-like feature can be disabled
253 #
254 PGAC_ARG_BOOL(enable, rpath, yes,
255               [  --disable-rpath         do not embed shared library search path in executables])
256 AC_SUBST(enable_rpath)
257
258
259 #
260 # --enable-debug adds -g to compiler flags
261 #
262 PGAC_ARG_BOOL(enable, debug, no,
263               [  --enable-debug          build with debugging symbols (-g)])
264
265
266 #
267 # C compiler
268 #
269
270 # For historical reasons you can also use --with-CC to specify the C compiler
271 # to use, although the standard way to do this is to set the CC environment
272 # variable.
273 PGAC_ARG_REQ(with, CC, [], [CC=$with_CC])
274
275 # On AIX, default compiler to xlc.
276 if test "$template" = aix && test -z "$CC" ; then CC=xlc; fi
277
278 # Save CFLAGS from the environment
279 has_environ_CFLAGS="${CFLAGS+yes}"
280 save_CFLAGS=$CFLAGS
281
282 AC_PROG_CC
283 # Read the template
284 . "$srcdir/src/template/$template" || exit
285
286 if test "$has_environ_CFLAGS" = yes; then
287   CFLAGS=$save_CFLAGS
288 fi
289 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
290   CFLAGS="$CFLAGS -g"
291 fi
292 echo "using CFLAGS=$CFLAGS"
293 # Check if the compiler still works with the template settings
294 AC_PROG_CC_WORKS
295 AC_EXEEXT
296 AC_PROG_CPP
297 AC_PROG_GCC_TRADITIONAL
298 AC_SUBST(GCC)
299
300 # Create compiler version string
301 if test x"$GCC" = x"yes" ; then
302   cc_string="GCC `${CC} --version`"
303 else
304   cc_string=$CC
305 fi
306 AC_DEFINE_UNQUOTED(PG_VERSION_STR, ["PostgreSQL $VERSION on $host, compiled by $cc_string"], [A canonical string containing the version number, platform, and C compiler])
307
308
309 #
310 # Automatic dependency tracking
311 #
312 PGAC_ARG_BOOL(enable, depend, no, [  --enable-depend         turn on automatic dependency tracking],
313               [autodepend=yes])
314 AC_SUBST(autodepend)
315
316
317 #
318 # Enable assert checks
319 #
320 PGAC_ARG_BOOL(enable, cassert, no, [  --enable-cassert        enable assertion checks (for debugging)],
321               [AC_DEFINE([USE_ASSERT_CHECKING], 1,
322                          [Define to 1 to build with assertion checks])])
323
324
325 #
326 # Include directories
327 #
328 ac_save_IFS=$IFS
329 IFS="${IFS}:"
330 # SRCH_INC comes from the template file
331 for dir in $with_includes $SRCH_INC; do
332   if test -d "$dir"; then
333     INCLUDES="$INCLUDES -I$dir"
334   else
335     AC_MSG_WARN([*** Include directory $dir does not exist.])
336   fi
337 done
338 IFS=$ac_save_IFS
339 AC_SUBST(INCLUDES)
340
341
342 #
343 # Library directories
344 #
345 ac_save_IFS=$IFS
346 IFS="${IFS}:"
347 # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
348 for dir in $LIBRARY_DIRS $SRCH_LIB; do
349   if test -d "$dir"; then
350     LIBDIRS="$LIBDIRS -L$dir"
351   else
352     AC_MSG_WARN([*** Library directory $dir does not exist.])
353   fi
354 done
355 IFS=$ac_save_IFS
356
357
358 #
359 # Tcl/Tk
360 #
361 AC_MSG_CHECKING([whether to build with Tcl])
362 PGAC_ARG_BOOL(with, tcl, no, [  --with-tcl              build Tcl and Tk interfaces])
363 AC_MSG_RESULT([$with_tcl])
364 AC_SUBST([with_tcl])
365
366 # If Tcl is enabled (above) then Tk is also, unless the user disables it using --without-tk
367 AC_MSG_CHECKING([whether to build with Tk])
368 if test "$with_tcl" = yes; then
369   PGAC_ARG_BOOL(with, tk, yes, [  --without-tk            do not build Tk interfaces if Tcl is enabled])
370 else
371   with_tk=no
372 fi
373 AC_MSG_RESULT([$with_tk])
374 AC_SUBST([with_tk])
375
376
377 # We see if the path to the TCL/TK configuration scripts is specified.
378 # This will override the use of tclsh to find the paths to search.
379
380 PGAC_ARG_REQ(with, tclconfig, [  --with-tclconfig=DIR    tclConfig.sh and tkConfig.sh are in DIR])
381
382 # We see if the path to the TK configuration scripts is specified.
383 # This will override the use of tclsh to find the paths to search.
384
385 PGAC_ARG_REQ(with, tkconfig,  [  --with-tkconfig=DIR     tkConfig.sh is in DIR])
386
387
388 #
389 # Optionally build Perl modules (Pg.pm and PL/Perl)
390 #
391 AC_MSG_CHECKING([whether to build Perl modules])
392 PGAC_ARG_BOOL(with, perl, no, [  --with-perl             build Perl interface and PL/Perl])
393 AC_MSG_RESULT([$with_perl])
394 AC_SUBST(with_perl)
395
396
397 #
398 # Optionally build Python interface module
399 #
400 AC_MSG_CHECKING([whether to build Python modules])
401 PGAC_ARG_BOOL(with, python, no, [  --with-python           build Python interface module],
402 [AC_MSG_RESULT(yes)
403 PGAC_PROG_PYTHON
404 PGAC_PATH_PYTHONDIR],
405 [AC_MSG_RESULT(no)])
406 AC_SUBST(with_python)
407
408
409 dnl A note on the Kerberos and OpenSSL options:
410 dnl
411 dnl The user can give an argument to the option in order the specify
412 dnl the base path of the respective installation (what he specified
413 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
414 dnl then we take the path where the package installs by default. This
415 dnl way the user doesn't have to use redundant --with-includes and
416 dnl --with-libraries options, but he can still use them if the layout
417 dnl is non-standard.
418
419 #
420 # Kerberos 4
421 #
422 PGAC_ARG_OPTARG(with, krb4, [  --with-krb4[=DIR]       build with Kerberos 4 support [/usr/athena]],
423                 [krb4_prefix=/usr/athena],
424                 [krb4_prefix=$withval],
425 [
426   AC_MSG_RESULT([building with Kerberos 4 support])
427   AC_DEFINE(KRB4, 1, [Define if you are building with Kerberos 4 support.])
428
429   if test -d "$krb4_prefix/include"; then
430     INCLUDES="$INCLUDES -I$krb4_prefix/include"
431   fi
432   if test -d "$krb4_prefix/lib"; then
433     LIBDIRS="$LIBDIRS -L$krb4_prefix/lib"
434   fi
435
436   krb_srvtab="/etc/srvtab"
437 ])
438
439 AC_SUBST(with_krb4)
440
441
442 #
443 # Kerberos 5
444 #
445 PGAC_ARG_OPTARG(with, krb5, [  --with-krb5[=DIR]       build with Kerberos 5 support [/usr/athena]],
446               [krb5_prefix=/usr/athena],
447               [krb5_prefix=$withval],
448 [
449   AC_MSG_RESULT([building with Kerberos 5 support])
450   AC_DEFINE(KRB5, 1, [Define if you are building with Kerberos 5 support.])
451
452   if test -d "$krb5_prefix/include"; then
453     INCLUDES="$INCLUDES -I$krb5_prefix/include"
454   fi
455   if test -d "$krb5_prefix/lib"; then
456     LIBDIRS="$LIBDIRS -L$krb5_prefix/lib"
457   fi
458
459   krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
460 ])
461
462 AC_SUBST(with_krb5)
463
464
465 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
466 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
467   AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
468 fi
469
470 AC_SUBST(krb_srvtab)
471
472
473 #
474 # Kerberos configuration parameters
475 #
476 PGAC_ARG_REQ(with, krb-srvnam,
477              [  --with-krb-srvnam=NAME  name of the service principal in Kerberos [postgres]],
478              [],
479              [with_krb_srvnam="postgres"])
480 AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
481                    [The name of the PostgreSQL service principal in Kerberos])
482
483
484
485 #
486 # OpenSSL
487 #
488 PGAC_ARG_OPTARG(with, openssl,
489                 [  --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]],
490                 [openssl_prefix=/usr/local/ssl],
491                 [openssl_prefix=$withval],
492 [
493   AC_MSG_RESULT([building with OpenSSL support])
494   AC_DEFINE([USE_SSL], 1, [Define to build with (Open)SSL support])
495
496   if test -d "${openssl_prefix}/include" ; then
497     INCLUDES="$INCLUDES -I${openssl_prefix}/include"
498   fi
499   if test -d "${openssl_prefix}/lib" ; then
500     LIBDIRS="$LIBDIRS -L${openssl_prefix}/lib"
501   fi
502 ])
503
504 AC_SUBST(with_openssl)
505
506
507
508 #
509 # Optionally enable the building of the ODBC driver
510 #
511  
512 # Old option name
513 if test "${with_odbc+set}" = set && test "${enable_odbc+set}" != set; then
514   enable_odbc=$with_odbc
515 fi
516  
517 AC_MSG_CHECKING([whether to build the ODBC driver])
518 PGAC_ARG_BOOL(enable, odbc, no, [  --enable-odbc           build the ODBC driver package])
519 AC_MSG_RESULT([$enable_odbc])
520 AC_SUBST([enable_odbc])
521
522
523 # Allow for overriding the default location of the odbcinst.ini
524 # file which is normally ${sysconfdir} (i.e., ${prefix}/etc).
525 PGAC_ARG_REQ(with, odbcinst,
526              [  --with-odbcinst=DIR     default directory for odbcinst.ini [sysconfdir]],
527              [odbcinst_ini_dir=$withval],
528              [odbcinst_ini_dir="\${sysconfdir}"])
529 AC_SUBST([odbcinst_ini_dir])
530
531
532
533 # Assume system is ELF if it predefines __ELF__ as 1,
534 # otherwise believe host_os based default.
535 case $host_os in
536   freebsd1*|freebsd2*) elf=yes;;
537 esac
538
539 AC_EGREP_CPP(yes,
540 [#if __ELF__
541   yes
542 #endif
543 ],
544 [ELF_SYS=true],
545 [if test "X$elf" = "Xyes" ; then
546   ELF_SYS=true
547 else
548   ELF_SYS=
549 fi])
550 AC_SUBST(ELF_SYS)
551
552
553
554 #
555 # Optionally build C++ code (i.e., libpq++)
556 #
557 AC_MSG_CHECKING([whether to build C++ modules])
558 PGAC_ARG_OPTARG(with, CXX, [  --with-CXX              build C++ modules (libpq++)],
559                 [],
560                 [CXX=$withval],
561 [
562   AC_MSG_RESULT(yes)
563
564   # If the user has specified CXXFLAGS in the environment, leave it
565   # alone, else use a default.
566
567   has_environ_CXXFLAGS="${CXXFLAGS+yes}"
568   AC_PROG_CXX
569   if test "$has_environ_CXXFLAGS" != yes; then
570     if test "$GXX" = yes; then
571       CXXFLAGS=-O2
572     else
573       case $template in
574         osf)            CXXFLAGS='-O4 -Olimit 2000' ;;
575         unixware)       CXXFLAGS='-O' ;;
576         *)              CXXFLAGS= ;;
577       esac
578     fi
579   fi
580   if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
581     CXXFLAGS="$CXXFLAGS -g"
582   fi
583   echo "using CXXFLAGS=$CXXFLAGS"
584
585   AC_PROG_CXXCPP
586   AC_SUBST(GXX)
587   PGAC_CLASS_STRING
588   PGAC_CXX_NAMESPACE_STD
589 ],
590 [AC_MSG_RESULT(no)])
591 AC_SUBST(with_CXX)
592
593 CPPFLAGS="$CPPFLAGS $INCLUDES"
594 LDFLAGS="$LDFLAGS $LIBDIRS"
595
596 echo "using CPPFLAGS=$CPPFLAGS"
597 echo "using LDFLAGS=$LDFLAGS"
598
599
600 # Figure out how to invoke "install" and what install options to use.
601
602 AC_PROG_INSTALL
603 # When Autoconf chooses install-sh as install program it tries to generate
604 # a relative path to it in each makefile where it subsitutes it. This clashes
605 # with our Makefile.global concept. This workaround helps.
606 case $INSTALL in
607   *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
608 esac
609
610 # Fix Autoconf's brain-dead defaults for script installs.
611 INSTALL_SCRIPT="\${INSTALL} -m 755"
612
613 # HPUX wants shared libs to be mode 555. Add your platform's special
614 # needs here if necessary.
615 case $host_os in
616     hpux*)      INSTL_SHLIB_OPTS="-m 555" ;;
617     *)          INSTL_SHLIB_OPTS="-m 755" ;;
618 esac
619
620 INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
621 AC_SUBST(INSTALL_SHLIB)
622
623
624 AC_PROG_AWK
625 PGAC_PATH_FLEX
626 AC_PROG_LN_S
627 AC_PROG_LD
628 AC_SUBST(LD)
629 AC_SUBST(with_gnu_ld)
630 case $host_os in sysv5uw*)
631   AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
632   [
633     pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,-R/usr/lib"
634     AC_TRY_LINK([], [], [pgac_cv_prog_ld_R=yes], [pgac_cv_prog_ld_R=no])
635     LDFLAGS=$pgac_save_LDFLAGS
636   ])
637   ld_R_works=$pgac_cv_prog_ld_R
638   AC_SUBST(ld_R_works)
639 esac
640 AC_PROG_RANLIB
641 AC_CHECK_PROGS(LORDER, lorder)
642 AC_PATH_PROG(TAR, tar)
643 AC_CHECK_PROGS(PERL, perl)
644 AC_PROG_YACC
645 AC_SUBST(YFLAGS)
646 if test "$with_tk" = yes; then
647     AC_PATH_PROG(WISH, wish)
648     test -z "$WISH" && AC_MSG_ERROR(['wish' is required for Tk support])
649 fi
650
651
652 ##
653 ## Libraries
654 ##
655
656 AC_CHECK_LIB(sfio,     main)
657 AC_CHECK_LIB(ncurses,  main, [], [AC_CHECK_LIB(curses, main)])
658 AC_CHECK_LIB(termcap,  main)
659 AC_CHECK_LIB(readline, readline)
660 AC_SEARCH_LIBS(using_history, history, [AC_DEFINE(HAVE_HISTORY_FUNCTIONS)])
661
662 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
663 then
664         AC_CHECK_LIB(bsd,      main)
665 fi
666 AC_CHECK_LIB(util,     setproctitle)
667 AC_CHECK_LIB(m,        main)
668 AC_CHECK_LIB(dl,       main)
669 AC_CHECK_LIB(socket,   main)
670 AC_CHECK_LIB(nsl,      main)
671 AC_CHECK_LIB(ipc,      main)
672 AC_CHECK_LIB(IPC,      main)
673 AC_CHECK_LIB(lc,       main)
674 AC_CHECK_LIB(dld,      main)
675 AC_CHECK_LIB(ld,       main)
676 AC_CHECK_LIB(compat,   main)
677 AC_CHECK_LIB(BSD,      main)
678 AC_CHECK_LIB(gen,      main)
679 AC_CHECK_LIB(PW,       main)
680 AC_SEARCH_LIBS(crypt,  crypt)
681 AC_CHECK_LIB(z,        inflate)
682 AC_CHECK_LIB(bind,     __inet_ntoa)
683
684
685 if test "$with_krb4" = yes ; then
686   AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])])
687   AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])])
688 fi
689
690 if test "$with_krb5" = yes ; then
691   AC_CHECK_LIB(com_err, [com_err], [], [AC_MSG_ERROR([library 'com_err' is required for Kerberos 5])])
692   AC_CHECK_LIB(crypto,  [krb5_encrypt], [],
693     [AC_CHECK_LIB(k5crypto, [krb5_encrypt], [], [AC_MSG_ERROR([library 'crypto' or 'k5crypto' is required for Kerberos 5])])])
694   AC_CHECK_LIB(krb5,    [krb5_sendauth], [], [AC_MSG_ERROR([library 'krb5' is required for Kerberos 5])])
695 fi
696
697 if test "$with_openssl" = yes ; then
698   dnl Order matters!
699   AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
700   AC_CHECK_LIB(ssl,    [SSL_library_init], [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
701 fi
702
703
704 ##
705 ## Header files
706 ##
707 dnl sys/socket.h and sys/types.h are required by AC_FUNC_ACCEPT_ARGTYPES
708 AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h pwd.h sys/ipc.h sys/pstat.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/types.h sys/un.h termios.h kernel/OS.h kernel/image.h SupportDefs.h])
709
710 dnl At least on IRIX, cpp test for netinet/tcp.h will fail unless netinet/in.h
711 dnl is included first.  So can't just use AC_CHECK_HEADERS; do it this way:
712 AC_CHECK_HEADERS([netinet/in.h])
713 AC_MSG_CHECKING([for netinet/tcp.h])
714 AC_TRY_CPP([
715 #ifdef HAVE_NETINET_IN_H
716 #include <netinet/in.h>
717 #endif
718 #include <netinet/tcp.h>
719 ], [AC_DEFINE(HAVE_NETINET_TCP_H) AC_MSG_RESULT(yes)],
720 [AC_MSG_RESULT(no)])
721
722 PGAC_HEADER_STRING
723
724 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
725 AC_CHECK_HEADERS([readline/history.h history.h], [break])
726
727 if test "$with_krb4" = yes ; then
728   AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
729 fi
730
731 if test "$with_krb5" = yes ; then
732   AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
733   AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
734 fi
735
736 if test "$with_openssl" = yes ; then
737   AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
738   AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
739 fi
740
741
742 ##
743 ## Types, structures, compiler characteristics
744 ##
745 AC_C_CONST
746 AC_C_INLINE
747 AC_C_STRINGIZE
748 PGAC_C_SIGNED
749 PGAC_C_VOLATILE
750 AC_STRUCT_TIMEZONE
751 PGAC_UNION_SEMUN
752 PGAC_STRUCT_SOCKADDR_UN
753
754 ##
755 ## Functions, global variables
756 ##
757 PGAC_VAR_INT_TIMEZONE
758 AC_FUNC_ACCEPT_ARGTYPES
759 PGAC_FUNC_GETTIMEOFDAY_1ARG
760
761 AC_CHECK_FUNCS([fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen])
762
763 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
764 [AC_TRY_LINK(
765 [#include <machine/vmparam.h>
766 #include <sys/exec.h>
767 ],
768 [PS_STRINGS->ps_nargvstr = 1;
769 PS_STRINGS->ps_argvstr = "foo";],
770 [pgac_cv_var_PS_STRINGS=yes],
771 [pgac_cv_var_PS_STRINGS=no])])
772 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
773   AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
774 fi
775
776 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
777 dnl is missing.  Yes, there are machines that have only one.
778 dnl We may also decide to use snprintf.c if snprintf() is present but does
779 dnl not have working "long long int" support -- see below.
780 SNPRINTF=''
781 AC_CHECK_FUNC(snprintf,
782               AC_DEFINE(HAVE_SNPRINTF),
783               SNPRINTF='snprintf.o')
784 AC_CHECK_FUNC(vsnprintf,
785               AC_DEFINE(HAVE_VSNPRINTF),
786               SNPRINTF='snprintf.o')
787 AC_SUBST(SNPRINTF)
788 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
789 dnl include/c.h will provide declarations.  Note this is a separate test
790 dnl from whether the functions exist in the C library --- there are systems
791 dnl that have the functions but don't bother to declare them :-(
792 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
793 dnl declares vsnprintf() but not snprintf().  Hopefully there are no
794 dnl systems that are *that* brain-damaged...
795 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
796 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
797
798 # do this one the hard way in case isinf() is a macro
799 AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
800 [AC_TRY_LINK(
801 [#include <math.h>
802 ],
803 [double x = 0.0; int res = isinf(x);],
804 [ac_cv_func_isinf=yes],
805 [ac_cv_func_isinf=no])])
806
807 if test $ac_cv_func_isinf = yes ; then
808   AC_DEFINE(HAVE_ISINF)
809   ISINF=
810 else
811   ISINF='isinf.o'
812   # Look for a way to implement a substitute for isinf()
813   AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
814 fi
815 AC_SUBST(ISINF)
816
817 AC_CHECK_FUNC(getrusage,
818               AC_DEFINE(HAVE_GETRUSAGE),
819               GETRUSAGE='getrusage.o')
820 AC_SUBST(GETRUSAGE)
821 AC_CHECK_FUNC(srandom,
822               AC_DEFINE(HAVE_SRANDOM),
823               SRANDOM='srandom.o')
824 AC_SUBST(SRANDOM)
825 AC_CHECK_FUNC(gethostname,
826               AC_DEFINE(HAVE_GETHOSTNAME),
827               GETHOSTNAME='gethostname.o')
828 AC_SUBST(GETHOSTNAME)
829 AC_CHECK_FUNC(random,
830               AC_DEFINE(HAVE_RANDOM),
831               MISSING_RANDOM='random.o')
832 AC_SUBST(MISSING_RANDOM)
833 AC_CHECK_FUNC(inet_aton,
834               AC_DEFINE(HAVE_INET_ATON),
835               INET_ATON='inet_aton.o')
836 AC_SUBST(INET_ATON)
837 AC_CHECK_FUNC(strerror,
838               AC_DEFINE(HAVE_STRERROR),
839               [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
840 AC_SUBST(STRERROR)
841 AC_SUBST(STRERROR2)
842 AC_CHECK_FUNC(strdup,
843               AC_DEFINE(HAVE_STRDUP),
844               STRDUP='../../utils/strdup.o')
845 AC_SUBST(STRDUP)
846 AC_CHECK_FUNC(strtol,
847               AC_DEFINE(HAVE_STRTOL),
848               STRTOL='strtol.o')
849 AC_SUBST(STRTOL)
850 AC_CHECK_FUNC(strtoul,
851               AC_DEFINE(HAVE_STRTOUL),
852               STRTOL='strtoul.o')
853 AC_SUBST(STRTOUL)
854 AC_CHECK_FUNC(strcasecmp,
855               AC_DEFINE(HAVE_STRCASECMP),
856               STRCASECMP='strcasecmp.o')
857 AC_SUBST(STRCASECMP)
858 AC_CHECK_FUNC(cbrt,
859               AC_DEFINE(HAVE_CBRT),
860               AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
861
862 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
863 # this hackery with HPUXMATHLIB allows us to cope.
864 HPUXMATHLIB=""
865 case $host_cpu in
866   hppa1.1) 
867         if [[ -r /lib/pa1.1/libm.a ]] ; then
868             HPUXMATHLIB="-L /lib/pa1.1 -lm"
869         fi ;;
870 esac
871 AC_SUBST(HPUXMATHLIB)
872
873 AC_CHECK_FUNC(rint,
874               AC_DEFINE(HAVE_RINT),
875               AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
876
877
878 # Readline versions < 2.1 don't have rl_completion_append_character
879 AC_MSG_CHECKING([for rl_completion_append_character])
880 AC_TRY_LINK([#include <stdio.h>
881 #ifdef HAVE_READLINE_H
882 # include <readline.h>
883 #endif
884 #ifdef HAVE_READLINE_READLINE_H
885 # include <readline/readline.h>
886 #endif],
887 [rl_completion_append_character = 'x';],
888 [AC_MSG_RESULT(yes)
889 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER)],
890 [AC_MSG_RESULT(no)])
891
892
893 # Check whether readline's filename_completion_function is declared.
894 # Some prehistoric versions of readline, in particular those shipped
895 # with earlier Cygwins don't have this declared, although it's in the
896 # library.
897 AC_MSG_CHECKING([whether filename_completion_function is declared])
898 if test "$ac_cv_header_readline_h" = yes; then
899     _readline_header='readline.h'
900 elif test "$ac_cv_header_readline_readline_h" = yes; then
901     _readline_header='readline/readline.h'
902 else
903     _readline_header='xxx'
904 fi
905 AC_EGREP_HEADER([filename_completion_function], [$_readline_header],
906 [AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
907 AC_MSG_RESULT(yes)],
908 [AC_MSG_RESULT(no)])
909
910
911
912 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
913 AC_MSG_CHECKING(for finite)
914 AC_TRY_LINK([#include <math.h>],
915         [int dummy=finite(1.0);],
916         [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
917         AC_MSG_RESULT(no))
918
919 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
920 dnl (especially on GNU libc)
921 dnl See also comments in config.h.
922 AC_MSG_CHECKING(for sigsetjmp)
923 AC_TRY_LINK([#include <setjmp.h>],
924         [sigjmp_buf x; sigsetjmp(x, 1);],
925         [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
926         AC_MSG_RESULT(no))
927
928
929 PGAC_ARG_BOOL(enable, syslog, no, [  --enable-syslog         enable logging to syslog],
930               [AC_CHECK_FUNC(syslog,
931                              [AC_DEFINE([ENABLE_SYSLOG], 1,
932                                         [Define to 1 if to enable the syslogging code])],
933                              [AC_MSG_ERROR([no syslog interface found])])])
934
935
936 AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
937 [AC_TRY_LINK([#include <unistd.h>],
938   [extern int optreset; optreset = 1;],
939   [pgac_cv_var_int_optreset=yes],
940   [pgac_cv_var_int_optreset=no])])
941 if test x"$pgac_cv_var_int_optreset" = x"yes"; then
942   AC_DEFINE(HAVE_INT_OPTRESET, 1)
943 fi
944
945
946 dnl Check to see if we have a working 64-bit integer type.
947 dnl This breaks down into two steps:
948 dnl (1) figure out if the compiler has a 64-bit int type with working
949 dnl arithmetic, and if so
950 dnl (2) see whether snprintf() can format the type correctly.  (Currently,
951 dnl snprintf is the only library routine we really need for int8 support.)
952 dnl It's entirely possible to have a compiler that handles a 64-bit type
953 dnl when the C library doesn't; this is fairly likely when using gcc on
954 dnl an older platform, for example.
955 dnl If there is no native snprintf() or it does not handle the 64-bit type,
956 dnl we force our own version of snprintf() to be used instead.
957 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
958
959 PGAC_TYPE_64BIT_INT([long int])
960
961 if test x"$HAVE_LONG_INT_64" = x"no" ; then
962   PGAC_TYPE_64BIT_INT([long long int])
963 fi
964
965
966 dnl If we found "long int" is 64 bits, assume snprintf handles it.
967 dnl If we found we need to use "long long int", better check.
968 dnl We cope with snprintfs that use either %lld or %qd as the format.
969 dnl If neither works, fall back to our own snprintf emulation (which we
970 dnl know uses %lld).
971
972 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
973   if [[ x$SNPRINTF = x ]] ; then
974     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
975     AC_TRY_RUN([#include <stdio.h>
976 typedef long long int int64;
977 #define INT64_FORMAT "%lld"
978
979 int64 a = 20000001;
980 int64 b = 40000005;
981
982 int does_int64_snprintf_work()
983 {
984   int64 c;
985   char buf[100];
986
987   if (sizeof(int64) != 8)
988     return 0;                   /* doesn't look like the right size */
989
990   c = a * b;
991   snprintf(buf, 100, INT64_FORMAT, c);
992   if (strcmp(buf, "800000140000005") != 0)
993     return 0;                   /* either multiply or snprintf is busted */
994   return 1;
995 }
996 main() {
997   exit(! does_int64_snprintf_work());
998 }],
999         [ AC_MSG_RESULT(yes)
1000           INT64_FORMAT='"%lld"'
1001         ],
1002   [ AC_MSG_RESULT(no)
1003     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd) 
1004     AC_TRY_RUN([#include <stdio.h>
1005 typedef long long int int64;
1006 #define INT64_FORMAT "%qd"
1007    
1008 int64 a = 20000001;
1009 int64 b = 40000005;
1010    
1011 int does_int64_snprintf_work()
1012 {  
1013   int64 c;
1014   char buf[100];
1015
1016   if (sizeof(int64) != 8)
1017     return 0;     /* doesn't look like the right size */
1018
1019   c = a * b;
1020   snprintf(buf, 100, INT64_FORMAT, c);
1021   if (strcmp(buf, "800000140000005") != 0)
1022     return 0;     /* either multiply or snprintf is busted */
1023   return 1;
1024 }
1025 main() {
1026   exit(! does_int64_snprintf_work());
1027 }],
1028   [ AC_MSG_RESULT(yes)
1029     INT64_FORMAT='"%qd"'
1030   ],
1031   [ AC_MSG_RESULT(no)
1032         # Force usage of our own snprintf, since system snprintf is broken
1033         SNPRINTF='snprintf.o'
1034         INT64_FORMAT='"%lld"'
1035   ],
1036   [ AC_MSG_RESULT(assuming not on target machine)
1037         # Force usage of our own snprintf, since we cannot test foreign snprintf
1038         SNPRINTF='snprintf.o'
1039         INT64_FORMAT='"%lld"'
1040   ]) ],
1041   [ AC_MSG_RESULT(assuming not on target machine)
1042         # Force usage of our own snprintf, since we cannot test foreign snprintf
1043         SNPRINTF='snprintf.o'
1044         INT64_FORMAT='"%lld"'
1045   ])
1046   else
1047     # here if we previously decided we needed to use our own snprintf
1048     INT64_FORMAT='"%lld"'
1049   fi
1050 else
1051   # Here if we are not using 'long long int' at all
1052   INT64_FORMAT='"%ld"'
1053 fi
1054
1055 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
1056
1057
1058 AC_CHECK_FUNCS([strtoll strtoq], [break])
1059 AC_CHECK_FUNCS([strtoull strtouq], [break])
1060
1061
1062 dnl Determine memory alignment requirements for the basic C datatypes.
1063
1064 PGAC_CHECK_ALIGNOF(short)
1065 PGAC_CHECK_ALIGNOF(int)
1066 PGAC_CHECK_ALIGNOF(long)
1067 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1068   PGAC_CHECK_ALIGNOF(long long int)
1069 fi
1070 PGAC_CHECK_ALIGNOF(double)
1071
1072 dnl Compute maximum alignment of any basic type.
1073 dnl We assume long's alignment is at least as strong as char, short, or int;
1074 dnl but we must check long long (if it exists) and double.
1075
1076 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1077   MAX_ALIGNOF=$pgac_cv_alignof_long
1078   if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1079     MAX_ALIGNOF=$pgac_cv_alignof_double
1080   fi
1081   if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1082     MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1083   fi
1084 else
1085   dnl cross-compiling: assume that double's alignment is worst case
1086   MAX_ALIGNOF="$pgac_cv_alignof_double"
1087 fi
1088 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1089
1090 PGAC_FUNC_POSIX_SIGNALS
1091
1092
1093 # Check for Tcl configuration script tclConfig.sh
1094 if test "$with_tcl" = yes; then
1095     PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
1096 fi
1097
1098 # Check for Tk configuration script tkConfig.sh
1099 if test "$with_tk" = yes; then
1100     PGAC_PATH_TKCONFIGSH([$with_tkconfig $with_tclconfig])
1101 fi
1102
1103
1104 #
1105 # Check for DocBook and tools
1106 #
1107 PGAC_PROG_NSGMLS
1108 # If you don't have nsgmls you won't get very far, so save the cycles.
1109 if test -n "$NSGMLS"; then
1110   PGAC_PROG_JADE
1111   PGAC_CHECK_DOCBOOK([3.1])
1112   PGAC_PATH_DOCBOOK_STYLESHEETS
1113   AC_CHECK_PROGS(SGMLSPL, sgmlspl)
1114 fi
1115
1116
1117 # Finally ready to produce output files ...
1118
1119 if test x"$abs_top_srcdir" != x"$abs_top_builddir"; then
1120   echo $ac_n "preparing build tree... $ac_c" 1>&6
1121   /bin/sh "$srcdir/config/prep_buildtree" "$abs_top_srcdir" "$abs_top_builddir" \
1122     || AC_MSG_ERROR(failed)
1123   AC_MSG_RESULT(done)
1124 fi
1125
1126 AC_OUTPUT(
1127 [
1128   GNUmakefile
1129   src/GNUmakefile
1130   src/Makefile.global
1131   src/backend/port/Makefile
1132 ],
1133 [echo "timestamp file" > src/include/stamp-h]
1134 )