ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hybrid-ircservices-1/configure
Revision: 1347
Committed: Wed Apr 11 14:31:21 2012 UTC (14 years, 6 months ago) by michael
File size: 85291 byte(s)
Error occurred while calculating annotation data.
Log Message:
- fixed several compile warnings

File Contents

# Content
1 #!/bin/sh
2 #
3 # Configuration script for Services.
4 #
5 # IRC Services is copyright (c) 1996-2009 Andrew Church.
6 # E-mail: <achurch@achurch.org>
7 # Parts written by Andrew Kempe and others.
8 # This program is free but copyrighted software; see the file GPL.txt for
9 # details.
10
11 ###########################################################################
12
13 # Temporary directory to use for various things.
14 CONFTMP=conf-tmp
15
16 ###########################################################################
17
18 # Nifty handy functions.
19
20 # Echo something and stay on the same line.
21 echo2 () {
22 $ECHO2 "$*$ECHO2SUF" # these are defined below
23 }
24
25 # Write a line to the log file, including the current test mode.
26 log () {
27 echo >&3 "$MODE: $*"
28 }
29
30 # Run a command, writing the command, output, and exit status (if nonzero)
31 # to the log.
32 run () {
33 echo >&3 "$MODE: >>> $*"
34 ("$@") >&3 2>&3 </dev/null
35 xxres=$?
36 if [ $xxres -ne 0 ] ; then
37 echo >&3 "$MODE: *** Command failed (exit code $xxres)"
38 fi
39 return $xxres
40 }
41
42 # Test whether a file exists (some shells don't have "test -e").
43 exists () {
44 if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
45 return 0
46 else
47 return 1
48 fi
49 }
50
51 # Run grep without any output.
52 grep_q () {
53 grep >/dev/null 2>&1 "$@"
54 }
55
56 ###########################################################################
57
58 # How can we echo something without going to the next line?
59
60 ECHO2SUF=''
61 if [ "`echo -n a ; echo -n b`" = "ab" ] ; then
62 ECHO2='echo -n'
63 elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then
64 ECHO2='echo' ; ECHO2SUF='\c'
65 elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then
66 ECHO2='printf "%s"'
67 else
68 # oh well...
69 ECHO2='echo'
70 fi
71 export ECHO2 ECHO2SUF
72
73 ###########################################################################
74
75 # Kludge around GNU coreutils stuffiness. (Some versions of `head' refused
76 # to recognize the standard "head -1" syntax, insisting on "head -n 1".)
77
78 head_is_broken=""
79 if [ x`echo test | head -1 2>/dev/null` != xtest ] ; then
80 head_is_broken=broken
81 elif [ "x`echo test | head -1 2>&1 >/dev/null`" != x ] ; then
82 head_is_broken=broken
83 fi
84 HEAD () {
85 if test "$head_is_broken" ; then
86 count=$1; shift
87 head -n`echo x$count | cut -c3-` "$@"
88 else
89 head "$@"
90 fi
91 }
92
93 ###########################################################################
94
95 # Return the default flags for the given C compiler.
96
97 def_cc_flags () {
98 GCC=no
99 a=`echo "x$1" | cut -c1-4`
100 if [ "$a" = "xgcc" -o "x$1" = "xkgc" ] ; then
101 GCC=yes
102 elif "$1" --version 2>/dev/null | grep_q '(GCC)' ; then
103 GCC=yes
104 fi
105 if [ $GCC = yes ] ; then
106 echo "-O2 -fno-strict-aliasing"
107 elif [ "X$1" = "Xicc" ] ; then
108 echo "-O0 -wd144,167,556"
109 fi
110 }
111
112 ###########################################################################
113
114 # Test for the presence of a given include file or function. If the
115 # variable TEST is non-empty, it contains code to be placed at the end of
116 # main(), and should return 0 if everything is okay, else 1.
117 #
118 # For includes: Pass the include filename as an argument. The variable
119 # HAVE_include_name, where "include_name" is the name of the include file
120 # with letters uppercased and non-alphanumerics replaced by underscores, is
121 # set to 1 if the include file is present, else 0.
122 #
123 # For functions: Pass the return type, function name, and prototype as
124 # arguments. The variable HAVE_function, where "function" is the name
125 # of the function with letters uppercased, is set to 1 if the function is
126 # available, else 0.
127 #
128 # For both: The result code of the function will be 0 (true) if the entity
129 # is present, else 1 (false).
130
131 test_include () {
132 include="$1"
133 inc2="`echo $include | sed 'y+abcdefghijklmnopqrstuvwxyz/.-+ABCDEFGHIJKLMNOPQRSTUVWXYZ___+'`"
134 if [ -f "/usr/include/$include" ] ; then
135 eval "HAVE_${inc2}=1"
136 log "found $include in /usr/include"
137 return 0
138 fi
139 cat >$CONFTMP/test.c <<EOT
140 #include <$include>
141 int main() { return 0; }
142 EOT
143 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
144 eval "HAVE_${inc2}=1"
145 log "found $include"
146 return 0
147 else
148 eval "HAVE_${inc2}=0"
149 log "didn't find $include"
150 return 1
151 fi
152 }
153
154
155 test_function () {
156 rettype="$1"
157 func="$2"
158 proto="$3"
159 if [ ! "$rettype" -o ! "$func" ] ; then
160 log "test_function: missing parameter(s)"
161 return 1
162 fi
163 if [ ! "$proto" ] ; then
164 proto="(...)"
165 fi
166 func2=`echo $func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
167 if [ ! "$TEST" ] ; then
168 TEST="return 0;"
169 fi
170 cat >$CONFTMP/test.c <<EOT
171 int main() {
172 extern $rettype $func$proto;
173 $TEST
174 }
175 EOT
176 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test && (run $CONFTMP/test) 2>&1 ; then
177 eval "HAVE_${func2}=1"
178 log "found $func"
179 return 0
180 else
181 eval "HAVE_${func2}=0"
182 log "didn't find $func"
183 return 1
184 fi
185 }
186
187 ###########################################################################
188
189 # If something happens that really shouldn't:
190
191 whoa_there () {
192 cat <<EOT
193
194 *** WHOA THERE! ***
195
196 We suddenly couldn't compile using the C compiler we already tested!
197 The command line we used was:
198 $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test
199 Please try to fix this; if you can't, mail achurch@achurch.org
200 with information about your system, the output from this script,
201 and the \`configure.log' file generated by this script.
202
203 Configuration aborted.
204
205 EOT
206 exit 4
207 }
208
209 ###########################################################################
210 ###########################################################################
211
212 # Start of actual script.
213
214 ###########################################################################
215
216 # Create a temporary directory for our use.
217
218 if exists $CONFTMP ; then
219 rm -rf $CONFTMP
220 fi
221 if mkdir $CONFTMP ; then : ; else
222 echo "Failed to create temporary directory! Exiting."
223 exit 2
224 fi
225 if chmod u+rwx $CONFTMP ; then : ; else
226 echo "Cannot write to temporary directory! Exiting."
227 exit 2
228 fi
229
230 ###########################################################################
231
232 # Variable initialization.
233
234 MY_CONFIG_VERSION=105
235 CONFIG_VERSION=
236
237 PROGRAM=ircservices
238 PREFIX=
239 BINDEST=/usr/local/sbin
240 DATDEST=/usr/local/lib/ircservices
241
242 TEST_NT=
243 INSTALL=
244 MKDIR=
245 CP_ALL=
246
247 CC=
248 CC_FLAGS=bonkle
249 CC_LFLAGS=bonkle
250 CC_LIBS=bonkle
251 EXE_SUFFIX=bonkle
252 NEED_GCC3_HACK=0
253 SYMS_NEED_UNDERSCORES=0
254
255 SORTED_LISTS=1
256 CLEAN_COMPILE=1
257 DUMPCORE=0
258 MEMCHECKS=0
259 SHOWALLOCS=0
260
261 STATIC_MODULES=
262 CC_SHARED=
263 CC_DYN_LFLAGS=
264 CC_DYN_LIBS=
265 RANLIB=
266
267 TYPE_INT8=
268 TYPE_INT16=
269 TYPE_INT32=
270 TYPE_INT64=
271 SIZEOF_INT=
272 SIZEOF_LONG=
273 SIZEOF_PTR=
274 SIZEOF_TIME_T=
275 MAX_TIME_T=
276 SIZEOF_GID_T=bonkle
277 HAVE_SOCKLEN_T=
278
279 HAVE_STDINT_H=
280 HAVE_STRINGS_H=
281 HAVE_SYS_SELECT_H=
282 HAVE_SYS_SYSPROTO_H=
283
284 HAVE_STRERROR=
285 HAVE_SYS_ERRLIST=0
286 HAVE_HSTRERROR=
287
288 HAVE_STRTOK=
289 HAVE_STRICMP=
290 HAVE_STRCASECMP=
291 HAVE_STRDUP=
292 HAVE_STRSPN=
293 HAVE_STRSIGNAL=
294 HAVE_GETTIMEOFDAY=
295 HAVE_SETGRENT=
296 HAVE_SETREGID=
297 HAVE_UMASK=
298 HAVE_FORK=
299 HAVE_GETHOSTBYNAME=
300 HAVE_GETSETRLIMIT=
301 HAVE_CRYPT=
302 MISSING=bonkle
303
304 ###########################################################################
305
306 # Command-line parsing.
307
308 OPT_OS2=
309 OPT_BINDEST=
310 OPT_DATDEST=
311 OPT_SORTED_LISTS=bonkle
312 OPT_CLEAN_COMPILE=bonkle
313 OPT_MEMCHECKS=bonkle
314 OPT_SHOWALLOCS=bonkle
315 OPT_DUMPCORE=bonkle
316 IGNORE_CACHE=
317 USE_LOCAL_FUNCS=
318 NO_USE_LOCAL_FUNCS=
319 USE_STATIC_MODULES=
320 USE_DYNAMIC_MODULES=
321
322 USER_CC=
323 USER_CC_FLAGS=bonkle
324 USER_CC_LFLAGS=bonkle
325 USER_CC_LIBS=
326
327 export OPT_OS2 OPT_BINDEST OPT_DATDEST IGNORE_CACHE
328 export USE_LOCAL_FUNCS NO_USE_LOCAL_FUNCS USE_STATIC_MODULES
329 export USE_DYNAMIC_MODULES OPT_SORTED_LISTS OPT_CLEAN_COMPILE
330 export OPT_DUMPCORE OPT_MEMCHECKS OPT_SHOWALLOCS
331 export USER_CC USER_CC_FLAGS USER_CC_LFLAGS USER_CC_LIBS
332
333 while [ $# -gt 0 ] ; do
334 if echo "$1" | grep_q '^-' ; then
335 option=`echo "$1" | cut -c2-`
336 shift
337 if echo "$option" | grep_q '^-' ; then
338 option=`echo "$option" | cut -c2-`
339 if echo "$option" | grep_q '=' ; then
340 value=`echo "$option" | sed 's/^[^=]*=//'`
341 option=`echo "$option" | sed 's/=.*$//'`
342 set -- "$value" "$@"
343 fi
344 fi
345 if [ "$option" = "check" ] ; then
346 rm -rf $CONFTMP
347 if [ -f config.cache ] ; then
348 CACHEVER=`grep '^CONFIG_VERSION=' config.cache | cut -d= -f2`
349 if [ "x$CACHEVER" = "x$MY_CONFIG_VERSION" ] ; then
350 exit 0
351 else
352 exit 1
353 fi
354 else
355 exit 1
356 fi
357 elif [ "$option" = "ignore-cache" ] ; then
358 IGNORE_CACHE=bonkle
359 elif [ "$option" = "cc" ] ; then
360 USER_CC="$1"
361 shift
362 elif [ "$option" = "cflags" ] ; then
363 USER_CC_FLAGS="$1"
364 shift
365 elif [ "$option" = "lflags" ] ; then
366 USER_CC_LFLAGS="$1"
367 shift
368 elif [ "$option" = "libs" ] ; then
369 USER_CC_LIBS="$1"
370 shift
371 elif [ "$option" = "os2" ] ; then
372 OPT_OS2=1
373 elif [ "$option" = "program" ] ; then
374 if echo "x$1" | grep_q / ; then
375 echo >&2 "Error: -program parameter must not contain a slash"
376 exit 1
377 elif [ "$1" = "modules" ] ; then
378 echo >&2 'Error: "modules" cannot be used as the program name'
379 exit 1
380 else
381 PROGRAM="$1"
382 fi
383 shift
384 elif [ "$option" = "bindest" ] ; then
385 OPT_BINDEST="$1"
386 shift
387 elif [ "$option" = "datdest" ] ; then
388 OPT_DATDEST="$1"
389 shift
390 elif [ "$option" = "prefix" ] ; then
391 PREFIX="$1"
392 shift
393 elif [ "$option" = "use-local-funcs" ] ; then
394 USE_LOCAL_FUNCS=bonkle
395 NO_USE_LOCAL_FUNCS=
396 elif [ "$option" = "no-use-local-funcs" ] ; then
397 USE_LOCAL_FUNCS=
398 NO_USE_LOCAL_FUNCS=bonkle
399 elif [ "$option" = "use-static-modules" ] ; then
400 USE_DYNAMIC_MODULES=
401 USE_STATIC_MODULES=bonkle
402 elif [ "$option" = "no-use-static-modules" ] ; then
403 USE_DYNAMIC_MODULES=bonkle
404 USE_STATIC_MODULES=
405 elif [ "$option" = "sorted-lists" ] ; then
406 OPT_SORTED_LISTS=1
407 elif [ "$option" = "no-sorted-lists" ] ; then
408 OPT_SORTED_LISTS=0
409 elif [ "$option" = "clean-compile" ] ; then
410 OPT_CLEAN_COMPILE=y
411 elif [ "$option" = "no-clean-compile" ] ; then
412 OPT_CLEAN_COMPILE=
413 elif [ "$option" = "memchecks" ] ; then
414 OPT_MEMCHECKS=y
415 elif [ "$option" = "no-memchecks" ] ; then
416 OPT_MEMCHECKS=
417 elif [ "$option" = "showallocs" ] ; then
418 OPT_SHOWALLOCS=y
419 elif [ "$option" = "no-showallocs" ] ; then
420 OPT_SHOWALLOCS=
421 elif [ "$option" = "dumpcore" ] ; then
422 OPT_DUMPCORE=y
423 elif [ "$option" = "no-dumpcore" ] ; then
424 OPT_DUMPCORE=
425 else
426 if [ "$option" != "help" -a "$option" != "h" ]; then
427 echo >&2 "Unknown option/parameter: $option"
428 exitval=1
429 else
430 exitval=0
431 fi
432 cat >&2 <<EOT
433
434 Available options:
435
436 *** Controlling the configure script ***
437
438 -help Display list of command-line options
439 -ignore-cache Don't use cache file if it exists
440
441 *** Controlling compilation ***
442
443 -cc PROGRAM Specify C compiler to use (overrides cache and
444 check; also clears cached CFLAGS/LFLAGS values)
445 -cflags FLAGS Specify compilation flags (overrides cache/check)
446 -lflags FLAGS Specify link flags for C compiler (default: none)
447 -libs LIBS Specify extra libraries to use (default: none)
448 -os2 Indicate that this is an OS/2 system
449
450 *** Controlling installation ***
451
452 -program NAME Specify name to use for executable file (default
453 "ircservices"); "ircservices-chk" script will
454 also be renamed to "NAME-chk"
455 -bindest DIR Specify directory for program file installation
456 -datdest DIR Specify directory for data file installation
457 -prefix DIR Specify GNU-style installation prefix (program
458 will be installed in DIR/sbin, data in
459 DIR/lib/<program>); overrides -bindest/-datdest
460
461 *** Controlling Services features ***
462
463 Note that the following functions can be disabled by adding "no-" before
464 the option name; for example, "-no-use-local-funcs". For options with a
465 * before the option name, the option is on by default, and you must
466 explicitly give -no-option-name to disable it.
467
468 -use-local-funcs Force the use of compatibility functions over
469 system library functions (for debugging)
470 -use-static-modules Force modules to be compiled statically, even if
471 dynamic modules could be used
472 * -sorted-lists Keep nickname/channel lists sorted (causes a
473 performance penalty on large networks)
474 * -clean-compile Attempt to compile with no warnings (causes a
475 slight performance penalty)
476 -memchecks Perform extra checks on memory allocation (for
477 debugging only; causes a significant
478 performance penalty)
479 -showallocs Log all memory allocation activity (for
480 debugging only; ignored unless -memchecks
481 is enabled)
482 -dumpcore Causes Services to attempt to write a core
483 file if it crashes (for debugging)
484
485 *** Other options ***
486
487 -check Check whether this script has already been run
488 and whether the cache is up-to-date. Exits
489 with status 0 if up-to-date, 1 if not.
490
491
492 GNU-style long options (--option[=value]) may also be used.
493
494 Note that environment variables such as CC and CFLAGS are ignored; use
495 the corresponding command-line options (-cc, -cflags, etc.) instead.
496 EOT
497 exit $exitval
498 fi
499 fi
500 done
501
502 ###########################################################################
503
504 echo ""
505 echo "Beginning Hybrid IRC Services configuration."
506 echo ""
507
508 ###########################################################################
509
510 # First, test for the presence of a config.cache file. If found, either
511 # don't use it (-ignore-cache), or let the user know how to not use it and
512 # then use it.
513
514 if [ -f config.cache -a -r config.cache -a ! "$IGNORE_CACHE" ] ; then
515 cat <<EOT
516 Using defaults from config.cache. To ignore, either remove config.cache or
517 give the command-line option "-ignore-cache".
518
519 EOT
520 . ./config.cache
521 # Clear list of missing functions if either a relevant HAVE_* variable
522 # is missing or -no-use-local-funcs was specified.
523 if [ "$NO_USE_LOCAL_FUNCS" \
524 -o ! "$HAVE_STRTOK" \
525 -o ! "$HAVE_STRICMP" \
526 -o ! "$HAVE_STRCASECMP" \
527 -o ! "$HAVE_STRDUP" \
528 -o ! "$HAVE_STRSPN" \
529 -o ! "$HAVE_STRSIGNAL" \
530 -o ! "$HAVE_GETTIMEOFDAY" \
531 -o ! "$HAVE_SETGRENT" \
532 -o ! "$HAVE_SETREGID" \
533 -o ! "$HAVE_UMASK" \
534 -o ! "$HAVE_FORK" \
535 -o ! "$HAVE_GETHOSTBYNAME" \
536 -o ! "$HAVE_GETSETRLIMIT" \
537 -o ! "$HAVE_CRYPT" \
538 ] ; then
539 MISSING=bonkle
540 fi
541 if [ ! "$CONFIG_VERSION" ] ; then
542 CONFIG_VERSION=0
543 CC_LFLAGS=bonkle
544 CC_LIBS=bonkle
545 fi
546 if [ $CONFIG_VERSION -lt 2 ] ; then
547 # missing -fno-strict-aliasing
548 CC=
549 CC_FLAGS=bonkle
550 fi
551 if [ $CONFIG_VERSION -lt 4 ] ; then
552 # socklen_t test broken on FreeBSD
553 HAVE_SOCKLEN_T=
554 fi
555 if [ $CONFIG_VERSION -lt 6 ] ; then
556 # deprecated GCC < 3.2, so recheck compiler
557 CC=
558 fi
559 if [ $CONFIG_VERSION -lt 7 ] ; then
560 # Added -fstack-protector avoidance, so recheck compiler flags
561 CC=
562 fi
563 if [ $CONFIG_VERSION -lt 8 ] ; then
564 # Added __builtin_xxx() bug check and fixed -fstack-protector
565 # avoidance, so recheck compiler and flags
566 CC=
567 fi
568 if [ $CONFIG_VERSION -lt 100 ] ; then
569 # Initial 5.1 version: remove support for pre-C99 compilers;
570 # use 0/1 instead of y/"" for compilation options
571 CC=
572 if [ "x$SORTED_LISTS" = "xy" ] ; then
573 SORTED_LISTS=1
574 else
575 SORTED_LISTS=0
576 fi
577 if [ "x$CLEAN_COMPILE" = "xy" ] ; then
578 CLEAN_COMPILE=1
579 else
580 CLEAN_COMPILE=0
581 fi
582 if [ "x$DUMPCORE" = "xy" ] ; then
583 DUMPCORE=1
584 else
585 DUMPCORE=0
586 fi
587 if [ "x$MEMCHECKS" = "xy" ] ; then
588 MEMCHECKS=1
589 else
590 MEMCHECKS=0
591 fi
592 if [ "x$SHOWALLOCS" = "xy" ] ; then
593 SHOWALLOCS=1
594 else
595 SHOWALLOCS=0
596 fi
597 fi
598 if [ $CONFIG_VERSION -lt 101 ] ; then
599 # Add checks for -lcrypt and crypt()
600 CC_LIBS=bonkle
601 MISSING=bonkle
602 fi
603 if [ $CONFIG_VERSION -lt 102 ] ; then
604 # Add check for -lm
605 CC_LIBS=bonkle
606 fi
607 if [ $CONFIG_VERSION -lt 103 ] ; then
608 # Modify checks for int8/int16/etc
609 TYPE_INT8=
610 TYPE_INT16=
611 TYPE_INT32=
612 TYPE_INT64= # not present in this version, but clear it anyway
613 fi
614 if [ $CONFIG_VERSION -lt 104 ] ; then
615 # Add symbol resolution test to dynamic module check
616 STATIC_MODULES=
617 fi
618 if [ "$USE_DYNAMIC_MODULES" ] ; then
619 STATIC_MODULES=
620 RANLIB=
621 fi
622 if [ "$USE_STATIC_MODULES" ] ; then
623 RANLIB=
624 fi
625 if [ "x$USER_CC" != "x" -o "x$CC" = "x" ] ; then
626 # don't mix old flags and new compiler
627 CC_FLAGS=bonkle
628 CC_LFLAGS=bonkle
629 fi
630 fi
631
632 if [ "$OPT_SORTED_LISTS" != bonkle ] ; then
633 if [ "$OPT_SORTED_LISTS" = y ] ; then
634 SORTED_LISTS=1
635 else
636 SORTED_LISTS=0
637 fi
638 fi
639 if [ "$OPT_CLEAN_COMPILE" != bonkle ] ; then
640 if [ "$OPT_CLEAN_COMPILE" = y ] ; then
641 CLEAN_COMPILE=1
642 else
643 CLEAN_COMPILE=0
644 fi
645 fi
646 if [ "$OPT_DUMPCORE" != bonkle ] ; then
647 if [ "$OPT_DUMPCORE" = y ] ; then
648 DUMPCORE=1
649 else
650 DUMPCORE=0
651 fi
652 fi
653 if [ "$OPT_MEMCHECKS" != bonkle ] ; then
654 if [ "$OPT_MEMCHECKS" = y ] ; then
655 MEMCHECKS=1
656 else
657 MEMCHECKS=0
658 fi
659 fi
660 if [ "$OPT_SHOWALLOCS" != bonkle ] ; then
661 if [ "$OPT_SHOWALLOCS" = y ] ; then
662 SHOWALLOCS=1
663 else
664 SHOWALLOCS=0
665 fi
666 fi
667
668 ###########################################################################
669
670 # Determine installation directories.
671
672 default=""
673
674 if [ "$PREFIX" ] ; then
675 OPT_BINDEST="$PREFIX/sbin"
676 OPT_DATDEST="$PREFIX/lib/$PROGRAM"
677 else
678 if [ ! "$OPT_BINDEST" ] ; then
679 OPT_BINDEST="$BINDEST"
680 default=1
681 fi
682 if [ ! "$OPT_DATDEST" ] ; then
683 if [ "$default" ] ; then
684 OPT_DATDEST="$DATDEST"
685 else
686 if [ x`echo "$OPT_BINDEST" | grep -c '/\(sbin\|bin\)$'` = x1 ] ; then
687 OPT_DATDEST=`echo "$OPT_BINDEST" | sed 's,\(sbin\|bin\)$,lib/$PROGRAM,'`
688 else
689 OPT_DATDEST=`echo "$OPT_BINDEST" | sed s,/*$,,`/lib
690 fi
691 fi
692 fi
693 fi
694
695
696 BINDEST="$OPT_BINDEST"
697 echo "Executable (program) files will be installed in $BINDEST"
698 if exists "$BINDEST/services.h" ; then
699 echo "$BINDEST appears to contain a Services source code distribution; aborting."
700 exit 1
701 fi
702
703
704 DATDEST="$OPT_DATDEST"
705 echo "Data files will be installed in $DATDEST"
706 if exists "$DATDEST/services.h" ; then
707 echo "$DATDEST appears to contain a Services source code distribution; aborting."
708 exit 1
709 fi
710
711 ###########################################################################
712
713 # Set up log file for automated tests, so we have a clue what's going on if
714 # something dies.
715
716 exec 3>configure.log
717
718 MODE=" "
719 TEST=""
720 export MODE TEST
721
722 ###########################################################################
723
724 # Check whether we have a working "test FILE_A -nt FILE_B".
725
726 MODE="check_test_nt "
727 if [ "$TEST_NT" ] ; then
728 log "cache says $TEST_NT"
729 else
730 echo2 "Checking sanity of /bin/sh... "
731 touch $CONFTMP/file1
732 sleep 2 # just in case sleep 1 really does a sleep 0.997 or some such
733 touch $CONFTMP/file2
734 if run /bin/sh -c "test $CONFTMP/file2 -nt $CONFTMP/file1" ; then
735 TEST_NT=test
736 log "test works"
737 echo "high."
738 elif run /bin/test $CONFTMP/file2 -nt $CONFTMP/file1 ; then
739 TEST_NT=/bin/test
740 log "/bin/test works"
741 echo "medium."
742 elif run /usr/bin/test $CONFTMP/file2 -nt $CONFTMP/file1 ; then
743 TEST_NT=/usr/bin/test
744 log "/usr/bin/test works"
745 echo "medium."
746 else
747 log "neither test nor /bin/test nor /usr/bin/test work!"
748 echo "low."
749 echo " Warning: Compilation may fail unless you pass a saner shell to make:"
750 echo " make [or gmake] SHELL=/usr/local/bin/bash ..."
751 fi
752 fi
753
754 ###########################################################################
755
756 # Search for a compiler.
757
758 MODE="find_cc "
759 # Don't use the cached flags unless we use the cached compiler as well
760 CACHED_CC_FLAGS=$CC_FLAGS
761 CC_FLAGS=bonkle
762 echo2 "Searching for a suitable compiler... "
763 if [ "$USER_CC" ] ; then
764 CC="$USER_CC"
765 echo "(supplied) using $CC."
766 log user supplied \`"$CC'"
767 elif [ "$CC" ] ; then
768 echo "(cached) using $CC."
769 log cache supplied \`"$CC'"
770 CC_FLAGS=$CACHED_CC_FLAGS
771 elif run gcc --version ; then
772 version=`gcc --version 2>&1 | HEAD -1 | sed 's/[^0-9]*[^0-9.]\([0-9][0-9.]*\).*/\1/'`
773 vmajor=`echo "x.$version.0" | cut -d. -f2`
774 vminor=`echo "x.$version.0" | cut -d. -f3`
775 if test "x$version" = x || (echo "x$vmajor" | cut -c2- | grep '[^0-9]' >/dev/null 2>&1) || (echo "x$vminor" | cut -c2- | grep '[^0-9]' >/dev/null 2>&1) ; then
776 log "unparseable version string: $version"
777 cat <<EOT
778
779
780 *** WHOA THERE! ***
781
782 Unable to determine the version of GCC installed on your system. Please
783 make certain you are using an official GCC distribution. If you are
784 certain \`gcc' is the correct compiler on your system and it is a recent
785 version of GCC, re-run this script with the option \`-cc gcc' (or
786 \`--cc=gcc').
787
788 Configuration aborted.
789
790 EOT
791 exit 1
792 elif test $vmajor -lt 3 || test $vmajor = 3 -a $vminor -lt 2 ; then
793 cat <<EOT
794
795
796 *** WHOA THERE! ***
797
798 Your version of GCC was detected as \`$version'. As of Services 5.1,
799 versions of GCC earlier than 3.2 are no longer supported, as they do not
800 understand certain features of the C99 standard used by Services. Please
801 upgrade your compiler to GCC 3.2 or later.
802
803 Configuration aborted.
804
805 EOT
806 log "found \`gcc', but bad version: $version"
807 exit 1
808 else # version okay
809 echo "great, found gcc!"
810 log using \`gcc\'
811 CC=gcc
812 fi
813 else
814 echo "gcc not found."
815 echo2 " Looking for alternatives... "
816 echo >$CONFTMP/test.c "int main(){return 1;}"
817 if run icc $CONFTMP/test.c -o $CONFTMP/test ; then
818 CC=icc
819 elif run cc $CONFTMP/test.c -o $CONFTMP/test ; then
820 CC=cc
821 else
822 echo "no C compiler found!"
823 echo " Use the -cc command line option to specify your C compiler."
824 log "automatic tests failed"
825 exit 1
826 fi
827 # See if it handles ANSI.
828 cat >$CONFTMP/test.c <<EOT
829 int main(int argc, char **argv) {
830 extern void foo(int bar);
831 }
832 EOT
833 log "test for ANSI..."
834 if run $CC $CONFTMP/test.c -o $CONFTMP/test ; then
835 echo "using $CC."
836 if [ "x`def_cc_flags $CC`" = "x" -a "x$USER_CC_FLAGS" = "x" ] ; then
837 echo " Defaulting to no compiler flags. Use the -cflags option"
838 echo " if you need to specify any."
839 fi
840 log using \`"$CC'"
841 else
842 echo "found $CC, but it's not ANSI-compliant!"
843 echo " Use the -cc command line option to specify your C compiler."
844 log \`"$CC' not ANSI-compliant"
845 exit 1
846 fi
847 fi
848
849
850 # See whether compiler supports various C99 features.
851
852 log "test vararg macros..."
853 cat >$CONFTMP/test.c <<EOT
854 #define foo(a,...) int a() {printf("hello %s\n" , ##__VA_ARGS__); return 69;}
855 foo(main,"world")
856 EOT
857 if run $CC $CONFTMP/test.c -o $CONFTMP/test && (run $CONFTMP/test; test $? = 69) ; then
858 log "vararg macros ok."
859 else
860 log "vararg macros NG! Aborting."
861 cat <<EOT
862
863 *** WHOA THERE! ***
864
865 Your C compiler is not compliant with modern C standards. Services 5.1
866 requires a C compiler that understands the C99 standard, such as GCC
867 (version 3.2 or later).
868
869 Configuration aborted.
870
871 EOT
872 exit 1
873 fi
874
875 log "test va_copy..."
876 cat >$CONFTMP/test.c <<EOT
877 #include <stdarg.h>
878 void foo(int a,...) {
879 va_list args, args2;
880 va_start(args,a);
881 va_copy(args2, args);
882 va_end(args);
883 va_end(args2);
884 }
885 int main() {
886 foo(1,2);
887 return 0;
888 }
889 EOT
890 if run $CC $CONFTMP/test.c -o $CONFTMP/test && run $CONFTMP/test ; then
891 log "va_copy ok."
892 else
893 log "va_copy NG! Aborting."
894 cat <<EOT
895
896 *** WHOA THERE! ***
897
898 Your C compiler is not compliant with modern C standards. Services 5.1
899 requires a C compiler that understands the C99 standard, such as GCC
900 (version 3.2 or later).
901
902 Configuration aborted.
903
904 EOT
905 exit 1
906 fi
907
908
909 # Test compiler options.
910
911 MODE="find_ccopts "
912 if [ "$USER_CC_FLAGS" != bonkle ] ; then
913 CC_FLAGS="$USER_CC_FLAGS"
914 echo "Compiler flags supplied: $CC_FLAGS"
915 log user supplied flags: \`"$CC_FLAGS'"
916 elif [ "$CC_FLAGS" != bonkle ] ; then
917 echo "Compiler flags: (cached) $CC_FLAGS"
918 log cache supplied flags: \`"$CC_FLAGS'"
919 else
920
921 CC_FLAGS=`def_cc_flags $CC`
922
923 # Test for GCC stack-protector patch (generates broken code).
924 log "check for SSP"
925 cat >$CONFTMP/test.c <<EOT
926 void bar(int hogehoge) { printf("%d", hogehoge); }
927 void foo(int xyzzy) { __builtin_apply(bar,__builtin_apply_args(),64); }
928 int main(int ac, char **av) { foo(ac>1 ? 24 : 42); return 0; }
929 EOT
930 if run $CC $CC_FLAGS -fstack-protector $CONFTMP/test.c -o $CONFTMP/test
931 then
932 log "SSP present"
933 # See if the bug exists; if so, disable stack protection. Test
934 # twice just in case the bug exists but the stack happens to
935 # randomly contain 42.
936 a=`$CONFTMP/test`
937 b=`$CONFTMP/test x`
938 log "test results: a=[$a] b=[$b]"
939 if [ "$a" != 42 -o "$b" != 24 ] ; then
940 CC_FLAGS="$CC_FLAGS -fno-stack-protector"
941 log "SSP bug found, disabling"
942 else
943 log "SSP bug not detected"
944 fi
945 else
946 log "SSP not present"
947 fi
948
949 echo2 "Testing default compiler flags ($CC_FLAGS)... "
950 cat >$CONFTMP/test.c <<EOT
951 int main(int argc, char **argv) {
952 extern void foo(int bar);
953 }
954 EOT
955 if run $CC $CC_FLAGS -c $CONFTMP/test.c -o $CONFTMP/test.o ; then
956 echo "looks good."
957 else
958 echo "no luck! Using no flags."
959 echo " If you know what flags you want, use the -cflags option to configure."
960 CC_FLAGS=
961 fi
962 log using flags: \`"$CC_FLAGS'"
963 fi
964 # If -fstack-protector isn't disabled, test once more to make sure
965 # __builtin_apply() is working--but watch out for the __builtin_apply()
966 # bugs below, as well as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20076
967 if ! echo "$CC_FLAGS" | grep_q fno-stack-protector ; then
968 log "-fstack-protector check"
969 cat >$CONFTMP/test.c <<EOT
970 #include <stdio.h>
971 #if defined(__sparc__)
972 # define APPLY __builtin_apply((void *)bar,__builtin_apply_args(),64); asm("ld [%sp-128],%i0")
973 #elif defined(__POWERPC__)
974 # define APPLY __builtin_apply((void *)bar,__builtin_apply_args(),64); asm("mr r0,r3")
975 #else
976 # define APPLY __builtin_return(__builtin_apply((void *)bar,__builtin_apply_args(),64))
977 #endif
978 int bar(int hogehoge) { return printf("%d", hogehoge); }
979 int foo(int xyzzy) { APPLY; }
980 int main(int ac, char **av) { printf(" %d",foo(ac>1?9:42)); return 0; }
981 EOT
982 if run $CC $CC_FLAGS -fno-inline-functions $CONFTMP/test.c -o $CONFTMP/test
983 then
984 run $CONFTMP/test # to get the output into the log file
985 a=`$CONFTMP/test`
986 b=`$CONFTMP/test x`
987 log "test results: a=[$a] b=[$b]"
988 if [ "$a" != "42 2" -o "$b" != "9 1" ] ; then
989 log "-fstack-protector check failed!"
990 cat <<EOT
991
992 *** WHOA THERE! ***
993
994 Your compiler is not compiling certain code correctly; this will result in
995 crashes when running Services. If you have specified compiler flags, please
996 add "-fno-stack-protector" to the flags, or remove "-fstack-protector" if it
997 is present. If this does not help, please reinstall or upgrade your
998 compiler. See section 2-1 of the manual for details.
999
1000 Configuration aborted.
1001
1002 EOT
1003 exit 1
1004 fi
1005 else
1006 # For whatever reason, the compilation failed; maybe the compiler
1007 # isn't a GCC flavor and doesn't understand -fno-inline-functions
1008 # or __builtin_apply(). Assume things are okay.
1009 log "-fstack-protector check compilation failed, ignoring"
1010 fi
1011 fi
1012
1013 ###########################################################################
1014
1015 # Check for the GCC __builtin_apply() and __builtin_return() bugs:
1016 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8028
1017 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11151
1018
1019 MODE="check_gcc_builtin "
1020
1021 # Check whether this is actually GCC--if it doesn't understand
1022 # __builtin_apply, then probably not.
1023 cat >$CONFTMP/test.c <<EOT
1024 int foo(int n)
1025 {
1026 return n;
1027 }
1028
1029 int bar(int n)
1030 {
1031 return n*n+1;
1032 }
1033
1034 int quux(int n)
1035 {
1036 foo(0);
1037 __builtin_return(__builtin_apply((void *)bar, __builtin_apply_args(), 64));
1038 }
1039
1040 int main(int argc, char **argv)
1041 {
1042 return quux(2)==5 && quux(3)==10 ? 0 : 1;
1043 }
1044 EOT
1045 # As with the SSP check, avoid Bugzilla bug 20076 with -fno-inline-functions
1046 if run $CC $CC_FLAGS -fno-inline-functions $CONFTMP/test.c -o $CONFTMP/test ; then
1047 log "checking for __builtin_apply()/__builtin_return() bugs"
1048 # This is GCC--see if it runs correctly.
1049 if run $CONFTMP/test ; then
1050 log "bugs not detected"
1051 else
1052 case `uname -m` in
1053 i?86|sparc|powerpc|"Power Macintosh")
1054 log "bugs detected, applying workaround"
1055 NEED_GCC3_HACK=1
1056 ;;
1057 *)
1058 cat <<EOT
1059
1060 *** WHOA THERE! ***
1061
1062 Your C compiler has a bug which causes Services to be compiled incorrectly,
1063 and no workaround is available for your hardware. Please try upgrading
1064 your compiler to the most recent version available (if you are using GCC,
1065 check http://gcc.gnu.org/ for the latest version). See FAQ B.1.5 for
1066 details.
1067
1068 Configuration aborted.
1069
1070 EOT
1071 exit 1
1072 ;;
1073 esac
1074 fi # if bug detected
1075 fi # if GCC
1076
1077 ###########################################################################
1078
1079 # Set linker flags.
1080
1081 MODE="find_lflags "
1082 if [ "$USER_CC_LFLAGS" != "bonkle" ] ; then
1083 CC_LFLAGS=$USER_CC_LFLAGS
1084 log user supplied \`"$CC_LFLAGS'"
1085 elif [ "$CC_LFLAGS" != "bonkle" ] ; then
1086 log cache supplied \`"$CC_LFLAGS'"
1087 else
1088 log using none
1089 CC_LFLAGS=""
1090 fi
1091
1092 ###########################################################################
1093
1094 # Find executable suffix.
1095
1096 MODE="find_exe_suffix "
1097 if [ "$OPT_OS2" ] ; then
1098 log "-os2 option given, using \`.exe'"
1099 EXE_SUFFIX=.exe
1100 else
1101 rm -f $CONFTMP/test $CONFTMP/test.exe
1102 echo >$CONFTMP/test.c "int main(){return 1;}"
1103 if run $CC $CC_FLAGS $CC_LFLAGS $CONFTMP/test.c -o $CONFTMP/test ; then
1104 if [ -f $CONFTMP/test.exe ] ; then
1105 log using .exe
1106 EXE_SUFFIX=.exe
1107 elif [ -f $CONFTMP/test ] ; then
1108 log using nothing
1109 EXE_SUFFIX=""
1110 else
1111 log "can't find executable, assuming nothing"
1112 EXE_SUFFIX=
1113 fi
1114 else
1115 log "can't link test program, assuming nothing"
1116 EXE_SUFFIX=
1117 fi
1118 fi
1119
1120 ###########################################################################
1121
1122 # See what libraries we have that we might need.
1123
1124 MODE="find_libs "
1125 echo2 "Let's see what libraries we need..."
1126 if [ "$CC_LIBS" != bonkle ] ; then
1127 if [ "$CC_LIBS" ] ; then
1128 echo " (cached) $CC_LIBS"
1129 else
1130 echo " (cached) none"
1131 fi
1132 log cache supplied \`"$CC_LIBS'"
1133 else
1134 CC_LIBS=
1135 HAVE_RESOLV=0
1136 cat >$CONFTMP/test.c <<EOT
1137 int main(int argc, char **argv) {
1138 extern void foo(int bar);
1139 }
1140 EOT
1141 cat >$CONFTMP/test-pow.c <<EOT
1142 int main(int argc, char **argv) {
1143 extern double pow(double, double);
1144 return pow(argc,argc);
1145 }
1146 EOT
1147 cat >$CONFTMP/test-socket.c <<EOT
1148 int main(int argc, char **argv) {
1149 extern void socket();
1150 socket();
1151 }
1152 EOT
1153 cat >$CONFTMP/test-gethost.c <<EOT
1154 int main(int argc, char **argv) {
1155 extern void gethostbyname();
1156 gethostbyname();
1157 }
1158 EOT
1159 cat >$CONFTMP/test-hstrerror.c <<EOT
1160 int main(int argc, char **argv) {
1161 extern void hstrerror();
1162 hstrerror();
1163 }
1164 EOT
1165 cat >$CONFTMP/test-crypt.c <<EOT
1166 int main(int argc, char **argv) {
1167 extern void crypt();
1168 crypt();
1169 }
1170 EOT
1171 if run $CC $CC_FLAGS $CONFTMP/test-pow.c $CC_LIBS -o $CONFTMP/test ; then
1172 :
1173 elif run $CC $CC_FLAGS $CONFTMP/test-pow.c $CC_LIBS -lm -o $CONFTMP/test ; then
1174 CC_LIBS="$CC_LIBS -lm"
1175 echo2 " -lm"
1176 fi
1177 if run $CC $CC_FLAGS $CONFTMP/test-socket.c $CC_LIBS -o $CONFTMP/test ; then
1178 :
1179 elif run $CC $CC_FLAGS $CONFTMP/test-socket.c $CC_LIBS -lsocket -o $CONFTMP/test ; then
1180 CC_LIBS="$CC_LIBS -lsocket"
1181 echo2 " -lsocket"
1182 fi
1183 if run $CC $CC_FLAGS $CONFTMP/test-gethost.c $CC_LIBS -o $CONFTMP/test ; then
1184 :
1185 elif run $CC $CC_FLAGS $CONFTMP/test-gethost.c $CC_LIBS -lresolv -o $CONFTMP/test ; then
1186 CC_LIBS="$CC_LIBS -lresolv"
1187 HAVE_RESOLV=1
1188 echo2 " -lresolv"
1189 elif run $CC $CC_FLAGS $CONFTMP/test-gethost.c $CC_LIBS -lnsl -o $CONFTMP/test ; then
1190 CC_LIBS="$CC_LIBS -lnsl"
1191 echo2 " -lnsl"
1192 elif run $CC $CC_FLAGS $CONFTMP/test-gethost.c $CC_LIBS -lnsl -lresolv -o $CONFTMP/test ; then
1193 CC_LIBS="$CC_LIBS -lnsl -lresolv"
1194 HAVE_RESOLV=1
1195 echo2 " -lnsl -lresolv"
1196 fi
1197 if [ $HAVE_RESOLV = 0 ] ; then
1198 if run $CC $CC_FLAGS $CONFTMP/test-hstrerror.c $CC_LIBS -o $CONFTMP/test ; then
1199 :
1200 elif run $CC $CC_FLAGS $CONFTMP/test-hstrerror.c $CC_LIBS -lresolv -o $CONFTMP/test ; then
1201 CC_LIBS="$CC_LIBS -lresolv"
1202 HAVE_RESOLV=1
1203 echo2 " -lresolv"
1204 fi
1205 fi
1206 if run $CC $CC_FLAGS $CONFTMP/test-crypt.c $CC_LIBS -o $CONFTMP/test ; then
1207 :
1208 elif run $CC $CC_FLAGS $CONFTMP/test-crypt.c $CC_LIBS -lcrypt -o $CONFTMP/test ; then
1209 CC_LIBS="$CC_LIBS -lcrypt"
1210 echo2 " -lcrypt"
1211 fi
1212 echo ""
1213 CC_LIBS="`echo $CC_LIBS | sed 's/^ *//'`"
1214 fi
1215 if [ "$USER_CC_LIBS" ] ; then
1216 CC_LIBS="$CC_LIBS $USER_CC_LIBS"
1217 echo "Additional user-supplied libraries: $USER_CC_LIBS"
1218 log user added \`"$USER_CC_LIBS'"
1219 fi
1220
1221 ###########################################################################
1222
1223 MODE="check_shared "
1224 if [ "$USE_STATIC_MODULES" ] ; then
1225 echo "Modules will be compiled statically (-use-static-modules option)."
1226 STATIC_MODULES=1
1227 CC_SHARED=
1228 CC_DYN_LFLAGS=
1229 CC_DYN_LIBS=
1230 log "static modules selected (-use-static-modules)"
1231 else
1232 echo2 "Checking whether we can use dynamic modules... "
1233 if [ "$STATIC_MODULES" = 0 ] ; then
1234 echo "(cached) yes."
1235 log "dynamic modules selected (cache)"
1236 elif [ "$STATIC_MODULES" = 1 ] ; then
1237 echo "(cached) no."
1238 log "static modules selected (cache)"
1239 else
1240 OK=
1241 dlfcn_ok=0
1242 if test_include dlfcn.h ; then
1243 dlfcn_ok=1
1244 else
1245 log "dlfcn.h not found, skipping dlfcn test"
1246 fi
1247 if [ $dlfcn_ok = 1 ] ; then
1248 log "testing dlfcn method"
1249 OK=ok
1250 cat >$CONFTMP/test-dlopen.c <<EOT
1251 #include <dlfcn.h>
1252 int main(int argc, char **argv) {
1253 void *lib1 = dlopen("$CONFTMP/test-lib.so",
1254 RTLD_NOW | RTLD_GLOBAL);
1255 void *lib2 = dlopen("$CONFTMP/test-lib2.so",
1256 RTLD_NOW | RTLD_GLOBAL);
1257 printf("%d %d %d\n", lib1 ? 1 : 0,
1258 lib2 ? (dlsym(lib2,"foo") ? 1 : 2) : 0,
1259 lib2 ? (dlsym(0,"foo") ? 1 : 2) : 0);
1260 if (lib1)
1261 dlclose(lib1);
1262 if (lib2)
1263 dlclose(lib2);
1264 return 0;
1265 }
1266 EOT
1267 cat >$CONFTMP/test-lib.c <<EOT
1268 int foo() {no_such_symbol();}
1269 EOT
1270 cat >$CONFTMP/test-lib2.c <<EOT
1271 int foo() {return 1;}
1272 EOT
1273 if run $CC $CC_FLAGS $CC_LIBS $CONFTMP/test-dlopen.c -o $CONFTMP/test ; then
1274 CC_DYN_LIBS=""
1275 log "dlopen() found (no libs)"
1276 elif run $CC $CC_FLAGS $CC_LIBS $CONFTMP/test-dlopen.c -ldl -o $CONFTMP/test
1277 then
1278 CC_DYN_LIBS=" -ldl"
1279 log "dlopen() found (libdl)"
1280 else
1281 log "dlopen() not found"
1282 OK=
1283 fi
1284 if [ "$OK" ] ; then
1285 if run $CC -rdynamic $CC_FLAGS $CC_LIBS $CC_DYN_LIBS $CONFTMP/test-dlopen.c -o $CONFTMP/test ; then
1286 log "-rdynamic works"
1287 CC_DYN_LFLAGS=" -rdynamic"
1288 else
1289 log "no -rdynamic, aborting dlfcn test"
1290 OK=
1291 fi
1292 fi
1293 if [ "$OK" ] ; then
1294 if [ "x`uname -s`" = "xOSF1" ] ; then
1295 CC_SHARED="$CC -shared -Wl,-expect_unresolved"
1296 else
1297 CC_SHARED="$CC -shared"
1298 fi
1299 if run $CC_SHARED $CC_FLAGS $CC_LIBS $CONFTMP/test-lib.c -o $CONFTMP/test-lib.so && run $CC_SHARED $CC_FLAGS $CC_LIBS $CONFTMP/test-lib2.c -o $CONFTMP/test-lib2.so ; then
1300 log "-shared works"
1301 else
1302 log "no -shared, aborting dlfcn test"
1303 CC_SHARED=
1304 OK=
1305 fi
1306 fi
1307 if [ "$OK" ] ; then
1308 if run $CONFTMP/test ; then
1309 a=`$CONFTMP/test 2>/dev/null`
1310 log "symbol resolution test: $CONFTMP/test => $a"
1311 if [ "x$a" = "x0 1 1" ] ; then
1312 log "symbol resolution test succeeded"
1313 else
1314 log "symbol resolution test failed"
1315 OK=
1316 fi
1317 else
1318 log "couldn't run symbol resolution test program"
1319 OK=
1320 fi
1321 fi
1322 if [ "$OK" ] ; then
1323 cat >$CONFTMP/test-dynamic2.c <<EOT
1324 #include <stdio.h>
1325 int main(int argc, char **argv) {
1326 printf("%d\n", foo(atoi(argv[1])));
1327 }
1328 int quux(int xyzzy) {
1329 return xyzzy+1;
1330 }
1331 EOT
1332 cat >$CONFTMP/test-dynamic.c <<EOT
1333 int foo(int bar) {
1334 return quux(bar)*2;
1335 }
1336 EOT
1337 if run $CC_SHARED $CC_FLAGS $CC_LIBS $CONFTMP/test-dynamic.c -o $CONFTMP/test.so \
1338 && run $CC $CC_FLAGS $CC_DYN_LFLAGS $CC_LIBS $CC_DYN_LIBS $CONFTMP/test-dynamic2.c $CONFTMP/test.so -o $CONFTMP/test
1339 then
1340 a=`$CONFTMP/test 1`
1341 log "symbol resolution test: $CONFTMP/test 1 => $a"
1342 if [ "x$a" = "x4" ] ; then
1343 log "symbol resolution test: succeeded => using dynamic modules (dlfcn)"
1344 else
1345 log "symbol resolution test: bad output (expected 4)"
1346 OK=
1347 fi
1348 else
1349 log "symbol resolution test: dynamic compile failed"
1350 OK=
1351 fi
1352 fi
1353 fi # dlfcn test
1354 if [ "$OK" ] ; then
1355 log "checking for underscores in symbols"
1356 cat >$CONFTMP/test-dynamic2.c <<EOT
1357 #include <stdio.h>
1358 #include <dlfcn.h>
1359 int main(int argc, char **argv) {
1360 void *handle = dlopen(NULL, 0);
1361 printf("%d%d\n", dlsym(handle,"foo")!=NULL ? 1 : 0,
1362 dlsym(handle,"_foo")!=NULL ? 1 : 0);
1363 return 0;
1364 }
1365 int quux(int x) {return x;}
1366 EOT
1367 if run $CC $CC_FLAGS $CC_DYN_LFLAGS $CC_LIBS $CC_DYN_LIBS $CONFTMP/test-dynamic2.c $CONFTMP/test.so -o $CONFTMP/test
1368 then
1369 a=`$CONFTMP/test`
1370 log "underscore test: $CONFTMP/test => $a"
1371 with_underscore=`echo "$a" | cut -c2`
1372 without_underscore=`echo "$a" | cut -c1`
1373 if [ "x$with_underscore" = "x1" ] ; then
1374 log "underscore test: succeeded with preceding underscore"
1375 SYMS_NEED_UNDERSCORES=1
1376 elif [ "x$without_underscore" = "x1" ] ; then
1377 log "underscore test: succeeded with no preceding underscore"
1378 SYMS_NEED_UNDERSCORES=0
1379 else
1380 log "underscore test: failed?! (bizarre output)"
1381 OK=
1382 fi
1383 else
1384 log "underscore test: dynamic compile failed"
1385 OK=
1386 fi
1387 fi # underscore test
1388 if [ "$OK" ] ; then
1389 echo "yes."
1390 STATIC_MODULES=0
1391 else
1392 log "static modules selected"
1393 echo "no."
1394 STATIC_MODULES=1
1395 CC_SHARED=
1396 CC_DYN_LFLAGS=
1397 CC_DYN_LIBS=
1398 SYMS_NEED_UNDERSCORES=
1399 fi
1400 fi
1401 fi
1402
1403 # Also check for ranlib, and use it if found.
1404 MODE="check_ranlib "
1405 echo2 "Checking whether ranlib exists... "
1406 if [ "$RANLIB" ] ; then
1407 if [ "x$RANLIB" = xranlib ] ; then
1408 log "cache says yes"
1409 echo "(cached) yes."
1410 else
1411 log "cache says no"
1412 echo "(cached) no."
1413 fi
1414 else
1415 if run echo test >$CONFTMP/testfile ; then : ; else
1416 log "couldn't create temp file!"
1417 echo ""
1418 echo ""
1419 echo "*** WHOA THERE! ***"
1420 echo ""
1421 echo "Unable to create a temporary file!"
1422 echo "Are you out of disk space?"
1423 exit 4
1424 fi
1425 if run ar -rc $CONFTMP/test.a $CONFTMP/testfile ; then
1426 if run ranlib $CONFTMP/test.a ; then
1427 log "ranlib found"
1428 RANLIB=ranlib
1429 echo "yes."
1430 else
1431 log "ranlib not found"
1432 RANLIB='echo >/dev/null'
1433 echo "no."
1434 fi
1435 else # no ar
1436 log "couldn't run ar!"
1437 if [ $STATIC_MODULES = 1 ] ; then
1438 echo ""
1439 cat <<EOT
1440
1441 *** WHOA THERE! ***
1442
1443 The \`ar' program could not be executed. This program is needed to
1444 compile Services, and is installed on most systems by default; make
1445 certain it is in your executable search path (for example, Solaris users
1446 may need to add /usr/ccs/bin to the search path) and re-run this script.
1447
1448 Configuration aborted.
1449
1450 EOT
1451 exit 4
1452 else
1453 log "ar not found, assuming no ranlib"
1454 RANLIB='echo >/dev/null'
1455 echo "no."
1456 cat <<EOT
1457
1458 NOTICE: The \`ar' command was not found on your system. This is not an
1459 immediate problem, but it will prevent you from compiling
1460 Services using static modules. Please check and make certain
1461 your executable search path is correct.
1462
1463 EOT
1464 fi
1465 fi
1466 fi
1467
1468 ###########################################################################
1469
1470 # Look for include files that might or might not be here.
1471 echo "Checking for presence of include files (it's okay if some aren't there):"
1472
1473 MODE="check_stdint "
1474 echo2 " stdint.h... "
1475 if [ "$HAVE_STDINT_H" ] ; then
1476 if [ "$HAVE_STDINT_H" = 1 ] ; then
1477 echo "(cached) present"
1478 log "cache says present"
1479 else
1480 echo "(cached) not present"
1481 log "cache says not present"
1482 fi
1483 else
1484 if test_include stdint.h ; then
1485 echo "present"
1486 else
1487 echo "not present"
1488 fi
1489 fi
1490
1491 MODE="check_strings "
1492 echo2 " strings.h... "
1493 if [ "$HAVE_STRINGS_H" ] ; then
1494 if [ "$HAVE_STRINGS_H" = 1 ] ; then
1495 echo "(cached) present"
1496 log "cache says present"
1497 else
1498 echo "(cached) not present"
1499 log "cache says not present"
1500 fi
1501 else
1502 if test_include strings.h ; then
1503 echo "present"
1504 else
1505 echo "not present"
1506 fi
1507 fi
1508
1509 MODE="check_sysselect "
1510 echo2 " sys/select.h... "
1511 if [ "$HAVE_SYS_SELECT_H" ] ; then
1512 if [ "$HAVE_SYS_SELECT_H" = 1 ] ; then
1513 echo "(cached) present"
1514 log "cache says present"
1515 else
1516 echo "(cached) not present"
1517 log "cache says not present"
1518 fi
1519 else
1520 if test_include sys/select.h ; then
1521 echo "present"
1522 else
1523 echo "not present"
1524 fi
1525 fi
1526
1527 MODE="check_sysproto "
1528 echo2 " sys/sysproto.h... "
1529 if [ "$HAVE_SYS_SYSPROTO_H" ] ; then
1530 if [ "$HAVE_SYS_SYSPROTO_H" = 1 ] ; then
1531 echo "(cached) present"
1532 log "cache says present"
1533 else
1534 echo "(cached) not present"
1535 log "cache says not present"
1536 fi
1537 else
1538 if test_include sys/sysproto.h ; then
1539 echo "present"
1540 else
1541 echo "not present"
1542 fi
1543 fi
1544
1545 ###########################################################################
1546
1547 # See what sizes various types are.
1548
1549 MODE="check_int8 "
1550 echo2 "Looking for an 8-bit integer type... "
1551 if [ "$TYPE_INT8" ] ; then
1552 echo "(cached) $TYPE_INT8"
1553 log "cache supplied $TYPE_INT8"
1554 else
1555 if [ "$HAVE_STDINT_H" = 1 ] ; then
1556 cat >$CONFTMP/test.c <<EOT
1557 #include <stdint.h>
1558 #include <stdio.h>
1559 int main() {
1560 char a;
1561 int8_t b;
1562 printf("%d,%d", sizeof(a), sizeof(b));
1563 return 0;
1564 }
1565 EOT
1566 else
1567 cat >$CONFTMP/test.c <<EOT
1568 #include <stdio.h>
1569 int main() {
1570 char a;
1571 printf("%d,0", sizeof(a));
1572 return 0;
1573 }
1574 EOT
1575 fi
1576 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1577 a="`$CONFTMP/test`"
1578 log "test program output (sizeof(char),sizeof(int8_t)): $a"
1579 b=`echo "$a" | cut -d, -f1`
1580 c=`echo "$a" | cut -d, -f2`
1581 if [ ! "$a" ] ; then
1582 echo "test program failed! Assuming char."
1583 log "assuming char"
1584 TYPE_INT8=char
1585 elif [ "$c" = 1 ] ; then
1586 echo int8_t
1587 log "int8_t is 8 bits"
1588 TYPE_INT8=int8_t
1589 elif [ "$b" = 1 ] ; then
1590 echo char
1591 log "char is 8 bits"
1592 TYPE_INT8=char
1593 else
1594 cat >$CONFTMP/test.c <<EOT
1595 #include <stdio.h>
1596 int main() {
1597 byte a;
1598 printf("%d", sizeof(a));
1599 return 0;
1600 }
1601 EOT
1602 if run $CC $CC_FLAGS $CONFTMP/tset.c $CC_LIBS -o $CONFTMP/test ; then
1603 a="`$CONFTMP/test`"
1604 log "test program 2 output (sizeof(byte)): $a"
1605 if [ "$a" = 1 ] ; then
1606 echo byte
1607 log "byte is 8 bits"
1608 TYPE_INT8=byte
1609 fi
1610 else
1611 log "couldn't compile test program 2, assuming no byte type"
1612 fi
1613 if [ ! "$TYPE_INT8" ] ; then
1614 echo "none found?!"
1615 cat <<EOF
1616 Services requires an 8-bit integer type. Please check your system
1617 configuration.
1618
1619 Configuration aborted.
1620
1621 EOF
1622 exit 1
1623 fi
1624 fi
1625 else
1626 whoa_there
1627 fi
1628 fi
1629
1630 MODE="check_int16 "
1631 echo2 "Looking for a 16-bit integer type... "
1632 if [ "$TYPE_INT16" ] ; then
1633 echo "(cached) $TYPE_INT16"
1634 log "cache supplied $TYPE_INT16"
1635 else
1636 if [ "$HAVE_STDINT_H" = 1 ] ; then
1637 cat >$CONFTMP/test.c <<EOT
1638 #include <stdint.h>
1639 #include <stdio.h>
1640 int main() {
1641 int a;
1642 short b;
1643 int16_t c;
1644 printf("%d,%d,%d", sizeof(a), sizeof(b), sizeof(c));
1645 return 0;
1646 }
1647 EOT
1648 else
1649 cat >$CONFTMP/test.c <<EOT
1650 #include <stdio.h>
1651 int main() {
1652 int a;
1653 short b;
1654 printf("%d,%d,0", sizeof(a), sizeof(b));
1655 return 0;
1656 }
1657 EOT
1658 fi
1659 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1660 a="`$CONFTMP/test`"
1661 log "test program output (sizeof(int),sizeof(short),sizeof(int16_t)): $a"
1662 if [ ! "$a" ] ; then
1663 echo "test program failed! Assuming short."
1664 log "assuming short"
1665 TYPE_INT16=short
1666 else
1667 size_int=`echo $a | cut -d, -f1`
1668 size_short=`echo $a | cut -d, -f2`
1669 size_int16_t=`echo $a | cut -d, -f3`
1670 if [ "$size_int16_t" = 2 ] ; then
1671 echo int16_t
1672 log "int16_t is 16 bits"
1673 TYPE_INT16=int16_t
1674 elif [ $size_int = 2 ] ; then
1675 echo int
1676 log "int is 16 bits"
1677 TYPE_INT16=int
1678 elif [ $size_short = 2 ] ; then
1679 echo short
1680 log "short is 16 bits"
1681 TYPE_INT16=short
1682 else
1683 echo "none found?!"
1684 cat <<EOF
1685 Services requires a 16-bit integer type. Please check your system
1686 configuration.
1687
1688 Configuration aborted.
1689
1690 EOF
1691 exit 1
1692 fi
1693 fi
1694 else
1695 whoa_there
1696 fi
1697 fi
1698
1699 MODE="check_int32 "
1700 echo2 "Looking for a 32-bit integer type... "
1701 if [ "$TYPE_INT32" ] ; then
1702 echo "(cached) $TYPE_INT32"
1703 log "cache supplied $TYPE_INT32"
1704 else
1705 if [ "$HAVE_STDINT_H" = 1 ] ; then
1706 cat >$CONFTMP/test.c <<EOT
1707 #include <stdint.h>
1708 #include <stdio.h>
1709 int main() {
1710 int a;
1711 long b;
1712 int32_t c;
1713 printf("%d,%d,%d", sizeof(a), sizeof(b), sizeof(c));
1714 return 0;
1715 }
1716 EOT
1717 else
1718 cat >$CONFTMP/test.c <<EOT
1719 #include <stdio.h>
1720 int main() {
1721 int a;
1722 long b;
1723 printf("%d,%d,0", sizeof(a), sizeof(b));
1724 return 0;
1725 }
1726 EOT
1727 fi
1728 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1729 a="`$CONFTMP/test`"
1730 log "test program output (sizeof(int),sizeof(long),sizeof(int32_t)): $a"
1731 if [ ! "$a" ] ; then
1732 echo "test program failed! Assuming long."
1733 log "assuming long"
1734 TYPE_INT32=long
1735 else
1736 size_int=`echo $a | cut -d, -f1`
1737 size_long=`echo $a | cut -d, -f2`
1738 size_int32_t=`echo $a | cut -d, -f3`
1739 if [ "$size_int32_t" = 4 ] ; then
1740 echo int32_t
1741 log "int32_t is 32 bits"
1742 TYPE_INT32=int32_t
1743 elif [ $size_int = 4 ] ; then
1744 echo int
1745 log "int is 32 bits"
1746 TYPE_INT32=int
1747 elif [ $size_long = 4 ] ; then
1748 echo long
1749 log "long is 32 bits"
1750 TYPE_INT32=long
1751 else
1752 echo "none found?!"
1753 cat <<EOF
1754 Services requires a 32-bit integer type. Please check your system
1755 configuration.
1756
1757 Configuration aborted.
1758
1759 EOF
1760 exit 1
1761 fi
1762 fi
1763 else
1764 whoa_there
1765 fi
1766 fi
1767
1768 MODE="check_int64 "
1769 echo2 "Looking for a 64-bit integer type... "
1770 if [ "$TYPE_INT64" ] ; then
1771 echo "(cached) $TYPE_INT64"
1772 log "cache supplied $TYPE_INT64"
1773 else
1774 ran=0
1775 if [ "$HAVE_STDINT_H" = 1 ] ; then
1776 cat >$CONFTMP/test.c <<EOT
1777 #include <stdint.h>
1778 #include <stdio.h>
1779 int main() {
1780 long a;
1781 long long b;
1782 int64_t c;
1783 printf("%d,%d,%d", sizeof(a), sizeof(b), sizeof(c));
1784 return 0;
1785 }
1786 EOT
1787 else
1788 cat >$CONFTMP/test.c <<EOT
1789 #include <stdio.h>
1790 int main() {
1791 long a;
1792 long long b;
1793 printf("%d,%d,0", sizeof(a), sizeof(b));
1794 return 0;
1795 }
1796 EOT
1797 fi
1798 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1799 ran=1
1800 else
1801 if [ "$HAVE_STDINT_H" = 1 ] ; then
1802 cat >$CONFTMP/test.c <<EOT
1803 #include <stdint.h>
1804 #include <stdio.h>
1805 int main() {
1806 long a;
1807 int64_t c;
1808 printf("%d,0,%d", sizeof(a), sizeof(c));
1809 return 0;
1810 }
1811 EOT
1812 else
1813 cat >$CONFTMP/test.c <<EOT
1814 #include <stdio.h>
1815 int main() {
1816 long a;
1817 printf("%d,0,0", sizeof(a));
1818 return 0;
1819 }
1820 EOT
1821 fi
1822 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1823 ran=1
1824 fi
1825 fi
1826 if test $ran = 1 ; then
1827 a="`$CONFTMP/test`"
1828 log "test program output (sizeof(long),sizeof(long long),sizeof(int64_t)): $a"
1829 if [ ! "$a" ] ; then
1830 echo "test program failed! Assuming long long."
1831 log "assuming long long"
1832 TYPE_INT64="long long"
1833 else
1834 size_long=`echo $a | cut -d, -f1`
1835 size_long_long=`echo $a | cut -d, -f2`
1836 size_int64_t=`echo $a | cut -d, -f3`
1837 if [ "$size_int64_t" = 8 ] ; then
1838 echo int64_t
1839 log "int64_t is 64 bits"
1840 TYPE_INT64=int64_t
1841 elif [ $size_long = 8 ] ; then
1842 echo long
1843 log "long is 64 bits"
1844 TYPE_INT64=long
1845 elif [ $size_long_long = 8 ] ; then
1846 echo "long long"
1847 log "long long is 64 bits"
1848 TYPE_INT64="long long"
1849 else
1850 echo "none found?!"
1851 cat <<EOF
1852 Services requires a 64-bit integer type. Please check your system
1853 configuration.
1854
1855 Configuration aborted.
1856
1857 EOF
1858 exit 1
1859 fi
1860 fi
1861 else
1862 whoa_there
1863 fi
1864 fi
1865
1866 MODE="check_int_size "
1867 echo2 "Checking the size of int... "
1868 if [ "$SIZEOF_INT" ] ; then
1869 echo "(cached) `expr $SIZEOF_INT \* 8` bits"
1870 log "cache supplied `expr $SIZEOF_INT \* 8` bits"
1871 else
1872 cat >$CONFTMP/test.c <<EOT
1873 #include <stdio.h>
1874 int main() {
1875 int a = 0;
1876 printf("%d", sizeof(a));
1877 return 0;
1878 }
1879 EOT
1880 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1881 a="`$CONFTMP/test`"
1882 log "test program output (sizeof(int)): $a"
1883 if [ ! "$a" ] ; then
1884 echo "test program failed! Assuming 16 bits."
1885 log "assuming 16 bits"
1886 SIZEOF_INT=2
1887 else
1888 SIZEOF_INT="$a"
1889 if [ $SIZEOF_INT -lt 2 ] ; then
1890 echo "`expr $SIZEOF_INT \* 8` bits... huh?"
1891 cat <<EOF
1892 \`int' must be at least 16 bits. Please check your compiler
1893 settings.
1894
1895 Configuration aborted.
1896
1897 EOF
1898 exit 1
1899 else
1900 echo `expr $SIZEOF_INT \* 8` bits
1901 log "`expr $SIZEOF_INT \* 8` bits"
1902 fi
1903 fi
1904 else
1905 whoa_there
1906 fi
1907 fi
1908
1909 MODE="check_long_size "
1910 echo2 "Checking the size of long... "
1911 if [ "$SIZEOF_LONG" ] ; then
1912 echo "(cached) `expr $SIZEOF_LONG \* 8` bits"
1913 log "cache supplied `expr $SIZEOF_LONG \* 8` bits"
1914 else
1915 cat >$CONFTMP/test.c <<EOT
1916 #include <stdio.h>
1917 int main() {
1918 long a = 0;
1919 printf("%d", sizeof(a));
1920 return 0;
1921 }
1922 EOT
1923 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1924 a="`$CONFTMP/test`"
1925 log "test program output (sizeof(long)): $a"
1926 if [ ! "$a" ] ; then
1927 echo "test program failed! Assuming 32 bits."
1928 log "assuming 32 bits"
1929 SIZEOF_LONG=4
1930 else
1931 SIZEOF_LONG="$a"
1932 if [ $SIZEOF_LONG -lt 4 ] ; then
1933 echo "`expr $SIZEOF_LONG \* 8` bits... huh?"
1934 cat <<EOF
1935 \`long' must be at least 32 bits. Please check your compiler
1936 settings.
1937
1938 Configuration aborted.
1939
1940 EOF
1941 exit 1
1942 else
1943 echo `expr $SIZEOF_LONG \* 8` bits
1944 log "`expr $SIZEOF_LONG \* 8` bits"
1945 fi
1946 fi
1947 else
1948 whoa_there
1949 fi
1950 fi
1951
1952 MODE="check_ptr_size "
1953 echo2 "Checking the size of pointers... "
1954 if [ "$SIZEOF_PTR" ] ; then
1955 echo "(cached) `expr $SIZEOF_PTR \* 8` bits"
1956 log "cache supplied `expr $SIZEOF_PTR \* 8` bits"
1957 else
1958 cat >$CONFTMP/test.c <<EOT
1959 #include <stdio.h>
1960 int main() {
1961 void *a = 0;
1962 printf("%d", sizeof(a));
1963 return 0;
1964 }
1965 EOT
1966 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
1967 a="`$CONFTMP/test`"
1968 log "test program output (sizeof(void *)): $a"
1969 if [ ! "$a" ] ; then
1970 echo "test program failed! Assuming 32 bits."
1971 log "assuming 32 bits"
1972 SIZEOF_PTR=4
1973 else
1974 SIZEOF_PTR="$a"
1975 if [ $SIZEOF_PTR -lt $SIZEOF_INT ] ; then
1976 echo "`expr $SIZEOF_PTR \* 8` bits... oops!"
1977 cat <<EOF
1978 Your compiler has a pointer type smaller than its integer type!
1979 This may cause problems compiling or running Services. Please check
1980 your compiler settings.
1981
1982 Configuration aborted.
1983
1984 EOF
1985 exit 1
1986 else
1987 echo `expr $SIZEOF_PTR \* 8` bits
1988 log "`expr $SIZEOF_PTR \* 8` bits"
1989 fi
1990 fi
1991 else
1992 whoa_there
1993 fi
1994 fi
1995
1996 MODE="check_time_t "
1997 echo2 "Checking the size of time_t... "
1998 if [ "$SIZEOF_TIME_T" -a "$MAX_TIME_T" ] ; then
1999 echo "(cached) `expr $SIZEOF_TIME_T \* 8` bits"
2000 log "cache supplied `expr $SIZEOF_TIME_T \* 8` bits, max $MAX_TIME_T"
2001 else
2002 cat >$CONFTMP/test.c <<EOT
2003 #include <stdio.h>
2004 #include <time.h>
2005 int main() {
2006 time_t a = 0;
2007 printf("%d ", sizeof(a));
2008 if (a-1 > 0)
2009 printf("(~(time_t)0)");
2010 else
2011 printf("(((time_t)1<<(sizeof(time_t)*8-2))+(((time_t)1<<(sizeof(time_t)*8-2))-1))");
2012 return 0;
2013 }
2014 EOT
2015 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
2016 a="`$CONFTMP/test`"
2017 log "test program output (sizeof(time_t) MAX_TIME_T): $a"
2018 if [ ! "$a" ] ; then
2019 echo "test program failed! Assuming 32 bits."
2020 log "assuming 32 bits"
2021 SIZEOF_TIME_T=4
2022 else
2023 SIZEOF_TIME_T=`echo "$a" | cut -d\ -f1`
2024 MAX_TIME_T=`echo "$a" | cut -d\ -f2`
2025 if [ $SIZEOF_TIME_T = 4 ] ; then
2026 echo 32 bits
2027 log "32 bits"
2028 elif [ $SIZEOF_TIME_T = 8 ] ; then
2029 echo "64 bits (nifty!)"
2030 log "64 bits"
2031 elif [ $SIZEOF_TIME_T -gt 4 ] ; then
2032 echo "`expr $SIZEOF_TIME_T \* 8` bits... huh?"
2033 echo " If you experience any problems compiling or running Services, please"
2034 echo " report this."
2035 log "`expr $SIZEOF_TIME_T \* 8` bits"
2036 else
2037 echo "`expr $SIZEOF_TIME_T \* 8` bits... huh?"
2038 cat <<EOT
2039 Services requires a \`time_t' of at least 32 bits. Please check your
2040 system configuration.
2041
2042 Configuration aborted.
2043
2044 EOT
2045 log "`expr $SIZEOF_TIME_T \* 8` bits -- too small, aborting"
2046 exit 1
2047 fi
2048 fi
2049 else
2050 whoa_there
2051 fi
2052 fi
2053
2054 MODE="check_gid_t "
2055 echo2 "Checking the size of gid_t... "
2056 if [ "$SIZEOF_GID_T" != bonkle ] ; then
2057 if [ "$SIZEOF_GID_T" ] ; then
2058 echo "(cached) `expr $SIZEOF_GID_T \* 8` bits"
2059 log "cache supplied `expr $SIZEOF_GID_T \* 8` bits"
2060 else
2061 echo "(cached) no gid_t"
2062 log "cache said no gid_t"
2063 fi
2064 else
2065 cat >$CONFTMP/test.c <<EOT
2066 #include <stdio.h>
2067 #include <sys/types.h>
2068 int main() {
2069 gid_t a;
2070 printf("%d", sizeof(a));
2071 return 0;
2072 }
2073 EOT
2074 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
2075 a="`$CONFTMP/test`"
2076 log "test program output (sizeof(gid_t)): $a"
2077 if [ ! "$a" ] ; then
2078 echo "test program failed! Assuming 16 bits."
2079 log "assuming 16 bits"
2080 SIZEOF_GID_T=2
2081 else
2082 SIZEOF_GID_T=$a
2083 if [ $SIZEOF_GID_T = 4 ] ; then
2084 echo 32 bits
2085 log "32 bits"
2086 elif [ $SIZEOF_GID_T = 2 ] ; then
2087 echo "16 bits"
2088 log "16 bits"
2089 else
2090 echo "`expr $SIZEOF_GID_T \* 8` bits... huh?"
2091 echo " If you experience any problems compiling or running Services, please"
2092 echo " report this."
2093 log "`expr $SIZEOF_GID_T \* 8` bits"
2094 fi
2095 fi
2096 else
2097 echo "no gid_t found."
2098 log "couldn't compile test program, assuming no gid_t"
2099 SIZEOF_GID_T=
2100 HAVE_SETREGID=0
2101 fi
2102 fi
2103
2104 MODE="check_socklen_t "
2105 echo2 "Checking for socklen_t... "
2106 if [ "$HAVE_SOCKLEN_T" ] ; then
2107 if [ $HAVE_SOCKLEN_T = 1 ] ; then
2108 echo "(cached) present."
2109 log "cache said present"
2110 else
2111 echo "(cached) not present."
2112 log "cache said not present"
2113 fi
2114 else
2115 cat >$CONFTMP/test.c <<EOT
2116 #include <unistd.h>
2117 #include <sys/socket.h>
2118 int main() {
2119 socklen_t a;
2120 return 0;
2121 }
2122 EOT
2123 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
2124 log "socklen_t found"
2125 echo "present."
2126 HAVE_SOCKLEN_T=1
2127 else
2128 log "socklen_t not found"
2129 echo "not present."
2130 HAVE_SOCKLEN_T=0
2131 fi
2132 fi
2133
2134 ###########################################################################
2135
2136 # AIX workaround.
2137
2138 MODE="check_aix_intNN "
2139 echo2 "Seeing if your system defines int16/int32... "
2140 res="`run egrep int16\|int32 /usr/include/sys/systypes.h`"
2141 if [ "$res" ] ; then
2142 echo "found."
2143 echo " (This is bad, but we can work around it.)"
2144 log "int16/int32 types found, enabling workaround"
2145 INTTYPE_WORKAROUND=1
2146 else
2147 echo "not found (this is good)."
2148 log "int16/int32 types not found"
2149 INTTYPE_WORKAROUND=0
2150 fi
2151
2152 ###########################################################################
2153
2154 # Look for missing/broken built-in routines, and similar compatibility
2155 # stuff.
2156
2157 MODE="check_strerror "
2158 if [ "$USE_LOCAL_FUNCS" ] ; then
2159 log "not checking (-use-local-funcs)"
2160 echo "Not checking for presence of strerror (-use-local-funcs specified)."
2161 HAVE_STRERROR=0
2162 HAVE_SYS_ERRLIST=0
2163 else
2164 echo2 "How to complain when something goes wrong... "
2165 if [ "$HAVE_STRERROR" ] ; then
2166 if [ "$HAVE_STRERROR" = 1 ] ; then
2167 echo "(cached) strerror()."
2168 log "cache supplied strerror()"
2169 elif [ "$HAVE_SYS_ERRLIST" = 1 ] ; then
2170 echo "(cached) sys_errlist."
2171 log "cache supplied sys_errlist"
2172 else
2173 HAVE_SYS_ERRLIST=0 # just in case... you never know.
2174 echo "(cached) pseudo sys_errlist."
2175 log "cache supplied pseudo sys_errlist"
2176 fi
2177 else
2178 cat >$CONFTMP/test.c <<EOT
2179 int main() {
2180 extern void strerror(void);
2181 strerror();
2182 }
2183 EOT
2184 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
2185 HAVE_STRERROR=1
2186 echo "ah, strerror() is here."
2187 log "using strerror()"
2188 else
2189 HAVE_STRERROR=0
2190 echo "no strerror()."
2191 cat >$CONFTMP/test.c <<EOT
2192 int main() {
2193 extern char *sys_errlist[];
2194 char *s;
2195 s = sys_errlist[0];
2196 }
2197 EOT
2198 log "trying sys_errlist..."
2199 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
2200 HAVE_SYS_ERRLIST=1
2201 echo " But you have sys_errlist, which will do nicely."
2202 log "using sys_errlist"
2203 else
2204 HAVE_SYS_ERRLIST=0
2205 echo " You don't have sys_errlist either, so we'll have to make do."
2206 log "using pseudo sys_errlist"
2207 fi
2208 fi
2209 fi
2210 fi # -use-local-funcs
2211
2212
2213 MODE="check_compat "
2214
2215 if [ "$USE_LOCAL_FUNCS" ] ; then
2216 echo "Enabling compatibility functions: hstrerror strtok str[n]icmp strdup str[c]spn strsignal"
2217 HAVE_HSTRERROR=0
2218 HAVE_STRTOK=0
2219 HAVE_STRICMP=0
2220 HAVE_STRCASECMP=0
2221 HAVE_STRDUP=0
2222 HAVE_STRSPN=0
2223 HAVE_STRSIGNAL=0
2224 fi
2225
2226 echo2 "Looking for other functions we want that you don't have... "
2227
2228 if [ "$MISSING" != bonkle -a ! "$USE_LOCAL_FUNCS" ] ; then
2229 if [ ! "$MISSING" ] ; then
2230 echo "(cached) none"
2231 log "cache supplied: (none)"
2232 else
2233 echo "(cached)$MISSING"
2234 log "cache supplied:$MISSING"
2235 fi
2236 else
2237
2238 if [ "$USE_LOCAL_FUNCS" ] ; then
2239
2240 MISSING=" hstrerror strtok str[n]icmp strdup str[c]spn strsignal"
2241
2242 else
2243
2244 MISSING=
2245
2246 MODE="check_hstrerror "
2247 TEST="(void) hstrerror(1); return 0;"
2248 if test_function "const char *" hstrerror "(int)" ; then : ; else
2249 MISSING="$MISSING hstrerror"
2250 echo2 "hstrerror "
2251 fi
2252
2253 # Common failings with strtok() implementations:
2254 # - strtok(NULL, ...) crashes after a NULL is returned
2255 # - strtok(NULL, " ") returns NULL but a subsequent
2256 # strtok(NULL, "") doesn't
2257 MODE="check_strtok "
2258 TEST=' char buf1[1];
2259 char buf2[] = "1 2 3";
2260 char buf3[] = "4 5 6";
2261 char buf4[] = " ";
2262 buf1[0] = 0;
2263 buf3[0] = 0;
2264 if (strtok(buf1, " ") != (char *)0)
2265 return 1;
2266 if (strtok((char *)0, " ") != (char *)0)
2267 return 2;
2268 if (strtok(buf2, " ") != buf2)
2269 return 3;
2270 if (strtok((char *)0, " ") != buf2+2)
2271 return 4;
2272 if (strtok(buf3, " ") != (char *)0)
2273 return 5;
2274 if (strtok((char *)0, " ") != (char *)0)
2275 return 6;
2276 if (strtok(buf4, " ") != (char *)0)
2277 return 7;
2278 if (strtok((char *)0, "") != (char *)0)
2279 return 8;
2280 return 0;'
2281 if test_function "char *" strtok "(char *, const char *)" ; then : ; else
2282 MISSING="$MISSING strtok"
2283 echo2 "strtok "
2284 fi
2285
2286 # stricmp() (STRing case-Insensitive CoMPare) is another name, used
2287 # by at least the Amiga DICE C compiler, for what POSIX calls
2288 # strcasecmp(). I prefer the former because the latter (1) is
2289 # unnecessarily long and (2) implies a case-sensitive compare when
2290 # it's really a case-INsensitive compare. If this system doesn't
2291 # have stricmp() but does have strcasecmp(), we use a #define in
2292 # defs.h to rename the latter to the former.
2293 MODE="check_stricmp "
2294 TEST='extern int strnicmp(const char *, const char *, int); return stricmp("ABC","abc")==0 && strnicmp("ABC","abd",2)==0 ? 0 : 1;'
2295 if test_function int stricmp "(const char *, const char *)" ; then
2296 HAVE_STRCASECMP=0 # doesn't really matter
2297 else
2298 TEST='extern int strncasecmp(const char *, const char *, int); return strcasecmp("ABC","abc")==0 && strncasecmp("ABC","abd",2)==0 ? 0 : 1;'
2299 if test_function int strcasecmp "(const char *, const char *)" ; then : ; else
2300 MISSING="$MISSING str[n]icmp"
2301 echo2 "str[n]icmp "
2302 fi
2303 fi
2304
2305 MODE="check_strdup "
2306 TEST=' char *s, *t;
2307 s = "ABC";
2308 t = strdup(s);'"
2309 return (t != (char *)0 && t[0]=='A' && t[1]=='B' && t[2]=='C' && t[3]==0) ? 0 : 1;"
2310 if test_function "char *" strdup "(const char *)" ; then : ; else
2311 MISSING="$MISSING strdup"
2312 echo2 "strdup "
2313 fi
2314
2315 MODE="check_strspn "
2316 TEST=' extern int strcspn(const char *, const char *);
2317 return (strspn("ABCBA","BA")==2 && strspn("123","123")==3
2318 && strcspn("ABCBA","C")==2 && strcspn("123","4")==3) ? 0 : 1;'
2319 if test_function int strspn "(const char *, const char *)" ; then : ; else
2320 MISSING="$MISSING str[c]spn"
2321 echo2 "str[c]spn "
2322 fi
2323
2324 MODE="check_strsignal "
2325 TEST="(void) strsignal(1); return 0;"
2326 if test_function "char *" strsignal "(int)" ; then : ; else
2327 MISSING="$MISSING strsignal"
2328 echo2 "strsignal "
2329 fi
2330
2331 fi # -use-local-funcs
2332
2333 MODE="check_gettimeofday "
2334 TEST="char buf[256]; (void) gettimeofday((void *)buf, (void *)buf); return 0;"
2335 if test_function "char *" gettimeofday "(void *, void *)" ; then : ; else
2336 MISSING="$MISSING gettimeofday"
2337 echo2 "gettimeofday "
2338 fi
2339
2340 MODE="check_setgrent "
2341 if [ "$SIZEOF_GID_T" ] ; then
2342 TEST="(void) setgrent(); return 0;"
2343 if test_function int setgrent "(void)" ; then : ; else
2344 MISSING="$MISSING setgrent"
2345 echo2 "setgrent "
2346 fi
2347 else
2348 log "skipped (no gid_t)"
2349 HAVE_SETGRENT=0
2350 fi
2351
2352 MODE="check_setregid "
2353 if [ "$SIZEOF_GID_T" ] ; then
2354 TEST="(void) setregid(-1,-1); return 0;"
2355 if test_function int setregid "(int,int)" ; then : ; else
2356 MISSING="$MISSING setregid"
2357 echo2 "setregid "
2358 fi
2359 else
2360 log "skipped (no gid_t)"
2361 HAVE_SETREGID=0
2362 fi
2363
2364 MODE="check_umask "
2365 TEST="(void) umask(1); return 0;"
2366 if test_function int umask "(int)" ; then : ; else
2367 MISSING="$MISSING umask"
2368 echo2 "umask "
2369 fi
2370
2371 MODE="check_fork "
2372 TEST="(void) fork(); return 0;"
2373 if test_function int fork "(void)" ; then : ; else
2374 MISSING="$MISSING fork"
2375 echo2 "fork "
2376 fi
2377
2378 MODE="check_gethostbyname"
2379 TEST='(void) gethostbyname("localhost"); return 0;'
2380 if test_function "struct hostent *" gethostbyname "(const char *)" ; then : ; else
2381 MISSING="$MISSING gethostbyname"
2382 echo2 "gethostbyname "
2383 fi
2384
2385 MODE="check_getsetrlimit "
2386 cat >$CONFTMP/test.c <<EOT
2387 int main() {
2388 extern void getrlimit(), setrlimit();
2389 getrlimit();
2390 setrlimit();
2391 }
2392 EOT
2393 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then
2394 log "found getrlimit/setrlimit"
2395 HAVE_GETSETRLIMIT=1
2396 else
2397 log "didn't find getrlimit/setrlimit"
2398 HAVE_GETSETRLIMIT=0
2399 MISSING="$MISSING get/setrlimit"
2400 echo2 "get/setrlimit "
2401 fi
2402
2403 MODE="check_crypt "
2404 TEST="(void) crypt(\"a\",\"bb\"); return 0;"
2405 if test_function "char *" crypt "(char *, char *)" ; then : ; else
2406 MISSING="$MISSING crypt"
2407 echo2 "crypt "
2408 fi
2409
2410 echo ""
2411 fi
2412
2413 if [ "$MISSING" -a "$MISSING" != " gethostbyname" ] ; then
2414 echo " Services will use its own versions of the functions listed above."
2415 fi
2416
2417 if [ "$HAVE_GETHOSTBYNAME" = 0 ] ; then
2418 cat <<EOT
2419
2420 NOTICE: Your system does not seem to have the gethostbyname() function.
2421 This function is used to translate hostnames into IP addresses.
2422 Since you don't have it (or we can't find it), you will need to
2423 use IP addresses instead of hostnames when setting server addresses
2424 in the configuration files (ircservices.conf and modules.conf).
2425
2426 EOT
2427 fi
2428
2429 ###########################################################################
2430
2431 MODE="check_install "
2432 echo2 "Checking how to install files... "
2433
2434 if [ "$INSTALL" ] ; then
2435 if [ "`echo $INSTALL | cut -c1`" = "$" ] ; then
2436 echo '(cached) using our own "install".'
2437 log "cache says use our own"
2438 else
2439 echo '(cached) this system'\''s "install" works.'
2440 log "cache says use regular "\`"install'"
2441 fi
2442 else
2443 cat >$CONFTMP/test.c <<EOT
2444 int main() { return 0; }
2445 EOT
2446 if run $CC $CC_FLAGS $CONFTMP/test.c $CC_LIBS -o $CONFTMP/test ; then : ; else
2447 whoa_there
2448 fi
2449 if run cp -p $CONFTMP/test$EXE_SUFFIX $CONFTMP/test3$EXE_SUFFIX ; then : ; else
2450 echo ""
2451 echo ""
2452 echo "*** WHOA THERE! ***"
2453 echo ""
2454 echo "A simple "\`"cp -p' failed!"
2455 echo "Are you out of disk space?"
2456 exit 4
2457 fi
2458
2459 if run install -m 500 $CONFTMP/test$EXE_SUFFIX $CONFTMP/test2$EXE_SUFFIX && test -f $CONFTMP/test$EXE_SUFFIX && run cmp $CONFTMP/test$EXE_SUFFIX $CONFTMP/test2$EXE_SUFFIX ; then
2460 echo 'looks like "install" will work.'
2461 INSTALL="install"
2462 elif run cp -p $CONFTMP/test3$EXE_SUFFIX $CONFTMP/test$EXE_SUFFIX ; run install -c -m 500 $CONFTMP/test$EXE_SUFFIX $CONFTMP/test2$EXE_SUFFIX && test -f $CONFTMP/test$EXE_SUFFIX && run cmp $CONFTMP/test$EXE_SUFFIX $CONFTMP/test2$EXE_SUFFIX ; then
2463 echo 'looks like "install -c" will work.'
2464 INSTALL="install -c"
2465 elif run cp -p $CONFTMP/test3$EXE_SUFFIX $CONFTMP/test$EXE_SUFFIX ; run ginstall -m 500 $CONFTMP/test$EXE_SUFFIX $CONFTMP/test2$EXE_SUFFIX && test -f $CONFTMP/test$EXE_SUFFIX && run cmp $CONFTMP/test$EXE_SUFFIX $CONFTMP/test2$EXE_SUFFIX ; then
2466 echo 'looks like "ginstall" will work.'
2467 INSTALL="ginstall"
2468 else
2469 echo \"install\"" doesn't seem to work."
2470 echo " But we can still use cp and friends, so we'll roll our own "\"install\".
2471 INSTALL='$(TOPDIR)/install-script'
2472 fi
2473 log "using: $INSTALL"
2474 fi
2475
2476 ###########################################################################
2477
2478 MODE="check_install-d "
2479
2480 if [ "$INSTALL" = '$(TOPDIR)/install-script' ] ; then
2481 MKDIR='$(INSTALL) -d'
2482 else
2483 tmp=`echo $INSTALL | cut -d\ -f1`
2484 echo2 "Seeing if \"$tmp\" will create directories... "
2485 if [ "$MKDIR" ] ; then
2486 if [ "$MKDIR" = '$(TOPDIR)/install-script' ] ; then
2487 echo "(cached) no"
2488 log "cache says no"
2489 else
2490 echo "(cached) yes"
2491 log "cache says yes"
2492 fi
2493 else
2494 MKDIR=$tmp
2495 log "trying $MKDIR"
2496 if run $MKDIR -d -m 700 $CONFTMP/testdir && test -d $CONFTMP/testdir ; then
2497 echo "OK."
2498 log "successful"
2499 else
2500 echo "nope, using workaround."
2501 log "failed"
2502 MKDIR='$(TOPDIR)/install-script'
2503 fi
2504 fi
2505 fi
2506
2507 ###########################################################################
2508
2509 MODE="check_copy_recurse "
2510 echo2 "Checking how to copy directories... "
2511
2512 if [ "$CP_ALL" ] ; then
2513 echo "(cached) $CP_ALL"
2514 log "cache supplied $CP_ALL"
2515 else
2516 sysname=`/bin/uname -s 2>&1`
2517 log "sysname: $sysname"
2518 case $sysname in
2519 *Linux) CP_ALL="/bin/cp -dpr";
2520 log "guessing: cp -dpr";;
2521 CYGWIN) CP_ALL="/bin/cp -dpr";
2522 log "guessing: cp -dpr";;
2523 *) CP_ALL="/bin/cp -pr";
2524 log "guessing: cp -pr";;
2525 esac
2526 run rm -rf $CONFTMP/test*
2527 run echo test >$CONFTMP/test
2528 run cp $CONFTMP/test $CONFTMP/test2
2529 if run /bin/mkdir $CONFTMP/testA && run /bin/mkdir $CONFTMP/testB && run /bin/mv $CONFTMP/test2 $CONFTMP/testA ; then
2530 :
2531 else
2532 echo ""
2533 echo ""
2534 echo "*** WHOA THERE! ***"
2535 echo ""
2536 echo "A few simple mkdir's and mv's failed!"
2537 echo "Are you out of disk space?"
2538 exit 4
2539 fi
2540 if run $CP_ALL $CONFTMP/testA $CONFTMP/testB/testC && run cmp $CONFTMP/testA/test2 $CONFTMP/testB/testC/test2 ; then
2541 echo "$CP_ALL"
2542 log \`"$CP_ALL' works"
2543 else
2544 log \`"$CP_ALL' doesn't work"
2545 run /bin/rm -rf $CONFTMP/testB/*
2546 if run sh -c '/bin/tar Ccf $CONFTMP/testA - . | /bin/tar Cxf $CONFTMP/testB -'
2547 then
2548 echo "tar (yuck)"
2549 CP_ALL='$(TOPDIR)/cp-recursive -t'
2550 log "using tar"
2551 else
2552 log "tar failed(!)"
2553 echo ""
2554 echo " Neither cp nor tar work! I give up."
2555 exit 2
2556 fi
2557 fi
2558 fi
2559
2560 ###########################################################################
2561
2562 # Create files.
2563
2564 echo2 "Creating config.h... "
2565 rm -f config.h.new
2566 cat >config.h.new <<EOT
2567 /*
2568 * This file is generated automatically by "configure". Any changes made
2569 * to it will be erased next time "configure" is run.
2570 */
2571
2572 #define PROGRAM "$PROGRAM"
2573 #define SERVICES_BIN "$BINDEST/$PROGRAM"
2574 #define SERVICES_DIR "$DATDEST"
2575
2576 #define GCC3_HACK $NEED_GCC3_HACK
2577 #define HASH_SORTED $SORTED_LISTS
2578 #define CLEAN_COMPILE $CLEAN_COMPILE
2579 #define DUMPCORE $DUMPCORE
2580 #ifndef CONVERT_DB
2581 # define MEMCHECKS $MEMCHECKS
2582 # define SHOWALLOCS $SHOWALLOCS
2583 #endif
2584
2585 #define STATIC_MODULES $STATIC_MODULES
2586 EOT
2587 if [ "$SYMS_NEED_UNDERSCORES" ] ; then cat >>config.h.new <<EOT ; fi
2588 #define SYMS_NEED_UNDERSCORES $SYMS_NEED_UNDERSCORES
2589 EOT
2590 cat >>config.h.new <<EOT
2591
2592 #define HAVE_STDINT_H $HAVE_STDINT_H
2593 #define HAVE_STRINGS_H $HAVE_STRINGS_H
2594 #define HAVE_SYS_SELECT_H $HAVE_SYS_SELECT_H
2595 #define HAVE_SYS_SYSPROTO_H $HAVE_SYS_SYSPROTO_H
2596
2597 EOT
2598 if [ "$TYPE_INT8" = int8_t ] ; then
2599 cat >>config.h.new <<EOT
2600 #define int8 int8_t
2601 #define uint8 uint8_t
2602 EOT
2603 else
2604 cat >>config.h.new <<EOT
2605 typedef signed $TYPE_INT8 int8;
2606 typedef unsigned $TYPE_INT8 uint8;
2607 EOT
2608 fi
2609 if [ "$TYPE_INT16" = int16_t ] ; then
2610 cat >>config.h.new <<EOT
2611 #define int16 int16_t
2612 #define uint16 uint16_t
2613 EOT
2614 else
2615 cat >>config.h.new <<EOT
2616 typedef signed $TYPE_INT16 int16;
2617 typedef unsigned $TYPE_INT16 uint16;
2618 EOT
2619 fi
2620 if [ "$TYPE_INT32" = int32_t ] ; then
2621 cat >>config.h.new <<EOT
2622 #define int32 int32_t
2623 #define uint32 uint32_t
2624 EOT
2625 else
2626 cat >>config.h.new <<EOT
2627 typedef signed $TYPE_INT32 int32;
2628 typedef unsigned $TYPE_INT32 uint32;
2629 EOT
2630 fi
2631 if [ "$TYPE_INT64" = int64_t ] ; then
2632 cat >>config.h.new <<EOT
2633 #define int64 int64_t
2634 #define uint64 uint64_t
2635 EOT
2636 else
2637 cat >>config.h.new <<EOT
2638 typedef signed $TYPE_INT64 int64;
2639 typedef unsigned $TYPE_INT64 uint64;
2640 EOT
2641 fi
2642 cat >>config.h.new <<EOT
2643
2644 #define SIZEOF_INT $SIZEOF_INT
2645 #define SIZEOF_LONG $SIZEOF_LONG
2646 #define SIZEOF_PTR $SIZEOF_PTR
2647 #define SIZEOF_TIME_T $SIZEOF_TIME_T
2648 #define MAX_TIME_T $MAX_TIME_T
2649 EOT
2650 if [ "$SIZEOF_GID_T" ] ; then cat >>config.h.new <<EOT ; fi
2651 #define SIZEOF_GID_T $SIZEOF_GID_T
2652 EOT
2653 cat >>config.h.new <<EOT
2654 #define HAVE_SOCKLEN_T $HAVE_SOCKLEN_T
2655
2656 #define HAVE_STRERROR $HAVE_STRERROR
2657 #define HAVE_SYS_ERRLIST $HAVE_SYS_ERRLIST
2658 #define HAVE_HSTRERROR $HAVE_HSTRERROR
2659 #define HAVE_STRTOK $HAVE_STRTOK
2660 #define HAVE_STRICMP $HAVE_STRICMP
2661 #define HAVE_STRCASECMP $HAVE_STRCASECMP
2662 #define HAVE_STRDUP $HAVE_STRDUP
2663 #define HAVE_STRSPN $HAVE_STRSPN
2664 #define HAVE_STRSIGNAL $HAVE_STRSIGNAL
2665 #define HAVE_GETTIMEOFDAY $HAVE_GETTIMEOFDAY
2666 #define HAVE_SETGRENT $HAVE_SETGRENT
2667 #define HAVE_SETREGID $HAVE_SETREGID
2668 #define HAVE_UMASK $HAVE_UMASK
2669 #define HAVE_FORK $HAVE_FORK
2670 #define HAVE_GETHOSTBYNAME $HAVE_GETHOSTBYNAME
2671 #define HAVE_GETSETRLIMIT $HAVE_GETSETRLIMIT
2672 #define HAVE_CRYPT $HAVE_CRYPT
2673 EOT
2674
2675 if cmp config.h config.h.new >/dev/null 2>&1 ; then
2676 rm -f config.h.new
2677 echo "done (unchanged)."
2678 else
2679 mv -f config.h.new config.h
2680 echo "done."
2681 fi
2682
2683 ###########################################################################
2684
2685 INSTEXEFLAGS="-m 750"
2686 INSTDATFLAGS="-m 640"
2687 MKDIRFLAGS="-m 750"
2688
2689 echo2 "Creating Makefile.inc... "
2690 rm -f Makefile.inc.new
2691 cat >Makefile.inc.new <<EOT
2692 # This file is generated automatically by "configure". Any changes made
2693 # to it will be erased next time "configure" is run.
2694
2695 CC=$CC
2696 BASE_CFLAGS=$CC_FLAGS
2697 CDEFS=$CDEFS
2698 LFLAGS=$CC_LFLAGS$CC_DYN_LFLAGS
2699 LIBS=$CC_LIBS$CC_DYN_LIBS
2700 EXE_SUFFIX=$EXE_SUFFIX
2701
2702 EOT
2703 if [ $STATIC_MODULES = 1 ] ; then
2704 cat >>Makefile.inc.new <<EOT
2705 STATIC_MODULES=1
2706 EOT
2707 else
2708 cat >>Makefile.inc.new <<EOT
2709 CC_SHARED=$CC_SHARED
2710 EOT
2711 fi
2712
2713 cat >>Makefile.inc.new <<EOT
2714 RANLIB=$RANLIB
2715
2716 PROGRAM=$PROGRAM
2717 BINDEST=$BINDEST
2718 DATDEST=$DATDEST
2719
2720 TEST_NT=$TEST_NT
2721 INSTALL_EXE=$INSTALL $INSTEXEFLAGS
2722 INSTALL_DAT=$INSTALL $INSTDATFLAGS
2723 MKDIR=$MKDIR -d $MKDIRFLAGS
2724 CP_ALL=$CP_ALL
2725 EOT
2726
2727 if cmp Makefile.inc Makefile.inc.new >/dev/null 2>&1 ; then
2728 rm -f Makefile.inc.new
2729 echo "done (unchanged)."
2730 else
2731 mv -f Makefile.inc.new Makefile.inc
2732 echo "done."
2733 fi
2734
2735 ###########################################################################
2736
2737 # Save results in cache for next time around.
2738
2739 echo2 "Saving configuration results in config.cache... "
2740
2741 cat <<EOT >config.cache
2742 CONFIG_VERSION=$MY_CONFIG_VERSION
2743
2744 BINDEST='$BINDEST'
2745 DATDEST='$DATDEST'
2746
2747 TEST_NT='$TEST_NT'
2748 INSTALL='$INSTALL'
2749 MKDIR='$MKDIR'
2750 CP_ALL='$CP_ALL'
2751
2752 CC='$CC'
2753 CC_FLAGS='$CC_FLAGS'
2754 CC_LFLAGS='$CC_LFLAGS'
2755 CC_LIBS='$CC_LIBS'
2756
2757 SORTED_LISTS=$SORTED_LISTS
2758 CLEAN_COMPILE=$CLEAN_COMPILE
2759 MEMCHECKS=$MEMCHECKS
2760 SHOWALLOCS=$SHOWALLOCS
2761 DUMPCORE=$DUMPCORE
2762
2763 STATIC_MODULES=$STATIC_MODULES
2764 CC_SHARED='$CC_SHARED'
2765 CC_DYN_LFLAGS='$CC_DYN_LFLAGS'
2766 CC_DYN_LIBS='$CC_DYN_LIBS'
2767 SYMS_NEED_UNDERSCORES=$SYMS_NEED_UNDERSCORES
2768 RANLIB='$RANLIB'
2769
2770 TYPE_INT8=$TYPE_INT8
2771 TYPE_INT16=$TYPE_INT16
2772 TYPE_INT32=$TYPE_INT32
2773 TYPE_INT64=$TYPE_INT64
2774 SIZEOF_INT=$SIZEOF_INT
2775 SIZEOF_LONG=$SIZEOF_LONG
2776 SIZEOF_PTR=$SIZEOF_PTR
2777 SIZEOF_TIME_T=$SIZEOF_TIME_T
2778 MAX_TIME_T='$MAX_TIME_T'
2779 SIZEOF_GID_T=$SIZEOF_GID_T
2780 HAVE_SOCKLEN_T=$HAVE_SOCKLEN_T
2781
2782 HAVE_STDINT_H=$HAVE_STDINT_H
2783 HAVE_STRINGS_H=$HAVE_STRINGS_H
2784 HAVE_SYS_SELECT_H=$HAVE_SYS_SELECT_H
2785 HAVE_SYS_SYSPROTO_H=$HAVE_SYS_SYSPROTO_H
2786
2787 HAVE_STRERROR=$HAVE_STRERROR
2788 HAVE_SYS_ERRLIST=$HAVE_SYS_ERRLIST
2789
2790 HAVE_HSTRERROR=$HAVE_HSTRERROR
2791 HAVE_STRTOK=$HAVE_STRTOK
2792 HAVE_STRICMP=$HAVE_STRICMP
2793 HAVE_STRCASECMP=$HAVE_STRCASECMP
2794 HAVE_STRDUP=$HAVE_STRDUP
2795 HAVE_STRSPN=$HAVE_STRSPN
2796 HAVE_STRSIGNAL=$HAVE_STRSIGNAL
2797 HAVE_GETTIMEOFDAY=$HAVE_GETTIMEOFDAY
2798 HAVE_SETGRENT=$HAVE_SETGRENT
2799 HAVE_SETREGID=$HAVE_SETREGID
2800 HAVE_UMASK=$HAVE_UMASK
2801 HAVE_FORK=$HAVE_FORK
2802 HAVE_GETHOSTBYNAME=$HAVE_GETHOSTBYNAME
2803 HAVE_GETSETRLIMIT=$HAVE_GETSETRLIMIT
2804 HAVE_CRYPT=$HAVE_CRYPT
2805 MISSING='$MISSING'
2806 EOT
2807
2808 echo "done."
2809
2810 ###########################################################################
2811
2812 # Delete the temporary directory we created.
2813
2814 rm -rf $CONFTMP
2815
2816 ###########################################################################
2817
2818 # All done!
2819
2820 cat <<EOT
2821
2822 All done! Now edit defs.h as needed, and run "make" (or possibly "gmake")
2823 to compile Services. See the README and FAQ if you have any problems.
2824
2825 EOT
2826
2827 exit 0
2828
2829 ###########################################################################
2830
2831 # Local variables:
2832 # indent-tabs-mode: nil
2833 # End:
2834 #
2835 # vim: expandtab shiftwidth=4:

Properties

Name Value
svn:executable