summaryrefslogtreecommitdiffstats
path: root/configure
blob: 4928ae0da77da019bf4df30bd83e395448f62def (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
#!/bin/sh
#
# Guess values for system-dependant variables and create `Makefile'.
# Can be distributed according to GPL.
#
# Usage:
#   configure -ask		(ask all questions)
#
# As soon as some other option is specified, configure
# will not ask questions. Other options:
#
#   configure -d[efault]	(language=en, +fhs)
#   configure -confdir DIR	(directory to hold man.conf)
#   configure +suid/sgid	(make man suid or sgid)
#   configure +lang cs,da,de,el,en,es,fi,fr,hr,it,ko,nl,pl,pt,ro,sl
#                               (language(s) as given)
#				("all" will specify all available languages)
#				("none" will disable NLS support)
#   configure +fhs		(follow FHS: use /var/cache/man)
#   configure +fsstnd		(follow FSSTND: use /var/catman)
#
LANGUAGES="bg,cs,da,de,el,en,es,fi,fr,hr,it,ja,ko,nl,pl,pt,ro,ru,sl"
LANGOPT="+lang {$LANGUAGES|all|none}"
#
# Some people prefer "-irs", but probably only when they have a broken setup.
# (Indeed, -r may cause the terminal to get into funny states.
# Very inconvenient. For viewing pages in strange locales, set LC_*.)
#
DEFAULTLESSOPT="-is"
#
# Note that not creating any cat directories (/var/cache/man or so)
# and not making man suid or sgid is recommended.
# This avoids security problems, the fact that different users have
# different window sizes and different character sets, etc.
# Formatting is fast enough today.

trap 'rm -f conftest conftest.c; exit 1' 1 3 15

set +u # Make sure unset variables are ok.

if [ $# = 0 ]; then
  echo "Usage: configure -ask"
  echo "   or: configure [-d|-default] [-confdir DIR] [+suid] [+sgid] \\"
  echo "                 [+fhs|+fsstnd|+traditional] [+lang none|all|LANGUAGES]"
  echo "   where LANGUAGES is a substring of $LANGUAGES".
  echo
  echo 'The default "configure -d" is equivalent to "configure +fhs +lang en".'
  echo 'The option +suid will make man suid to a user "man". Create this first.'
  echo 'The option +sgid will make man sgid to a group "man". Create this first.'
  echo 'The options +fhs, +fsstnd, +traditional will make man use'
  echo ' /var/cache/man, /var/catman and /usr/man/cat?, respectively.'
  echo 'It is recommended not to use suid/sgid and not to keep cat pages.'
  echo 'The -confdir option specifies where man.conf lives (default /usr/share/misc).'
  echo
  exit 1
fi

default=true
usenls=true

for arg in $*; do
  if [ x$setlang = xtrue ]
  then
    case $arg in
      none)
	usenls=false
	;;
      all)
	languages="??"
	;;
      *)
	languages=`echo $arg | sed -e 's/,/ /g'`
    esac
    setlang=false
  elif [ x$setconfdir = xtrue ]
  then
    confdir=$arg
    confexplicit=1
    setconfdir=false
  else
    # help people used to GNU-style --options
    # e.g. --enable-suid, --disable-suid, --prefix
    case $arg in
      --enable-*)
          arg=`echo $arg | sed -e 's/--enable-/+/'`
	  ;;
      --disable-*)
          arg=`echo $arg | sed -e 's/--disable-/-/'`
	  ;;
      --*)
          arg=`echo $arg | sed -e 's/--/-/'`
    esac
    case $arg in
      -default | -d)
	  usefhs=true
	  ;;
      -ask | -a)
	  default=
	  ;;
      -prefix=*)
	  prefix=`echo $arg | sed -e 's/-prefix=//'`
	  ;;
      -bindir=*)
          bindir=`echo $arg | sed -e 's/-bindir=//'`
	  ;;
      -confdir=*)
          confdir=`echo $arg | sed -e 's/-confdir=//'`
	  confexplicit=1
	  ;;
      -confdir)
          setconfdir=true;
          ;;
      -confprefix=*)
          confprefix=`echo $arg | sed -e 's/-confprefix=//'`
	  ;;
      -mandir=*)
          mandir=`echo $arg | sed -e 's/-mandir=//'`
	  manexplicit=1
	  ;;
      -sbindir=*)
          sbindir=`echo $arg | sed -e 's/-sbindir=//'`
	  ;;
      +lang)
	  setlang=true
	  ;;
      +suid)
	  suid=true
	  ;;
      -suid)
	  suid=false
	  ;;
      +sgid)
	  sgid=true
	  ;;
      -sgid)
	  sgid=false
	  ;;
      +traditional)
          usefsstnd=false
          usefhs=false
          ;;
      +fsstnd)
	  usefsstnd=true
	  ;;
      -fsstnd)
	  usefsstnd=false
          ;;
      +fhs)
	  usefhs=true
	  ;;
      -fhs)
          usefhs=false
          ;;
      -compatibility_mode_for_colored_groff)
          set_compatibility_mode_for_colored_groff=true;
	  ;;
      *)
  echo "Usage: configure -ask"
  echo "   or: configure [-d|-default] [-confdir DIR] [+suid] [+sgid] \\"
  echo "                 [+fhs|+fsstnd|+traditional] [+lang all|LANGUAGES]"
  echo "       where LANGUAGES is a substring of $LANGUAGES".
  echo
  echo 'The default "configure -d" is equivalent to "configure +fhs +lang en".'
  echo 'The option +suid will make man suid to a user "man". Create this first.'
  echo 'The option +sgid will make man sgid to a group "man". Create this first.'
  echo 'The options +fhs, +fsstnd, +traditional will make man use'
  echo ' /var/cache/man, /var/catman and /usr/man/cat?, respectively.'
  echo 'The -confdir option specifies where man.conf lives (default /usr/share/misc).'
  exit 1
	  ;;
    esac
  fi
