-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure
executable file
·1483 lines (1323 loc) · 35.5 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# Configuration script for K9 Services.
#
# This program is free but copyrighted software; see the file COPYING for
# details.
###########################################################################
# Nifty handy functions.
echo2 () {
$ECHO2 "$*$ECHO2SUF" # these are defined later
}
log () {
echo >&3 "$MODE: $*"
}
run () {
echo >&3 "$MODE: >>> $*"
($*) >&3 2>&3 </dev/null
xxres=$?
if [ $xxres -ne 0 ] ; then
echo >&3 "$MODE: *** Command failed (exit code $xxres)"
fi
return $xxres
}
exists () { # because some shells don't have test -e
if [ -f $1 -o -d $1 -o -p $1 -o -c $1 -o -b $1 ] ; then
return 0
else
return 1
fi
}
###########################################################################
# Test for the presence of a given include file or function. If the
# variable TEST is non-empty, it contains code to be placed at the end of
# main(), and should return 0 if everything is okay, else 1.
#
# For includes: Pass the include filename as an argument. The variable
# HAVE_include_name, where "include_name" is the name of the include file
# with letters uppercased and non-alphanumerics replaced by underscores, is
# set to 1 if the include file is present, else 0.
#
# For functions: Pass the return type, function name, and prototype as
# arguments. The variable HAVE_function, where "function" is the name
# of the function with letters uppercased, is set to 1 if the function is
# available, else 0.
#
# For both: The result code of the function will be 0 (true) if the entity
# is present, else 1 (false).
test_include () {
include="$1"
inc2="`echo $include | sed 'y+abcdefghijklmnopqrstuvwxyz/.-+ABCDEFGHIJKLMNOPQRSTUVWXYZ___+'`"
if [ -f "/usr/include/$include" ] ; then
eval "HAVE_${inc2}=1"
log "found $include in /usr/include"
return 0
fi
cat >tmp/test.c <<EOT
#include <$include>
int main() { return 0; }
EOT
if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then
eval "HAVE_${inc2}=1"
log "found $include"
return 0
else
eval "HAVE_${inc2}=0"
log "didn't find $include"
return 1
fi
}
test_function () {
rettype="$1"
func="$2"
proto="$3"
if [ ! "$rettype" -o ! "$func" ] ; then
log "test_function: missing parameter(s)"
return 1
fi
if [ ! "$proto" ] ; then
proto="(...)"
fi
func2=`echo $func | tr '[a-z]' '[A-Z]'`
if [ ! "$TEST" ] ; then
TEST="return 0;"
fi
cat >tmp/test.c <<EOT
int main() {
extern int $func$proto;
$TEST
}
EOT
if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test && (run tmp/test) 2>&1 ; then
eval "HAVE_${func2}=1"
log "found $func"
return 0
else
eval "HAVE_${func2}=0"
log "didn't find $func"
return 1
fi
}
###########################################################################
# If something happens that really shouldn't:
whoa_there () {
echo ""
echo ""
echo "*** WHOA THERE! ***"
echo ""
echo "We suddenly couldn't compile using the C compiler we already tested!"
echo "The command line we used was:"
echo " $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test"
echo "Please try to fix this; if you can't, mail achurch@achurch.org"
echo "with information about your system, the output from this script,"
echo "and the "\`"configure.log' file generated by this script."
echo ""
exit 4
}
###########################################################################
###########################################################################
# Create a temporary directory for our use.
if [ -d tmp ] ; then
rm -rf tmp
fi
if mkdir tmp ; then : ; else
echo "Failed to create temporary directory! Exiting."
exit 2
fi
if chmod u+rwx tmp ; then : ; else
echo "Cannot write to temporary directory! Exiting."
exit 2
fi
###########################################################################
# Variable initialization.
PROGRAM=k9
BINDEST=/usr/local/sbin
DATDEST=/usr/local/lib/k9
RUNGROUP=
UMASK=
NETWORK_DOMAIN=
IRCTYPE="no default"
IRCTYPE_DEF=
IRCTYPE_DEF2=
IRCTYPE_DEF3=
ENCRYPTION=
BROKEN_MD5_COMPAT=
DUMPCORE=
INSTALL=
CP_ALL=
CC=
CC_FLAGS=bonkle
CC_LFLAGS=bonkle
CC_LIBS=bonkle
TYPE_INT16=
TYPE_INT32=
HAVE_STRINGS_H=
HAVE_SYS_SELECT_H=
HAVE_SYS_SYSPROTO_H=
HAVE_STRERROR=
HAVE_SYS_ERRLIST=0
HAVE_SNPRINTF=
BAD_SNPRINTF=
HAVE_STRTOK=
HAVE_STRICMP=
HAVE_STRCASECMP=
HAVE_STRDUP=
HAVE_STRSPN=
HAVE_STRSIGNAL=
HAVE_GETTIMEOFDAY=
HAVE_SETGRENT=
HAVE_UMASK=
HAVE_FORK=
MISSING=bonkle
###########################################################################
# How can we echo something without going to the next line?
ECHO2SUF=''
if [ "`echo -n a ; echo -n b`" = "ab" ] ; then
ECHO2='echo -n'
elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then
ECHO2='echo' ; ECHO2SUF='\c'
elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then
ECHO2='printf "%s"'
else
# oh well...
ECHO2='echo'
fi
export ECHO2 ECHO2SUF
###########################################################################
# Command-line parsing.
IGNORE_CACHE= ; NO_DIR_CHECK= ; USE_LOCAL_FUNCS=
USER_CC= ; USER_CC_FLAGS=bonkle ; USER_CC_LFLAGS=bonkle ; USER_CC_LIBS=
export IGNORE_CACHE NO_DIR_CHECK USE_LOCAL_FUNCS
export USER_CC USER_CC_FLAGS USER_CC_LFLAGS USER_CC_LIBS
while [ $# -gt 0 ] ; do
if [ "$1" = "-ignore-cache" ] ; then
IGNORE_CACHE=bonkle
elif [ "$1" = "-no-dir-check" ] ; then
NO_DIR_CHECK=bonkle
elif [ "$1" = "-use-local-funcs" ] ; then
USE_LOCAL_FUNCS=bonkle
elif [ "$1" = "-os2" ] ; then
PROGRAM=k9.exe
elif [ "$1" = "-cc" ] ; then
shift
USER_CC=$1
elif [ "$1" = "-cflags" ] ; then
shift
USER_CC_FLAGS=$1
elif [ "$1" = "-lflags" ] ; then
shift
USER_CC_LFLAGS=$1
elif [ "$1" = "-libs" ] ; then
shift
USER_CC_LIBS=$1
else
if [ "$1" != "-help" -a "$1" != "-h" -a "$1" != "--help" ]; then
echo >&2 Unknown option/parameter: "$1"
exitval=1
else
exitval=0
fi
cat >&2 <<EOT
Available options:
-ignore-cache Don't use cache file if it exists
-no-dir-check Don't check for existence of install directories
-use-local-funcs Force the use of compatibility functions over system
library functions (for debugging)
-os2 Indicate that this is an OS/2 system.
-cc Specify C compiler to use (overrides cache and check)
-cflags Specify compilation flags (defaults: -O2 for gcc,
-O for other compilers; overrides cache/check)
-lflags Specify link flags for C compiler (default: none)
-libs Specify extra link libraries to use (default: none)
EOT
exit $exitval
fi
shift
done
###########################################################################
echo ""
echo "Beginning K9 IRC Services configuration."
echo ""
###########################################################################
# First, test for the presence of a config.cache file. If found, either
# don't use it (-ignore-cache), or let the user know how to not use it and
# then use it.
if [ -f config.cache -a -r config.cache -a ! "$IGNORE_CACHE" ] ; then
cat <<EOT
Using defaults from config.cache. To ignore, either remove config.cache or
give the command-line option "-ignore-cache".
EOT
. config.cache
if [ ! "$HAVE_SNPRINTF" \
-o ! "$BAD_SNPRINTF" \
-o ! "$HAVE_STRTOK" \
-o ! "$HAVE_STRICMP" \
-o ! "$HAVE_STRCASECMP" \
-o ! "$HAVE_STRDUP" \
-o ! "$HAVE_STRSPN" \
-o ! "$HAVE_STRSIGNAL" ] ; then
MISSING=bonkle
fi
fi
###########################################################################
# Ask the user anything we need to know ahead of time.
export ok INPUT
####
ok=0
echo "In what directory do you want the binaries to be installed?"
echo "Press Return for the default, or enter a new value."
while [ $ok -eq 0 ] ; do
echo2 "[$BINDEST] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$BINDEST
fi
if echo "$INPUT" | grep -q \[\'\"\\\] ; then
echo 'Please use a pathname without the characters: '\'' " \'
elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
if exists "$INPUT" ; then
echo "$INPUT exists, but is not a directory!"
else
echo "$INPUT does not exist. Create it?"
echo2 "[y] "
read YN
if [ "$YN" != "n" ] ; then
if mkdir -p $INPUT ; then
ok=1
fi
fi
fi
elif exists "$INPUT/services.h" ; then
echo "You cannot use the K9 Services source directory as a target directory."
else
ok=1
fi
done
BINDEST=$INPUT
echo ""
####
ok=0
echo "Where do you want the data files to be installed?"
while [ $ok -eq 0 ] ; do
echo2 "[$DATDEST] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$DATDEST
fi
if echo "$INPUT" | grep -q \[\'\"\\\] ; then
echo 'Please use a pathname without the characters: '\'' " \'
elif [ ! "$NO_DIR_CHECK" -a ! -d "$INPUT" ] ; then
if exists "$INPUT" ; then
echo "$INPUT exists, but is not a directory!"
else
echo "$INPUT does not exist. Create it?"
echo2 "[y] "
read YN
if [ "$YN" != "n" ] ; then
if mkdir $INPUT ; then
ok=1
fi
fi
fi
elif exists "$INPUT/services.h" ; then
echo "You cannot use the K9 Services source directory as a target directory."
else
ok=1
fi
done
DATDEST=$INPUT
echo ""
####
ok=0
OLD_RUNGROUP="$RUNGROUP"
if [ "$RUNGROUP" ] ; then
echo "Which group should all K9 Services data files be owned by? (If K9 Services"
echo "should not force files to be owned by a particular group, type "\"none\"
echo "(without the quotes) and press Return.)"
else
echo "Which group should all K9 Services data files be owned by? (If K9 Services"
echo "should not force files to be owned by a particular group, just press"
echo "Return.)"
fi
while [ $ok -eq 0 ] ; do
echo2 "[$RUNGROUP] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
ok=1
if echo "$INPUT" | grep -q \[\'\"\\\] ; then
echo 'Please use a group name without the characters: '\'' " \'
ok=0
elif [ "$INPUT" ] ; then
if [ "$INPUT" = "none" ] ; then
RUNGROUP=""
else
RUNGROUP="$INPUT"
fi
fi
done
echo ""
####
if [ ! "$UMASK" -o "$RUNGROUP" != "$OLD_RUNGROUP" ] ; then
if [ "$RUNGROUP" ] ; then
UMASK=007
else
UMASK=077
fi
fi
ok=0
echo "What should the default umask for data files be (in octal)?"
echo "(077 = only accessible by owner; 007 = accessible by owner and group)"
while [ $ok -eq 0 ] ; do
echo2 "[$UMASK] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$UMASK
fi
if [ `echo "$INPUT" | grep -c '[^0-7]'` -gt 0 ] ; then
echo "$UMASK is not a valid octal number!"
else
if [ "`echo $INPUT | cut -c1`" != "0" ] ; then
INPUT=0$INPUT
fi
ok=1
fi
done
UMASK=$INPUT
echo ""
####
echo "If all of your servers run under a common domain name, what is that"
echo "domain name? (For example: All EsperNet servers have names ending in"
echo \`.esper.net\', so \`esper.net\' "would be entered here.) If your servers"
echo "do not all share a common domain name, just press Return."
echo2 "[$NETWORK_DOMAIN] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ "$INPUT" ] ; then
NETWORK_DOMAIN=`echo $INPUT`
fi
echo ""
####
# XXX ircu 2.10 commented out because it doesn't seem to work
ok=0
echo "Which of the following is closest to the type of server on your IRC"
echo "network?"
echo " 1) Base irc2 distribution (RFC 1459 compliant)"
echo " 2) irc2 with TS8 protocol"
echo " 11) Undernet 2.9.32 or earlier"
#echo " 12) Undernet 2.10.x (version 9 protocol support required)"
echo " 21) DALnet prior to 4.4.15"
echo " 22) DALnet 4.4.15 or later (Dreamforge)"
echo " 23) Bahamut 1.4.23 or later"
echo " 31) Unreal (EXPERIMENTAL)"
while [ $ok -eq 0 ] ; do
echo2 "[$IRCTYPE] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$IRCTYPE
fi
case $INPUT in
no\ default)
echo "You must specify your IRC server type in order for K9 Services to function"
echo "correctly."
;;
1)
IRCTYPE_DEF="IRC_CLASSIC"
ok=1
;;
2)
IRCTYPE_DEF="IRC_TS8"
ok=1
;;
11)
IRCTYPE_DEF="IRC_UNDERNET"
ok=1
;;
# 12)
# IRCTYPE_DEF="IRC_UNDERNET"
# IRCTYPE_DEF2="IRC_UNDERNET_NEW"
# ok=1
# ;;
21)
IRCTYPE_DEF="IRC_DALNET"
ok=1
;;
22)
IRCTYPE_DEF="IRC_DALNET"
IRCTYPE_DEF2="IRC_DAL4_4_15"
ok=1
;;
23)
IRCTYPE_DEF="IRC_DALNET"
IRCTYPE_DEF2="IRC_DAL4_4_15"
IRCTYPE_DEF3="IRC_BAHAMUT"
ok=1
;;
31)
IRCTYPE_DEF="IRC_DALNET"
IRCTYPE_DEF2="IRC_DAL4_4_15"
IRCTYPE_DEF3="IRC_UNREAL"
ok=1
;;
*)
echo "Please enter a valid option number."
;;
esac
done
IRCTYPE=$INPUT
echo ""
####
if [ "$ENCRYPTION" = "ENCRYPT_MD5" ] ; then
DEF=yes
else
DEF=no
fi
ok=0
echo "Do you want to use the MD5 message-digest algorithm to encrypt passwords?"
echo "(Selecting "\"yes\"" protects your passwords from being stolen if someone"
echo "gains access to the K9 Services databases, but makes it impossible to recover"
echo "forgotten passwords.)"
echo "WARNING: Once you run K9 Services with encryption enabled you cannot go back!"
while [ $ok -eq 0 ] ; do
echo2 "[$DEF] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$DEF
fi
case $INPUT in
n*|N*)
ENCRYPTION=
ok=1
;;
y*|Y*)
ENCRYPTION=ENCRYPT_MD5
ok=1
;;
*)
echo 'Please enter "yes" or "no".'
;;
esac
done
echo ""
####
if [ "$ENCRYPTION" = ENCRYPT_MD5 ] ; then
if [ "$BROKEN_MD5_COMPAT" = 0 ] ; then
DEF=no
else
DEF=yes
fi
ok=0
cat <<EOT
Do you want to support MD5-encrypted passwords from K9 Services and
earlier? These versions had a bug which caused the encrypted passwords
to be wrongly generated. Saying "no" here will cause passwords from
those versions to become unreadable; however, saying "yes" may reduce
the security of your passwords.
EOT
while [ $ok -eq 0 ] ; do
echo2 "[$DEF] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$DEF
fi
case $INPUT in
y*|Y*)
BROKEN_MD5_COMPAT=1
ok=1
;;
n*|N*)
BROKEN_MD5_COMPAT=0
ok=1
;;
*)
echo 'Please enter "yes" or "no".'
;;
esac
done
echo ""
else
BROKEN_MD5_COMPAT=0
fi # ENCRYPT_MD5
####
if [ "$DUMPCORE" = 1 ] ; then
DEF=yes
else
DEF=no
fi
ok=0
echo "Do you want IRC K9 Services to generate a core file if a segmentation fault"
echo "occurs? Core files are extremely useful when submitting bug reports as"
echo "they show which line of code caused K9 Services to crash. However, it is"
echo "recommended that you only enable this option if you are experiencing"
echo "problems with K9 Services and are attempting to debug the problem."
while [ $ok -eq 0 ] ; do
echo2 "[$DEF] "
if read INPUT ; then : ; else echo "" ; exit 1 ; fi
if [ ! "$INPUT" ] ; then
INPUT=$DEF
fi
case $INPUT in
n*|N*)
DUMPCORE=0
ok=1
;;
y*|Y*)
DUMPCORE=1
ok=1
;;
*)
echo 'Please enter "yes" or "no".'
;;
esac
done
echo ""
####
echo "End of interactive configuration."
echo ""
###########################################################################
# Set up log file for automated tests, so we have a clue what's going on if
# something dies.
exec 3>configure.log
MODE=" "
TEST=""
export MODE TEST
###########################################################################
# Search for a compiler.
MODE="find_cc "
echo2 "Searching for a suitable compiler... "
if [ "$USER_CC" ] ; then
CC="$USER_CC"
echo "(supplied) using $CC."
log user supplied \`"$USER_CC'"
elif [ "$CC" ] ; then
echo "(cached) using $CC."
log cache supplied \`"$CC'"
elif run gcc --version ; then
echo "great, found gcc!"
CC=gcc
DEF_CC_FLAGS=-O2
log using \`gcc\'
else
echo "gcc not found."
echo2 " Looking for alternatives... "
echo >tmp/test.c "int main(){return 1;}"
if run cc tmp/test.c -o tmp/test ; then
CC=cc
elif run c89 tmp/test.c -o tmp/test ; then
CC=c89
else
echo "no C compiler found!"
echo " Use the -cc command line option to specify your C compiler."
log "automatic tests failed"
exit 2
fi
# See if it handles ANSI.
cat >tmp/test.c <<EOT
int main(int argc, char **argv) {
extern void foo(int bar);
}
EOT
log "test for ANSI..."
if run $CC tmp/test.c -o tmp/test ; then
echo "using $CC."
log using \`"$CC'"
else
echo "found $CC, but it's not ANSI-compliant!"
echo " Use the -cc command line option to specify your C compiler."
log \`"$CC' not ANSI-compliant"
exit 2
fi
DEF_CC_FLAGS=-O
fi
# Test compiler options.
MODE="find_ccopts "
if [ "$USER_CC_FLAGS" != bonkle ] ; then
CC_FLAGS="$USER_CC_FLAGS"
echo "Compiler flags supplied: $CC_FLAGS"
log user supplied flags: \`"$CC_FLAGS'"
elif [ "$CC_FLAGS" != bonkle ] ; then
echo "Compiler flags: (cached) $CC_FLAGS"
log cache supplied flags: \`"$CC_FLAGS'"
else
CC_FLAGS=$DEF_CC_FLAGS
echo2 "Testing default compiler flags ($CC_FLAGS)... "
cat >tmp/test.c <<EOT
int main(int argc, char **argv) {
extern void foo(int bar);
}
EOT
if run $CC $CC_FLAGS -c tmp/test.c -o tmp/test.o ; then
echo "looks good."
else
echo "no luck! Using no flags."
echo " If you know what flags you want, use the -cflags option to configure."
CC_FLAGS=
fi
log using flags: \`"$CC_FLAGS'"
fi
###########################################################################
# Set linker flags.
MODE="find_lflags "
if [ "$USER_CC_LFLAGS" != "bonkle" ] ; then
CC_LFLAGS=$USER_CC_LFLAGS
log user supplied \`"$CC_LFLAGS'"
elif [ "$CC_LFLAGS" != "bonkle" ] ; then
log cache supplied \`"$CC_LFLAGS'"
else
log using no flags
CC_LFLAGS=""
fi
###########################################################################
# See what libraries we have that we might need.
MODE="find_libs "
echo2 "Let's see what libraries are lying around... "
if [ "$CC_LIBS" != bonkle ] ; then
if [ "$CC_LIBS" ] ; then
echo "(cached) $CC_LIBS"
else
echo "(cached) none"
fi
log cache supplied \`"$CC_LIBS'"
else
CC_LIBS=
if run $CC $CC_FLAGS tmp/test.c -lnsl -o tmp/test ; then
CC_LIBS="$CC_LIBS -lnsl"
echo2 "-lnsl "
fi
if run $CC $CC_FLAGS tmp/test.c -lsocket -o tmp/test ; then
CC_LIBS="$CC_LIBS -lsocket"
echo2 "-lsocket "
fi
if run $CC $CC_FLAGS tmp/test.c -lresolv -o tmp/test ; then
CC_LIBS="$CC_LIBS -lresolv"
echo2 "-lresolv "
fi
if run $CC $CC_FLAGS tmp/test.c -lbsd -o tmp/test ; then
CC_LIBS="$CC_LIBS -lbsd"
echo2 "-lbsd "
fi
echo ""
CC_LIBS="`echo $CC_LIBS | sed 's/^ +//'`"
fi
if [ "$USER_CC_LIBS" ] ; then
CC_LIBS="$CC_LIBS $USER_CC_LIBS"
echo "Additional user-supplied libraries: $USER_CC_LIBS"
log user added \`"$USER_CC_LIBS'"
fi
###########################################################################
# See what sizes various types are.
MODE="check_int16 "
echo2 "Looking for a 16-bit integer type... "
if [ "$TYPE_INT16" ] ; then
echo "(cached) $TYPE_INT16"
log "cache supplied $TYPE_INT16"
else
cat >tmp/test.c <<EOT
int main() {
int a;
short b;
printf("%d %d", sizeof(a), sizeof(b));
return 0;
}
EOT
if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then
a="`tmp/test`"
log "test program output (sizeof(int) sizeof(short)): $a"
if [ ! "$a" ] ; then
echo "test program failed! Assuming short."
log "assuming short"
TYPE_INT16=short
else
size_int=`echo $a | cut -d\ -f1`
size_short=`echo $a | cut -d\ -f2`
if [ $size_int = 2 ] ; then
echo int
log "int is 16 bits"
TYPE_INT16=int
elif [ $size_short = 2 ] ; then
echo short
log "short is 16 bits"
TYPE_INT16=short
else
echo "none found?! Assuming short."
log "no 16-bit type found, assuming short"
TYPE_INT16=short
fi
fi
else
whoa_there
fi
fi
MODE="check_int32 "
echo2 "Looking for a 32-bit integer type... "
if [ "$TYPE_INT32" ] ; then
echo "(cached) $TYPE_INT32"
log "cache supplied $TYPE_INT32"
else
cat >tmp/test.c <<EOT
int main() {
int a;
long b;
printf("%d %d", sizeof(a), sizeof(b));
return 0;
}
EOT
if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then
a="`tmp/test`"
log "test program output (sizeof(int) sizeof(long)): $a"
if [ ! "$a" ] ; then
echo "test program failed! Assuming long."
log "assuming long"
TYPE_INT32=long
else
size_int=`echo $a | cut -d\ -f1`
size_long=`echo $a | cut -d\ -f2`
if [ $size_int = 4 ] ; then
echo int
log "int is 32 bits"
TYPE_INT32=int
elif [ $size_long = 4 ] ; then
echo long
log "long is 32 bits"
TYPE_INT32=long
else
echo "none found?! Assuming long."
log "no 32-bit type found, assuming long"
TYPE_INT32=long
fi
fi
else
whoa_there
fi
fi
###########################################################################
# Look for include files that might or might not be here.
echo "Checking for presence of include files (it's okay if some aren't there):"
MODE="check_strings "
echo2 " strings.h... "
if [ "$HAVE_STRINGS_H" ] ; then
if [ "$HAVE_STRINGS_H" = 1 ] ; then
echo "(cached) present"
log "cache says present"
else
echo "(cached) not present"
log "cache says not present"
fi
else
if test_include strings.h ; then
echo "present"
else
echo "not present"
fi
fi
MODE="check_sysselect "
echo2 " sys/select.h... "
if [ "$HAVE_SYS_SELECT_H" ] ; then
if [ "$HAVE_SYS_SELECT_H" = 1 ] ; then
echo "(cached) present"
log "cache says present"
else
echo "(cached) not present"
log "cache says not present"
fi
else
if test_include sys/select.h ; then
echo "present"
else
echo "not present"
fi
fi
MODE="check_sysproto "
echo2 " sys/sysproto.h... "
if [ "$HAVE_SYS_SYSPROTO_H" ] ; then
if [ "$HAVE_SYS_SYSPROTO_H" = 1 ] ; then
echo "(cached) present"
log "cache says present"
else
echo "(cached) not present"
log "cache says not present"
fi
else
if test_include sys/sysproto.h ; then
echo "present"
else
echo "not present"
fi
fi
###########################################################################
# AIX workaround.
MODE="check_aix_intNN "
echo2 "Seeing if your system defines int16/int32... "
res="`run egrep int16\|int32 /usr/include/sys/systypes.h`"
if [ "$res" ] ; then
echo "found."
echo " (This is bad, but we can work around it.)"
log "int16/int32 types found, enabling workaround"
INTTYPE_WORKAROUND=1
else
echo "not found (this is good)."
log "int16/int32 types not found"
INTTYPE_WORKAROUND=0
fi
###########################################################################
# Look for missing/broken built-in routines, and similar compatibility
# stuff.
MODE="check_strerror "
if [ "$USE_LOCAL_FUNCS" ] ; then
log "not checking (-use-local-funcs)"
echo "Not checking for presence of strerror (-use-local-funcs specified)."
HAVE_STRERROR=0
HAVE_SYS_ERRLIST=0
else
echo2 "How to complain when something goes wrong... "
if [ "$HAVE_STRERROR" ] ; then
if [ "$HAVE_STRERROR" = 1 ] ; then
echo "(cached) strerror()."
log "cache supplied strerror()"
elif [ "$HAVE_SYS_ERRLIST" = 1 ] ; then
echo "(cached) sys_errlist."
log "cache supplied sys_errlist"
else
HAVE_SYS_ERRLIST=0 # just in case... you never know.
echo "(cached) pseudo sys_errlist."
log "cache supplied pseudo sys_errlist"
fi
else
cat >tmp/test.c <<EOT
int main() {
extern void strerror(void);
strerror();
}
EOT
if run $CC $CC_FLAGS tmp/test.c $CC_LIBS -o tmp/test ; then
HAVE_STRERROR=1
echo "ah, strerror() is here."
log "using strerror()"
else
HAVE_STRERROR=0
echo "no strerror()."
cat >tmp/test.c <<EOT
int main() {
extern char *sys_errlist[];
char *s;
s = sys_errlist[0];
}
EOT
log "trying sys_errlist..."