]> granicus.if.org Git - postgresql/blob - configure.in
Another round of those unportable config/build changes :-/
[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 AC_INIT(src/backend/access/common/heaptuple.c)
18 AC_PREFIX_DEFAULT(/usr/local/pgsql)
19 AC_CONFIG_HEADER(src/include/config.h)
20
21 AC_PREREQ(2.13)
22 AC_CONFIG_AUX_DIR(config)
23
24 VERSION='7.1devel'
25 AC_SUBST(VERSION)
26 AC_DEFINE_UNQUOTED(PG_VERSION, "$VERSION")
27
28 AC_CANONICAL_HOST
29
30 tas_file=dummy.s
31 case "$host_os" in
32  solaris*)
33         case "$host_cpu" in
34           sparc) os=solaris_sparc need_tas=yes tas_file=solaris_sparc.s ;;
35            i386) os=solaris_i386 need_tas=yes tas_file=solaris_i386.s ;;
36         esac ;;
37    sunos*) os=sunos4 need_tas=no ;;
38      beos) os=beos need_tas=no ;;
39      aux*) os=aux need_tas=no ;;
40    linux*) os=linux need_tas=no ;;
41     bsdi*) os=bsdi need_tas=no ;;
42  freebsd1*|freebsd2*) os=freebsd need_tas=no ;;
43  freebsd*) os=freebsd need_tas=no elf=yes ;;
44   netbsd*) os=netbsd need_tas=no ;;
45   openbsd*) os=bsd need_tas=no ;;
46     dgux*) os=dgux need_tas=no ;;
47      aix*) os=aix need_tas=no ;;
48 nextstep*) os=nextstep need_tas=no ;;
49   ultrix*) os=ultrix4 need_tas=no ;;
50     irix*) os=irix5 need_tas=no ;;
51     hpux*) os=hpux need_tas=yes tas_file=hpux.s ;;
52      osf*) os=alpha need_tas=no ;;
53      sco*) os=sco need_tas=no ;;
54  machten*) os=machten need_tas=no ;;
55   cygwin*) os=win need_tas=no ;;
56  sysv4.2*)
57        case "$host_vendor" in
58                univel) os=univel need_tas=no ;;
59                     *) os=unknown need_tas=no ;;
60        esac ;;
61    sysv4*) os=svr4 need_tas=no ;;
62    sysv5uw*) os=unixware need_tas=no ;;
63    unixware*) os=unixware need_tas=no ;;
64     qnx*) os=qnx4 need_tas=no ;;
65 *) echo ""
66    echo "*************************************************************"
67    echo "configure does not currently recognize your operating system,"
68    echo "therefore you must do a manual configuration of:"
69    echo "$host_os"
70    echo "Please contact scrappy@hub.org to see about rectifying this, "
71    echo "including the above 'checking host system type...' line "
72    echo "*************************************************************"
73    echo ""
74    exit;;
75 esac
76
77 PORTNAME=${os}
78 CPU=${host_cpu}
79 AC_LINK_FILES(src/backend/port/dynloader/${os}.c, src/backend/port/dynloader.c)
80 AC_LINK_FILES(src/backend/port/dynloader/${os}.h, src/include/dynloader.h)
81 AC_LINK_FILES(src/include/port/${os}.h, src/include/os.h)
82 AC_LINK_FILES(src/makefiles/Makefile.${os}, src/Makefile.port)
83
84 if test "X$need_tas" = "Xyes"
85 then
86         AC_LINK_FILES(src/backend/port/tas/${tas_file}, src/backend/port/tas.s)
87         TAS=tas.o
88         AC_SUBST(TAS)
89 fi
90
91 dnl this part selects the template from the ones in the template directory.
92
93 AC_MSG_CHECKING(setting template to)
94 AC_ARG_WITH(template,
95     [  --with-template=TEMPLATE
96                           use operating system template file 
97                               see template directory],
98     [  TEMPLATE=$withval ],
99     [
100
101 # lowercase $host
102 host="`echo $host | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`"
103
104 # First, try for a template exactly matching $host
105 if test -f "src/template/$host"
106 then TEMPLATE="$host"
107 else
108     # Scan template/.similar for a rule that tells us which template to use.
109     # The format of each line of the file is
110     #           hostnamepattern=templatefilename
111     # where the hostnamepattern is evaluated per the rules of expr(1) ---
112     # namely, it is a standard regular expression with an implicit ^ at the
113     # start.  If multiple lines match, we will end up using the last match.
114     #
115     # The tempfile hackery is needed because some shells will run the loop
116     # inside a subshell, whereupon shell variables set therein aren't seen
117     # outside the loop :-(
118     TMPFILE="guesses.$$"
119     cat /dev/null > $TMPFILE
120     while read LINE
121     do
122         SIMHOST=`expr "$LINE" : '\(.*\)='`
123         MATCH=`expr "$host" : "$SIMHOST"`
124         if test "$MATCH" != 0
125         then
126             echo "$LINE" | sed 's/^.*=//' > $TMPFILE
127         fi
128     done <src/template/.similar
129     GUESS=`cat $TMPFILE`
130     rm -f $TMPFILE
131     if test "$GUESS"
132     then TEMPLATE="$GUESS"
133     else
134         # Last chance ... maybe uname -s will match an entry.
135         TEMPLATE=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
136     fi
137 fi
138     ])
139 AC_MSG_RESULT($TEMPLATE)
140
141 export TEMPLATE
142 if test ! -f "src/template/$TEMPLATE"; then
143         echo ""
144         echo "$TEMPLATE does not exist"
145         echo ""
146         echo "Available Templates (select one using --with-template):"
147         echo ""
148         ls src/template
149         echo ""
150         exit
151 fi
152
153 dnl Read the selected template file.
154 dnl For reasons of backwards compatibility, lines of the form
155 dnl     IDENTIFIER: something
156 dnl should be treated as variable assignments.  However, we also want to
157 dnl allow other shell commands in the template file (in case the file
158 dnl needs to make conditional tests, etc).  So, generate a temp file with
159 dnl the IDENTIFIER: lines translated, then source it.
160
161 [
162 rm -f conftest.sh
163 sed 's/^\([A-Za-z_]*\):\(.*\)$/\1="\2"/' "src/template/$TEMPLATE" >conftest.sh
164 . ./conftest.sh
165 rm -f conftest.sh
166 ]
167
168 dnl
169 dnl Add non-standard directories to the include path
170 dnl
171 AC_ARG_WITH(includes, [  --with-includes=DIRS    add non-standard include paths],
172 [if test x"$withval" = x"yes" || test x"$withval" = x"no" ; then
173   AC_MSG_ERROR([You must supply an argument to the --with-includes option.])
174 fi])
175
176 # SRCH_INC comes from the template file
177 ac_save_IFS=$IFS
178 IFS=':'
179 for dir in $with_includes $SRCH_INC; do
180   if test -d "$dir"; then
181     INCLUDES="$INCLUDES -I$dir"
182   else
183     AC_MSG_WARN([*** Include directory $dir does not exist.])
184   fi
185 done
186 IFS=$ac_save_IFS
187 AC_SUBST(INCLUDES)
188
189
190 dnl
191 dnl Add non-standard directories to the library search path
192 dnl
193 AC_ARG_WITH(libraries,
194     [  --with-libraries=DIRS   look for additional libraries in DIRS],
195     [
196         case "$withval" in
197         "" | y | ye | yes | n | no)
198             AC_MSG_ERROR([*** You must supply an argument to the --with-libraries option.])
199           ;;
200         esac
201         LIBRARY_DIRS="$withval"
202     ])
203
204 AC_ARG_WITH(libs,
205     [  --with-libs=DIRS        alternate spelling of --with-libraries],
206     [
207         case "$withval" in
208         "" | y | ye | yes | n | no)
209             AC_MSG_ERROR([*** You must supply an argument to the --with-libs option.])
210           ;;
211         esac
212         LIBRARY_DIRS="$withval"
213     ])
214
215 dnl LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
216 dnl Each can name one or more directories.
217 if test "$LIBRARY_DIRS" -o "$SRCH_LIB"; then
218         for dir in $LIBRARY_DIRS $SRCH_LIB; do
219                 if test -d "$dir"; then
220                         PGSQL_LDFLAGS="$PGSQL_LDFLAGS -L$dir"
221                 else
222                         AC_MSG_WARN([*** Library directory $dir does not exist.])
223                 fi
224         done
225 fi
226
227
228 AC_MSG_CHECKING(whether to support locale)
229 AC_ARG_ENABLE(
230    locale,
231    [  --enable-locale         enable locale support ],
232    [AC_DEFINE(USE_LOCALE) AC_MSG_RESULT(enabled)],
233    AC_MSG_RESULT(disabled)
234 )
235
236 dnl We exclude cyrillic recode support unless we override it with
237 dnl     --enable-recode to explicitly enable it
238 dnl It defaults to disabled
239 AC_MSG_CHECKING(whether to support cyrillic recode)
240 AC_ARG_ENABLE(
241    recode,
242    [  --enable-recode         enable cyrillic recode support ],
243    [AC_DEFINE(CYR_RECODE) AC_MSG_RESULT(enabled)],
244    AC_MSG_RESULT(disabled)
245 )
246
247 dnl Multibyte support
248
249 AC_MSG_CHECKING(whether to support multibyte)
250 AC_ARG_ENABLE(multibyte,
251     [  --enable-multibyte      enable multibyte character support ], 
252     [
253         MULTIBYTE=SQL_ASCII
254         if test "$enableval" != "yes"; then
255                 case "$enableval" in
256                         SQL_ASCII|EUC_JP|EUC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|KOI8|WIN|ALT)
257                         # ok
258                         ;;
259                 *)
260                         AC_MSG_ERROR(
261 [Argument to --enable-multibyte must be one of:
262   SQL_ASCII, EUC_JP, EUC_CN, EUC_KR, EUC_TW,
263   UNICODE, MULE_INTERNAL,
264   LATIN1, LATIN2, LATIN3, LATIN4, LATIN5,
265   KOI8, WIN, ALT
266 Or do not specify an argument to the option to use the default.])
267                 esac
268                 MULTIBYTE=$enableval
269         fi
270         AC_DEFINE(MULTIBYTE)
271         AC_MSG_RESULT(enabled)
272     ],
273     AC_MSG_RESULT("disabled")
274 )
275
276 dnl Old option variant
277 if test "${with_mb}"; then
278   AC_MSG_ERROR([--with-mb is not supported anymore. Use --enable-multibyte instead.])
279 fi
280
281
282 dnl We use the default value of 5432 for the DEF_PGPORT value.  If
283 dnl we over-ride it with --with-pgport=port then we bypass this piece
284 AC_MSG_CHECKING(setting DEF_PGPORT)
285 AC_ARG_WITH(
286    pgport,
287    [  --with-pgport=PORTNUM   change default postmaster port ],
288    [default_port="$withval"],
289    [default_port=5432]
290 )
291 dnl Need both of these because backend wants an integer and frontend a string
292 AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port})
293 AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
294 AC_MSG_RESULT(${default_port})
295
296
297 dnl DEF_MAXBACKENDS can be set by --with-maxbackends.  Default value is 32.
298 AC_MSG_CHECKING(setting DEF_MAXBACKENDS)
299 AC_ARG_WITH(
300    maxbackends,
301    [  --with-maxbackends=N    set default maximum number of server processes ],
302    AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, ${withval}) AC_MSG_RESULT($with_maxbackends),
303    AC_DEFINE_UNQUOTED(DEF_MAXBACKENDS, 32) AC_MSG_RESULT(32)
304 )
305
306
307 dnl Check for C support (allow override if needed)
308 dnl Note: actually, setting CC environment variable works just as well.
309 AC_ARG_WITH(CC,
310     [  --with-CC=compiler      use specific C compiler],
311     [
312         case "$withval" in
313         "" | y | ye | yes | n | no)
314             AC_MSG_ERROR([*** You must supply an argument to the --with-CC option.])
315           ;;
316         esac
317         CC="$withval"
318     ])
319
320 dnl Find a compiler if CC is not already set.
321 AC_PROG_CC
322 dnl Find CPP, then check traditional.
323 dnl Caution: these macros must be called in this order...
324 AC_PROG_CPP
325 AC_PROG_GCC_TRADITIONAL
326 AC_SUBST(GCC)
327
328 if test x"$GCC" = x"yes" ; then
329   cc_string="GCC `${CC} --version`"
330 else
331   cc_string=$CC
332 fi
333 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])
334
335
336
337 dnl We exclude tcl support unless user says --with-tcl
338 AC_MSG_CHECKING(setting USE_TCL)
339 AC_ARG_WITH(
340    tcl,
341    [  --with-tcl              build Tcl interfaces and pgtclsh ],
342    [
343         case "$withval" in
344         y | ye | yes)           USE_TCL=true; USE_TK=true; AC_MSG_RESULT(enabled) ;;
345         *)                      USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ;;
346         esac
347    ],
348    [ USE_TCL=; USE_TK=; AC_MSG_RESULT(disabled) ]
349 )
350
351 export USE_TCL
352 export USE_TK
353
354 dnl We see if the path to the TCL/TK configuration scripts is specified.
355 dnl This will override the use of tclsh to find the paths to search.
356
357 AC_ARG_WITH(tclconfig,
358     [  --with-tclconfig=DIR    tclConfig.sh and tkConfig.sh are in DIR],
359     [
360         case "$withval" in
361         "" | y | ye | yes | n | no)
362             AC_MSG_ERROR([*** You must supply an argument to the --with-tclconfig option.])
363           ;;
364         esac
365         TCL_DIRS="$withval"
366     ]
367 )
368
369 dnl We see if the path to the TK configuration scripts is specified.
370 dnl This will override the use of tclsh to find the paths to search.
371
372 AC_ARG_WITH(tkconfig,
373     [  --with-tkconfig=DIR     tkConfig.sh is in DIR],
374     [
375         case "$withval" in
376         "" | y | ye | yes | n | no)
377             AC_MSG_ERROR([*** You must supply an argument to the --with-tkconfig option.])
378           ;;
379         esac
380         TK_DIRS="$withval"
381     ]
382 )
383
384
385 dnl
386 dnl Optionally build Perl modules (Pg.pm and PL/Perl)
387 dnl
388 AC_MSG_CHECKING(whether to build Perl modules)
389 AC_ARG_WITH(perl, [  --with-perl             build Perl interface and plperl],
390 [if test x"${withval}" = x"yes" ; then
391   AC_MSG_RESULT(yes)
392 else
393   AC_MSG_RESULT(no)
394 fi],
395 [AC_MSG_RESULT(no)])
396 AC_SUBST(with_perl)
397
398
399 dnl
400 dnl Optionally build Python interface module
401 dnl
402 AC_MSG_CHECKING(whether to build Python modules)
403 AC_ARG_WITH(python, [  --with-python           build Python interface module],
404 [if test x"${withval}" = x"yes" ; then
405   AC_MSG_RESULT(yes)
406   PGAC_PROG_PYTHON
407   PGAC_PATH_PYTHONDIR
408 else
409   AC_MSG_RESULT(no)
410 fi],
411 [AC_MSG_RESULT(no)])
412 AC_SUBST(with_python)
413
414
415 dnl A note on the Kerberos and OpenSSL options:
416 dnl
417 dnl The user can give an argument to the option in order the specify
418 dnl the base path of the respective installation (what he specified
419 dnl perhaps as --prefix). If no argument is given ($withval is "yes")
420 dnl then we take the path where the package installs by default. This
421 dnl way the user doesn't have to use redundant --with-includes and
422 dnl --with-libraries options, but he can still use them if the layout
423 dnl is non-standard.
424
425 #
426 # Kerberos 4
427 #
428 AC_ARG_WITH(krb4, [  --with-krb4[=DIR]       use Kerberos 4 [/usr/athena]],
429 [if test x"$withval" != x"no"; then
430   if test x"$withval" != x"yes"; then
431     krb4_prefix=$withval
432   else
433     krb4_prefix=/usr/athena
434   fi
435   with_krb4=yes
436 else
437   with_krb4=no
438 fi],
439 [with_krb4=no])
440
441 AC_SUBST(with_krb4)
442 if test "$with_krb4" = yes ; then
443   AC_MSG_RESULT([building with Kerberos 4 support])
444   AC_DEFINE(KRB4, [], [Define if you are building with Kerberos 4 support.])
445
446   if test -d "$krb4_prefix"; then
447     if test -d "$krb4_prefix/include"; then
448       INCLUDES="$INCLUDES -I$krb4_prefix/include"
449     fi
450     if test -d "$krb4_prefix/lib"; then
451       krb_libdir="-L$krb4_prefix/lib"
452       LIBS="$krb_libdir $LIBS"
453     fi
454   fi
455   dnl Test for these libraries is below
456   KRB_LIBS="$krb_libdir -lkrb -ldes"
457 fi
458
459
460 #
461 # Kerberos 5
462 #
463 AC_ARG_WITH(krb5, [  --with-krb5[=DIR]       use Kerberos 5 [/usr/athena]],
464 [if test x"$withval" != x"no"; then
465   if test x"$withval" != x"yes"; then
466     krb5_prefix=$withval
467   else
468     krb5_prefix=/usr/athena
469   fi
470   with_krb5=yes
471 else
472   with_krb5=no
473 fi],
474 [with_krb5=no])
475
476 AC_SUBST(with_krb5)
477 if test "$with_krb5" = yes ; then
478   AC_MSG_RESULT([building with Kerberos 5 support])
479   AC_DEFINE(KRB5,, [Define if you are building with Kerberos 5 support.])
480
481   if test -d $krb5_prefix; then
482     if test -d "$krb5_prefix/include"; then
483       INCLUDES="$INCLUDES -I$krb5_prefix/include"
484     fi
485     if test -d "$krb5_prefix/lib"; then
486       krb_libdir="-L$krb5_prefix/lib"
487       LIBS="$krb_libdir $LIBS"
488     fi
489   fi
490
491   dnl Test for these libraries is below
492   KRB_LIBS="$krb_libdir -lkrb5 -lcrypto -lcom_err"
493 fi
494
495
496 # Using both Kerberos 4 and Kerberos 5 at the same time isn't going to work.
497 if test "$with_krb4" = yes && test "$with_krb5" = yes ; then
498   AC_MSG_ERROR([Kerberos 4 and Kerberos 5 support cannot be combined])
499 fi
500
501 dnl Necessary for special libpq link
502 AC_SUBST(KRB_LIBS)
503
504
505 #
506 # Kerberos configuration parameters
507 #
508 AC_ARG_WITH(krb-srvnam, [  --with-krb-srvnam=NAME  name of the Postgres service principal in Kerberos],
509 [if test x"$withval" = x"yes"; then
510   AC_MSG_ERROR([argument required for --with-krb-srvnam])
511 else
512   krb_srvnam=$withval
513 fi],
514 [krb_srvnam="postgres"])
515 AC_DEFINE_UNQUOTED(PG_KRB_SRVNAM, ["$krb_srvnam"], [The name of the Postgres service principal])
516
517 AC_ARG_WITH(krb-srvtab, [  --with-krb-srvtab=FILE  location of Kerberos server's keytab file],
518 [if test x"$withval" = x"yes"; then
519   AC_MSG_ERROR([argument required for --with-krb-srvtab])
520 else
521   krb_srvtab=$withval
522 fi],
523 [if test "$with_krb5" = yes ; then
524   krb_srvtab='FILE:${sysconfdir}/krb5.keytab'
525 elif test "$with_krb4" = yes ; then
526   krb_srvtab='/etc/srvtab'
527 else
528   krb_srvtab=
529 fi])
530 AC_SUBST(krb_srvtab)
531
532
533 #
534 # OpenSSL
535 #
536 AC_ARG_WITH(openssl, [  --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]],
537 [if test x"$withval" != x"no" ; then
538   if test x"$withval" != x"yes" ; then
539     openssl_prefix=$withval
540   else
541     openssl_prefix=/usr/local/ssl
542   fi
543   with_openssl=yes
544 else
545   with_openssl=no
546 fi],
547 [with_openssl=no])
548
549 AC_SUBST(with_openssl)
550 if test "$with_openssl" = yes ; then
551   AC_MSG_RESULT([building with OpenSSL support])
552   AC_DEFINE([USE_SSL], [], [Define to build with (Open)SSL support])
553
554   if test -d "${openssl_prefix}/include" ; then
555     INCLUDES="$INCLUDES -I${openssl_prefix}/include"
556   fi
557   if test -d "${openssl_prefix}/lib" ; then
558     openssl_libdir="${openssl_prefix}/lib"
559     LIBS="$LIBS -L${openssl_prefix}/lib"
560   fi
561 fi
562
563
564 # OpenSSL and Kerberos 5 both have a `crypto' library, so if you want to
565 # use both of them you'll have to figure it out yourself.
566 if test "$with_openssl" = yes && test "$with_krb5" = yes ; then
567   AC_MSG_ERROR([OpenSSL and Kerberos 5 support cannot be combined])
568 fi
569
570
571 dnl
572 dnl Optionally enable the building of the ODBC driver
573 dnl
574  
575 dnl Old option name
576 if test "x${with_odbc+set}" = xset && test "x${enable_odbc+set}" != xset; then
577   enable_odbc=$with_odbc
578 fi
579  
580 AC_MSG_CHECKING(whether to build the ODBC driver)
581 AC_ARG_ENABLE(odbc, [  --enable-odbc           build the ODBC driver package],
582 [if test x"$enableval" = x"yes" ; then
583   AC_MSG_RESULT(yes)
584 else
585   AC_MSG_RESULT(no)
586 fi],
587 [AC_MSG_RESULT(no)])
588 AC_SUBST(enable_odbc)
589
590
591 dnl Allow for overriding the default location of the odbcinst.ini
592 dnl file which is normally ${datadir} (i.e., ${prefix}/share).
593 if test x"$enable_odbc" = x"yes" ; then
594 AC_ARG_WITH(odbcinst, [  --with-odbcinst=DIR     default directory for odbcinst.ini [sysconfdir]],
595 [if test x"$with_odbcinst" = x"yes" || test x"$with_odbcinst" = x"no" ; then
596   AC_MSG_ERROR([You must supply an argument to the --with-odbcinst option.])
597 fi
598 odbcinst_ini_dir=$withval],
599 [odbcinst_ini_dir='${sysconfdir}'])
600 else
601   odbcinst_ini_dir='${sysconfdir}'
602 fi
603 AC_SUBST(odbcinst_ini_dir)
604
605
606
607 dnl Unless we specify the command line options
608 dnl     --enable cassert        to explicitly enable it
609 dnl If you do not explicitly do it, it defaults to disabled
610 AC_MSG_CHECKING(setting ASSERT CHECKING)
611 AC_ARG_ENABLE(
612    cassert,
613    [  --enable-cassert        enable assertion checks (for debugging) ],
614    AC_DEFINE(USE_ASSERT_CHECKING) AC_MSG_RESULT(enabled),
615    AC_MSG_RESULT(disabled)
616 )
617
618 CPPFLAGS="$CPPFLAGS $INCLUDES"
619 echo "- setting CPPFLAGS=$CPPFLAGS"
620
621 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
622 echo "- setting LDFLAGS=$LDFLAGS"
623
624 dnl --enable-debug adds -g to compiler flags
625 dnl --disable-debug will forcefully remove it
626 AC_MSG_CHECKING(setting debug compiler flag)
627 AC_ARG_ENABLE(
628     debug,
629     [  --enable-debug          build with debugging symbols (-g) ],
630     [
631         case "$enableval" in
632         y | ye | yes)
633             CFLAGS="$CFLAGS -g"
634             AC_MSG_RESULT(enabled)
635             ;;
636         *)
637             CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' | sed -e 's/^-g//'`
638             AC_MSG_RESULT(disabled)
639             ;;
640         esac            
641    ],
642    AC_MSG_RESULT(using default)
643 )
644
645 # Assume system is ELF if it predefines __ELF__ as 1,
646 # otherwise believe "elf" setting from check of host_os above.
647 AC_EGREP_CPP(yes,
648 [#if __ELF__
649   yes
650 #endif
651 ],
652         ELF_SYS=true,
653 [if test "X$elf" = "Xyes"
654 then
655         ELF_SYS=true
656 else
657         ELF_SYS=
658 fi
659 ])
660
661 AC_SUBST(ELF_SYS)
662 AC_SUBST(PORTNAME)
663 AC_SUBST(CPU)
664 AC_SUBST(SRCDIR)
665 AC_SUBST(LDFLAGS)
666 AC_SUBST(AROPT)
667 AC_SUBST(SHARED_LIB)
668 AC_SUBST(CFLAGS)
669 AC_SUBST(DLSUFFIX)
670 AC_SUBST(DL_LIB)
671 AC_SUBST(USE_TCL)
672 AC_SUBST(USE_TK)
673 AC_SUBST(WISH)
674 AC_SUBST(MULTIBYTE)
675
676
677 dnl
678 dnl Optionally build C++ code (i.e., libpq++)
679 dnl
680 AC_MSG_CHECKING(whether to build C++ modules)
681 AC_ARG_WITH(CXX, [  --with-CXX              build C++ modules (libpq++)],
682 [if test "x${withval+set}" = xset; then
683   AC_MSG_RESULT(yes)
684   if test x"$withval" != xyes ; then
685     CXX=$withval
686   fi
687   AC_PROG_CXX
688   AC_PROG_CXXCPP
689   PGAC_CLASS_STRING
690   PGAC_CXX_NAMESPACE_STD
691 else
692   AC_MSG_RESULT(no)
693 fi],
694 [AC_MSG_RESULT(no)])
695 AC_SUBST(with_CXX)
696
697
698 # Figure out how to invoke "install" and what install options to use.
699
700 AC_PROG_INSTALL
701 # When Autoconf chooses install-sh as install program it tries to generate
702 # a relative path to it in each makefile where it subsitutes it. This clashes
703 # with our Makefile.global concept. This workaround helps.
704 case $INSTALL in
705   *install-sh*) INSTALL='\${SHELL} \${top_srcdir}/config/install-sh -c';;
706 esac
707
708 # Fix Autoconf's brain-dead defaults for script installs.
709 INSTALL_SCRIPT="\${INSTALL} -m 755"
710
711 # HPUX wants shared libs to be mode 555. Add your platform's special
712 # needs here if necessary.
713 case $host_os in
714     hpux*)      INSTL_SHLIB_OPTS="-m 555" ;;
715     *)          INSTL_SHLIB_OPTS="-m 644" ;;
716 esac
717
718 INSTALL_SHLIB="\${INSTALL} $INSTL_SHLIB_OPTS"
719 AC_SUBST(INSTALL_SHLIB)
720
721
722 mkinstalldirs="\$(SHELL) \$(top_srcdir)/config/mkinstalldirs"
723 AC_SUBST(mkinstalldirs)
724
725
726 AC_PROG_AWK
727
728 AC_PROG_LEX
729 if test "$LEX" = "flex"; then
730         $LEX --version 2> /dev/null | grep -s '2\.5\.3' > /dev/null 2>&1
731         if test $? -eq 0 ; then
732                 AC_MSG_WARN([
733 ***
734 You have flex version 2.5.3, which is broken. Get version 2.5.4 or
735 a different lex.
736 (If you are using the official distribution of PostgreSQL then you
737 do not need to worry about this because the lexer files are
738 pre-generated. However, other software using flex is likely to be
739 broken as well.)
740 ***])
741         fi
742 fi
743 AC_PROG_LN_S
744 AC_PROG_RANLIB
745 AC_PATH_PROG(tar, tar)
746 AC_CHECK_PROGS(PERL, perl,)
747 AC_PROG_YACC
748 AC_SUBST(YFLAGS)
749
750
751 AC_CHECK_LIB(sfio,     main)
752 AC_CHECK_LIB(ncurses,  main, [], [AC_CHECK_LIB(curses, main)])
753 AC_CHECK_LIB(termcap,  main)
754 AC_CHECK_LIB(readline, main)
755 AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE),
756     AC_CHECK_LIB(history,  main) )
757
758 if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
759 then
760         AC_CHECK_LIB(bsd,      main)
761 fi
762 AC_CHECK_LIB(util,     setproctitle)
763 AC_CHECK_LIB(m,        main)
764 AC_CHECK_LIB(dl,       main)
765 AC_CHECK_LIB(socket,   main)
766 AC_CHECK_LIB(nsl,      main)
767 AC_CHECK_LIB(ipc,      main)
768 AC_CHECK_LIB(IPC,      main)
769 AC_CHECK_LIB(lc,       main)
770 AC_CHECK_LIB(dld,      main)
771 AC_CHECK_LIB(ln,       main)
772 AC_CHECK_LIB(ld,       main)
773 AC_CHECK_LIB(compat,   main)
774 AC_CHECK_LIB(BSD,      main)
775 AC_CHECK_LIB(gen,      main)
776 AC_CHECK_LIB(PW,       main)
777 AC_SEARCH_LIBS(crypt,  crypt)
778 AC_CHECK_LIB(z,        inflate)
779
780 if test "$with_krb4" = yes ; then
781   AC_CHECK_LIB(des, [des_encrypt], [], [AC_MSG_ERROR([library \`des' is required for Kerberos 4])])
782   AC_CHECK_LIB(krb, [krb_sendauth], [], [AC_MSG_ERROR([library \`krb' is required for Kerberos 4])])
783 fi
784
785 if test "$with_krb5" = yes ; then
786   AC_CHECK_LIB(com_err, main, [], [AC_MSG_ERROR([library \`com_err' is required for Kerberos 5])])
787   AC_CHECK_LIB(crypto,  main, [], [AC_MSG_ERROR([library \`crypto' is required for Kerberos 5])])
788   AC_CHECK_LIB(krb5,    main, [], [AC_MSG_ERROR([library \`krb5' is required for Kerberos 5])])
789 fi
790
791 if test "$with_openssl" = yes ; then
792   dnl Order matters!
793   AC_CHECK_LIB(crypto, [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
794   AC_CHECK_LIB(ssl,    [SSL_library_init], [], [AC_MSG_ERROR([library \`ssl' is required for OpenSSL])])
795 fi
796
797
798 dnl
799 dnl Checks for header files.
800 dnl
801 AC_HEADER_STDC
802 AC_HEADER_SYS_WAIT
803 AC_CHECK_HEADERS(arpa/inet.h)
804 AC_CHECK_HEADERS(crypt.h)
805 AC_CHECK_HEADERS(dld.h)
806 AC_CHECK_HEADERS(endian.h)
807 AC_CHECK_HEADERS(float.h)
808 AC_CHECK_HEADERS(fp_class.h)
809 AC_CHECK_HEADERS(getopt.h)
810 AC_CHECK_HEADERS(ieeefp.h)
811 AC_CHECK_HEADERS(limits.h)
812 AC_CHECK_HEADERS(netdb.h)
813 AC_CHECK_HEADERS(netinet/in.h)
814 AC_CHECK_HEADERS([readline/readline.h readline.h], [break])
815 AC_CHECK_HEADERS([readline/history.h history.h], [break])
816 AC_CHECK_HEADERS(sys/select.h)
817 AC_CHECK_HEADERS(termios.h)
818 AC_CHECK_HEADERS(unistd.h)
819 AC_CHECK_HEADERS(values.h)
820 AC_CHECK_HEADERS(sys/pstat.h)
821 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
822 AC_CHECK_HEADERS(sys/param.h pwd.h)
823
824 if test "$with_krb4" = yes ; then
825   AC_CHECK_HEADER(krb.h, [], [AC_MSG_ERROR([header file <krb.h> is required for Kerberos 4])])
826 fi
827
828 if test "$with_krb5" = yes ; then
829   AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([header file <krb5.h> is required for Kerberos 5])])
830   AC_CHECK_HEADER(com_err.h, [], [AC_MSG_ERROR([header file <com_err.h> is required for Kerberos 5])])
831 fi
832
833 if test "$with_openssl" = yes ; then
834   AC_CHECK_HEADER([openssl/ssl.h], [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
835   AC_CHECK_HEADER([openssl/err.h], [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
836 fi
837
838
839 dnl
840 dnl Checks for typedefs, structures, and compiler characteristics.
841 dnl
842 AC_C_CONST
843 AC_C_INLINE
844 AC_C_STRINGIZE
845 AC_TYPE_UID_T
846 AC_TYPE_MODE_T
847 AC_TYPE_OFF_T
848 AC_TYPE_SIZE_T
849 AC_STRUCT_TIMEZONE
850 PGAC_C_SIGNED
851 PGAC_C_VOLATILE
852 AC_FUNC_ACCEPT_ARGTYPES
853
854
855 PGAC_VAR_INT_TIMEZONE
856 PGAC_FUNC_GETTIMEOFDAY_1ARG
857 PGAC_UNION_SEMUN
858
859
860 AC_MSG_CHECKING(for fcntl(F_SETLK))
861 if test "$os" != linux ; then
862 AC_TRY_LINK([#include <stdio.h>
863 #include <fcntl.h>],
864             [struct flock lck;
865              lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0;
866              lck.l_type = F_WRLCK;
867              fcntl(0, F_SETLK, &lck);],
868             [AC_DEFINE(HAVE_FCNTL_SETLK) AC_MSG_RESULT(yes)],
869             AC_MSG_RESULT(no))
870 else
871   AC_MSG_RESULT([broken on Linux])
872 fi
873
874 dnl Checks for library functions.
875 AC_FUNC_MEMCMP
876 AC_TYPE_SIGNAL
877 AC_FUNC_VPRINTF
878 AC_CHECK_FUNCS(memmove sysconf)
879 AC_CHECK_FUNCS(sigprocmask waitpid setsid fcvt)
880 AC_CHECK_FUNCS(setproctitle pstat)
881
882 AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
883 [AC_TRY_LINK(
884 [#include <machine/vmparam.h>
885 #include <sys/exec.h>
886 ],
887 [PS_STRINGS->ps_nargvstr = 1;
888 PS_STRINGS->ps_argvstr = "foo";],
889 [pgac_cv_var_PS_STRINGS=yes],
890 [pgac_cv_var_PS_STRINGS=no])])
891 if test "$pgac_cv_var_PS_STRINGS" = yes ; then
892   AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS thing exists.])
893 fi
894
895 AC_CHECK_FUNCS(fpclass fp_class fp_class_d class)
896 dnl We use our snprintf.c emulation if either snprintf() or vsnprintf()
897 dnl is missing.  Yes, there are machines that have only one.
898 dnl We may also decide to use snprintf.c if snprintf() is present but does
899 dnl not have working "long long int" support -- see below.
900 SNPRINTF=''
901 AC_CHECK_FUNC(snprintf,
902               AC_DEFINE(HAVE_SNPRINTF),
903               SNPRINTF='snprintf.o')
904 AC_CHECK_FUNC(vsnprintf,
905               AC_DEFINE(HAVE_VSNPRINTF),
906               SNPRINTF='snprintf.o')
907 AC_SUBST(SNPRINTF)
908 dnl Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
909 dnl include/c.h will provide declarations.  Note this is a separate test
910 dnl from whether the functions exist in the C library --- there are systems
911 dnl that have the functions but don't bother to declare them :-(
912 dnl Note: simple-minded pattern here will do wrong thing if stdio.h
913 dnl declares vsnprintf() but not snprintf().  Hopefully there are no
914 dnl systems that are *that* brain-damaged...
915 AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_DECL))
916 AC_EGREP_HEADER(vsnprintf, stdio.h, AC_DEFINE(HAVE_VSNPRINTF_DECL))
917 dnl
918 dnl do this one the hard way in case isinf() is a macro
919 AC_MSG_CHECKING(for isinf)
920 AC_CACHE_VAL(ac_cv_func_or_macro_isinf,
921 [AC_TRY_LINK(
922 [#include <math.h>],
923 [double x = 0.0; int res = isinf(x);],
924 [ac_cv_func_or_macro_isinf=yes],
925 [ac_cv_func_or_macro_isinf=no])])
926 if [[ $ac_cv_func_or_macro_isinf = yes ]]; then
927   AC_MSG_RESULT(yes)
928   AC_DEFINE(HAVE_ISINF)
929   ISINF=''
930 else
931   AC_MSG_RESULT(no)
932   ISINF='isinf.o'
933 fi
934 AC_SUBST(ISINF)
935 AC_CHECK_FUNC(getrusage,
936               AC_DEFINE(HAVE_GETRUSAGE),
937               GETRUSAGE='getrusage.o')
938 AC_SUBST(GETRUSAGE)
939 AC_CHECK_FUNC(srandom,
940               AC_DEFINE(HAVE_SRANDOM),
941               SRANDOM='srandom.o')
942 AC_SUBST(SRANDOM)
943 AC_CHECK_FUNC(gethostname,
944               AC_DEFINE(HAVE_GETHOSTNAME),
945               GETHOSTNAME='gethostname.o')
946 AC_SUBST(GETHOSTNAME)
947 AC_CHECK_FUNC(random,
948               AC_DEFINE(HAVE_RANDOM),
949               MISSING_RANDOM='random.o')
950 AC_SUBST(MISSING_RANDOM)
951 AC_CHECK_FUNC(inet_aton,
952               AC_DEFINE(HAVE_INET_ATON),
953               INET_ATON='inet_aton.o')
954 AC_SUBST(INET_ATON)
955 AC_CHECK_FUNC(strerror,
956               AC_DEFINE(HAVE_STRERROR),
957               [STRERROR='strerror.o' STRERROR2='../../backend/port/strerror.o'])
958 AC_SUBST(STRERROR)
959 AC_SUBST(STRERROR2)
960 AC_CHECK_FUNC(strdup,
961               AC_DEFINE(HAVE_STRDUP),
962               STRDUP='../../utils/strdup.o')
963 AC_SUBST(STRDUP)
964 AC_CHECK_FUNC(strtol,
965               AC_DEFINE(HAVE_STRTOL),
966               STRTOL='strtol.o')
967 AC_SUBST(STRTOL)
968 AC_CHECK_FUNC(strtoul,
969               AC_DEFINE(HAVE_STRTOUL),
970               STRTOL='strtoul.o')
971 AC_SUBST(STRTOUL)
972 AC_CHECK_FUNC(strcasecmp,
973               AC_DEFINE(HAVE_STRCASECMP),
974               STRCASECMP='strcasecmp.o')
975 AC_SUBST(STRCASECMP)
976 AC_CHECK_FUNC(cbrt,
977               AC_DEFINE(HAVE_CBRT),
978               AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT)))
979
980 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
981 # this hackery with HPUXMATHLIB allows us to cope.
982 HPUXMATHLIB=""
983 case "$host_cpu" in
984   hppa1.1) 
985         if [[ -r /lib/pa1.1/libm.a ]] ; then
986             HPUXMATHLIB="-L /lib/pa1.1 -lm"
987         fi ;;
988 esac
989 AC_SUBST(HPUXMATHLIB)
990
991 AC_CHECK_FUNC(rint,
992               AC_DEFINE(HAVE_RINT),
993               AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
994
995 dnl Some old versions of libreadline don't have rl_completion_append_character
996 AC_EGREP_HEADER(rl_completion_append_character, readline.h,
997         AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER),
998         [AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h,
999                 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
1000 AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
1001
1002 dnl Check for readline's filename_completion_function.
1003 dnl Some versions have it but it's not in the headers, so we have to take
1004 dnl care of that, too.
1005 AC_CHECK_FUNCS(filename_completion_function,
1006     AC_EGREP_HEADER(filename_completion_function, readline.h,
1007         AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
1008         [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
1009             AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
1010 )
1011 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
1012 AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
1013
1014 dnl Check for GNU style long options support (getopt_long)
1015 AC_CHECK_FUNCS(getopt_long)
1016
1017 dnl Cannot use AC_CHECK_FUNC because finite may be a macro
1018 AC_MSG_CHECKING(for finite)
1019 AC_TRY_LINK([#include <math.h>],
1020         [int dummy=finite(1.0);],
1021         [AC_DEFINE(HAVE_FINITE) AC_MSG_RESULT(yes)],
1022         AC_MSG_RESULT(no))
1023
1024 dnl Cannot use AC_CHECK_FUNC because sigsetjmp may be a macro
1025 dnl (especially on GNU libc)
1026 dnl See also comments in config.h.
1027 AC_MSG_CHECKING(for sigsetjmp)
1028 AC_TRY_LINK([#include <setjmp.h>],
1029         [sigjmp_buf x; sigsetjmp(x, 1);],
1030         [AC_DEFINE(HAVE_SIGSETJMP) AC_MSG_RESULT(yes)],
1031         AC_MSG_RESULT(no))
1032
1033 AC_ARG_ENABLE(syslog, [  --enable-syslog         enable logging to syslog],
1034     [case $enableval in y|ye|yes)
1035         AC_CHECK_FUNC(syslog, [AC_DEFINE(ENABLE_SYSLOG)], [AC_MSG_ERROR([no syslog interface found])])
1036         ;;
1037      esac]
1038 )
1039
1040 dnl Check to see if we have a working 64-bit integer type.
1041 dnl This breaks down into two steps:
1042 dnl (1) figure out if the compiler has a 64-bit int type with working
1043 dnl arithmetic, and if so
1044 dnl (2) see whether snprintf() can format the type correctly.  (Currently,
1045 dnl snprintf is the only library routine we really need for int8 support.)
1046 dnl It's entirely possible to have a compiler that handles a 64-bit type
1047 dnl when the C library doesn't; this is fairly likely when using gcc on
1048 dnl an older platform, for example.
1049 dnl If there is no native snprintf() or it does not handle the 64-bit type,
1050 dnl we force our own version of snprintf() to be used instead.
1051 dnl Note this test must be run after our initial check for snprintf/vsnprintf.
1052
1053 PGAC_TYPE_64BIT_INT([long int])
1054
1055 if test x"$HAVE_LONG_INT_64" = x"no" ; then
1056   PGAC_TYPE_64BIT_INT([long long int])
1057 fi
1058
1059
1060 dnl If we found "long int" is 64 bits, assume snprintf handles it.
1061 dnl If we found we need to use "long long int", better check.
1062 dnl We cope with snprintfs that use either %lld or %qd as the format.
1063 dnl If neither works, fall back to our own snprintf emulation (which we
1064 dnl know uses %lld).
1065
1066 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1067   if [[ x$SNPRINTF = x ]] ; then
1068     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
1069     AC_TRY_RUN([#include <stdio.h>
1070 typedef long long int int64;
1071 #define INT64_FORMAT "%lld"
1072
1073 int64 a = 20000001;
1074 int64 b = 40000005;
1075
1076 int does_int64_snprintf_work()
1077 {
1078   int64 c;
1079   char buf[100];
1080
1081   if (sizeof(int64) != 8)
1082     return 0;                   /* doesn't look like the right size */
1083
1084   c = a * b;
1085   snprintf(buf, 100, INT64_FORMAT, c);
1086   if (strcmp(buf, "800000140000005") != 0)
1087     return 0;                   /* either multiply or snprintf is busted */
1088   return 1;
1089 }
1090 main() {
1091   exit(! does_int64_snprintf_work());
1092 }],
1093         [ AC_MSG_RESULT(yes)
1094           INT64_FORMAT='"%lld"'
1095         ],
1096   [ AC_MSG_RESULT(no)
1097     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd) 
1098     AC_TRY_RUN([#include <stdio.h>
1099 typedef long long int int64;
1100 #define INT64_FORMAT "%qd"
1101    
1102 int64 a = 20000001;
1103 int64 b = 40000005;
1104    
1105 int does_int64_snprintf_work()
1106 {  
1107   int64 c;
1108   char buf[100];
1109
1110   if (sizeof(int64) != 8)
1111     return 0;     /* doesn't look like the right size */
1112
1113   c = a * b;
1114   snprintf(buf, 100, INT64_FORMAT, c);
1115   if (strcmp(buf, "800000140000005") != 0)
1116     return 0;     /* either multiply or snprintf is busted */
1117   return 1;
1118 }
1119 main() {
1120   exit(! does_int64_snprintf_work());
1121 }],
1122   [ AC_MSG_RESULT(yes)
1123     INT64_FORMAT='"%qd"'
1124   ],
1125   [ AC_MSG_RESULT(no)
1126         # Force usage of our own snprintf, since system snprintf is broken
1127         SNPRINTF='snprintf.o'
1128         INT64_FORMAT='"%lld"'
1129   ],
1130   [ AC_MSG_RESULT(assuming not on target machine)
1131         # Force usage of our own snprintf, since we cannot test foreign snprintf
1132         SNPRINTF='snprintf.o'
1133         INT64_FORMAT='"%lld"'
1134   ]) ],
1135   [ AC_MSG_RESULT(assuming not on target machine)
1136         # Force usage of our own snprintf, since we cannot test foreign snprintf
1137         SNPRINTF='snprintf.o'
1138         INT64_FORMAT='"%lld"'
1139   ])
1140   else
1141     # here if we previously decided we needed to use our own snprintf
1142     INT64_FORMAT='"%lld"'
1143   fi
1144 else
1145   # Here if we are not using 'long long int' at all
1146   INT64_FORMAT='"%ld"'
1147 fi
1148
1149 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT)
1150
1151
1152 dnl Determine memory alignment requirements for the basic C datatypes.
1153
1154 PGAC_CHECK_ALIGNOF(short)
1155 PGAC_CHECK_ALIGNOF(int)
1156 PGAC_CHECK_ALIGNOF(long)
1157 if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
1158   PGAC_CHECK_ALIGNOF(long long int)
1159 fi
1160 PGAC_CHECK_ALIGNOF(double)
1161
1162 dnl Compute maximum alignment of any basic type.
1163 dnl We assume long's alignment is at least as strong as char, short, or int;
1164 dnl but we must check long long (if it exists) and double.
1165
1166 if test $pgac_cv_alignof_double != 'sizeof(double)' ; then
1167   MAX_ALIGNOF=$pgac_cv_alignof_long
1168   if test $MAX_ALIGNOF -lt $pgac_cv_alignof_double ; then
1169     MAX_ALIGNOF=$pgac_cv_alignof_double
1170   fi
1171   if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $pgac_cv_alignof_long_long_int ; then
1172     MAX_ALIGNOF="$pgac_cv_alignof_long_long_int"
1173   fi
1174 else
1175   dnl cross-compiling: assume that double's alignment is worst case
1176   MAX_ALIGNOF="$pgac_cv_alignof_double"
1177 fi
1178 AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any type])
1179
1180 PGAC_FUNC_POSIX_SIGNALS
1181
1182
1183 dnl Check for Tcl configuration script tclConfig.sh
1184
1185 dnl If --with-tclconfig was given, don't check for tclsh, tcl
1186 if test -z "$TCL_DIRS"
1187 then
1188         AC_PATH_PROG(TCLSH, tclsh)
1189         if test -z "$TCLSH"
1190         then
1191                 AC_PATH_PROG(TCLSH, tcl)
1192                 if test -z "$TCLSH"
1193                 then
1194                         AC_MSG_WARN(TCL/TK support disabled; tcl shell is not in your path)
1195                         USE_TCL=
1196                 fi
1197         fi
1198 fi
1199         
1200 if test "$USE_TCL" = true
1201 then
1202         AC_MSG_CHECKING(for tclConfig.sh)
1203         TCL_CONFIG_SH=
1204         library_dirs=
1205         if test -z "$TCL_DIRS"
1206         then
1207                 library_dirs=`echo 'puts $auto_path' | $TCLSH`
1208         fi
1209         library_dirs="$TCL_DIRS $TK_DIRS $library_dirs"
1210         for dir in $library_dirs; do
1211                 if test -d "$dir" -a -r "$dir/tclConfig.sh"; then
1212                         TCL_CONFIG_SH=$dir/tclConfig.sh
1213                         break
1214                 fi
1215         done
1216         if test -z "$TCL_CONFIG_SH"; then
1217                 AC_MSG_RESULT(no)
1218                 AC_MSG_WARN(TCL/TK support disabled; Tcl configuration script missing)
1219                 USE_TCL=
1220         else
1221                 AC_MSG_RESULT($TCL_CONFIG_SH)
1222                 AC_SUBST(TCL_CONFIG_SH)
1223         fi
1224 fi
1225
1226 USE_TK=$USE_TCL         # If TCL is disabled, disable TK
1227
1228 dnl Check for Tk configuration script tkConfig.sh
1229 if test "$USE_TK" = true
1230 then
1231         AC_MSG_CHECKING(for tkConfig.sh)
1232         TK_CONFIG_SH=
1233         # library_dirs are set in the check for TCL
1234         for dir in $library_dirs
1235         do
1236                 if test -d "$dir" -a -r "$dir/tkConfig.sh"
1237                 then
1238                         TK_CONFIG_SH=$dir/tkConfig.sh
1239                         break
1240                 fi
1241         done
1242         if test -z "$TK_CONFIG_SH"
1243         then
1244                 AC_MSG_RESULT(no)
1245                 AC_MSG_WARN(TK support disabled; Tk configuration script missing)
1246                 USE_TK=
1247         else
1248                 AC_MSG_RESULT($TK_CONFIG_SH)
1249                 AC_SUBST(TK_CONFIG_SH)
1250                 AC_PATH_PROG(WISH, wish)
1251         fi
1252 fi
1253
1254 USE_X=$USE_TK
1255
1256 dnl Check for X libraries
1257
1258 if test "$USE_X" = true; then
1259
1260         ice_save_LIBS="$LIBS"
1261         ice_save_CFLAGS="$CFLAGS"
1262         ice_save_CPPFLAGS="$CPPFLAGS"
1263         ice_save_LDFLAGS="$LDFLAGS"
1264
1265         AC_PATH_XTRA
1266
1267         LIBS="$LIBS $X_EXTRA_LIBS"
1268         CFLAGS="$CFLAGS $X_CFLAGS"
1269         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1270         LDFLAGS="$LDFLAGS $X_LIBS"
1271
1272         dnl Check for X library
1273
1274         X11_LIBS=""
1275         AC_CHECK_LIB(X11, XOpenDisplay, X11_LIBS="-lX11",,${X_PRE_LIBS})
1276         if test "$X11_LIBS" = ""; then
1277                 dnl Not having X is bad news for pgtksh. Let the user fix this.
1278                 AC_MSG_WARN([The X11 library '-lX11' could not be found,
1279 so TK support will be disabled.  To enable TK support,
1280 please use the configure options '--x-includes=DIR'
1281 and '--x-libraries=DIR' to specify the X location.
1282 See the file 'config.log' for further diagnostics.])
1283                 USE_TK=
1284         fi
1285         AC_SUBST(X_LIBS)
1286         AC_SUBST(X11_LIBS)
1287         AC_SUBST(X_PRE_LIBS)
1288
1289         LIBS="$ice_save_LIBS"
1290         CFLAGS="$ice_save_CFLAGS"
1291         CPPFLAGS="$ice_save_CPPFLAGS"
1292         LDFLAGS="$ice_save_LDFLAGS"
1293 fi
1294
1295
1296 # Wait with these until we're done so no tests fail because of too
1297 # many warnings.
1298 if test x"$GCC" = x"yes" ; then
1299   CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations"
1300 fi
1301
1302 dnl Finally ready to produce output files ...
1303
1304 AC_OUTPUT(
1305         GNUmakefile
1306         src/GNUmakefile
1307         src/Makefile.global
1308         src/backend/port/Makefile
1309         src/test/regress/GNUmakefile
1310 )