done

# Default installation paths
#
# prefix="/usr/local" or "/usr"
# confprefix="/usr/local" or "/usr" or "/etc"
# 
# The configuration file has various names and pathnames in the
# various distributions, such as /usr/share/misc/man.conf,
# /usr/lib/man.conf, /etc/man.config.
# The FHS wants it in /usr/share/misc
# All documentation assumes "man.conf" - in case you invent some other name
# (why?), also man pages and other docs need to be patched.
if [ -z "${prefix}" ]; then prefix="/usr"; fi
if [ -z "${confprefix}" ]; then confprefix=${prefix}; fi
if [ -z "${bindir}" ]; then bindir="${prefix}/bin"; fi
if [ -z "${sbindir}" ]; then sbindir="${prefix}/sbin"; fi
if [ -z "${mandir}" ]; then mandir="${prefix}/man"; fi

if [ -z "$manexplicit" -a x"$usefhs" = xtrue ]; then
  mandir="${prefix}/share/man"
fi
if [ -z "$confexplicit" ]; then
  confdir="${confprefix}/lib"
  if [ x"$usefhs" = xtrue ]; then
    confdir="${confprefix}/share/misc"
  fi
fi
conffilename="man.conf"

if test "$RANDOM" = "$RANDOM"; then
  # Plain old Bourne shell.
  echo checking for gcc
  test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O"
else
  # ksh, bash or zsh.  ksh and zsh write "command not found" to stderr.
  echo checking for gcc
  test -z "$CC" && type gcc && CC="gcc -O"
fi

CC=${CC-cc}
BUILD_CC=${BUILD_CC-${CC}}
INSTALL=${INSTALL-install}
INCLUDEDIR=${INCLUDEDIR-/usr/include}

rm -f conftest conftest.c
compile="$CC $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1"

# Check for various header files.

echo checking for ANSI C header files
echo "#include <stdlib.h>
#include <string.h>
main() { exit(0); strerror(0); }" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
  DEFS="$DEFS -DSTDC_HEADERS"
fi
echo checking for Windows EXEEXT
EXEEXT=
test -f ./conftest.exe && EXEEXT=.exe

rm -f conftest conftest.c

echo checking for sys/termios.h
echo "#include <sys/termios.h>
main() { exit(0); }" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
  DEFS="$DEFS -DTERMIOS_HEADER"
fi
rm -f conftest conftest.c

echo checking for POSIX.1 header files
echo "#include <unistd.h>
main() {
#ifdef _POSIX_VERSION
exit(0);
#else
exit(1);
#endif
}" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
  DEFS="$DEFS -DPOSIX"
fi
rm -f conftest conftest.c

echo checking for BSD string and memory functions
echo "#include <strings.h>
main() { exit(0); rindex(0, 0); bzero(0, 0); }" > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then :
  else DEFS="$DEFS -DUSG"
fi
rm -f conftest conftest.c

echo checking whether sys/types.h defines uid_t
echo '#include <sys/types.h>
main() { uid_t x; exit(0); }' > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then :
else
  uid_t=`awk '/pw_uid;/ {print $1}' $INCLUDEDIR/pwd.h`
  DEFS="$DEFS -Duid_t=${uid_t} -Dgid_t=${uid_t}"
fi
rm -f conftest conftest.c

echo checking for Xenix
if test -f /xenix; then
  LIBS="$LIBS -lx"
  case "$DEFS" in
  *SYSNDIR*) ;;
  *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx.
  esac
fi

echo checking how to get alloca
echo '
#ifdef __GNUC__
#define alloca __builtin_alloca
#else
#ifdef sparc
#include <alloca.h>
#else
#ifdef _AIX
 #pragma alloca
