~hww3/caudium

ref: 93d5a75fba08db71b832716377276978cdd7888d caudium/configure.ac -rw-r--r-- 21.1 KiB
93d5a75fWilliam Welliver storage: method "None" was missing stop function. should fix error on shutdown 1 year, 9 days ago
                                                                                
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
#
# $Id: configure.ac,v 1.65 2007-10-12 01:20:32 hww3 Exp $
#
AC_PREREQ(2.53)
AC_INIT(Caudium, 1.5.1, bugs@caudium.net)

AC_REVISION($Revision: 1.65 $)

#
# Some prerequisites of ours
#
# The oldest version of Pike we run
REQ_MIN_PIKE_MAJOR=8
REQ_MIN_PIKE_MINOR=0
REQ_MIN_PIKE_BUILD=0
# But on the other end we can't run Pike above or equal this one
REQ_MAX_PIKE_MAJOR=8
REQ_MAX_PIKE_MINOR=1
REQ_MAX_PIKE_BUILD=0

# Some DMALLOC and usefull macros
# Copyright 1996, 1998, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

# serial 2

AC_DEFUN([AM_WITH_DMALLOC],
[AC_MSG_CHECKING([if malloc debugging is wanted])
AC_ARG_WITH(dmalloc,
[  --with-dmalloc          use dmalloc, as in
                          http://www.dmalloc.com/dmalloc.tar.gz],
[if test "$withval" = yes; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(WITH_DMALLOC,1,
            [Define if using the dmalloc debugging malloc package])
  LIBS="$LIBS -ldmalloc"
  LDFLAGS="$LDFLAGS -g"
else
  AC_MSG_RESULT(no)
fi], [AC_MSG_RESULT(no)])
])

AU_DEFUN([fp_WITH_DMALLOC], [AM_WITH_DMALLOC])

## End of DMALLOC definitions.

AC_SET_MAKE

AC_PROG_INSTALL
BUILDDIR=`pwd`
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
#--------------------------

# Strip smartlink from cached CC if it's there.
if test ! -z "$ac_cv_prog_CC"; then
 ac_cv_prog_CC="`echo $ac_cv_prog_CC|sed -e 's/.*smartlink //'`"
 export ac_cv_prog_CC
fi

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 Caudium 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
])

# Test the following compiler flag only for OS + CPU that NOT 
# passed in $1 and $2 args
AC_DEFUN(AC_SYS_NOT_OS_CPU_COMPILER_FLAG,
 [
   if test "x$caudium_cv_sys_os" != "x$1"; then
     if test "`uname -m 2>/dev/null`" != "$2" ; then
       AC_SYS_COMPILER_FLAG($3,$4,$5)
     fi
   fi
])


# We need some special hacks when running slowaris
## Build smartlink

AC_CHECK_HEADERS(stdlib.h string.h unistd.h sys/stat.h sys/types.h sys/errno.h)

AC_PATH_PROG(uname_prog,uname,no)
if test "$uname_prog" != "no"; then
  UNAME=`$uname_prog -sr`
elif test -x /usr/bin/uname 2>/dev/null; then
  UNAME=`/usr/bin/uname -sr`
elif test -x /usr/bin/uname 2>/dev/null; then
  UNAME=`/usr/bin/uname -sr`
elif test -x /bin/uname 2>/dev/null; then
  UNAME=`/bin/uname -sr`
else
  UNAME=unknown
fi

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
    ;;
    Monterey64)
      # According to the release notes, the string "Monterey64"
      # will be changed to "AIX" in the final release.
      # (Monterey 64 is also known as AIX 5L).
      caudium_cv_sys_os="AIX"
    ;;
  esac
else
  caudium_cv_sys_os="Not Solaris"
fi
])
AC_MSG_RESULT($caudium_cv_sys_os)

if test "$caudium_cv_sys_os" = "Solaris" ; then
  AC_DEFINE(SOLARIS)
else
  :
fi

