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