#else
char *alloca ();
#endif
#endif
#endif
main() { char *p = (char *) alloca(1); exit(0); }' > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then :
elif test -d /usr/ucblib; then LIBS="$LIBS -L/usr/ucblib -lucb"
elif test -f /usr/lib/libPW.a; then LIBS="$LIBS -lPW"
else DEFS="$DEFS -DALLOCA_MISSING"
fi
rm -f conftest conftest.c

if [ $usenls = true ]; then
  echo checking for nls
  echo '#include <nl_types.h>
  main() {nl_catd catfd; exit(0); }' > conftest.c
  eval $compile
  if test -s conftest && ./conftest 2>/dev/null; then :
  else
    usenls=false
  fi
  rm -f conftest conftest.c
fi

if [ $usenls = false ]; then
  DEFS="$DEFS -DNONLS"
fi

echo checking for getopt.h
echo '#define _GNU_SOURCE
#include <getopt.h>
#include <stdio.h>
struct option long_opts[] = { { "", no_argument, NULL, 0 } };
main() { exit(0); }' > conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then
  manpathoption="--path"
else
  manpathoption="-w"
  DEFS="$DEFS -DNOGETOPT"
fi
rm -f conftest conftest.c

# first determine how to suppress newline on echo command (stolen from
# Perl's Configure) ...

echo "Checking echo to see how to suppress newlines..."
(echo "hi there\c" ; echo " ") >conftest
if grep c conftest >/dev/null 2>&1 ; then
    echo "...using -n."
    n='-n'
    c=''
else
    cat <<'EOM'
...using \c
EOM
    n=''
    c='\c'
fi
rm -f conftest