# FIXME: Add proper tests
case "$UNAME" in
  OSF1\ V4.*)
    AC_DEFINE(USE_RPATH)
    ;;
  HPUX\ 11.*)
    AC_DEFINE(USE_PLUS_b)
    ;;
  IRIX\ 6.*)
    AC_DEFINE(USE_RPATH)
    ;;
  IRIX\ 5.*)
    AC_DEFINE(USE_RPATH)
    ;;
  SunOS\ 5.*)
    if test "$TCC" = "yes"; then
      # tcc doesn't know about -R
      AC_DEFINE(USE_Wl_R)
    else
      AC_DEFINE(USE_R)
    fi
    ;;
  Linux\ 2.*)
    AC_DEFINE(USE_Wl)
    ;;
  UnixWare\ 7.*)
    if test "$ac_cv_prog_gcc" = "yes"; then
      AC_DEFINE(USE_XLINKER_YP_)
    else
      AC_DEFINE(USE_YP_)
    fi
    ;;
  *)
    AC_DEFINE(USE_LD_LIBRARY_PATH)
    ;;
esac

# Fix a smartlink
SMARTLINK="$BUILDDIR/smartlink"

AC_MSG_CHECKING(if $SMARTLINK exists is up to date and works)
if ls -1tr "$SMARTLINK" "$srcdir/tools/smartlink.c" 2>/dev/null | head -1 | grep "smartlink" >/dev/null 2>&5 && "$SMARTLINK" -v >/dev/null 2>&5; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  rm -f "$SMARTLINK"
  AC_MSG_CHECKING(whether smartlink compiles)

  link_cmd='${CC} -o smartlink $CFLAGS -I. $CPPFLAGS $LDFLAGS $srcdir/tools/smartlink.c $LIBS 2>&5'
   if { (eval echo Compiling smartlink: \"$link_cmd\") 1>&5; (eval $link_cmd) 2>&5; } && "$BUILDDIR/smartlink" -v >/dev/null 2>&5; then
      AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no - use the sh script)
    SMARTLINK="$srcdir/tools/smartlink" 
 fi
fi
CC="$SMARTLINK $CC"
ac_cv_prog_CC="$CC"
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)

### Let's set the default,            ###
### which we can change if we'd like. ###
#########################################
# Sometimes prefix is set to NONE (EPITA, why ?)
if test "$prefix" != "NONE"; then
  CAUDIUM_SERVERDIR="$prefix/caudium/server/"
else
  CAUDIUM_SERVERDIR="/usr/local/caudium/server/"
fi

AC_ARG_WITH(serverdir,
AC_HELP_STRING([--with-serverdir=DIR],[Location of the top-level Caudium directory after installation]),
[
  if test ! -z "$withval"; then
    CAUDIUM_SERVERDIR="$withval/"
  else
    CAUDIUM_SERVERDIR="$prefix/caudium/server/"
  fi
])

### Pike Detection ###
######################
CHECK_PIKE_VERSION=1

AC_ARG_WITH(any-pike-version, 
AC_HELP_STRING([--with-any-pike-version],[Allow any pike version to be used, disabling the standard version compatibility checks]), 
  [CHECK_PIKE_VERSION=0], [CHECK_PIKE_VERSION=1])

