File: configure.ac.in

package info (click to toggle)
pexts 0.1.1-8
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,796 kB
  • ctags: 4,278
  • sloc: ansic: 49,040; sh: 12,104; makefile: 775
file content (830 lines) | stat: -rw-r--r-- 23,668 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
#
# $Id: configure.ac.in,v 1.2 2003/06/17 17:32:39 grendel Exp $
#
AC_PREREQ(2.53)
AC_INIT(Makefile.in)

makefile_rules=$srcdir/src/Makefile.rules; export makefile_rules

caudium_shtool=$srcdir/tools/shtool
T_MD=`$caudium_shtool echo -n -e %B`
T_ME=`$caudium_shtool echo -n -e %b`

export T_MD T_ME

dnl from this point onwards, one can use the $host_os
dnl $host, $host_cpu, $host_vendor variables
dnl to see what kind of OS are we running on and on what machine
AC_CANONICAL_HOST

AC_PREFIX_DEFAULT([/usr/local])

AC_ARG_WITH(pike, 
AC_HELP_STRING([--with-pike[=binary]],[Use the specified Pike.]),
[
    if test ! -z "$withval" -a "$withval" != "yes"; then 
		extpike="`type  $withval |sed "s:$withval is ::" 2>/dev/null`"
                if test "$extpike" != ""; then
                   withval="$extpike";
                fi
		if test -f "$withval" -a  ! -x "$withval" ; then
			echo "$withval is not an executable file"
 			exit 1
		elif test -x "$withval" -a -f "$withval"; then
			DEFPIKE="$withval"
		else
			echo "$withval doesn't exist or isn't an executable file."
 			exit 1
		fi
	fi
])
#
# The --with-* macros will be replaced for the placeholder below by
# autogen.sh
#
@module_with_pre@

#
# Some prerequisites of ours
#
REQ_PIKE_MAJOR=7
REQ_PIKE_MINOR=0
REQ_PIKE_BUILD=78
REQ_PIKE_VER="$REQ_PIKE_MAJOR.$REQ_PIKE_MINOR.$REQ_PIKE_BUILD"
REQ_PIKE_VERNUM="$REQ_PIKE_MAJOR$REQ_PIKE_MINOR$REQ_PIKE_BUILD"

AC_SET_MAKE

AC_PROG_INSTALL

case "$ac_cv_path_install" in
  *installbsd*)
    AC_MSG_CHECKING(if $ac_cv_path_install works)
    AC_CACHE_VAL(caudium_cv_install_works,
[
    if $ac_cv_path_install "$srcdir/configure.ac" ./conftest >/dev/null 2>&1
    then
      if cmp "$srcdir/configure.ac" ./conftest >/dev/null 2>&1; then
        caudium_cv_install_works=yes;
      else
        caudium_cv_install_works=no;
      fi
    else
      caudium_cv_install_works=no;
    fi
    if test -f ./conftest; then
      rm -f ./conftest
    fi
])
    AC_MSG_RESULT($caudium_cv_install_works)
    if test "$caudium_cv_install_works" = "no"; then
      echo "Warning: Falling back to $ac_install_sh"
      INSTALL="$ac_install_sh"
    fi
  ;;
esac