# Ask the installer where various things are located.
# (A separate variable is needed since various shells do
# word-splitting at different moments, which means that
#   for i in /bin:/usr/bin:$PATH
# does not work everywhere.)
# Some people might prefer having $PATH first in PREPATH
PREPATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:$PATH
IFS0="$IFS"
IFS=":$IFS"
for i in $PREPATH
do
  case $i in
    /*)
      DEFPATH="$DEFPATH $i"
      ;;
  esac
done
IFS="$IFS0"

if [ x$default = x ]; then
  echo ""
  echo $n "Do you have the nroff source for man pages?  [yes] $c"
  ans=
  while [ x$ans = x ]
  do
    read yesno
    if test "$yesno" = "" || test "$yesno" = "yes"
    then
      ans=true
    elif test "$yesno" = "no"
    then
      ans=false
    else
      echo "You must enter yes or no"
    fi
  done
else
  echo ""
  echo "Assuming you want to be able to handle the nroff source for man pages."
  ans=true
fi

if test "$ans" = "false"
then
  for i in more less cmp cat awk gawk mawk
  do
    eval F$i="missing"
    for j in $DEFPATH
    do
      if test -f $j/$i
      then
	eval F$i=$j/$i
	break
      fi
    done
  done
  troff=""
  nroff=""
  jnroff=""
  eqn=""
  neqn=""
  jneqn=""
  tbl=""
  col=""
  vgrind=""
  refer=""
  grap=""
  pic=""
  if test $Fless = "missing"
  then
    pager="$Fmore"
  else
    pager="$Fless $DEFAULTLESSOPT"
  fi
  if test $Fawk = "missing"
  then
    Fawk="$Fgawk"
  fi
  if test $Fawk = "missing"
  then
    Fawk="$Fmawk"
  fi
  cmp="$Fcmp -s"
  cat="$Fcat"
  awk="$Fawk"

  FILTERS="pager cmp cat awk"
else
  for i in nroff groff geqn gtbl col vgrind grefer grap gpic more less lynx cmp cat awk gawk mawk
  do
    eval F$i="missing"
    for j in $DEFPATH
    do
      if test -f $j/$i
      then
	eval F$i=$j/$i
	break
      fi
    done
  done
  for i in eqn tbl refer pic
  do
    if test `eval echo \\$Fg$i` = "missing"
    then
      for j in $DEFPATH
      do
        if test -f $j/$i
        then
	  eval Fg$i=$j/$i
	  break
        fi
      done
    fi
  done
# -Tlatin1 is bad when utf8 is used, but needed for groff, not for nroff
# Hmm - also needed for nroff, to prevent double conversion on uxterm
  if test $Fgroff = "missing"
  then
    if test $Fnroff = "missing"
    then
      nroff="nroff -Tlatin1 -mandoc"
    else
      nroff="$Fnroff -Tlatin1 -mandoc"
    fi
    troff="troff -mandoc"
    echo "Warning: could not find groff"
  else
    if test $Fnroff = "missing"
    then
      nroff="$Fgroff -Tlatin1 -mandoc"
    else
      nroff="$Fnroff -Tlatin1 -mandoc"
    fi
    troff="$Fgroff -Tps -mandoc"
    jnroff="$Fgroff -Tnippon -mandocj"
  fi
  eqn="$Fgeqn -Tps"
  neqn="$Fgeqn -Tlatin1"
  jneqn="$Fgeqn -Tnippon"
  tbl="$Fgtbl"
  col="$Fcol"
  vgrind="$Fvgrind"
  refer="$Fgrefer"
  grap="$Fgrap"
  pic="$Fgpic"
  if test $Fless = "missing"
  then
    pager="$Fmore"
  else
    pager="$Fless $DEFAULTLESSOPT"
  fi
  if test $Flynx = "missing"
  then
    browser=$pager
    htmlpager=$Fcat
  else
    browser="$Flynx"
    htmlpager="$Flynx -dump"
  fi
  if test $Fawk = "missing"
  then
    Fawk="$Fgawk"
  fi
  if test $Fawk = "missing"
  then
    Fawk="$Fmawk"
  fi
  cmp="$Fcmp -s"
  cat="$Fcat"
  awk="$Fawk"

  FILTERS="troff nroff jnroff eqn neqn jneqn tbl col vgrind refer grap pic pager browser htmlpager cmp cat awk"
fi

# Note: older nroff gives an error message for -c
# Do this only when you have troff 1.18.1 or so.
if [ "x$set_compatibility_mode_for_colored_groff" = "xtrue" ]; then
    troff="$troff -c"
    nroff="$nroff -c"
    jnroff="$jnroff -c"
fi

if [ x$default = x ]; then
  echo ""
  echo "If you don't have one of the following programs, enter \`missing'."
  echo "It's best to enter absolute pathnames so that man won't have to"
  echo "depend on the user's path to work properly.  Default values are"
  echo "given in square brackets.  The answers given are only checked to"
  echo "see if the programs exist, not to see see if the given flags are"
  echo "correct."
  
  for filter in $FILTERS
  do
    found=false
    while test "$found" = "false"
    do
      echo ""
      echo $n "$filter command to use [`eval echo \\$$filter`] $c"
      read tmp
      if test -n "$tmp"
      then
        if test "$tmp" = "missing"
        then
          if test "$filter" = "pager"
          then
            found=false
            echo "You must have a pager!"
          else
            found=true
            eval $filter=""
          fi
        elif test -f `echo $tmp | $awk '{print $1}'`
        then
          found=true
          eval $filter=\""$tmp"\"
        else
          found=false
          echo ""
          echo "`echo $tmp | $awk '{print $1}'` doesn't seem to exist!  Try again or enter \`missing'"
        fi
      elif test `eval echo \\$$filter | $awk '{print $1}'` = "missing"
      then
        found=true
        eval $filter=""
      elif test -f `eval echo \\$$filter | $awk '{print $1}'`
      then
        found=true
      else
        found=false
        echo ""
        echo "`eval echo \\$$filter | $awk '{print $1}'` doesn't seem to exist!  Try again or enter \`missing'"
      fi
    done
  done
else
  echo ""
  echo "Assuming the following ways to invoke the various commands and filters":
  for filter in $FILTERS
  do
    echo "$filter command:	`eval echo \\$$filter`"
    if test `eval echo \\$$filter | $awk '{print $1}'` = "missing"
    then
      eval $filter=""
    fi
  done
fi

case $nroff in
  *roff*)
    echo ""
    echo "It seems that no col is needed, since you use groff."
    pcol=
    nocol="# " ;;
  *)
    pcol=$col
    nocol= ;;
esac
  
fhs="# "
fsstnd="# "
FHSDIR=/var/cache/man
FSSTNDDIR=/var/catman
if [ x$usefhs = x -a x$usefsstnd = x ]; then
  if [ x$default = x ]; then
    echo ""
    echo $n "Do you want to put the cat pages under $FHSDIR ? [no] $c"
    ans=
    while [ x$ans = x ]
    do
      read yesno
      if test "$yesno" = "" || test "$yesno" = "no"
      then
        ans=false
      elif test "$yesno" = "yes"
      then
        ans=true
      else
        echo "You must enter yes or no"
      fi
    done
    if [ $ans = true ]; then
      fhs=
    else
      echo $n "Do you want to put the cat pages under $FSSTNDDIR ? [no] $c"
      ans=
      while [ x$ans = x ]
      do
        read yesno
        if test "$yesno" = "" || test "$yesno" = "no"
        then
          ans=false
        elif test "$yesno" = "yes"
        then
          ans=true
        else
          echo "You must enter yes or no"
        fi
      done
      if [ $ans = true ]; then
        fsstnd=
      fi
    fi
  else
    echo ""
    if [ -d $FHSDIR ]; then
      echo "Using $FHSDIR for cat pages, following FHS."
      fhs=
    elif [ -d $FSSTNDDIR ]; then
      echo "Using $FSSTNDDIR for cat pages, following FSSTND."
      fsstnd=
    else
      echo "Using /usr/man/cat* (if that exists) for cat pages."
    fi
  fi
else
  if [ x$usefsstnd = xtrue ]; then
    fsstnd=
  elif [ x$usefhs = xtrue ]; then
    fhs=
  fi
fi

# How should man be installed?

if [ x$default = x ]; then
  for d in bindir sbindir mandir confdir
  do
    case $d in
      bindir)
        echo ""
        echo $n "Where should executables be installed?  [${bindir}] $c" ;;
      sbindir)
        echo ""
        echo $n "Where should makewhatis be installed?  [${sbindir}] $c" ;;
      confdir)
        echo ""
        echo $n "Where should $conffilename be installed?  [${confdir}] $c" ;;
      mandir)
        echo ""
        echo $n "Where should man pages be installed? [${mandir}] $c" ;;
    esac
    dd=`eval echo \\$$d`
    dir=$prefix/$dd
    ok=false
    while test "$ok" = "false"
    do
      read tmpdir
      if test "$tmpdir" = "" && test "$dir" != ""
      then
        if test -d $dir
        then
          ok=true
          eval $d=$dir
        else
          echo ""
          echo "$dir doesn't seem to exist!  Try again!"
        fi
      elif test -d "$tmpdir"
      then
        ok=true
        eval $d=$tmpdir
        newprefix=`echo $tmpdir | sed -e "s:/$dd::"`
        if test "$tmpdir" = "$newprefix/$dd"
        then
          prefix=$newprefix
        fi
      else
        ok=false
        echo ""
        echo "$tmpdir doesn't seem to exist!  Try again!"
      fi
    done
  done

  tmpext=1
  echo ""
  echo $n "What extension should installed man(1) pages have? [${tmpext}] $c"
  read man1ext
  if test "$man1ext" = ""; then man1ext=$tmpext; fi

  tmpext=5
  echo ""
  echo $n "What extension should installed man(5) pages have? [${tmpext}] $c"
  read man5ext
  if test "$man5ext" = ""; then man5ext=$tmpext; fi

  tmpext=8
  echo ""
  echo $n "What extension should installed man(8) pages have? [${tmpext}] $c"
  read man8ext
  if test "$man8ext" = ""; then man8ext=$tmpext; fi
else
  echo ""
  echo "Assuming that binaries go to $bindir, the configuration file"
  echo "goes to $confdir, makewhatis to $sbindir, and the man pages"
  echo "to $mandir/man*."
  man1ext=1
  man5ext=5
  man8ext=8
fi

if [ x$default = x ]; then
  echo ""
  echo $n "Do you want to install non-english man pages? [no] $c"
  ok=false
  while test "$ok" = "false"
  do
    read yesno
    if test "$yesno" = "" || test "$yesno" = "no"
    then
      ok=true
      ans=false
    elif test "$yesno" = "yes"
    then
      ok=true
      ans=true
    else
      ok=false
      echo "You must enter yes or no"
    fi
  done
else
  if [ "x$languages" = x ]; then
    echo ""
    echo "Assuming that you do not want to install non-english man pages."
  fi
  ans=false
fi

if test "$ans" = "true"
then
  cd man
  languages=""
  for i in ??; do
    langname=`cat $i.txt`
    echo $n "Install $langname pages? [no] $c"
    ok=false
    while test "$ok" = "false"
    do
      read yesno
      if test "$yesno" = "" || test "$yesno" = "no"
      then
        ok=true
        ans=false
      elif test "$yesno" = "yes"
      then
        ok=true
        ans=true
      else
        ok=false
        echo "You must enter yes or no"
      fi
    done
    if test "$ans" = "true"
    then
      languages="$languages $i"
    fi
  done
  cd ..
  if [ "x$languages" = x ]; then echo "Not installing any man pages, then."; fi
else
  if [ "x$languages" = x ]
  then
    languages="en"
  fi
fi

if [ "x$languages" != x -a "x$languages" != xen ]
then
  DEF_NLSPATH="/usr/share/locale/%L/%N:/usr/lib/locale/%N/%L"
  deflocalepath=`echo $NLSPATH:$DEF_NLSPATH | sed 's/:/ /g'`
  for i in $deflocalepath; do
    if [ x$deflocale = x ]; then
      tstdir=`echo $i | sed -e 's/%N//; s/%L//'`
      if [ -d "$tstdir" ]; then
	deflocale=$i
#      else
#	tstdir=`echo $i | sed -e 's/%N/*/; s/%L/*/'`
#	if [ -d "$tstdir" ]; then
#	  deflocale=$i
#	fi
      fi
    fi
  done
  if [ x$deflocale = x ]; then
    deflocale="/usr/lib/locale/%N/%L"
  fi
  if [ x$default = x ]; then
    echo ""
    echo $n "Do you want to install non-english message catalogs for man? [yes] $c"
    ok=false
    while test "$ok" = "false"
    do
      read yesno
      if test "$yesno" = "" || test "$yesno" = "yes"
      then
        ok=true
        ans=true
      elif test "$yesno" = "no"
      then
        ok=true
        ans=false
      else
        ok=false
        echo "You must enter yes or no"
      fi
    done
    if [ $ans = true ]; then
      echo $n "Where? [$deflocale] $c"
      read locale
      if [ x$locale = x ]; then
        locale=$deflocale
      fi
    else
      locale=
    fi
  else
    locale=$deflocale
  fi
  echo
  echo "Using localedir $locale"
fi

if [ x$suid = x -a x$sgid = x ]; then
  if [ x$default = x ]; then
    echo ""
    echo "Do you want to install man setuid or setgid to some user"
    echo $n "who owns all the formatted man pages?  [no] $c"
    ok=false
    while test "$ok" = "false"
    do
      read yesno
      if test "$yesno" = "" || test "$yesno" = "no"
      then
        ok=true
        ans=false
      elif test "$yesno" = "yes"
      then
        ok=true
        ans=true
      else
        ok=false
        echo "You must enter yes or no"
      fi
    done
  else
    echo "Assuming that you do not want man to be suid or sgid."
    echo "(But you can always do _chown man man; chmod 04555 man_ later.)"
    ans=false
  fi
else
  ans=true
fi

if test "$ans" = "true"
then
  # prefer uid/gid man above root, but prefer not to give man the
  # ability to write into its own binary; never install man suid root

  if [ x$sgid = x ]; then
    man_user=man
    man_mode=4555
    if grep -q '^man:' /etc/group >/dev/null 2>/dev/null;
    then
      man_group=man
    else
      man_group=root
    fi
    if grep -q '^man:' /etc/passwd >/dev/null 2>/dev/null;
    then
      :
    else
      echo "Warning: you still have to create a user \"man\""
    fi
  else
    man_user=root
    man_group=man
    man_mode=2555
    if grep -q '^man:' /etc/group >/dev/null 2>/dev/null;
    then
      :
    else
      echo "Warning: you still have to create a group \"man\""
    fi
  fi
  if [ x$default = x ]; then
    echo ""
    echo $n "What owner should man have? [${man_user}] $c"
    read user
    if test "$user" != ""; then man_user=$user; fi
    echo ""
    echo $n "What group should man have? [${man_group}] $c"
    read group
    if test "$group" != ""; then man_group=$group; fi
    echo ""
    echo $n "What mode should the installed man have? [${man_mode}] $c"
    read mode
    if test "$mode" != ""; then man_mode=$mode; fi
  fi
  man_install_flags="-m $man_mode -o $man_user -g $man_group"
fi

# What sections do we anticipate?

tmpsections="1 1p 8 2 3 3p 4 5 6 7 9 0p tcl n l p o"

if [ x$default = x ]; then
  echo ""
  echo "Enter the man page sections your system uses, separated by"
  echo "spaces, and in the order they should be searched."
  echo $n "[${tmpsections}] $c"
  read sects
  if test "$sects" != ""; then tmpsections="$sects"; fi
else
  echo
  echo "Setting the default section search order to $tmpsections."
fi

for sect in $tmpsections
do
  if [ x$sections = x ]; then
    sections=$sect
  else
    sections=$sections:$sect
  fi
done

if test "$nroff" != ""
then
  if [ x$default = x ]; then
    echo ""
    echo $n "Compress formatted pages? [yes] $c"
    ok=false
    while test "$ok" = "false"
    do
      read yesno
      if test "$yesno" = "" || test "$yesno" = "yes"
      then
        ok=true
        ans=true
      elif test "$yesno" = "no"
      then
        ok=true
        ans=false
      else
        ok=false
        echo "You must enter yes or no"
      fi
    done
  else
    echo ""
    echo "Assuming that formatted pages should be compressed."
    ans=true
  fi

  if test "$ans" = "true"
  then
    DO_COMPRESSION=true
    compress=
    for i in xz lzma bzip2 gzip bzip tzip pack compress freeze yabba
    do
      eval F$i=missing
      for j in $DEFPATH
      do
        if test -f $j/$i
        then
	  eval F$i=$j/$i
	  if [ x$compress = x ]; then compress=$j/$i; fi
	  break
        fi
      done
    done

    if [ x$default = x ]; then
      echo ""
      echo "What program should be used to compress the formatted pages?"
      echo $n "Note that it must work as a filter! [${compress}] $c"
      found=false
      while test "$found" = "false"
      do
        read tmp
        if test -n "$tmp"
        then
          if test -f `echo $tmp | $awk '{print $1}'`
          then
            found=true
            compress=$tmp
          else
            found=false
            echo ""
            echo "`echo $tmp | $awk '{print $1}'` doesn't seem to exist!  Try again!"
          fi
        elif test -f `echo "$compress" | $awk '{print $1}'`
        then
          found=true
        else
          found=false
          echo ""
          echo "`echo "$compress" | $awk '{print $1}'` doesn't seem to exist!  Try again!"
        fi
      done
    else
      if [ x$compress = x ]
      then
	DO_COMPRESSION=false
	echo "Could not find any compression programs."
      else
        echo "Using $compress for compression."
      fi
    fi

    case $compress in
      *xz*) ext=".xz" ;;
      *lzma*) ext=".lzma" ;;
      *bzip2*) ext=".bz2" ;;
      *gzip*) ext=".gz" ;;
      *bzip*) ext=".bz" ;;
      *tzip*) ext=".tz" ;;
      *pack*) ext=".z" ;;
      *compress*) ext=".Z" ;;
      *freeze*) ext=".F" ;;
      *yabba*) ext=".Y" ;;
      *) ext="" ;;
    esac
    if [ x$default = x ]; then
      echo ""
      echo "What extension should be added to"
      if test "$ext" = ""
      then
        echo "compressed files?"
      else
        echo $n "compressed files?  [${ext}] $c"
      fi
      ok=false
      while test "$ok" = "false"
      do
        read tmp_ext
        if test "$tmp_ext" = "" && test "$ext" != ""
        then
          ok=true
          compress_ext=$ext
        elif test "$tmp_ext" != ""
        then
          ok=true
          compress_ext=$tmp_ext
        fi
      done
    else
      compress_ext=$ext
    fi
  else
    DO_COMPRESSION=false
  fi
fi

# unconditionally handle uncompression
UNCOMPRESSORS="unxz unlzma gunzip bzip2 pcat zcat fcat unyabba"
for i in $UNCOMPRESSORS
do
  eval F$i=missing
  for j in $DEFPATH
  do
    if test -f $j/$i
    then
      eval F$i=$j/$i
      break
    fi
  done
done
unxz=missing
if [ $Funxz != missing ]; then
  unxz="$Funxz -c"
fi
gunzip=missing
if [ $Fgunzip != missing ]; then
  gunzip="$Fgunzip -c"
fi
bzip2=missing
if [ $Fbzip2 != missing ]; then
  bzip2="$Fbzip2 -c -d"
fi
unlzma=missing
if [ $Funlzma != missing ]; then
  unlzma="$Funlzma -c -d"
fi
pcat="$Fpcat"
zcat="$Fzcat"
fcat="$Ffcat"
unyabba="$Funyabba"

if [ x$default = x ]; then
  echo ""
  echo "Now let us look at programs for uncompressing compressed man pages."
  echo ""
  echo "If you don't have one of the following programs, enter \`missing'."
  echo "It's best to enter absolute pathnames so that man won't have to"
  echo "depend on the user's path to work properly.  Default values are"
  echo "given in square brackets.  The answers given are only checked to"
  echo "see if the programs exist, not to see see if the given flags are"
  echo "correct."
  for filter in $UNCOMPRESSORS
  do
    found=false
    while test "$found" = "false"
    do
      echo ""
      case $filter in
	unxz)
	  echo "Command to use for .xz files (standard xz)"
	  echo $n "[`eval echo \\$$filter`] $c" ;;
	gunzip)
	  echo "Command to use for .gz files (standard gzip)"
	  echo $n "[`eval echo \\$$filter`] $c" ;;
	bzip2)
	  echo "Command to use for .bz2 files (standard bzip2)"
	  echo $n "[`eval echo \\$$filter`] $c" ;;
	unlzma)
	  echo "Command to use for .lzma files (standard lzma)"
	  echo $n "[`eval echo \\$$filter`] $c" ;;
        pcat)
          echo "Command to use for .z files (pack/unpack)"
          echo $n "[`eval echo \\$$filter`] $c" ;;
        zcat)
          echo "Command to use for .Z files (standard compress)"
          echo $n "[`eval echo \\$$filter`] $c" ;;
        fcat)
          echo "Command to use for .F files (freeze/melt from net posting)"
          echo $n "[`eval echo \\$$filter`] $c" ;;
        unyabba)
          echo "Command to use for .Y files (yabba/unyabba from net posting)"
          echo $n "[`eval echo \\$$filter`] $c" ;;
        esac
      read tmp
      if test -n "$tmp"
      then
        if test "$tmp" = "missing"
        then
          found=true
          eval $filter=""
        elif test -f `echo $tmp | $awk '{print $1}'`
        then
          found=true
          eval $filter=\""$tmp"\"
        else
          found=false
          echo ""
          echo "`echo $tmp | $awk '{print $1}'` doesn't seem to exist!  Try again or enter \`missing'"
        fi
      elif test `eval echo \\$$filter | $awk '{print $1}'` = "missing"
      then
        found=true
        eval $filter=""
      elif test -f `eval echo \\$$filter | $awk '{print $1}'`
      then
        found=true
      else
        found=false
        echo ""
        echo "`eval echo \\$$filter | $awk '{print $1}'` doesn't seem to exist!  Try again or enter \`missing'"
      fi
    done
  done
else
  echo ""
  echo "Assuming the following ways to invoke the various decompressors:"
  for filter in $UNCOMPRESSORS
  do
    echo "$filter command:   	`eval echo \\$$filter`"
    if test `eval echo \\$$filter | $awk '{print $1}'` = "missing"
    then
      eval $filter=""
    fi
  done
fi

# set $decompress to the program that decompresses things
# with the $compress_ext extension.
case $compress_ext in
  .xz) decompress=$unxz ;;
  .gz) decompress=$gunzip ;;
  .bz2) decompress=$bzip2 ;;
  .lzma) decompress=$unlzma ;;
  .z) decompress=$pcat ;;
  .Z) decompress=$zcat ;;
  .F) decompress=$fcat ;;
  .Y) decompress=$unyabba ;;
  *) decompress= ;;
esac

if test "$DO_COMPRESSION" = "true"
then
  DEFS="$DEFS -DDO_COMPRESS"
fi

man=$bindir/man$EXEEXT
apropos=$bindir/apropos
whatis=$bindir/whatis
man2dvi=$bindir/man2dvi
makewhatis=$sbindir/makewhatis
man_config_dir=$confdir
man_config_file=$confdir/$conffilename

if [ x$locale = x ]; then
  sed -e 's/%.*//' < Makefile.in > Makefile
