summaryrefslogtreecommitdiff
path: root/unix/configure
blob: 73ba803ba06bcd8510cd5a8f5860e86872c93f59 (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
:
#!/bin/sh -x
# The above : is necessary on some buggy systems.

# configure: Guess values for system-dependent variables
# Output the flag definitions to the file "flags".
#
# Parameters: $1 = $CC, $2 = $CFLAGS, $3 = $IZ_BZIP2
#
# This file is typically called from Makefile rather than executed
# from the command line.
#
# To construct zip automatically using this file, type
# "make -f unix/Makefile generic".
# If this fails, then type "make list" to get a list of special targets.

trap "rm -f conftest* core a.out; exit 1" 1 2 3 15

CC=${1-cc}
CFLAGS=${2-"-I. -DUNIX"}
LFLAGS1=''
LFLAGS2=''
LN="ln -s"

CFLAGS_OPT=''

# bzip2
IZ_BZIP2=${3-}
CFLAGS_BZ=''


echo 'Check C compiler type (optimization options)'
# Sun C?
cat > conftest.c << _EOF_
int main()
{
#ifndef __SUNPRO_C
   bad code
#endif
   return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
if test $? -eq 0; then
  CFLAGS_OPT='-xO3'
  echo "  Sun C ($CFLAGS_OPT)"
else
  # Tru64 DEC/Compaq/HP C?
  cat > conftest.c << _EOF_
int main()
{
#ifndef __DECC
   bad code
#endif
   return 0;
}
_EOF_
  $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  if test $? -eq 0; then
    CFLAGS_OPT='-O3'
    echo "  DEC C ($CFLAGS_OPT)"
  else
    # HP-UX HP C?
    cat > conftest.c << _EOF_
int main()
{
#ifdef __GNUC__
   bad code
#endif
#ifndef __hpux
   bad code
#endif
   return 0;
}
_EOF_
    $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
    if test $? -eq 0; then
      # HP-UX, not GCC.  Lame bundled or real ANSI compiler?
      CFLAGS_OPT_TRY="+O3 +Onolimit"
      $CC $CFLAGS $CFLAGS_OPT_TRY -c conftest.c 2>&1 | \
       grep '(Bundled)' > /dev/null
      if test $? -ne 0; then
        CFLAGS_OPT="$CFLAGS_OPT_TRY"
        echo "  HP-UX ANSI C ($CFLAGS_OPT)"
      else
        echo '  HP-UX Bundled C (no opt)'
      fi
    else
      # GNU C?
      cat > conftest.c << _EOF_
int main()
{
#ifndef __GNUC__
   bad code
#endif
   return 0;
}
_EOF_
      $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
      if test $? -eq 0; then
        CFLAGS_OPT='-O3'
        echo "  GNU C ($CFLAGS_OPT)"
        # Special Mac OS X shared library "ld" option?
        if test ` uname -s 2> /dev/null ` = 'Darwin'; then
          lf='-Wl,-search_paths_first'
          $CC $CFLAGS $lf conftest.c > /dev/null 2>/dev/null
          if test $? -eq 0; then
            LFLAGS2="${LFLAGS2} ${lf}"
          fi
          rm -f conftest
        fi
      else
        CFLAGS_OPT='-O'
        echo "  Other-unknown C ($CFLAGS_OPT)"
      fi
    fi
  fi
fi

# optimization flags
if test -n "${CFLAGS_OPT}"; then
  CFLAGS="${CFLAGS} ${CFLAGS_OPT}"
  CFLAGS_BZ="${CFLAGS_BZ} ${CFLAGS_OPT}"
fi


# bzip2

echo "Check bzip2 support"
CC_BZ="${CC}"
LIB_BZ=''
if test -n "${IZ_BZIP2}"; then
  echo "  Check for bzip2 compiled library in IZ_BZIP2 (${IZ_BZIP2})"
  if test -f "${IZ_BZIP2}/libbz2.a"; then
#
#   A bzip2 library built with BZ_NO_STDIO should have an
#   unresolved external, "bz_internal_error".  The default,
#   full-function library will not mention it.
#
    nm ${IZ_BZIP2}/libbz2.a | grep bz_internal_error > /dev/null
    if test $? -eq 0; then
      echo "    Found bzip2 BZ_NO_STDIO library, ${IZ_BZIP2}/libbz2.a"
    else
      echo "    Found bzip2 library, ${IZ_BZIP2}/libbz2.a,"
      echo "      but library not compiled with BZ_NO_STDIO"
      echo "    WARNING:  We recommend using a bzip2 library compiled"
      echo "      with BZ_NO_STDIO defined for proper error handling"
      echo "    Please see the Zip installation instructions in bzip2/install.txt"
      echo "    Continuing anyway with standard bzip2 library..."
    fi
    if test -f "${IZ_BZIP2}/bzlib.h"; then
      CFLAGS="${CFLAGS} -I${IZ_BZIP2} -DBZIP2_SUPPORT"
      LFLAGS2="${LFLAGS2} -L${IZ_BZIP2} -lbz2"
      echo "-- Found bzip2 library - linking in bzip2"
    else
      echo "    ${IZ_BZIP2}/bzlib.h not found"
      echo "-- Since IZ_BZIP2 defined, skipping OS and bzip2 dir checks - no bzip2"
    fi
  else
    echo "    ${IZ_BZIP2}/libbz2.a not found"
    echo "-- Since IZ_BZIP2 defined, skipping OS and bzip2 checks - no bzip2"
  fi
else
  echo "  Check for bzip2 in bzip2 directory"
  IZ_BZIP2=bzip2
  if test -f "${IZ_BZIP2}/libbz2.a"; then
    nm ${IZ_BZIP2}/libbz2.a | grep bz_internal_error > /dev/null
    if test $? -eq 0; then
      echo "    Found bzip2 BZ_NO_STDIO library in bzip2 directory"
    else
      echo "    Found bzip2 library in bzip2 directory,"
      echo "      but not built with the BZ_NO_STDIO option"
      echo "    WARNING:  We recommend using a bzip2 library compiled"
      echo "      with BZ_NO_STDIO defined for proper error handling"
      echo "    Please see the Zip installation instructions"
      echo "    Continuing anyway with standard bzip2 library..."
    fi
  fi
  if test -f "bzip2/bzlib.h" -a -f "bzip2/libbz2.a"; then
    CFLAGS="${CFLAGS} -I${IZ_BZIP2} -DBZIP2_SUPPORT"
    LFLAGS2="${LFLAGS2} -Lbzip2 -lbz2"
    echo "-- Found bzip2 library - linking in bzip2"
  else
    if test -f "bzip2/bzlib.c" -a -f "bzip2/bzlib.h"; then
      echo "-- No library, but found bzip2 source in bzip2 directory"
      echo "-- Will try to build bzip2 library from source and link in"
#
# Arrange to build a BZ_NO_STDIO bzip2 object library using the
# same compiler and optimization options as used for Zip, and
# to compile and link Zip with bzip2.
#
      CFLAGS_BZ="${CFLAGS_BZ} -DBZ_NO_STDIO"
      LIB_BZ="bzip2/libbz2.a"
      CFLAGS="${CFLAGS} -Ibzip2 -DBZIP2_SUPPORT"
      LFLAGS2="${LFLAGS2} -Lbzip2 -lbz2"
    else
      echo "  Check if OS already has bzip2 library installed"
      cat > conftest.c << _EOF_
#include "bzlib.h"
int main()
{
  bz_stream strm;
  BZ2_bzCompressEnd(&strm);
  return 0;
}
_EOF_
      $CC $CFLAGS -o conftest conftest.c -lbz2 > /dev/null 2>/dev/null
      if test $? -eq 0; then
        echo "-- OS supports bzip2 - linking in bzip2"
        CFLAGS="${CFLAGS} -DBZIP2_SUPPORT"
        LFLAGS2="${LFLAGS2} -lbz2"
      else
        echo "-- Either bzlib.h or libbz2.a not found - no bzip2"
      fi
    fi
  fi
fi


echo Check for the C preprocessor
# on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
CPP="${CC} -E"
# solaris as(1) needs -P, maybe others as well ?
[ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
[ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
[ -f /lib/cpp ] && CPP=/lib/cpp
[ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
[ -f /xenix ] && CPP="${CC} -E"
[ -f /lynx.os ] && CPP="${CC} -E"

echo "#include <stdio.h>" > conftest.c
$CPP conftest.c >/dev/null 2>/dev/null || CPP="${CC} -E"


echo Check if we can use asm code
OBJA=""
OCRCU8=""
if eval "$CPP match.S > _match.s 2>/dev/null"; then
  if test ! -s _match.s || grep error < _match.s > /dev/null; then
    :
  elif eval "$CC -c _match.s >/dev/null 2>/dev/null" && [ -f _match.o ]; then
    CFLAGS="${CFLAGS} -DASMV"
    OBJA="match.o"
    echo "int foo() { return 0;}" > conftest.c
    $CC -c conftest.c >/dev/null 2>/dev/null
    echo Check if compiler generates underlines
    nm conftest.o | grep "(^|[^_])foo" >/dev/null 2>/dev/null
    [ $? -eq 0 ] && CPP="${CPP} -DNO_UNDERLINE"
    if eval "$CPP crc_i386.S > _crc_i386.s 2>/dev/null"; then
      if eval "$CC -c _crc_i386.s >/dev/null 2>/dev/null" && [ -f _crc_i386.o ]
      then
        OBJA="$OBJA crc_i386.o"
        OCRCU8="crc_i386.o"
        CFLAGS="${CFLAGS} -DASM_CRC"
      fi
    fi
  fi
fi
rm -f _match.s _match.o _crc_i386.s _crc_i386.o


# ANSI options for compilers that don't have __STDC__ defined by default
# Currently HPUX, pyramid, Dynix, AIX, OSF/1 and ultrix

echo Check for ANSI options
cat > conftest.c << _EOF_
int main()
{
#ifndef __STDC__
   forget it
#endif
   return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
  for OPT in -Ae -Xa -qlanglvl=ansi -std1 -std
  do
    $CC $CFLAGS $OPT -c conftest.c > /dev/null 2>/dev/null
    [ $? -eq 0 ] && CFLAGS="${CFLAGS} ${OPT}" && break
  done
fi


echo Check for prototypes
echo "int main(int argc, char *argv[]) { return 0; }" > conftest.c
$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_PROTO"

# const check currently handles mips cc and non ANSI compilers.
# does it need more ?
echo Check the handling of const
cat > conftest.c << _EOF_
typedef int charset[2];
int main()
{
  const charset x;
  const char *foo;
  return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_CONST"


echo Check for time_t
cat > conftest.c << _EOF_
#include <sys/types.h>
#include <time.h>
int main()
{
  time_t t;
  return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_TIME_T"


echo Check for size_t
cat > conftest.c << _EOF_
#include <sys/types.h>
int main()
{
  size_t s;
  return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_SIZE_T"


echo Check for off_t
cat > conftest.c << _EOF_
#include <sys/types.h>
int main()
{
  off_t s;
  return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_OFF_T"


echo Check size of UIDs and GIDs
echo "(Now zip stores variable size UIDs/GIDs using a new extra field.  This"
echo " tests if this OS uses 16-bit UIDs/GIDs and so if the old 16-bit storage"
echo " should also be used for backward compatibility.)"
# Added 2008-04-15 CS
cat > conftest.c << _EOF_
# define _LARGEFILE_SOURCE          /* some OSes need this for fseeko */
# define _LARGEFILE64_SOURCE
# define _FILE_OFFSET_BITS 64       /* select default interface as 64 bit */
# define _LARGE_FILES               /* some OSes need this for 64-bit off_t */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
  struct stat s;

  printf("  s.st_uid is %u bytes\n", sizeof(s.st_uid));
  printf("  s.st_gid is %u bytes\n", sizeof(s.st_gid));

  /* see if have 16-bit UID */
  if (sizeof(s.st_uid) != 2) {
    return 1;
  }
  /* see if have 16-bit GID */
  if (sizeof(s.st_gid) != 2) {
    return 2;
  }
  return 3;
}
_EOF_
# compile it
$CC -o conftest conftest.c >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
  echo -- UID/GID test failed on compile - disabling old 16-bit UID/GID support
  CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
else
# run it
  ./conftest
  r=$?
  if [ $r -eq 1 ]; then
    echo -- UID not 2 bytes - disabling old 16-bit UID/GID support
    CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  elif [ $r -eq 2 ]; then
    echo -- GID not 2 bytes - disabling old 16-bit UID/GID support
    CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  elif [ $r -eq 3 ]; then
    echo -- 16-bit UIDs and GIDs - keeping old 16-bit UID/GID support
  else
    echo -- test failed - conftest returned $r - disabling old 16-bit UID/GID support
    CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
  fi
fi


# Now we set the 64-bit file environment and check the size of off_t
# Added 11/4/2003 EG
# Revised 8/12/2004 EG

echo Check for Large File Support
cat > conftest.c << _EOF_
# define _LARGEFILE_SOURCE       /* some OSes need this for fseeko */
# define _LARGEFILE64_SOURCE
# define _FILE_OFFSET_BITS 64       /* select default interface as 64 bit */
# define _LARGE_FILES        /* some OSes need this for 64-bit off_t */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
  off_t offset;
  struct stat s;
  /* see if have 64-bit off_t */
  if (sizeof(offset) < 8)
    return 1;
  printf("  off_t is %d bytes\n", sizeof(off_t));
  /* see if have 64-bit stat */
  if (sizeof(s.st_size) < 8) {
    printf("  s.st_size is %d bytes\n", sizeof(s.st_size));
    return 2;
  }
  return 3;
}
_EOF_
# compile it
$CC -o conftest conftest.c >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
  echo -- no Large File Support
else
# run it
  ./conftest
  r=$?
  if [ $r -eq 1 ]; then
    echo -- no Large File Support - no 64-bit off_t
  elif [ $r -eq 2 ]; then
    echo -- no Large File Support - no 64-bit stat
  elif [ $r -eq 3 ]; then
    echo -- yes we have Large File Support!
    CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
  else
    echo -- no Large File Support - conftest returned $r
  fi
fi


# Check for wide char for Unicode support
# Added 11/24/2005 EG

echo Check for wide char support
cat > conftest.c << _EOF_
#include <stdlib.h>
#include <stdio.h>
int main()
{
  int wsize;
  wchar_t *wide_string;

  if ((wide_string = (wchar_t *)malloc(4 * sizeof(wchar_t))) == NULL) {
    return 0;
  }
  /* get wide string */
  wsize = mbstowcs(wide_string, "foo", 3);
  wide_string[wsize] = (wchar_t) NULL;
  return 1;
}
_EOF_
# compile it
$CC -o conftest conftest.c >/dev/null 2>/dev/null
# OCRCU8 is used by all utilities if Unicode is enabled
# OCRCTB is only used by zipcloak
if [ $? -ne 0 ]; then
  echo -- no Unicode support
  OCRCU8=""
  OCRCTB="crc32_.o"
else
# have wide char support
  echo -- have wchar_t - enabling Unicode support
  CFLAGS="${CFLAGS} -DUNICODE_SUPPORT"
  OCRCU8="crc32_.o ${OCRCU8}"
  OCRCTB=""
fi


# from configure 2.4i (Onno) 12/5/04

echo Check for gcc no-builtin flag
# -fno-builtin since version 2
cat > conftest.c << _EOF_
int main()
{
#if __GNUC__ >= 2
   return 0;
#else
   forget it
#endif
}
_EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -eq 0 ] && BFLAG="-fno-builtin"


# Check for missing functions
# add NO_'function_name' to flags if missing

for func in rmdir strchr strrchr rename mktemp mktime mkstemp
do
  echo Check for $func
  echo "int main(){ $func(); return 0; }" > conftest.c
  $CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
  [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
done


echo Check for memset
echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
$CC -o conftest conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"


echo Check for memmove
cat > conftest.c << _EOF_
#include <string.h>
int main() { int a; int b = 0; memmove( &a, &b, sizeof( a)); return a; }
_EOF_
$CC -o conftest conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNEED_MEMMOVE"


echo Check for strerror
cat > conftest.c << _EOF_
#include <string.h>
int main() { strerror( 0); return 0; }
_EOF_
$CC -o conftest conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNEED_STRERROR"

echo Check for errno declaration
cat > conftest.c << _EOF_
#include <errno.h>
main()
{
  errno = 0;
  return 0;
}
_EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO"


echo Check for directory libraries
cat > conftest.c << _EOF_
int main() { return closedir(opendir(".")); }
_EOF_

$CC -o conftest conftest.c >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
  OPT=""
  for lib in ndir dir ucb bsd BSD PW x dirent
  do
    $CC -o conftest conftest.c -l$lib >/dev/null 2>/dev/null
    [ $? -eq 0 ] && OPT=-l$lib && break
  done
  if [ ${OPT} ]; then
    LFLAGS2="${LFLAGS2} ${OPT}"
  else
    CFLAGS="${CFLAGS} -DNO_DIR"
  fi
fi


# Dynix/ptx 1.3 needed this

echo Check for readlink
echo "int main(){ return readlink(); }" > conftest.c
$CC -o conftest conftest.c >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
  $CC -o conftest conftest.c -lseq >/dev/null 2>/dev/null
  [ $? -eq 0 ] && LFLAGS2="${LFLAGS2} -lseq"
fi


echo Check for directory include file
OPT=""
for inc in dirent.h sys/ndir.h ndir.h sys/dir.h
do
   echo "#include <$inc>" > conftest.c
   $CPP conftest.c > /dev/null 2>/dev/null
   [ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
done
CFLAGS="${CFLAGS} ${OPT}"


echo Check for nonexistent include files
for inc in stdlib.h stddef.h unistd.h fcntl.h string.h
do
   echo "#include <$inc>" > conftest.c
   $CPP conftest.c >/dev/null 2>/dev/null
   [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
done


echo Check for term I/O include file
OPT=""
for inc in termios.h termio.h sgtty.h
do
   echo "#include <$inc>" > conftest.c
   $CPP conftest.c > /dev/null 2>/dev/null
   [ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
done
CFLAGS="${CFLAGS} ${OPT}"


# needed for AIX (and others ?) when mmap is used

echo Check for valloc
cat > conftest.c << _EOF_
main()
{
#ifdef MMAP
    valloc();
#endif
}
_EOF_
$CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC"


echo Check for /usr/local/bin and /usr/local/man
BINDIR=$HOME/bin
[ -d /usr/local/bin ] && BINDIR=/usr/local/bin

MANDIR=manl
[ -d /usr/man/manl ]       && MANDIR=/usr/man/manl
[ -d /usr/local/man/manl ] && MANDIR=/usr/local/man/manl
[ -d /usr/local/man/man1 ] && MANDIR=/usr/local/man/man1


echo Check for OS-specific flags
if [ -f /usr/bin/hostinfo ]; then
  if /usr/bin/hostinfo | grep NeXT > /dev/null; then
    CFLAGS="${CFLAGS} -posix"
    LFLAGS1="${LFLAGS1} -posix -object"
  fi
# XXX ATT6300, Cray
elif [ -f /xenix ]; then
  if uname -p | grep 286 > /dev/null; then
    CFLAGS="${CFLAGS} -LARGE -Mel2 -DMEDIUM_MEM -DWSIZE=16384 -DNO_VOID"
    LFLAGS1="${LFLAGS1} -LARGE -Mel2"
  fi
elif uname -X >/dev/null 2>/dev/null; then
# SCO shared library check
  echo "int main() { return 0;}" > conftest.c
  $CC -o conftest conftest.c -lc_s -nointl >/dev/null 2> /dev/null
  [ $? -eq 0 ] && LFLAGS2="-lc_s -nointl"
else
  SYSTEM=`uname -s 2>/dev/null` || SYSTEM="unknown"
  echo "int main() { return 0;}" > conftest.c
  case $SYSTEM in
     OSF1|ULTRIX)
        echo Check for -Olimit option
        $CC ${CFLAGS} -Olimit 1000 -o conftest conftest.c >/dev/null 2>/dev/null
        [ $? -eq 0 ] && CFLAGS="${CFLAGS} -Olimit 1000"
        ;;
###     HP-UX)
###        echo Check for +Onolimit option
###        $CC ${CFLAGS} +Onolimit -o conftest conftest.c >/dev/null 2>/dev/null
###        [ $? -eq 0 ] && CFLAGS="${CFLAGS} +Onolimit"
###        ;;
###     SunOS)
###        CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
###        ;;
  esac
fi


echo Check for symbolic links
ln -s /dev/null null > /dev/null 2>/dev/null || LN=ln


rm -f a.out conftest.c conftest.o conftest null

echo CC=\"${CC}\" CFLAGS=\"${CFLAGS}\"  CPP=\"${CPP}\" OBJA=\"${OBJA}\" \
       OCRCU8=\"${OCRCU8}\" OCRCTB=\"${OCRCTB}\" \
       BINDIR=${BINDIR} MANDIR=${MANDIR} LFLAGS1=\"${LFLAGS1}\" \
       LFLAGS2=\"${LFLAGS2}\" LN=\"${LN}\" \
       CC_BZ=\"${CC_BZ}\" CFLAGS_BZ=\"${CFLAGS_BZ}\" \
       IZ_BZIP2=\"${IZ_BZIP2}\" LIB_BZ=\"${LIB_BZ}\" > flags