AC_ARG_WITH(pike, 
AC_HELP_STRING([--with-pike[=binary]],[Use the specified Pike rather than searching for a suitable 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
])
RESULT=no
AC_MSG_CHECKING([for a working Pike (>= $REQ_MIN_PIKE_MAJOR.$REQ_MIN_PIKE_MINOR.$REQ_MIN_PIKE_BUILD <= $REQ_MAX_PIKE_MAJOR.$REQ_MAX_PIKE_MINOR.$REQ_MAX_PIKE_BUILD)])
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=""
REQ_MIN_PIKE_DECNUM=`expr '(' $REQ_MIN_PIKE_MAJOR '*' 10000 ')' + '(' $REQ_MIN_PIKE_MINOR '*' 1000 ')' + $REQ_MIN_PIKE_BUILD`
REQ_MAX_PIKE_DECNUM=`expr '(' $REQ_MAX_PIKE_MAJOR '*' 10000 ')' + '(' $REQ_MAX_PIKE_MINOR '*' 1000 ')' + $REQ_MAX_PIKE_BUILD`
OLD_DIR=`pwd`
if test "x$DEFPIKE" != "x" ; then
PIKES_TO_CHECK="$DEFPIKE"
else
PIKES_TO_CHECK="$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/pike76 /opt/local/bin/pike /opt/local/bin/pike76 /opt/bin/pike /opt/bin/pike76 /usr/bin/pike7.6 /usr/bin/pike7.6"
fi

for PIKE in $PIKES_TO_CHECK; 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`


    if test $THIS_PIKE_DECNUM -lt $REQ_MIN_PIKE_DECNUM; then
      if test CHECK_PIKE_VERSION = 1 ; then
         echo " => too old"
         continue
      else
         echo " => too old (but using anyway due to --with-any-pike-version)"
      fi
    elif test $THIS_PIKE_DECNUM -ge $REQ_MAX_PIKE_DECNUM; then
      if test CHECK_PIKE_VERSION = 1 ; then
        echo " => too new"
        continue
      else
         FOUND_PIKE=1
	 PIKE_VERSION=$THIS_PIKE_VER
	 break;
         echo " => too new (but using anyway due to --with-any-pike-version)"
      fi
    else
      FOUND_PIKE=1
      PIKE_VERSION=$THIS_PIKE_VER
      echo " => good version"
      break;
    fi

  fi
done

cd $OLD_DIR
if test "x$FOUND_PIKE" = "x1"; then 
  AC_MSG_RESULT([found Pike $PIKE_VERSION ($PIKE)])
else
  cat << EOF
*****************************************************************************
*** I couldn't find a suitable Pike for Caudium. 
***
*** PLEASE NOTE: THIS VERSION OF Caudium DOES NOT WORK WITH 
*** PIKE OLDER THAN $REQ_MIN_PIKE_MAJOR.$REQ_MIN_PIKE_MINOR.$REQ_MIN_PIKE_BUILD!
*** 
*** You can download and install one of our Pike $REQ_MIN_PIKE_MAJOR.$REQ_MIN_PIKE_MINOR or 
*** newer snapshots available from our website at:
***
*** http://caudium.net/download/source/caudiumbuild.rxml
***
*** 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)

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

# 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 Caudium does not compile, or
does not run, please try this to compile Caudium again:
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 \
    /opt/include /opt/local/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/pkg/lib \
    /usr/gnu/lib /opt/gnu/lib /sw/gnu/lib /usr/freeware/lib \
    /opt/lib /opt/local/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

WARN=""
OPTIMIZE=""

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";;
    NetBSD*) LDSHARED="ld -Bshareable";;
    OpenBSD*) LDSHARED="ld -Bshareable";;
    BSD/OS*) LDSHARED="shlicc -r";;
    Darwin*) LDSHARED="$CC -bundle -undefined error -bundle_loader $PIKE";;
    UNIX_SV*) LDSHARED="ld -G";;
    SCO_SV*) LDSHARED="cc -G -KPIC -Wl,-Bexport";;
    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

# Strip smartlink from $CC
LDSHARED="$SMARTLINK `echo $LDSHARED|sed -e 's/.*smartlink //'`"

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


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

CCSHARED="$caudium_cv_sys_ccshared"
AC_MSG_RESULT($CCSHARED)

CPPFLAGS="$CPPFLAGS -I$srcdir/src/cmods/"
#
# CPPFLAGS is a precious variable in Autoconf, it is saved with its
# initial value. We must resort to a different way of substituting that
# in the makefile. Ugh.
#
CPPFLAGS="$CPPFLAGS -I$srcdir/src/cmods/"
CAUDIUM_CPPFLAGS="$CPPFLAGS"
AC_SUBST(CAUDIUM_CPPFLAGS)
AC_SUBST(CAUDIUM_SERVERDIR)

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

AC_CONFIG_SUBDIRS(src tools)
AC_CONFIG_COMMANDS([hail_epita],[sh tools/fixperms])
AC_OUTPUT(Makefile server/start-caudium server/bin/install)

echo "

Caudium 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:         $CC
        LDSHARED:   $LDSHARED

        CFLAGS:     $CFLAGS

        CPPFLAGS:   $CPPFLAGS

        LDFLAGS:    $LDFLAGS

        Pike binary used:      $PIKE
        Pike version:          $PIKE_VERSION
        Pike include dir:      $PIKE_INCLUDE_DIRS

	"

# Verify the pike ... 
$PIKE $srcdir/tools/verify_pike.pike