else
  sed -e 's/%//' < Makefile.in > Makefile
fi

# some definitions to avoid extensive quoting in the script below
allargs='$@'
infiles='$infiles'
infile='$infile'
shebang='`sed -n -e 1p $infile.in`'
cb='$cb'
cs='$cs'
ce='$ce'
mancomment='.\\\"'

# Note: the script below only works when none of the variables
# contains a comma.
version=`cat version`

cat > conf_script << EOS
#!/bin/sh
infiles=$allargs
trap 'rm -f $infiles; exit 1' 1 3 15

# echo ""
for infile in $infiles
do
  case $infile in
  *.h)
    cb="/*"; cs=" *"; ce=" */";;
  *.1|*.5|*.8|*.man)
    cb=$mancomment; cs=$mancomment; ce=$mancomment;;
  *)
    case "$shebang" in
    '#!'*) cb="$shebang";;
    *)     cb="#";;
    esac
    cs="#"; ce="#";;
  esac
  echo "$cb"                                                    > $infile
  echo "$cs Generated automatically from $infile.in by the"     >> $infile
  echo "$cs configure script."                                  >> $infile
  echo "$ce"                                                    >> $infile
  echo "Creating $infile from $infile.in"
  sed -e '
s,@version@,$version,
s,@CC@,$CC,
s,@EXEEXT@,$EXEEXT,
s,@BUILD_CC@,$BUILD_CC,
s,@INSTALL@,$INSTALL,
s,@DEFS@,$DEFS,
s,@LIBS@,$LIBS,
s,@LIBOBJS@,$LIBOBJS,
s,@troff@,$troff,
s,@nroff@,$nroff,
s,@jnroff@,$jnroff,
s,@eqn@,$eqn,
s,@neqn@,$neqn,
s,@jneqn@,$jneqn,
s,@tbl@,$tbl,
s,@nocol@,$nocol,
s,@pcol@,$pcol,
s,@col@,$col,
s,@vgrind@,$vgrind,
s,@refer@,$refer,
s,@grap@,$grap,
s,@pic@,$pic,
s,@fcat@,$fcat,
s,@pcat@,$pcat,
s,@zcat@,$zcat,
s,@unxz@,$unxz,
s,@gunzip@,$gunzip,
s,@bzip2@,$bzip2,
s,@unlzma@,$unlzma,
s,@unyabba@,$unyabba,
s,@compress@,$compress,
s,@compress_ext@,$compress_ext,
s,@decompress@,$decompress,
s,@pager@,$pager,
s,@browser@,$browser,
s,@htmlpager@,$htmlpager,
s,@cmp@,$cmp,
s,@cat@,$cat,
s,@awk@,$awk,
s,@bindir@,$bindir,
s,@sbindir@,$sbindir,
s,@mandir@,$mandir,
s,@locale@,$locale,
s,@fhs@,$fhs,
s,@fsstnd@,$fsstnd,
s,@man1ext@,$man1ext,g
s,@man5ext@,$man5ext,g
s,@man8ext@,$man8ext,g
s,@man_install_flags@,$man_install_flags,
s,@man_user@,$man_user,
s,@languages@,$languages,
s,@man@,$man,
s,@apropos@,$apropos,
s,@whatis@,$whatis,
s,@man2dvi@,$man2dvi,
s,@makewhatis@,$makewhatis,
s,@man_config_dir@,$man_config_dir,
s,@man_config_file@,$man_config_file,
s,@manpathoption@,$manpathoption,
s/@sections@/$sections/
' $infile.in >> $infile
done
EOS

chmod +x conf_script

echo ""
echo 'Created Makefile and conf_script. Now do "make" and "make install".'
echo ""