# We want an absolute path to the source-dir.
case "$srcdir" in
    /*)
    ;;
    *)
	oldsrcdir="$srcdir"
	srcdir="`cd \"$srcdir\";pwd`"
	AC_MSG_WARN([ Converted $oldsrcdir to $srcdir,
If this does not work, please use an absolute path to the configure script. ])
    ;;
esac


# Compiler checks
#--------------------------

if test ! -z "$caudium_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$caudium_cv_prog_CC"
then
  AC_MSG_WARN([CC is different than last time Pexts was compiled,
It is probably best to delete ./config.cache before proceeding])
fi

#
# NOTE: These tests must be before AC_PROG_CC
# since AC_PROG_CC sets CFLAGS by itself.
#

if test "x${CFLAGS-}" = "x" ; then
  cflags_is_set=no
else
  cflags_is_set=yes
fi

if test "x${CPPFLAGS-}" = "x" ; then
  cppflags_is_set=no
else
  cppflags_is_set=yes
fi

if test "x${LDFLAGS-}" = "x" ; then
  ldflags_is_set=no
else
  ldflags_is_set=yes
fi

caudium_cv_prog_CC="$CC"

AC_PROG_CC
AC_AIX
AC_MINIX

AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(dld, shl_load)
AC_CHECK_LIB(dld, dld_link)

#############################################################
# Set some OS/Compiler Specific flags...
# Compiler flags...

AC_DEFUN(AC_SYS_COMPILER_FLAG,
[
  AC_MSG_CHECKING($1)
  OLD_CFLAGS="[$]CFLAGS"
  AC_CACHE_VAL(caudium_cv_option_$2,
  [
    CFLAGS="[$]OLD_CFLAGS $1"
    AC_TRY_RUN([int main(){exit(0);}],caudium_cv_option_$2=yes,caudium_cv_option_$2=no)
  ])
  
  CFLAGS="[$]OLD_CFLAGS"
  
  if test x"[$]caudium_cv_option_$2" = "xyes" ; then
    $3="[$]$3 $1"
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
])

AC_DEFUN(AC_SYS_CPU_COMPILER_FLAG,
[
  if test "`uname -m 2>/dev/null`" = "$1" ; then
    AC_SYS_COMPILER_FLAG($2,$3,$4)
  fi
])

AC_DEFUN(AC_SYS_OS_COMPILER_FLAG,
[
  if test "x$caudium_cv_sys_os" = "x$1" ; then
    AC_SYS_COMPILER_FLAG($2,$3,$4)
  fi
])

SMARTLINK="$srcdir/tools/smartlink"
case $CC in
 *smartlink*) ;;
 *)
   CC="$SMARTLINK $CC"
   ac_cv_prog_CC="$CC"
 ;;
esac

# We need some special hacks when running slowaris
AC_PATH_PROG(uname_prog,uname,no)
AC_MSG_CHECKING(operating system)
AC_CACHE_VAL(caudium_cv_sys_os,
[
if test "$uname_prog" != "no"; then
  caudium_cv_sys_os="`uname`"

  case "$caudium_cv_sys_os" in
    SunOS)
      case "`uname -r`" in
        5.*) caudium_cv_sys_os="Solaris";
      esac
    ;;
  esac
else
  caudium_cv_sys_os="Not Solaris"
fi
])
AC_MSG_RESULT($caudium_cv_sys_os)

case "$caudium_cv_sys_os" in
  SCO*)
    case "$CFLAGS" in
      *-belf*) 
        AC_SYS_COMPILER_FLAG(-belf,sco_belf_option,CFLAGS,[],[
          case "$LDFLAGS" in
            *-belf*) ;;
            *)
	      echo "Adding -belf option to ldflags."
              LDFLAGS="$LDFLAGS -belf"
            ;;
          esac
        ])
      ;;
      *)
        AC_SYS_COMPILER_FLAG(-belf,sco_belf_option,CFLAGS,[],[
          case "$LDFLAGS" in
            *-belf*) ;;
            *)
	      echo "Adding -belf option to ldflags."
              LDFLAGS="$LDFLAGS -belf"
            ;;
          esac
        ])
      ;;
    esac
  ;;
 
  UnixWare*)
    case "$CFLAGS" in
      *-Kalloca*) ;;
      *)
	if test "$GCC" != "yes"; then
 	# We are using built-in inline function
          CFLAGS="$CFLAGS -Kalloca"
          CXX="CC -DNO_CPLUSPLUS_ALLOCA"
 	fi
      ;;
    esac
  ;;
esac
  
AC_SUBST(CXX)
AC_SUBST(LD)

### Pike Detection ###
######################


RESULT=no
AC_MSG_CHECKING([for a working Pike (>= $REQ_PIKE_VER)])
AC_MSG_RESULT( )
pathpike="`type  pike 2> /dev/null |sed 's/pike is//' 2>/dev/null`"
if test "$prefix" != "NONE"; then
  PREFIXPIKE="$prefix/bin/pike"
fi
FOUND_PIKE=0
PIKE_INCLUDE_DIRS=""
for PIKE in $DEFPIKE $PREFIXPIKE $pathpike /usr/local/bin/pike /opt/pike/bin/pike /sw/bin/pike74 /sw/local/bin/pike /opt/local/bin/pike /usr/gnu/bin/pike /usr/bin/pike /usr/pkg/bin/pike /usr/pkg/bin/pike74; do
  if test -x $PIKE; then
    echo -n "  ...${PIKE}"
    THIS_PIKE_VER=`$PIKE -e 'int maj,min,bld;sscanf(version(),"Pike v%d.%d release %d",maj,min,bld);write(sprintf("%d.%d.%d",maj,min,bld));exit(0);'`
    if test -z "$THIS_PIKE_VER"; then
      continue
    fi
    echo -n " ${THIS_PIKE_VER}"
    THIS_PIKE_MAJOR=`echo $THIS_PIKE_VER | cut -d '.' -f 1`
    THIS_PIKE_MINOR=`echo $THIS_PIKE_VER | cut -d '.' -f 2`
    THIS_PIKE_BUILD=`echo $THIS_PIKE_VER | cut -d '.' -f 3`
    THIS_PIKE_VERNUM=$THIS_PIKE_MAJOR$THIS_PIKE_MINOR$THIS_PIKE_BUILD
    THIS_PIKE_DECNUM=`expr '(' $THIS_PIKE_MAJOR '*' 10000 ')' + '(' $THIS_PIKE_MINOR '*' 1000 ')' + $THIS_PIKE_BUILD`

    REQ_PIKE_DECNUM=`expr '(' $REQ_PIKE_MAJOR '*' 10000 ')' + '(' $REQ_PIKE_MINOR '*' 1000 ')' + $REQ_PIKE_BUILD`
    
    if test $THIS_PIKE_DECNUM -lt $REQ_PIKE_DECNUM; then
       echo " => too old"
       continue
    fi

    echo -n " => good version"

    PIKE_INCDIR="`dirname $PIKE`/.."
    for INCDIR in $PIKE_INCDIR/pike/$THIS_PIKE_VER/include/pike $PIKE_INCDIR/include/`basename $PIKE` $PIKE_INCDIR/include/pike/${THIS_PIKE_VER} \
                  $PIKE_INCDIR/include/pike$THIS_PIKE_VER $PIKE_INCDIR/include/pike${THIS_PIKE_MAJOR}.${THIS_PIKE_MINOR} $PIKE_INCDIR/include/pike; do
      OLD_DIR=`pwd`
      cd $INCDIR &> /dev/null
      if test $? -ne 0; then
        continue
      fi
      INCLUDE_DIR=`pwd`
      if test -f version.h; then
        C_PIKE_MAJOR=`cat version.h | grep PIKE_MAJOR_VERSION | tr -s ' ' | cut -d ' ' -f 3`
        C_PIKE_MINOR=`cat version.h | grep PIKE_MINOR_VERSION | tr -s ' ' | cut -d ' ' -f 3`
        C_PIKE_BUILD=`cat version.h | grep PIKE_BUILD_VERSION | tr -s ' ' | cut -d ' ' -f 3`

        if test $C_PIKE_MAJOR -ne $THIS_PIKE_MAJOR -o $C_PIKE_MINOR -ne $THIS_PIKE_MINOR -o $C_PIKE_BUILD -ne $THIS_PIKE_BUILD; then
          echo
          break
        fi
        echo ", $INCLUDE_DIR"
        FOUND_PIKE=1
        PIKE_VERSION=$THIS_PIKE_VER
        PIKE_INCLUDE_DIRS="$PIKE_INCLUDE_DIRS -I$INCLUDE_DIR"
        cd $OLD_DIR
        break
      else
        echo
      fi
    done
  fi
  if test x"$FOUND_PIKE" = "x1"; then
    break
  fi
done

if test x"$FOUND_PIKE" = "x1"; then 
  AC_MSG_RESULT([found Pike $PIKE_VERSION ($PIKE) with C headers in $PIKE_INCLUDE_DIRS])
else
  cat << EOF
*****************************************************************************
*** I couldn't find a suitable Pike for Caudium. Caudium 1.3
*** requires Pike $REQ_PIKE_VER or newer. Running Caudium with Pike 0.6, 7.0,
*** 7.2 or 7.3 is no longer supported. You can download and install one of
*** our Pike $REQ_PIKE_MAJOR.$REQ_PIKE_MINOR snapshots available from our website at:
***
***     http://caudium.net/download/source/caudiumbuild.rxml 
***
*** PLEASE NOTE: THIS VERSION OF CAUDIUM NO LONGER SUPPORTS PIKE < $REQ_PIKE_MAJOR.$REQ_PIKE_MINOR.$REQ_PIKE_BUILD!
***
*** If you have this or newer version of Pike installed in a different 
*** location or under a different name, please use the --with-pike argument
*** to the configure script to specify the location of the Pike binary you
*** want to use with Caudium
***
*****************************************************************************
EOF
  exit 1;
fi

export PIKE PIKE_INCLUDE_DIRS PIKE_VERSION
AC_SUBST(PIKE)
AC_SUBST(PIKE_VERSION)

#############################################################################
dnl find the module dirs for this pike
dnl we work only with pike 7.x.x, so no checks for major < 7 needed
dnl Code below builds a variable with a list of module directories
PIKE_MODULE_DIR=""
AC_MSG_CHECKING([for a available module locations])
AC_MSG_RESULT( )

if test "$prefix" == "NONE"; then
  TMP_PREFIX=/usr/local
  TMP_ANY_PREFIX="yes"
else
  TMP_PREFIX="$prefix"
  TMP_ANY_PREFIX="no"
fi

TMP_MD_PREFIX="`$PIKE -e \"foreach(sort(master()->pike_module_path), string p) if(String.common_prefix(({\\\"$TMP_PREFIX\\\",p})) == \\\"$TMP_PREFIX\\\") write(p+\\\" \\\");\"`"
TMP_MD_NOPREFIX="`$PIKE -e \"foreach(sort(master()->pike_module_path), string p) if(String.common_prefix(({\\\"$TMP_PREFIX\\\",p})) != \\\"$TMP_PREFIX\\\") write(p+\\\" \\\");\"`"

for md in $TMP_MD_PREFIX; do
  echo -n "considering $md => "
  if test -d $md; then
    echo winner
    PIKE_MODULE_DIR="$md"
    break
  fi
done

if test -z "$PIKE_MODULE_DIR" -a "x$TMP_ANY_PREFIX" = "xyes"; then
  for md in $TMP_MD_NOPREFIX; do
    echo -n "considering $md => "
    if test -d $md; then
      echo winner
      PIKE_MODULE_DIR="$md"
      break
    fi
  done
fi

if test -z "$PIKE_MODULE_DIR"; then
  echo
  echo "Cannot find a suitable directory for modules. Aborting"
  exit 1
fi

AC_SUBST(PIKE)
AC_SUBST(PIKE_VERSION)

export PIKE PIKE_INCLUDE_DIRS PIKE_VERSION PIKE_MODULE_DIR

#############################################################################


# Set some of the compiler flags.

for ac_site_file in $CONFIG_SITE; do
  if test -r "$ac_site_file"; then
    AC_MSG_WARN([You are using a site file to initialize configure, please
note that this can lead to problems if anything in
$ac_site_file is not correct. If the extension modules does not compile, or
does not run, please rerun configure like this to disable the site file:
rm ./config.cache ; CONFIG_SITE=x ./configure ; make])
  fi
done

#############################################################################

## Search for some popular places where libraries may be hidden.

#############################################################################

AC_MSG_CHECKING(for extra include directories)
AC_MSG_RESULT( )
if test $cppflags_is_set = no -a x${C_INCLUDE_PATH-} = x ; then
  for d in `echo ${with_include_path} | sed 's/:/ /g'` \
    `echo $prefix | sed "s@^NONE@$ac_default_prefix@g"`/include \
    /usr/local/include /sw/local/include /usr/gnu/include /opt/gnu/include \
    /sw/gnu/include /sw/include /usr/freeware/include /usr/pkg/include \
    `echo /usr/X11*/include | sort -r`
  do
    AC_MSG_CHECKING($d)
    if test -d "$d/." ; then
      AC_MSG_RESULT(added)
      CPPFLAGS="${CPPFLAGS} -I$d"
    else
      AC_MSG_RESULT(no)
    fi
  done
else
  :
fi

AC_MSG_CHECKING(for extra library directories)
AC_MSG_RESULT( )
if test $ldflags_is_set = no ; then
  for d in `echo ${with_lib_path} | sed 's/:/ /g'` \
    `echo $exec_prefix | sed "s@^NONE@$prefix/lib@g" | sed "s@^NONE@$ac_default_prefix/lib@g"` \
    /usr/local/lib /sw/local/lib /sw/lib \
    /usr/gnu/lib /opt/gnu/lib /sw/gnu/lib /usr/freeware/lib /usr/pkg/lib \
    `echo /usr/X11*/lib | sort -r`
  do
    AC_MSG_CHECKING($d)
    if test -d "$d/." ; then
      AC_MSG_RESULT(added)
      LDFLAGS="${LDFLAGS} -R$d -L$d"
    else
      AC_MSG_RESULT(no)
    fi
  done
else
  :
fi

#############################################################
# Optimization flags...
#
# Do we really need that crap here?
# /grendel, 19.03.2003
WARN=""
OPTIMIZE=""

if test $cflags_is_set = no; then
 if test "x${GCC-}" = xyes ; then
  WARN="-W -Wall -Wpointer-arith -Wno-unused -Wstrict-prototypes \
	-Wpointer-arith  -Wmissing-declarations -Winline -Wcast-align"
  AC_SYS_COMPILER_FLAG(-O2,O2,OPTIMIZE)
  AC_SYS_COMPILER_FLAG(-ffast-math,ffast_math,OPTIMIZE)
  AC_SYS_COMPILER_FLAG(-fexpensive-optimizations,expensiveoptimizations,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(AIX,-mprototype,mprototype,WARN)
### Optimize for different SUN machines. If there is no working 'uname'
### no extra optimization will be done, but nothing should break either.

# The -sparclite option seems to generate assembler that /bin/as doesn't
# understand.	/grubba 1998-07-17
#  AC_SYS_CPU_COMPILER_FLAG(sun4c,-msparclite,sparclite,OPTIMIZE)
  AC_SYS_CPU_COMPILER_FLAG(sun4m,-mcpu=v8,microsparc,OPTIMIZE)
  AC_SYS_CPU_COMPILER_FLAG(sun4d,-mcpu=v8,supersparc,OPTIMIZE)
  AC_SYS_CPU_COMPILER_FLAG(sun4u,-mcpu=v9,ultrasparc,OPTIMIZE)

  AC_SYS_COMPILER_FLAG(-mcpu=pentiumpro,pentiumpro,OPTIMIZE)
  AC_SYS_COMPILER_FLAG(-faltivec,faltivec,OPTIMIZE)
  AC_SYS_COMPILER_FLAG(-maltivec,maltivec,OPTIMIZE)
  AC_SYS_COMPILER_FLAG(-mcpu=powerpc,powerpc,OPTIMIZE)
dnl  AC_SYS_COMPILER_FLAG(-malign-power,alignpower,OPTIMIZE)
  AC_SYS_COMPILER_FLAG(-malign-natural,alignnatural,OPTIMIZE)
 else

### Non-gcc thingies. This should probably be enhanced...

  # Solaris
  AC_SYS_OS_COMPILER_FLAG(Solaris,-dalign,dalign,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(Solaris,-fast,fast,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(Solaris,-native,native,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(Solaris,-xdepend,xdepend,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(Solaris,-fd,fd,WARN)
  AC_SYS_OS_COMPILER_FLAG(Solaris,-xtransition,xtransition,WARN)
  AC_SYS_OS_COMPILER_FLAG(Solaris,-xs,xs,CFLAGS)
  # Causes __STDC__ to be 1 which causes several headerfiles to behave
  # differently.
  # AC_SYS_OS_COMPILER_FLAG(Solaris,-Xc,Xc,WARN)

  # HP-UX
  AC_SYS_OS_COMPILER_FLAG(HP-UX,-D__STDC_EXT__,stdc_ext,CFLAGS)
  AC_SYS_OS_COMPILER_FLAG(HP-UX,+z,plus_z,CFLAGS)
  AC_SYS_OS_COMPILER_FLAG(HP-UX,+Odataprefetch,plus_Odataprefetch,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(HP-UX,+Ofailsafe,plus_Ofailsafe,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(HP-UX,+O3,plus_O3,OPTIMIZE)
  if test x$ac_with_fullwarn = xyes ; then
    # Ignore warnings 530 and 414 if you turn this on.
    AC_SYS_OS_COMPILER_FLAG(HP-UX,+w1,plus_w1,WARN)
  fi

  # OSF/1
  AC_SYS_OS_COMPILER_FLAG(OSF1,-fast,fast,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(OSF1,-g3,g3,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(OSF1,-host,host,OPTIMIZE)
  AC_SYS_OS_COMPILER_FLAG(OSF1,-std1,std1,WARN)
  AC_SYS_OS_COMPILER_FLAG(OSF1,-warnprotos,warnprotos,WARN)

  # IRIX
  # sopt disabled since it takes too much time on interpret.c (>45min on an O)
  # AC_SYS_OS_COMPILER_FLAG(IRIX,-sopt,sopt)
  AC_SYS_OS_COMPILER_FLAG(IRIX,-n32,n32,CFLAGS)
  if test x$caudium_cv_option_n32 = xyes ; then
    echo Adding -n32 to LDFLAGS.
    LDFLAGS="$LDFLAGS -n32"
  fi
  AC_SYS_OS_COMPILER_FLAG(IRIX,-g3,g3,OPTIMIZE)
  if test x$ac_with_fullwarn = xyes ; then
    # This warns about a lot of standard constructs, so it isn't enabled
    # by default.
    AC_SYS_OS_COMPILER_FLAG(IRIX,-fullwarn,fullwarn,WARN)
  fi
  if test x$with_debug = xyes ; then
    AC_SYS_OS_COMPILER_FLAG(IRIX,-trapuw,trapuw,WARN)
  fi

dnl
dnl This does not work with Digital UNIX cc/ld (cc thinks it is ok, ld does not)
dnl  
dnl AC_SYS_COMPILER_FLAG(-native,native)
dnl

dnl ### Ok. This is for apcc...
case "$CC" in
  *apcc)
    AC_SYS_COMPILER_FLAG(-XO=5,apcc_opt,OPTIMIZE)
    AC_SYS_COMPILER_FLAG(-Xcallmod=2,apcc_opt_2,OPTIMIZE)
  ;;
esac


  AC_SYS_CPU_COMPILER_FLAG(sun4m,-Xpipe=micro,microsparc,OPTIMIZE)
  AC_SYS_CPU_COMPILER_FLAG(sun4d,-Xpipe=super,supersparc,OPTIMIZE)
  AC_SYS_CPU_COMPILER_FLAG(sun4u,-Xpipe=super,ultrasparc,OPTIMIZE)

  case "${CFLAGS-} $OPTIMIZE" in
     *-O*) ;;
     *+O*) ;;
     *-fast*) ;;
     *)
       if test "$GCC" != "yes"; then
         case "$caudium_cv_sys_os" in
           UnixWare*)
             OPTIMIZE=""
	   ;;
         esac
       else
         AC_SYS_COMPILER_FLAG(-O2,O2,OPTIMIZE)
         if test "x$caudium_cv_option_O2" != "xyes"; then
           AC_SYS_COMPILER_FLAG(-O,O,OPTIMIZE)
         fi
       fi
     ;;
  esac
 fi
fi

if test "$GCC" = "yes"; then
# Disabled since -pipe causes gcc to hang on some systems
# (gcc-2.7.2 on Slackware Linux 3.2 when compiling assembler files).
# Thanks to Michael Finken <finken@nentec.de> for pointing it out.
#	/grubba 1997-10-07
#   if test $cflags_is_set = no; then
#     AC_SYS_COMPILER_FLAG(-pipe, pipe, CFLAGS)
#   fi
    :
else
#
# Special hack for HP-UX stupid cc
#
  if test "$caudium_cv_sys_os" = "HP-UX"; then
    AC_TRY_COMPILE([int foo(int bar);],[],[],
    [
      OLD_CC="${CC-cc}"
      OLD_CFLAGS="$CFLAGS"
      if test "$CC" = "$SMARTLINK cc" -a -x /usr/bin/cc ; then
        CC="$SMARTLINK /usr/bin/cc"
      fi
      CFLAGS="-Ae +Olibcalls $CFLAGS"
      AC_TRY_COMPILE([int foo(int bar);],[],[],[
        CC="$OLD_CC"
	CFLAGS="$OLD_CFLAGS"
      ])
    ])
  fi
fi

if test $ac_cv_prog_gcc = yes; then
  AC_MSG_CHECKING(for libgcc file name)
  AC_CACHE_VAL(caudium_cv_libgcc_filename,
  [
    caudium_cv_libgcc_filename="`${CC-cc} -print-libgcc-file-name`"
    if test -z "$caudium_cv_libgcc_filename"; then
      caudium_cv_libgcc_filename=no
    else
       if test -f "$caudium_cv_libgcc_filename"; then
         :
       else
         caudium_cv_libgcc_filename=no
       fi
    fi
  ])
  AC_MSG_RESULT($caudium_cv_libgcc_filename)
  if test x"$caudium_cv_libgcc_filename" = xno; then
    LIBGCC=""
  else
    LIBGCC="$caudium_cv_libgcc_filename"
  fi
else
  LIBGCC=""
fi

export LIBGCC

# SO is the extension of shared libraries
# -- usually so, sl on HP-UX
AC_MSG_CHECKING(SO)
if test -z "$SO"
then
	case "$caudium_cv_sys_os" in
	hp*|HP*)   SO=sl;;
	*)	   SO=so;;
	esac
fi
AC_MSG_RESULT($SO)

# LDSHARED is the ld *command* used to create shared library
# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
AC_MSG_CHECKING(LDSHARED)
if test -z "$LDSHARED" ; then
  case "$caudium_cv_sys_os" in
    AIX*)
      if test "$GCC" = yes ; then
        if test "`uname -r`" -ge 2 -a "`uname -v`" -ge 4 ; then
          LDSHARED="ld -G -bexpall"
	else if test "`uname -v`" -gt 4 ; then
	    # Extra forward compatibility...
	    # AIX 5+
	    LDSHARED="ld -G -bexpall"
	  else
	    # AIX 4.1 and earlier don't have/have unreliable
	    # handling of dlopen et al.
	    #
	    # Even AIX 4.2.1 has buggy dlopen -- NEVER attempt
	    # to dlopen a file that hasn't been linked with -G.
	    caudium_cv_sys_dynamic_loading=no
	    LDSHARED="ld"
	  fi
        fi
      else
        # Dynamic linking turned off for AIX-cc
	#
	# In addition, the dynamic loading test seems to
	# cause our RS/6000 to hang, which causes the
	# watchdog-timer to PANIC.
	caudium_cv_sys_dynamic_loading=no
        LDSHARED="ld"
      fi
    ;;
    IRIX*)
      if test "$GCC" = yes ; then
        # egcs defaults to building -n32 objects
        LDSHARED="ld -shared -n32"
      else
        LDSHARED="ld -shared"
      fi
      # -woff isn't understood by ld on Irix 5.
      if test "`uname -r`" -ge 6 ; then
        LDSHARED="$LDSHARED -woff 84,85,134"
      else :; fi
    ;;
    SunOS*) LDSHARED="ld";;
    Solaris) LDSHARED="/usr/ccs/bin/ld -G";;
    hp*|HP*) LDSHARED="ld -b";;
    OSF*) LDSHARED="ld -expect_unresolved '*' -shared -msym -O3";;
    DYNIX/ptx*) LDSHARED="ld -G";;
    next*) LDSHARED="$CC $CFLAGS -nostdlib -r";;
    Linux*) LDSHARED="$CC -shared";;
    GNU*) LDSHARED="ld -Bshareable";;
    FreeBSD*) 
	LDSHARED="$CC -Wl,-Bshareable"
	AC_DEFINE(RUNNING_BSD, 1, [Define if your system is BSD flavour (FreeBSD, NetBSD, OpenBSD...)])
	;;
    NetBSD*) 
	LDSHARED="ld -Bshareable"
	AC_DEFINE(RUNNING_BSD, 1, [Define if your system is BSD flavour (FreeBSD, NetBSD, OpenBSD, Darwin, ...)])
	;;
    OpenBSD*)
	LDSHARED="ld -Bshareable"
	AC_DEFINE(RUNNING_BSD, 1, [Define if your system is BSD flavour (FreeBSD, NetBSD, OpenBSD, Darwin, ...)])
	;;
    BSD/OS*) LDSHARED="shlicc -r";;
    SCO_SV*) LDSHARED="cc -G -KPIC -Wl,-Bexport";;
    UNIX_SV*) LDSHARED="ld -G";;
    Darwin*)
        LDSHARED="$CC -bundle -undefined error -bundle_loader $PIKE"
        AC_DEFINE(RUNNING_BSD, 1, [Define if your system is BSD flavour (FreeBSD, NetBSD, OpenBSD, Darwin, ...)])
        ;;
    UnixWare*)
      if test "$GCC" = yes ; then
        LDSHARED="ld -G"
      else
        LDSHARED="cc -G -KPIC -Wl,-Bexport"
      fi
    ;;
    Windows_NT*) LDSHARED="$CC -shared";;
    *) LDSHARED="ld";;
  esac
fi
AC_MSG_RESULT($LDSHARED)

# CCSHARED are the C *flags* used to create objects to go into a shared
# library -- this is only needed for a few systems
AC_MSG_CHECKING(CCSHARED)
AC_CACHE_VAL(caudium_cv_sys_ccshared,[
if test -z "$CCSHARED" ; then
  if test "$GCC" = yes ; then
    case $caudium_cv_sys_os in
      BSD/OS*) CCSHARED="";;
      Darwin*) CCSHARED="-fPIC";;
      *) CCSHARED="-fpic";;
    esac
  else
    case $caudium_cv_sys_os in
	hp*|HP*) CCSHARED="+z"; ;;
	FreeBSD*) CCSHARED="-fpic";;
	Darwin*) CCSHARED="-fPIC";;
	SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
	UnixWare*) CCSHARED="-KPIC -dy -Bdynamic";;
	Solaris*) CCSHARED="-KPIC -Bdynamic";;
        Windows_NT*) CCSHARED="-shared" ;;
    esac
  fi
fi
  OLD_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $CCSHARED"
  AC_TRY_COMPILE([], [int main() { exit(0); }],
    caudium_cv_sys_ccshared="$CCSHARED", caudium_cv_sys_ccshared='')
  CFLAGS="$OLD_CFLAGS"
])

if test "$GCC" != "yes"; then
  case $caudium_cv_sys_os in
    UnixWare*) CCSHARED="-KPIC -dy -Bdynamic"
    caudium_cv_sys_ccshared="$CCSHARED"
    ;;
  esac
fi

CCSHARED="$caudium_cv_sys_ccshared"
AC_MSG_RESULT($CCSHARED)

CLIBRARY_LINK="-lc"
# In special cases we don't want -lc...
case $caudium_cv_sys_os in
  UnixWare*|SCO_SV*)
    CLIBRARY_LINK=""      
  ;;
esac


#
# Some variables we want to export to the other configure scripts.
#
CPPFLAGS="-I$srcdir/src/  $CPPFLAGS"
CFLAGS="$CFLAGS $CCSHARED $WARN $OPTIMIZE"
export CC CFLAGS CPPFLAGS LDFLAGS LDSHARED SO CLIBRARY_LINK

AC_CONFIG_HEADER(config.h)
AC_CONFIG_SUBDIRS(src)
AC_OUTPUT(Makefile)

cat <<EOF

The Pike Extension module package is now configured.  This is some
information about the build environment. If the wrong pike was
selected, try re-running configure with
'--with-pike=/path/to/correct/pike'.

 CC:         ${T_MD}$CC${T_ME}
 LDSHARED:   ${T_MD}$LDSHARED${T_ME}
 CFLAGS:     ${T_MD}$CFLAGS${T_ME}
 CPPFLAGS:   ${T_MD}$CPPFLAGS${T_ME}
 LDFLAGS:    ${T_MD}$LDFLAGS${T_ME}

 Pike binary used:      ${T_MD}$PIKE${T_ME}
 Pike version:          ${T_MD}$PIKE_VERSION${T_ME}
 Pike include dir:      ${T_MD}$PIKE_INCLUDE_DIRS${T_ME}
 Pike module dir:       ${T_MD}$PIKE_MODULE_DIR${T_ME}

 Enabled modules:
EOF

for m in $ENABLE_MODULES; do
  echo "  ${T_MD}$m${T_ME}"
done
echo