forked from Orc/discount
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.inc
executable file
·1766 lines (1499 loc) · 34.6 KB
/
configure.inc
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
# @(#) configure.inc 1.42@(#)
# Copyright (c) 1999-2007 David Parsons. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. My name may not be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
# PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
#
# this preamble code is executed when this file is sourced and it picks
# interesting things off the command line.
#
ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
ac_standard="--src=DIR where the source lives (.)
--prefix=DIR where to install the final product (/usr/local)
--execdir=DIR where to put executables (prefix/bin)
--sbindir=DIR where to put static executables (prefix/sbin)
--confdir=DIR where to put configuration information (/etc)
--libdir=DIR where to put libraries (prefix/lib)
--libexecdir=DIR where to put private executables
--mandir=DIR where to put manpages"
__fail=exit
if dirname B/A 2>/dev/null >/dev/null; then
__ac_dirname() {
dirname "$1"
}
else
__ac_dirname() {
echo "$1" | sed -e 's:/[^/]*$::'
}
fi
__remove() {
if [ \( -x "$1" \) -a "$__MACOS_DSYM" ]; then
rm -rf "$1".dSYM
fi
rm -f "$@"
}
ac_progname=$0
ac_configure_command=
Q=\'
for x in "$@"; do
ac_configure_command="$ac_configure_command $Q$x$Q"
done
# ac_configure_command="$*"
__d=`__ac_dirname "$ac_progname"`
if [ "$__d" = "$ac_progname" ]; then
AC_SRCDIR=`pwd`
else
AC_SRCDIR=`cd $__d;pwd`
fi
__ac_dir() {
if test -d "$1"; then
(cd "$1";pwd)
else
echo "$1";
fi
}
#
# echo w/o newline
#
echononl()
{
${ac_echo:-echo} "${@}$ac_echo_nonl"
}
#
# log something to the terminal and to a logfile.
#
LOG () {
echo "$@"
echo "$@" 1>&5
}
#
# log something to the terminal without a newline, and to a logfile with
# a newline
#
LOGN () {
echononl "$@" 1>&5
echo "$@"
}
#
# log something to the terminal
#
TLOG () {
echo "$@" 1>&5
}
#
# log something to the terminal, no newline
#
TLOGN () {
echononl "$@" 1>&5
}
#
# AC_CONTINUE tells configure not to bomb if something fails, but to
# continue blithely along
#
AC_CONTINUE () {
__fail="return"
}
#
# generate a .o file from sources
#
__MAKEDOTO() {
AC_PROG_CC
if $AC_CC -c -o ngc$$.o "$@" $AC_LIBS 2>ngc$$.err; then
__remove ngc$$.o ngc$$.err
TLOG " (found)"
return 0
fi
__remove ngc$$.o
TLOG " (not found)"
echo "test failed: command was $AC_CC -c -o ngc$$.o" "$@" $AC_LIBS
echo "output:"
cat ngc$$.err
__remove ngc$$.err
echo "offending sources:"
for x in "$@"; do
echo "$x:"
cat $x
done
return 1
}
#
# Emulate gnu autoconf's AC_CHECK_HEADERS() function
#
AC_CHECK_HEADERS () {
echo "/* AC_CHECK_HEADERS */" > ngc$$.c
for hdr in $*; do
echo "#include <$hdr>" >> ngc$$.c
done
echo "int main() { }" >> ngc$$.c
LOGN "looking for header $hdr"
if __MAKEDOTO ngc$$.c; then
AC_DEFINE 'HAVE_'`echo $hdr | $AC_UPPERCASE | tr './' '_'` 1
rc=0
else
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# emulate GNU autoconf's AC_CHECK_FUNCS function
#
AC_CHECK_FUNCS () {
AC_PROG_CC
B=`echo "$1" | sed -e 's/(.*)//'`
case "$B" in
"$1") F="$1()"; need_proto=1 ;;
*) F="$1" ; unset need_proto ;;
esac
shift
__remove ngc$$.c
while [ "$1" ]; do
echo "#include <$1>" >> ngc$$.c
shift
done
if [ "$need_proto" ]; then
echo "void $F;" >> ngc$$.c
fi
cat >> ngc$$.c << EOF
int main()
{
$F;
}
EOF
LOGN "looking for the $B function"
if $AC_CC -o ngc$$ ngc$$.c $LIBS; then
AC_DEFINE `echo ${2:-HAVE_$B} | $AC_UPPERCASE` 1
TLOG " (found)"
rc=0
else
echo "offending command was:"
cat ngc$$.c
echo "$AC_CC -o ngc$$ ngc$$.c $LIBS"
TLOG " (not found)"
rc=1
fi
__remove ngc$$ ngc$$.c
return $rc
}
#
# check to see if some structure exists
#
# usage: AC_CHECK_STRUCT structure {include ...}
#
AC_CHECK_STRUCT () {
struct=$1
shift
__remove ngc$$.c
for include in $*; do
echo "#include <$include>" >> ngc$$.c
done
cat >> ngc$$.c << EOF
int main()
{
struct $struct foo;
}
EOF
LOGN "looking for struct $struct"
if __MAKEDOTO ngc$$.c; then
AC_DEFINE HAVE_STRUCT_`echo ${struct} | $AC_UPPERCASE`
rc=0
else
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# check to see if some type exists
#
# usage: AC_CHECK_TYPE type {include ...}
#
AC_CHECK_TYPE () {
type=$1
shift
__remove ngc$$.c
for include in $*; do
echo "#include <$include>" >> ngc$$.c
done
cat >> ngc$$.c << EOF
int main()
{
$type foo;
}
EOF
LOGN "looking for $type type"
if __MAKEDOTO ngc$$.c; then
AC_DEFINE HAVE_TYPE_`echo ${type} | $AC_UPPERCASE`
rc=0
else
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# check to see if some structure contains a field
#
# usage: AC_CHECK_FIELD structure field {include ...}
#
AC_CHECK_FIELD () {
struct=$1
field=$2
shift 2
__remove ngc$$.c
for include in $*;do
echo "#include <$include>" >> ngc$$.c
done
cat >> ngc$$.c << EOF
int main()
{
struct $struct foo;
foo.$field;
}
EOF
LOGN "checking that struct $struct has a $field field"
if __MAKEDOTO ngc$$.c; then
AC_DEFINE HAVE_`echo ${struct}_$field | $AC_UPPERCASE`
rc=0
else
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# check that the C compiler works
#
AC_PROG_CC () {
test "$AC_CC" && return 0
cat > ngc$$.c << \EOF
#include <stdio.h>
int main()
{
puts("hello, sailor");
}
EOF
TLOGN "checking the C compiler"
unset AC_CFLAGS AC_LDFLAGS __MACOS_DSYM
if [ "$CC" ] ; then
AC_CC="$CC"
elif [ "$WITH_PATH" ]; then
AC_CC=`acLookFor cc`
elif [ "`acLookFor cc`" ]; then
# don't specify the full path if the user is looking in their $PATH
# for a C compiler.
AC_CC=cc
fi
# finally check for POSIX c89
test "$AC_CC" || AC_CC=`acLookFor c89`
if [ ! "$AC_CC" ]; then
TLOG " (no C compiler found)"
$__fail 1
fi
echo "checking out the C compiler"
$AC_CC -o ngc$$ ngc$$.c
status=$?
TLOGN " ($AC_CC)"
if [ $status -eq 0 ]; then
if $AC_CC -x c /dev/null -dM -E 2>&1 | grep '__clang__' >/dev/null; then
TLOG " yuck, you're using clang"
IS_CLANG=T
IS_BROKEN_CC=T
elif $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then
TLOG " oh ick, it looks like gcc"
IS_GCC=T
IS_BROKEN_CC=T
else
TLOG " ok"
fi
# check that the CFLAGS and LDFLAGS aren't bogus
unset AC_CFLAGS AC_LDFLAGS
if [ "$CFLAGS" ]; then
test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
if $AC_CC $CFLAGS -o ngc$$.o ngc$$.c ; then
AC_CFLAGS=${CFLAGS:-"-g"}
test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
elif [ "$CFLAGS" ]; then
echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
fi
else
AC_CFLAGS=-g
fi
if [ "$LDFLAGS" ]; then
test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
if $AC_CC $LDFLAGS -o ngc$$ ngc$$.o; then
AC_LDFLAGS=${LDFLAGS:-"-g"}
test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
elif [ "$LDFLAGS" ]; then
TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
fi
else
AC_LDFLAGS=${CFLAGS:-"-g"}
fi
# macos-specific(?) test for .dSYM resource directories
$AC_CC $AC_CFLAGS $AC_LDFLAGS -o ngc$$ ngc$$.c
ls -dl ngc$$*
test -d ngc$$.dSYM && __MACOS_DSYM=1
else
AC_FAIL " does not compile code properly"
fi
__remove ngc$$ ngc$$.c ngc$$.o
return $status
}
#
# acLookFor actually looks for a program, without setting anything.
#
acLookFor () {
path=${AC_PATH:-$ac_default_path}
case "X$1" in
X-[rx]) __mode=$1
shift
;;
*) __mode=-x
;;
esac
oldifs="$IFS"
for program in $*; do
IFS=":"
for x in $path; do
if [ $__mode $x/$program -a -f $x/$program ]; then
echo $x/$program
break 2
fi
done
done
IFS="$oldifs"
unset __mode
}
#
# check that a program exists and set its path
#
MF_PATH_INCLUDE () {
SYM=$1; shift
case X$1 in
X-[rx]) __mode=$1
shift
;;
*) unset __mode
;;
esac
TLOGN "looking for $1"
DEST=`acLookFor $__mode $*`
__sym=`echo "$SYM" | $AC_UPPERCASE`
if [ "$DEST" ]; then
TLOG " ($DEST)"
echo "$1 is $DEST"
AC_MAK $SYM
AC_DEFINE PATH_$__sym \""$DEST"\"
AC_SUB $__sym "$DEST"
eval CF_$SYM=$DEST
return 0
else
#AC_SUB $__sym ''
echo "$1 is not found"
TLOG " (not found)"
return 1
fi
}
#
# AC_INIT starts the ball rolling
#
# After AC_INIT, fd's 1 and 2 point to config.log
# and fd 5 points to what used to be fd 1
#
AC_INIT () {
__config_files="config.cmd config.sub config.h config.mak config.log"
rm -f $__config_files
__cwd=`pwd`
exec 5>&1 1>"$__cwd"/config.log 2>&1
AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | $AC_UPPERCASE | tr ' ' '_'`_D
# check to see whether to use echo -n or echo ...\c
#
echo -n hello > $$
echo world >> $$
if grep "helloworld" $$ >/dev/null; then
ac_echo="echo -n"
echo "[echo -n] works"
else
ac_echo="echo"
echo 'hello\c' > $$
echo 'world' >> $$
if grep "helloworld" $$ >/dev/null; then
ac_echo_nonl='\c'
echo "[echo ...\\c] works"
fi
fi
rm -f $$
LOG "Configuring for [$1]"
cat > "$__cwd"/config.h << EOF
/*
* configuration for $1${2:+" ($2)"}, generated `date`
* by ${LOGNAME:-`whoami`}@`hostname`
*/
#ifndef $AC_CONFIGURE_FOR
#define $AC_CONFIGURE_FOR 1
EOF
unset __share
if [ -d $AC_PREFIX/share/man ]; then
for t in 1 2 3 4 5 6 7 8 9; do
if [ -d $AC_PREFIX/share/man/man$t ]; then
__share=/share
elif [ -d $AC_PREFIX/share/man/cat$t ]; then
__share=/share
fi
done
else
__share=
fi
if [ -d $AC_PREFIX/libexec ]; then
__libexec=libexec
else
__libexec=lib
fi
AC_PREFIX=${AC_PREFIX:-/usr/local}
AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin}
AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin}
AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib}
AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man}
AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec}
AC_CONFDIR=${AC_CONFDIR:-/etc}
AC_PATH=${WITH_PATH:-$PATH}
AC_PROG_CPP
AC_PROG_INSTALL
ac_os=`uname -s`
_os=`echo $ac_os | $AC_UPPERCASE | sed -e 's/[^A-Z0-9_].*$//'`
AC_DEFINE OS_$_os 1
eval OS_${_os}=1
unset _os
}
#
# AC_LIBRARY checks to see if a given library exists and contains the
# given function.
# usage: AC_LIBRARY function library [alternate ...]
#
AC_LIBRARY() {
SRC=$1
shift
__acllibs=
__aclhdrs=
for x in "$@"; do
case X"$x" in
X-l*) __acllibs="$__acllibs $x" ;;
*) __aclhdrs="$__aclhdrs $x" ;;
esac
done
# first see if the function can be found in any of the
# current libraries
AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs && return 0
# then search through the list of libraries
__libs="$LIBS"
for x in $__acllibs; do
LIBS="$__libs $x"
if AC_QUIET AC_CHECK_FUNCS $SRC $__aclhdrs; then
AC_LIBS="$AC_LIBS $x"
return 0
fi
done
return 1
}
#
# AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
#
AC_PROG_LEX() {
TLOGN "looking for lex "
DEST=`acLookFor lex`
if [ "$DEST" ]; then
AC_MAK LEX
AC_DEFINE PATH_LEX \"$DEST\"
AC_SUB 'LEX' "$DEST"
echo "lex is $DEST"
else
DEST=`acLookFor flex`
if [ "$DEST" ]; then
AC_MAK FLEX
AC_DEFINE 'LEX' \"$DEST\"
AC_SUB 'LEX', "$DEST"
echo "lex is $DEST"
else
AC_SUB LEX ''
echo "neither lex or flex found"
TLOG " (not found)"
return 1
fi
fi
if AC_LIBRARY yywrap -ll -lfl; then
TLOG "($DEST)"
return 0
fi
TLOG "(no lex library found)"
return 1
}
#
# AC_PROG_YACC checks to see if YACC exists, and if it's bison or
# not.
#
AC_PROG_YACC () {
TLOGN "looking for yacc "
DEST=`acLookFor yacc`
if [ "$DEST" ]; then
AC_MAK YACC
AC_DEFINE PATH_YACC \"$DEST\"
AC_SUB 'YACC' "$DEST"
TLOG "($DEST)"
echo "yacc is $DEST"
else
DEST=`acLookFor bison`
if [ "$DEST" ]; then
AC_MAK BISON
AC_DEFINE 'YACC' \"$DEST\"
AC_SUB 'YACC' "$DEST -y"
echo "yacc is $DEST -y"
TLOG "($DEST -y)"
else
AC_SUB 'YACC' ''
echo "neither yacc or bison found"
TLOG " (not found)"
return 1
fi
fi
return 0
}
#
# AC_PROG looks for a program
#
AC_PROG () {
PN=`basename $1 | $AC_UPPERCASE | tr -dc $AC_UPPER_PAT`
if set | grep -v PROG_$PN >/dev/null; then
TLOGN "looking for $1"
DEST=`acLookFor $1`
if [ "$DEST" ]; then
eval PROG_$PN="$DEST"
AC_SUB $PN $DEST
TLOG " ($DEST)"
return 0
fi
AC_SUB $PN true
TLOG " (not found)"
return 1
fi
}
#
# AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
#
AC_PROG_LN_S () {
test "$AC_FIND_PROG" || AC_PROG_FIND
test "$AC_FIND_PROG" || return 1
TLOGN "looking for \"ln -s\""
DEST=`acLookFor ln`
if [ "$DEST" ]; then
rm -f /tmp/b$$
$DEST -s /tmp/a$$ /tmp/b$$
if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
TLOG " ($DEST)"
echo "$DEST exists, and ln -s works"
PROG_LN_S="$DEST -s"
AC_SUB 'LN_S' "$DEST -s"
rm -f /tmp/b$$
else
AC_SUB 'LN_S' ''
TLOG " ($DEST exists, but -s does not seem to work)"
echo "$DEST exists, but ln -s doesn't seem to work"
rm -f /tmp/b$$
return 1
fi
else
AC_SUB 'LN_S' ''
echo "ln not found"
TLOG " (not found)"
return 1
fi
}
#
# AC_PROG_FIND looks for the find program and sets the FIND environment
# variable
#
AC_PROG_FIND () {
if test -z "$AC_FIND_PROG"; then
MF_PATH_INCLUDE FIND find
rc=$?
AC_FIND_PROG=$DEST
return $rc
fi
return 0
}
#
# AC_PROG_AWK looks for the awk program and sets the AWK environment
# variable
#
AC_PROG_AWK () {
if test -z "$AC_AWK_PROG"; then
MF_PATH_INCLUDE AWK awk
rc=$?
AC_AWK_PROG=$DEST
return $rc
fi
return 0
}
#
# AC_PROG_SED looks for the sed program and sets the SED environment
# variable
#
AC_PROG_SED () {
if test -z "$AC_SED_PROG"; then
MF_PATH_INCLUDE SED sed
rc=$?
AC_SED_PROG=$DEST
return $rc
fi
return 0
}
#
# AC_HEADER_SYS_WAIT looks for sys/wait.h
#
AC_HEADER_SYS_WAIT () {
AC_CHECK_HEADERS sys/wait.h || return 1
}
#
# AC_TYPE_PID_T checks to see if the pid_t type exists
#
AC_TYPE_PID_T () {
AC_CHECK_TYPE pid_t sys/types.h
return $?
}
#
# AC_C_CONST checks to see if the compiler supports the const keyword
#
AC_C_CONST () {
cat > ngc$$.c << EOF
const char me=1;
EOF
LOGN "checking for \"const\" keyword"
if __MAKEDOTO ngc$$.c; then
rc=0
else
AC_DEFINE 'const' '/**/'
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# AC_C_VOLATILE checks to see if the compiler supports the volatile keyword
#
AC_C_VOLATILE () {
echo 'f() { volatile char me=1; }' > ngc$$.c
LOGN "checking for \"volatile\" keyword"
if __MAKEDOTO ngc$$.c; then
rc=0
else
AC_DEFINE 'volatile' '/**/'
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# AC_C_INLINE checks to see if compiler supports the inline keyword
#
AC_C_INLINE() {
echo 'inline int foo() { return 1; }' > ngc$$.c
LOGN 'Checking for "inline" keyword'
if __MAKEDOTO ngc$$.c; then
rc=0
else
AC_DEFINE inline '/**/'
rc=1
fi
__remove ngc$$.c
return $rc
}
#
# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
#
AC_SCALAR_TYPES () {
rc=1
LOGN "defining WORD & DWORD scalar types"
# --- is this needed anymore? ---
# if AC_QUIET AC_CHECK_HEADERS WinDef.h; then
# # windows machine; BYTE, WORD, DWORD already
# # defined
#
# for x in $@; do
# case "$x" in
# sub)AC_SUB DWORD DWORD
# AC_SUB WORD WORD
# AC_SUB BYTE BYTE
# ;;
# *)
# echo "#include <WinDef.h>" >> "$__cwd"/config.h
# ;;
# esac
# done
# TLOG " (defined in WinDef.h)"
# return 0
# fi
cat > ngc$$.c << EOF
#include <stdio.h>
#include <string.h>
int pound_define = 1;
void
say(char *w, char *v)
{
printf(pound_define ? "#define %s %s\n"
: "s:@%s@:%s:g\n", w, v);
}
main(argc, argv)
char **argv;
{
unsigned long v_long;
unsigned int v_int;
unsigned short v_short;
if ( argc > 1 && strcmp(argv[1], "sub") == 0 )
pound_define = 0;
if (sizeof v_long == 4)
say("DWORD", "unsigned long");
else if (sizeof v_int == 4)
say("DWORD", "unsigned int");
else
exit(1);
if (sizeof v_int == 2)
say("WORD", "unsigned int");
else if (sizeof v_short == 2)
say("WORD", "unsigned short");
else
exit(2);
say("BYTE", "unsigned char");
exit(0);
}
EOF
if $AC_CC ngc$$.c -o ngc$$; then
while [ "$1" ]; do
case "$1" in
sub)if ./ngc$$ sub >> "$__cwd"/config.sub; then
rc=0
fi;;
*) if ./ngc$$ >> "$__cwd"/config.h; then
rc=0
fi ;;
esac
shift
done
if [ "$rc" != 0 ]; then
if ./ngc$$ >> "$__cwd"/config.h; then
rc=1
fi
fi
fi
__remove ngc$$ ngc$$.c
case "$rc" in
0) TLOG "" ;;
*) AC_FAIL " ** FAILED **" ;;
esac
return $rc
}
#
# AC_OUTPUT generates makefiles from makefile.in's
#
AC_OUTPUT () {
cd "$__cwd"
AC_SUB 'LIBS' "$AC_LIBS"
AC_SUB 'CONFIGURE_FILES' "$__config_files"
if test "$__MACOS_DSYM"; then
# deal with extra OSX droppings, if they exist
AC_SUB 'GENERATED_FILES' "-r *.dSYM $*"
else
AC_SUB 'GENERATED_FILES' "$*"
fi
AC_SUB 'CC' "$AC_CC"
AC_SUB 'CFLAGS' "$AC_CFLAGS"
AC_SUB 'LDFLAGS' "$AC_LDFLAGS"
AC_SUB 'srcdir' "$AC_SRCDIR"
AC_SUB 'prefix' "$AC_PREFIX"
AC_SUB 'exedir' "$AC_EXECDIR"
AC_SUB 'sbindir' "$AC_SBINDIR"
AC_SUB 'libdir' "$AC_LIBDIR"
AC_SUB 'libexec' "$AC_LIBEXEC"
AC_SUB 'confdir' "$AC_CONFDIR"
AC_SUB 'mandir' "$AC_MANDIR"
if echo "$__config_files" | grep -v librarian.sh >/dev/null; then
# write a librarian that works with static libraries
if AC_PROG_LN_S ; then
__dolink=$PROG_LN_S
elif AC_PROG ln; then
__dolink=$PROG_LN
elif AC_PROG cp; then