forked from zlib-ng/zlib-ng
-
Notifications
You must be signed in to change notification settings - Fork 12
/
configure
executable file
·2188 lines (2020 loc) · 72.7 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
# configure script for zlib.
#
# Normally configure builds both a static and a shared library.
# If you want to build just a static library, use: ./configure --static
#
# To impose specific compiler or flags or install directory, use for example:
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
# or for csh/tcsh users:
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
# If you have problems, try without defining CC and CFLAGS before reporting
# an error.
# start off configure.log
echo -------------------- >> configure.log
echo $0 $* >> configure.log
date >> configure.log
SRCDIR=$(cd $(dirname $0); pwd)
BUILDDIR=$(pwd)
# set command prefix for cross-compilation
if [ -n "${CHOST}" ]; then
# normalize the chost before parsing it
NORM_CHOST=$(sh "$SRCDIR"/tools/config.sub $CHOST)
uname="$(echo "${NORM_CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')"
CROSS_PREFIX="${CHOST}-"
ARCH="$(echo "${NORM_CHOST}" | sed -e 's/-.*//')"
else
ARCH="$(uname -m)"
fi
case "${ARCH}" in
x86_64)
case "${CFLAGS}" in
*-m32*)
ARCH=i686
;;
esac
;;
i386 | i486 | i586 | i686)
case "${CFLAGS}" in
*-m64*)
ARCH=x86_64
;;
esac
;;
esac
# destination name for windows import library
IMPORTLIB=
# establish commands for library building
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
AR=${AR-"${CROSS_PREFIX}ar"}
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
else
AR=${AR-"ar"}
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
fi
ARFLAGS=${ARFLAGS-"rc"}
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
else
RANLIB=${RANLIB-"ranlib"}
fi
# set defaults before processing command line options
LDCONFIG=${LDCONFIG-"ldconfig"}
DEFFILE=
RC=
RCFLAGS=
RCOBJS=
STRIP=
ARCHS=
PC_CFLAGS=
prefix=${prefix-/usr/local}
exec_prefix=${exec_prefix-'${prefix}'}
bindir=${bindir-'${exec_prefix}/bin'}
libdir=${libdir-'${exec_prefix}/lib'}
sharedlibdir=${sharedlibdir-'${libdir}'}
includedir=${includedir-'${prefix}/include'}
mandir=${mandir-'${prefix}/share/man'}
shared_ext='.so'
shared=1
gzfileops=1
unalignedok=1
compat=0
cover=0
build32=0
build64=0
buildvpclmulqdq=1
buildacle=1
buildarmv6=1
buildaltivec=1
buildpower8=1
buildpower9=1
buildneon=1
builddfltccdeflate=0
builddfltccinflate=0
buildcrc32vx=1
floatabi=
forcesse2=0
# For CPUs that can benefit from AVX512, it seems GCC generates suboptimal
# instruction scheduling unless you specify a reasonable -mtune= target
avx512flag="-mavx512f -mavx512dq -mavx512bw -mavx512vl"
avx512vnniflag="${avx512flag} -mavx512vnni"
avx2flag="-mavx2"
sse2flag="-msse2"
ssse3flag="-mssse3"
sse42flag="-msse4.2"
pclmulflag="-mpclmul"
vpclmulflag="-mvpclmulqdq -mavx512f"
xsaveflag="-mxsave"
acleflag=
neonflag=
armv6flag=
noltoflag="-fno-lto"
vgfmaflag="-march=z13"
vmxflag="-maltivec"
symbol_prefix=""
without_optimizations=0
without_new_strategies=0
reducedmem=0
gcc=0
warn=0
debug=0
visibility=1
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ)'
PIC_OBJC='$(PIC_OBJZ)'
INSTALLTARGETS="install-shared install-static"
UNINSTALLTARGETS="uninstall-shared uninstall-static"
TEST="teststatic"
# leave this script, optionally in a bad way
leave()
{
if test "$*" != "0"; then
echo "** $0 aborting." | tee -a configure.log
fi
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
echo -------------------- >> configure.log
echo >> configure.log
echo >> configure.log
exit $1
}
# process command line options
while test $# -ge 1
do
case "$1" in
-h* | --help)
echo 'usage:' | tee -a configure.log
echo ' configure [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
echo ' [--static] [--32] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
echo ' [--sprefix=SYMBOL_PREFIX] Adds a prefix to all exported symbols' | tee -a configure.log
echo ' [--warn] Enables extra compiler warnings' | tee -a configure.log
echo ' [--debug] Enables extra debug prints during operation' | tee -a configure.log
echo ' [--zlib-compat] Compiles for zlib-compatible API instead of zlib-ng API' | tee -a configure.log
echo ' [--without-unaligned] Compiles without fast unaligned access' | tee -a configure.log
echo ' [--without-gzfileops] Compiles without the gzfile parts of the API enabled' | tee -a configure.log
echo ' [--without-optimizations] Compiles without support for optional instruction sets' | tee -a configure.log
echo ' [--without-new-strategies] Compiles without using new additional deflate strategies' | tee -a configure.log
echo ' [--without-acle] Compiles without ARM C Language Extensions' | tee -a configure.log
echo ' [--without-neon] Compiles without ARM Neon SIMD instruction set' | tee -a configure.log
echo ' [--without-armv6] Compiles without ARMv6 SIMD instruction set' | tee -a configure.log
echo ' [--without-altivec] Compiles without PPC AltiVec support' | tee -a configure.log
echo ' [--without-power8] Compiles without Power8 instruction set' | tee -a configure.log
echo ' [--with-dfltcc-deflate] Use DEFLATE CONVERSION CALL instruction for compression on IBM Z' | tee -a configure.log
echo ' [--with-dfltcc-inflate] Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z' | tee -a configure.log
echo ' [--without-crc32-vx] Build without vectorized CRC32 on IBM Z' | tee -a configure.log
echo ' [--with-reduced-mem] Reduced memory usage for special cases (reduces performance)' | tee -a configure.log
echo ' [--force-sse2] Assume SSE2 instructions are always available (disabled by default on x86, enabled on x86_64)' | tee -a configure.log
exit 0 ;;
-p*=* | --prefix=*) prefix=$(echo $1 | sed 's/.*=//'); shift ;;
-e*=* | --eprefix=*) exec_prefix=$(echo $1 | sed 's/.*=//'); shift ;;
-m*=* | --sprefix=*) symbol_prefix=$(echo $1 | sed 's/.*=//'); shift ;;
-l*=* | --libdir=*) libdir=$(echo $1 | sed 's/.*=//'); shift ;;
--sharedlibdir=*) sharedlibdir=$(echo $1 | sed 's/.*=//'); shift ;;
-i*=* | --includedir=*) includedir=$(echo $1 | sed 's/.*=//');shift ;;
-u*=* | --uname=*) uname=$(echo $1 | sed 's/.*=//');shift ;;
-p* | --prefix) prefix="$2"; shift; shift ;;
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
-m* | --sprefix) symbol_prefix="$2"; shift; shift ;;
-l* | --libdir) libdir="$2"; shift; shift ;;
-i* | --includedir) includedir="$2"; shift; shift ;;
-s* | --shared | --enable-shared) shared=1; shift ;;
-t | --static) shared=0; shift ;;
--zlib-compat) compat=1; shift ;;
--without-unaligned) unalignedok=0; shift ;;
--without-gzfileops) gzfileops=0; shift ;;
--cover) cover=1; shift ;;
-3* | --32) build32=1; shift ;;
-6* | --64) build64=1; shift ;;
--without-vpclmulqdq) buildvpclmulqdq=0; shift ;;
--without-acle) buildacle=0; shift ;;
--without-neon) buildneon=0; shift ;;
--without-armv6) buildarmv6=0; shift ;;
--without-altivec) buildaltivec=0 ; shift ;;
--without-power8) buildpower8=0 ; shift ;;
--without-power9) buildpower9=0 ; shift ;;
--with-dfltcc-deflate) builddfltccdeflate=1; shift ;;
--with-dfltcc-inflate) builddfltccinflate=1; shift ;;
--without-crc32-vx) buildcrc32vx=0; shift ;;
--with-reduced-mem) reducedmem=1; shift ;;
--force-sse2) forcesse2=1; shift ;;
-a*=* | --archs=*) ARCHS=$(echo $1 | sed 's/.*=//'); shift ;;
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
-noopt | --without-optimizations) without_optimizations=1; shift;;
-oldstrat | --without-new-strategies) without_new_strategies=1; shift;;
-w* | --warn) warn=1; shift ;;
-d* | --debug) debug=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
leave 1;;
esac
done
# temporary file name
test=ztest$$
# put arguments in log, also put test file in log if used in arguments
show()
{
case "$@" in
*$test.c*)
echo "=== $test.c ===" >> configure.log
cat $test.c >> configure.log
echo "===" >> configure.log;;
esac
echo "$@" >> configure.log
}
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
cat > $test.c <<EOF
extern int getchar();
int main() {return getchar();}
EOF
cc=${CC-${CROSS_PREFIX}gcc}
printf "Checking for compiler... " | tee -a configure.log
case "$cc" in
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
esac
case $($cc -v 2>&1) in
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
esac
if test $build32 -eq 1; then
CFLAGS="${CFLAGS} -m32"
SFLAGS="${SFLAGS} -m32"
LDFLAGS="${LDFLAGS} -m32"
fi
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64"
LDFLAGS="${LDFLAGS} -m64"
fi
# Set library name depending on zlib-compat option
if test $compat -eq 0; then
LIBNAME=libz-ng
LIBNAME2=zlib-ng
SUFFIX=-ng
else
LIBNAME=libz
LIBNAME2=zlib
SUFFIX=""
fi
STATICLIB=${LIBNAME}.a
MAPNAME=${LIBNAME2}.map
# extract zlib version numbers from zlib.h
if test $compat -eq 0; then
VER=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
VER3=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
VER2=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\.[0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
VER1=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
else
VER=$(sed -n -e '/ZLIB_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib.h.in)
VER3=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib.h.in)
VER2=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\.[0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib.h.in)
VER1=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib.h.in)
fi
show $cc -c $test.c
if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then
echo "$cc" | tee -a configure.log
CC="$cc"
if test "${CFLAGS#*"-std="}" = "$CFLAGS" ; then
CFLAGS="${CFLAGS} -std=c11"
fi
# Re-check ARCH if the compiler is a cross-compiler.
if $CC -print-multiarch 1> /dev/null 2>&1 && test -n "$($CC -print-multiarch)" 1> /dev/null 2>&1; then
CC_ARCH=$($CC $CFLAGS -print-multiarch | sed 's/-.*//g')
else
CC_ARCH=$($CC $CFLAGS -dumpmachine | sed 's/-.*//g')
fi
case $CC_ARCH in
i386 | i486 | i586 | i686)
# Honor user choice if gcc is multilib and 64-bit is requested
if test $build64 -eq 1; then
ARCH=x86_64
else
ARCH=$CC_ARCH
fi ;;
x86_64)
# Honor user choice if gcc is multilib and 32-bit is requested
if test $build32 -ne 1; then
ARCH=$CC_ARCH
fi ;;
arm | armeb)
ARCH=arm
if test "${uname}" = "eabi"; then
uname=arm
fi ;;
armv8l)
ARCH=armv8-a ;;
aarch64 | aarch64_be | arm64)
if test "${uname}" = "elf"; then
uname=aarch64
fi
ARCH=aarch64 ;;
powerpc | ppc)
ARCH=powerpc ;;
powerpc64 | ppc64)
ARCH=powerpc64 ;;
powerpc64le | ppc64le)
ARCH=powerpc64le ;;
esac
CFLAGS="-O2 ${CFLAGS}"
if test -n "${ARCHS}"; then
CFLAGS="${CFLAGS} ${ARCHS}"
LDFLAGS="${LDFLAGS} ${ARCHS}"
fi
CFLAGS="${CFLAGS} -Wall"
SFLAGS="${CFLAGS} -fPIC"
if test "$warn" -eq 1; then
CFLAGS="${CFLAGS} -Wextra"
fi
if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
SFLAGS="${SFLAGS} -DZLIB_DEBUG"
else
CFLAGS="${CFLAGS} -DNDEBUG"
SFLAGS="${SFLAGS} -DNDEBUG"
fi
if test -z "$uname"; then
uname=$( (uname -s || echo unknown) 2>/dev/null)
fi
case "$uname" in
Linux* | linux* | GNU | GNU/* | solaris*)
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1},--version-script,${SRCDIR}/${MAPNAME}" ;;
*BSD | *bsd* | DragonFly)
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1},--version-script,${SRCDIR}/${MAPNAME}"
LDCONFIG="ldconfig -m" ;;
CYGWIN* | Cygwin* | cygwin*)
visibility=0
ARFLAGS="rcs"
SFLAGS="${CFLAGS}"
shared_ext='.dll'
sharedlibdir='${bindir}'
if test $compat -eq 0; then
SHAREDLIB=cygz-ng$shared_ext
else
SHAREDLIB=cygz$shared_ext
fi
SHAREDLIBM=''
SHAREDLIBV=''
SHAREDTARGET=$SHAREDLIB
IMPORTLIB="${LIBNAME}.dll.a"
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB},--version-script,${SRCDIR}/${MAPNAME}"
LDSHAREDLIBC=""
if test $gzfileops -eq 0; then
DEFFILE='win32/${LIBNAME2}.def'
fi
RC="${CROSS_PREFIX}windres"
RCFLAGS="-I ${BUILDDIR}"
RCOBJS='zlibrc.o'
STRIP="${CROSS_PREFIX}strip"
EXE='.exe' ;;
MSYS* | msys*)
visibility=0
ARFLAGS="rcs"
SFLAGS="${CFLAGS}"
shared_ext='.dll'
sharedlibdir='${bindir}'
if test $compat -eq 0; then
SHAREDLIB=msys-z-ng$shared_ext
else
SHAREDLIB=msys-z$shared_ext
fi
SHAREDLIBM=''
SHAREDLIBV=''
SHAREDTARGET=$SHAREDLIB
IMPORTLIB="${LIBNAME}.dll.a"
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB}"
LDSHAREDLIBC=""
if test $gzfileops -eq 0; then
DEFFILE='win32/${LIBNAME2}.def'
fi
RC="${CROSS_PREFIX}windres"
RCFLAGS="-I ${BUILDDIR}"
RCOBJS='zlibrc.o'
STRIP="${CROSS_PREFIX}strip"
EXE='.exe' ;;
MINGW* | mingw*)
visibility=0
ARFLAGS="rcs"
CFLAGS="${CFLAGS} -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -Wno-pedantic-ms-format"
SFLAGS="${CFLAGS}"
shared_ext='.dll'
sharedlibdir='${bindir}'
SHAREDLIB=${LIBNAME}-$VER1$shared_ext
SHAREDLIBM=''
SHAREDLIBV=''
SHAREDTARGET=$SHAREDLIB
IMPORTLIB="${LIBNAME}.dll.a"
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,--out-implib=${IMPORTLIB} -Wl,--version-script=${SRCDIR}/${MAPNAME}"
LDSHAREDLIBC=""
if test $gzfileops -eq 0; then
DEFFILE='win32/${LIBNAME2}.def'
fi
RC="${CROSS_PREFIX}windres"
RCFLAGS="-I ${BUILDDIR}"
if [ "$CC" = "mingw32-gcc" ]; then
case $ARCH in
i386 | i486 | i586 | i686) RCFLAGS="${RCFLAGS} -F pe-i386";;
esac;
fi
RCOBJS='zlibrc.o'
STRIP="${CROSS_PREFIX}strip"
EXE='.exe' ;;
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,-h${LIBNAME}.so.${VER1}" ;;
HP-UX*)
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared"
case $( (uname -m || echo unknown) 2>/dev/null) in
ia64)
shared_ext='.so'
SHAREDLIB='${LIBNAME}.so' ;;
*)
shared_ext='.sl'
SHAREDLIB='${LIBNAME}.sl' ;;
esac ;;
Darwin* | darwin*)
shared_ext='.dylib'
SHAREDLIB=${LIBNAME}$shared_ext
SHAREDLIBV=${LIBNAME}.$VER$shared_ext
SHAREDLIBM=${LIBNAME}.$VER1$shared_ext
SHAREDTARGET=$SHAREDLIBV
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-dynamiclib -install_name @rpath/${SHAREDLIBM} -compatibility_version ${VER1} -current_version ${VER3}"
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
AR="${CROSS_PREFIX}libtool"
elif libtool -V 2>&1 | grep Apple > /dev/null; then
AR="libtool"
else
AR="/usr/bin/libtool"
fi
ARFLAGS="-o" ;;
aarch64)
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1} -Wl,--version-script,${SRCDIR}/${MAPNAME}"
LDSHAREDLIBC="-Wl,--start-group -lc -lrdimon -Wl,--end-group" ;;
*)
LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared" ;;
esac
else
# find system name and corresponding cc options
CC=${CC-cc}
gcc=0
echo "$CC" | tee -a configure.log
if test -z "$uname"; then
uname=$( (uname -sr || echo unknown) 2>/dev/null)
fi
case "$uname" in
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"ld"}
LDSHAREDFLAGS="-b"
case $( (uname -m || echo unknown) 2>/dev/null) in
ia64)
shared_ext='.so'
SHAREDLIB='${LIBNAME}.so' ;;
*)
shared_ext='.sl'
SHAREDLIB='${LIBNAME}.sl' ;;
esac ;;
AIX*) # Courtesy of [email protected]
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
LDSHARED=${LDSHARED-"xlc"}
LDSHAREDFLAGS="-G" ;;
# send working options for other systems to [email protected]
*) SFLAGS=${CFLAGS-"-O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc"}
LDSHAREDFLAGS="-shared" ;;
esac
fi
# Symbol versioning
case "$uname" in
CYGWIN* | Cygwin* | cygwin* | MINGW* | mingw* | MSYS* | msys* | Darwin* | darwin*)
echo "Checking for Symbol versioning... No."
;;
*)
if test $shared -eq 1; then
echo "Checking for Symbol versioning... Yes."
CFLAGS="${CFLAGS} -DHAVE_SYMVER"
SFLAGS="${SFLAGS} -DHAVE_SYMVER"
else
echo "Checking for Symbol versioning... No."
fi
;;
esac
# Simplify some later conditionals
case "$uname" in
Linux* | linux*)
LINUX=1 ;;
*)
LINUX=0 ;;
esac
# destination names for shared library if not defined above
SHAREDLIB=${SHAREDLIB-"${LIBNAME}$shared_ext"}
SHAREDLIBV=${SHAREDLIBV-"${LIBNAME}$shared_ext.$VER"}
SHAREDLIBM=${SHAREDLIBM-"${LIBNAME}$shared_ext.$VER1"}
SHAREDTARGET=${SHAREDTARGET-"${LIBNAME}$shared_ext.$VER"}
echo >> configure.log
# define functions for testing compiler and library characteristics and logging the results
cat > $test.c <<EOF
#error error
EOF
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
try()
{
show "$@"
test "$( ("$@") 2>&1 | tee -a configure.log)" = ""
}
echo - using any output from compiler to indicate an error >> configure.log
else
try()
{
show "$@"
( "$@" ) >> configure.log 2>&1
ret=$?
if test $ret -ne 0; then
echo "(exit code $ret)" >> configure.log
fi
return $ret
}
fi
cat > $test.c << EOF
int foo() { return 0; }
EOF
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
if try $CC -c $CFLAGS $test.c; then
:
else
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
leave 1
fi
echo >> configure.log
# see if shared library build supported
cat > $test.c <<EOF
extern int getchar();
int hello() {return getchar();}
EOF
if test $shared -eq 1; then
printf "Checking for shared library support... " | tee -a configure.log
# we must test in two steps (cc then ld), required at least on SunOS 4.x
if try $CC -c $SFLAGS $test.c &&
try $LDSHARED $LDSHAREDFLAGS $LDFLAGS -o $test$shared_ext $test.o $LDSHAREDLIBC; then
echo "Building shared library $SHAREDTARGET with $CC." | tee -a configure.log
elif test -z "$old_cc" -a -z "$old_cflags"; then
echo "No shared library support." | tee -a configure.log
shared=0;
else
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
shared=0;
fi
fi
if test $shared -eq 0; then
LDSHARED="$CC"
LDSHAREDFLAGS=""
ALL="static"
SHAREDLIB=""
SHAREDLIBV=""
SHAREDLIBM=""
SHAREDTARGET=""
INSTALLTARGETS=install-static
UNINSTALLTARGETS=uninstall-static
echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
else
ALL="static shared"
TEST="${TEST} testshared"
fi
echo >> configure.log
# check for large file support, and if none, check for fseeko()
cat > $test.c <<EOF
#include <sys/types.h>
off64_t dummy = 0;
EOF
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
echo "Checking for off64_t... Yes." | tee -a configure.log
echo "Checking for fseeko... Yes." | tee -a configure.log
else
echo "Checking for off64_t... No." | tee -a configure.log
echo >> configure.log
cat > $test.c <<EOF
#include <sys/types.h>
int main() {
_off64_t dummy = 0;
return 0;
}
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for _off64_t... Yes." | tee -a configure.log
else
echo "Checking for _off64_t... No." | tee -a configure.log
fi
echo >> configure.log
cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
fseeko(NULL, 0, 0);
return 0;
}
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for fseeko... Yes." | tee -a configure.log
else
CFLAGS="${CFLAGS} -DNO_FSEEKO"
SFLAGS="${SFLAGS} -DNO_FSEEKO"
echo "Checking for fseeko... No." | tee -a configure.log
fi
fi
echo >> configure.log
cat > $test.c <<EOF
#define _POSIX_C_SOURCE 200112L
#include <stdlib.h>
int main(void) {
void *ptr = 0;
int ret = posix_memalign(&ptr, 64, 10);
if (ptr)
free(ptr);
return ret;
}
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for posix_memalign... Yes." | tee -a configure.log
CFLAGS="${CFLAGS} -DHAVE_POSIX_MEMALIGN"
SFLAGS="${SFLAGS} -DHAVE_POSIX_MEMALIGN"
else
echo "Checking for posix_memalign... No." | tee -a configure.log
fi
echo >> configure.log
cat > $test.c <<EOF
#define _ISOC11_SOURCE 1
#include <stdlib.h>
int main(void) {
void *ptr = aligned_alloc(64, 10);
if (ptr)
free(ptr);
return 0;
}
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for aligned_alloc... Yes." | tee -a configure.log
CFLAGS="${CFLAGS} -DHAVE_ALIGNED_ALLOC"
SFLAGS="${SFLAGS} -DHAVE_ALIGNED_ALLOC"
else
echo "Checking for aligned_alloc... No." | tee -a configure.log
fi
echo >> configure.log
# check for strerror() for use by gz* functions
cat > $test.c <<EOF
#include <string.h>
#include <errno.h>
int main() { return strlen(strerror(errno)); }
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for strerror... Yes." | tee -a configure.log
else
CFLAGS="${CFLAGS} -DNO_STRERROR"
SFLAGS="${SFLAGS} -DNO_STRERROR"
echo "Checking for strerror... No." | tee -a configure.log
fi
# check for getauxval() or elf_aux_info() for architecture feature detection at run-time
cat > $test.c <<EOF
#include <sys/auxv.h>
int main() {
#ifdef __FreeBSD__
int test;
return elf_aux_info(AT_PAGESZ, &test, sizeof(test));
#else
return getauxval(0);
#endif
}
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for getauxval() or elf_aux_info() in sys/auxv.h... Yes." | tee -a configure.log
CFLAGS="${CFLAGS} -DHAVE_SYS_AUXV_H"
SFLAGS="${SFLAGS} -DHAVE_SYS_AUXV_H"
else
echo "Checking for getauxval() in sys/auxv.h... No." | tee -a configure.log
fi
# We need to remove consigured files (zconf.h etc) from source directory if building outside of it
if [ "$SRCDIR" != "$BUILDDIR" ]; then
rm -f $SRCDIR/zconf${SUFFIX}.h
rm -f $SRCDIR/zlib${SUFFIX}.h
rm -f $SRCDIR/zlib_name_mangling${SUFFIX}.h
fi
# Rename @ZLIB_SYMBOL_PREFIX@ to $symbol_prefix in gzread.c, zlib.h and zlib_name_mangling.h
sed < $SRCDIR/gzread.c.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > gzread.c
sed < $SRCDIR/zlib${SUFFIX}.h.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > zlib${SUFFIX}.h
if [ ! -z "$symbol_prefix" ]; then
sed < $SRCDIR/zlib_name_mangling${SUFFIX}.h.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > zlib_name_mangling${SUFFIX}.h
else
# symbol_prefix is not set, copy the empty mangling header
cp -p $SRCDIR/zlib_name_mangling.h.empty zlib_name_mangling${SUFFIX}.h
fi
# copy clean zconf.h for subsequent edits
cp -p $SRCDIR/zconf${SUFFIX}.h.in zconf${SUFFIX}.h
echo >> configure.log
# check for unistd.h and save result in zconf.h
cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf${SUFFIX}.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf${SUFFIX}.temp.h
mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
echo "Checking for unistd.h... Yes." | tee -a configure.log
else
sed < zconf${SUFFIX}.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be set to #if 1/ 0\1 was set to #if 0/" > zconf${SUFFIX}.temp.h
mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
echo "Checking for unistd.h... No." | tee -a configure.log
fi
echo >> configure.log
# check for ptrdiff_t and save result in zconf.h
printf "Checking for ptrdiff_t... " | tee -a configure.log
cat > $test.c <<EOF
#include <stddef.h>
int fun(ptrdiff_t *a) { (void)a; return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
echo "Yes." | tee -a configure.log
else
echo "No." | tee -a configure.log
sed < zconf${SUFFIX}.h "/^#ifdef NEED_PTRDIFF_T.* may be/s/def NEED_PTRDIFF_T\(.*\) may be/ 1\1 was/" > zconf${SUFFIX}.temp.h
mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
printf "Checking for sizeof(void *)... " | tee -a configure.log
cat > $test.c <<EOF
#include <stdint.h>
#define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; }
COMPILE_TIME_ASSERT(sizeof(int32_t) == sizeof(void *));
EOF
if try $CC -c $CFLAGS $test.c; then
echo "sizeof(int32_t)." | tee -a configure.log
sed < zconf${SUFFIX}.h "s/^typedef PTRDIFF_TYPE ptrdiff_t;/typedef int32_t ptrdiff_t;/g" > zconf${SUFFIX}.temp.h
mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
else
cat > $test.c <<EOF
#include <stdint.h>
#define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; }
COMPILE_TIME_ASSERT(sizeof(int64_t) == sizeof(void *));
EOF
if try $CC -c $CFLAGS $test.c; then
echo "sizeof(int64_t)." | tee -a configure.log
sed < zconf${SUFFIX}.h "s/^typedef PTRDIFF_TYPE ptrdiff_t;/typedef int64_t ptrdiff_t;/g" > zconf${SUFFIX}.temp.h
mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
else
echo "unknown." | tee -a configure.log
exit 1
fi
fi
fi
# if --zlib-compat was requested
if test $compat -eq 1; then
gzfileops=1
CFLAGS="${CFLAGS} -DZLIB_COMPAT"
SFLAGS="${SFLAGS} -DZLIB_COMPAT"
case "$uname" in
CYGWIN* | Cygwin* | cygwin* | MSYS* | msys* | MINGW* | mingw*)
DEFFILE="win32/zlibcompat.def" ;;
esac
fi
if [ ! -z "$DEFFILE" ]; then
mkdir -p win32
sed < $SRCDIR/$DEFFILE.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > $DEFFILE
fi
# if --gzfileops was requested
if test $gzfileops -eq 1; then
CFLAGS="${CFLAGS} -DWITH_GZFILEOP"
SFLAGS="${SFLAGS} -DWITH_GZFILEOP"
OBJC="${OBJC} \$(OBJG)"
PIC_OBJC="${PIC_OBJC} \$(PIC_OBJG)"
else
TESTOBJG="\$(OBJG)"
PIC_TESTOBJG="\$(OBJG)"
fi
# set architecture alignment requirements
if test $unalignedok -eq 0; then
CFLAGS="${CFLAGS} -DNO_UNALIGNED"
SFLAGS="${SFLAGS} -DNO_UNALIGNED"
echo "Unaligned reads manually disabled." | tee -a configure.log
fi
# enable reduced memory configuration
if test $reducedmem -eq 1; then
echo "Configuring for reduced memory environment." | tee -a configure.log
CFLAGS="${CFLAGS} -DHASH_SIZE=32768u -DGZBUFSIZE=8192"
fi
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
if test $cover -eq 1; then
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
LDFLAGS="${LDFLAGS} -fprofile-arcs -ftest-coverage"
if test -n "$GCC_CLASSIC"; then
CC=$GCC_CLASSIC
fi
fi
echo >> configure.log
# Check for ANSI C compliant compiler
cat > $test.c <<EOF
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include "zconf${SUFFIX}.h"
int main() {
#ifdef STDC
return 0;
#endif
return 1;
}
EOF
if try $CC -c $CFLAGS $test.c; then
echo "Checking for ANSI C compliant compiler... Yes." | tee -a configure.log
:
else
echo "Checking for ANSI C compliant compiler... No." | tee -a configure.log
echo "Error: ANSI C compatible compiler needed, cannot continue." | tee -a configure.log
leave 1
fi
# Check for -fno-semantic-interposition compiler support
echo "" > test.c
cat > $test.c <<EOF
int main() { return 0; }
EOF
if test "$gcc" -eq 1 && ($cc $CFLAGS -fno-semantic-interposition -c $test.c) >> configure.log 2>&1; then
echo "Checking for -fno-semantic-interposition... Yes." | tee -a configure.log
SFLAGS="$SFLAGS -fno-semantic-interposition"
else
echo "Checking for -fno-semantic-interposition... No." | tee -a configure.log
fi
# Check for -fno-lto compiler support
if test $gcc -eq 1 -a $without_optimizations -eq 0; then
cat > $test.c <<EOF
int main() { return 0; }
EOF
if $cc $CFLAGS -fno-lto -c $test.c >> configure.log 2>&1; then
echo "Checking for -fno-lto... Yes." | tee -a configure.log
else
echo "Checking for -fno-lto... No." | tee -a configure.log
noltoflag=""
fi
fi
# see if we can hide zlib internal symbols that are linked between separate source files using hidden
if test "$gcc" -eq 1 && test "$visibility" -eq 1; then
echo >> configure.log
cat > $test.c <<EOF
#define Z_INTERNAL __attribute__((visibility ("hidden")))
int Z_INTERNAL foo;
int main() { return 0; }
EOF
if try $CC $CFLAGS $test.c; then
CFLAGS="$CFLAGS -DHAVE_VISIBILITY_HIDDEN"
SFLAGS="$SFLAGS -DHAVE_VISIBILITY_HIDDEN"
echo >> configure.log
echo "Checking for attribute(visibility(hidden)) support... Yes." | tee -a configure.log
else
echo >> configure.log
echo "Checking for attribute(visibility(hidden)) support... No." | tee -a configure.log
fi
fi
# see if we can hide zlib internal symbols that are linked between separate source files using internal
if test "$gcc" -eq 1 && test "$visibility" -eq 1; then
echo >> configure.log
cat > $test.c <<EOF
#define Z_INTERNAL __attribute__((visibility ("internal")))
int Z_INTERNAL foo;
int main() { return 0; }
EOF
if try $CC $CFLAGS $test.c; then
CFLAGS="$CFLAGS -DHAVE_VISIBILITY_INTERNAL"
SFLAGS="$SFLAGS -DHAVE_VISIBILITY_INTERNAL"
echo >> configure.log
echo "Checking for attribute(visibility(internal)) support... Yes." | tee -a configure.log
else
echo >> configure.log
echo "Checking for attribute(visibility(internal)) support... No." | tee -a configure.log
fi
fi
# Check for attribute(aligned) support in compiler
cat > $test.c << EOF
int main(void) {
__attribute__((aligned(8))) int test = 0;
(void)test;
return 0;
}
EOF
if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then
echo "Checking for attribute(aligned) ... Yes." | tee -a configure.log
CFLAGS="$CFLAGS -DHAVE_ATTRIBUTE_ALIGNED"
SFLAGS="$SFLAGS -DHAVE_ATTRIBUTE_ALIGNED"
else
echo "Checking for attribute(aligned) ... No." | tee -a configure.log
fi
# Check for __builtin_ctz() support in compiler
cat > $test.c << EOF
long f(unsigned int x) { return __builtin_ctz(x); }
int main(void) { return 0; }
EOF
if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then
echo "Checking for __builtin_ctz ... Yes." | tee -a configure.log
CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZ"
SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZ"
else
echo "Checking for __builtin_ctz ... No." | tee -a configure.log
fi
# Check for __builtin_ctzll() support in compiler
cat > $test.c << EOF
long f(unsigned long long x) { return __builtin_ctzll(x); }
int main(void) { return 0; }
EOF
if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then
echo "Checking for __builtin_ctzll ... Yes." | tee -a configure.log
CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZLL"