Debian Codegraph @

src/c-blosc2/internal-complibs/zlib-ng-2.0.7/configure

raw
1 #!/usr/bin/env bash
2 # configure script for zlib.
3 #
4 # Normally configure builds both a static and a shared library.
5 # If you want to build just a static library, use: ./configure --static
6 #
7 # To impose specific compiler or flags or install directory, use for example:
8 # prefix=$HOME CC=cc CFLAGS="-O4" ./configure
9 # or for csh/tcsh users:
10 # (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
11
12 # Incorrect settings of CC or CFLAGS may prevent creating a shared library.
13 # If you have problems, try without defining CC and CFLAGS before reporting
14 # an error.
15
16 # start off configure.log
17 echo -------------------- >> configure.log
18 echo $0 $* >> configure.log
19 date >> configure.log
20
21 SRCDIR=$(cd $(dirname $0); pwd)
22 BUILDDIR=$(pwd)
23
24 # set command prefix for cross-compilation
25 if [ -n "${CHOST}" ]; then
26 # normalize the chost before parsing it
27 NORM_CHOST=$(sh "$SRCDIR"/tools/config.sub $CHOST)
28 uname="$(echo "${NORM_CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/')"
29 CROSS_PREFIX="${CHOST}-"
30 ARCH="$(echo "${NORM_CHOST}" | sed -e 's/-.*//')"
31 else
32 ARCH="`uname -m`"
33 fi
34
35 case "${ARCH}" in
36 x86_64)
37 case "${CFLAGS}" in
38 *-m32*)
39 ARCH=i686
40 ;;
41 esac
42 ;;
43 i386 | i486 | i586 | i686)
44 case "${CFLAGS}" in
45 *-m64*)
46 ARCH=x86_64
47 ;;
48 esac
49 ;;
50 esac
51
52 # destination name for windows import library
53 IMPORTLIB=
54
55 # establish commands for library building
56 if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
57 AR=${AR-"${CROSS_PREFIX}ar"}
58 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
59 else
60 AR=${AR-"ar"}
61 test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
62 fi
63 ARFLAGS=${ARFLAGS-"rc"}
64 if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
65 RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
66 test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
67 else
68 RANLIB=${RANLIB-"ranlib"}
69 fi
70
71 # set defaults before processing command line options
72 LDCONFIG=${LDCONFIG-"ldconfig"}
73 DEFFILE=
74 RC=
75 RCFLAGS=
76 RCOBJS=
77 STRIP=
78 ARCHS=
79 prefix=${prefix-/usr/local}
80 exec_prefix=${exec_prefix-'${prefix}'}
81 bindir=${bindir-'${exec_prefix}/bin'}
82 libdir=${libdir-'${exec_prefix}/lib'}
83 sharedlibdir=${sharedlibdir-'${libdir}'}
84 includedir=${includedir-'${prefix}/include'}
85 mandir=${mandir-'${prefix}/share/man'}
86 shared_ext='.so'
87 shared=1
88 gzfileops=1
89 compat=0
90 cover=0
91 build32=0
92 build64=0
93 buildacle=1
94 buildneon=1
95 builddfltccdeflate=0
96 builddfltccinflate=0
97 with_sanitizer=""
98 with_fuzzers=0
99 floatabi=
100 native=0
101 forcesse2=0
102 forcetzcnt=0
103 avx2flag="-mavx2"
104 sse2flag="-msse2"
105 ssse3flag="-mssse3"
106 sse4flag="-msse4"
107 sse42flag="-msse4.2"
108 pclmulflag="-mpclmul"
109 acleflag=
110 neonflag=
111 noltoflag="-fno-lto"
112 without_optimizations=0
113 without_new_strategies=0
114 gcc=0
115 warn=0
116 debug=0
117 old_cc="$CC"
118 old_cflags="$CFLAGS"
119 OBJC='$(OBJZ)'
120 PIC_OBJC='$(PIC_OBJZ)'
121 INSTALLTARGETS="install-shared install-static"
122 UNINSTALLTARGETS="uninstall-shared uninstall-static"
123
124 TEST="teststatic"
125
126 # leave this script, optionally in a bad way
127 leave()
128 {
129 if test "$*" != "0"; then
130 echo "** $0 aborting." | tee -a configure.log
131 fi
132 rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
133 echo -------------------- >> configure.log
134 echo >> configure.log
135 echo >> configure.log
136 exit $1
137 }
138
139 # process command line options
140 while test $# -ge 1
141 do
142 case "$1" in
143 -h* | --help)
144 echo 'usage:' | tee -a configure.log
145 echo ' configure [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
146 echo ' [--static] [--32] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
147 echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
148 echo ' [--warn] Enables extra compiler warnings' | tee -a configure.log
149 echo ' [--debug] Enables extra debug prints during operation' | tee -a configure.log
150 echo ' [--zlib-compat] Compiles for zlib-compatible API instead of zlib-ng API' | tee -a configure.log
151 echo ' [--without-gzfileops] Compiles with the gzfile parts of the API enabled' | tee -a configure.log
152 echo ' [--without-optimizations] Compiles without support for optional instruction sets' | tee -a configure.log
153 echo ' [--without-new-strategies] Compiles without using new additional deflate strategies' | tee -a configure.log
154 echo ' [--without-acle] Compiles without ARM C Language Extensions' | tee -a configure.log
155 echo ' [--without-neon] Compiles without ARM Neon SIMD instruction set' | tee -a configure.log
156 echo ' [--with-dfltcc-deflate] Use DEFLATE CONVERSION CALL instruction for compression on IBM Z' | tee -a configure.log
157 echo ' [--with-dfltcc-inflate] Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z' | tee -a configure.log
158 echo ' [--force-sse2] Assume SSE2 instructions are always available (disabled by default on x86, enabled on x86_64)' | tee -a configure.log
159 echo ' [--force-tzcnt] Assume TZCNT instructions are always available (disabled by default)' | tee -a configure.log
160 echo ' [--with-sanitizer] Build with sanitizer (memory, address, undefined)' | tee -a configure.log
161 echo ' [--with-fuzzers] Build test/fuzz (disabled by default)' | tee -a configure.log
162 echo ' [--native] Compiles with full instruction set supported on this host' | tee -a configure.log
163 exit 0 ;;
164 -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
165 -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
166 -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
167 --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
168 -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
169 -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
170 -p* | --prefix) prefix="$2"; shift; shift ;;
171 -e* | --eprefix) exec_prefix="$2"; shift; shift ;;
172 -l* | --libdir) libdir="$2"; shift; shift ;;
173 -i* | --includedir) includedir="$2"; shift; shift ;;
174 -s* | --shared | --enable-shared) shared=1; shift ;;
175 -t | --static) shared=0; shift ;;
176 --zlib-compat) compat=1; shift ;;
177 --without-gzfileops) gzfileops=0; shift ;;
178 --cover) cover=1; shift ;;
179 -3* | --32) build32=1; shift ;;
180 -6* | --64) build64=1; shift ;;
181 --without-acle) buildacle=0; shift ;;
182 --without-neon) buildneon=0; shift ;;
183 --with-dfltcc-deflate) builddfltccdeflate=1; shift ;;
184 --with-dfltcc-inflate) builddfltccinflate=1; shift ;;
185 --force-sse2) forcesse2=1; shift ;;
186 --force-tzcnt) forcetzcnt=1; shift ;;
187 -n | --native) native=1; shift ;;
188 -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
189 --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
190 --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
191 -noopt | --without-optimizations) without_optimizations=1; shift;;
192 -oldstrat | --without-new-strategies) without_new_strategies=1; shift;;
193 -w* | --warn) warn=1; shift ;;
194 -d* | --debug) debug=1; shift ;;
195 --with-sanitizer=*) with_sanitizer=`echo $1 | sed 's/.*=//'`; shift ;;
196 --with-fuzzers) with_fuzzers=1; shift ;;
197
198 *)
199 echo "unknown option: $1" | tee -a configure.log
200 echo "$0 --help for help" | tee -a configure.log
201 leave 1;;
202 esac
203 done
204
205 # temporary file name
206 test=ztest$$
207
208 # put arguments in log, also put test file in log if used in arguments
209 show()
210 {
211 case "$*" in
212 *$test.c*)
213 echo "=== $test.c ===" >> configure.log
214 cat $test.c >> configure.log
215 echo "===" >> configure.log;;
216 esac
217 echo $* >> configure.log
218 }
219
220 # check for gcc vs. cc and set compile and link flags based on the system identified by uname
221 cat > $test.c <<EOF
222 extern int getchar();
223 int main() {return getchar();}
224 EOF
225
226 cc=${CC-${CROSS_PREFIX}gcc}
227 echo -n "Checking for compiler... " | tee -a configure.log
228 case "$cc" in
229 *gcc*) gcc=1 ;;
230 *clang*) gcc=1 ;;
231 esac
232 case `$cc -v 2>&1` in
233 *gcc*) gcc=1 ;;
234 *clang*) gcc=1 ;;
235 esac
236
237 if test $native -eq 1; then
238 avx2flag=""
239 sse2flag=""
240 ssse3flag=""
241 sse4flag=""
242 sse42flag=""
243 pclmulflag=""
244 noltoflag=""
245 fi
246
247 if test $build32 -eq 1; then
248 CFLAGS="${CFLAGS} -m32"
249 SFLAGS="${SFLAGS} -m32"
250 LDFLAGS="${LDFLAGS} -m32"
251 fi
252 if test $build64 -eq 1; then
253 CFLAGS="${CFLAGS} -m64"
254 SFLAGS="${SFLAGS} -m64"
255 LDFLAGS="${LDFLAGS} -m64"
256 fi
257
258 # Set library name depending on zlib-compat option
259 if test $compat -eq 0; then
260 LIBNAME=libz-ng
261 LIBNAME2=zlib-ng
262 SUFFIX=-ng
263 else
264 LIBNAME=libz
265 LIBNAME2=zlib
266 SUFFIX=""
267 fi
268
269 STATICLIB=${LIBNAME}.a
270 MAPNAME=${LIBNAME2}.map
271
272 # extract zlib version numbers from zlib.h
273 if test $compat -eq 0; then
274 VER=`sed -n -e '/ZLIBNG_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib-ng.h`
275 VER3=`sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib-ng.h`
276 VER2=`sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}/zlib-ng.h`
277 VER1=`sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}/zlib-ng.h`
278 else
279 VER=`sed -n -e '/ZLIB_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib.h`
280 VER3=`sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib.h`
281 VER2=`sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}/zlib.h`
282 VER1=`sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}/zlib.h`
283 fi
284
285 show $cc -c $test.c
286 if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then
287 echo "$cc" | tee -a configure.log
288 CC="$cc"
289 CFLAGS="${CFLAGS} -std=c99"
290
291 # Re-check ARCH if the compiler is a cross-compiler.
292 if $CC -print-multiarch 1> /dev/null 2>&1 && test -n "$($CC -print-multiarch)" 1> /dev/null 2>&1; then
293 CC_ARCH=`$CC $CFLAGS -print-multiarch | sed 's/-.*//g'`
294 else
295 CC_ARCH=`$CC $CFLAGS -dumpmachine | sed 's/-.*//g'`
296 fi
297 case $CC_ARCH in
298 i386 | i486 | i586 | i686)
299 # Honor user choice if gcc is multilib and 64-bit is requested
300 if test $build64 -eq 1; then
301 ARCH=x86_64
302 else
303 ARCH=$CC_ARCH
304 fi ;;
305 x86_64)
306 # Honor user choice if gcc is multilib and 32-bit is requested
307 if test $build32 -ne 1; then
308 ARCH=$CC_ARCH
309 fi ;;
310 arm | armeb)
311 if test $native -eq 0; then
312 ARCH=arm
313 else
314 ARCH=native
315 fi
316 if test "${uname}" = "eabi"; then
317 # No ACLE support
318 uname=arm
319 if test $buildacle -eq 1; then
320 echo ACLE support not available
321 buildacle=0
322 fi
323 fi
324 if test $buildacle -eq 1; then
325 if test $native -eq 0; then
326 ARCH=armv8-a+crc
327 fi
328 fi ;;
329 armv8l)
330 if test $native -eq 0; then
331 ARCH=armv8-a
332 else
333 ARCH=native
334 fi ;;
335 aarch64 | aarch64_be | arm64)
336 if test "${uname}" = "elf"; then
337 uname=aarch64
338 fi
339 if test $native -eq 0; then
340 ARCH=aarch64
341 else
342 ARCH=native
343 fi ;;
344 powerpc | ppc)
345 ARCH=powerpc ;;
346 powerpc64 | ppc64)
347 ARCH=powerpc64 ;;
348 powerpc64le | ppc64le)
349 ARCH=powerpc64le ;;
350 esac
351 CFLAGS="-O2 ${CFLAGS}"
352 if test -n "${ARCHS}"; then
353 CFLAGS="${CFLAGS} ${ARCHS}"
354 LDFLAGS="${LDFLAGS} ${ARCHS}"
355 fi
356 CFLAGS="${CFLAGS} -Wall"
357 SFLAGS="${CFLAGS} -fPIC"
358 if test $native -eq 1; then
359 case $ARCH in
360 powerpc*)
361 NATIVE_FLAG="-mcpu=native" ;;
362 *)
363 NATIVE_FLAG="-march=native" ;;
364 esac
365 CFLAGS="${CFLAGS} ${NATIVE_FLAG}"
366 SFLAGS="${SFLAGS} ${NATIVE_FLAG}"
367 fi
368 if test "$warn" -eq 1; then
369 CFLAGS="${CFLAGS} -Wextra -Wpedantic -Wno-implicit-fallthrough"
370 fi
371 if test $debug -eq 1; then
372 CFLAGS="${CFLAGS} -DZLIB_DEBUG"
373 SFLAGS="${SFLAGS} -DZLIB_DEBUG"
374 fi
375 if test -z "$uname"; then
376 uname=`(uname -s || echo unknown) 2>/dev/null`
377 fi
378 case "$uname" in
379 Linux* | linux* | GNU | GNU/* | solaris*)
380 LDSHARED=${LDSHARED-"$cc"}
381 LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1},--version-script,${SRCDIR}/${MAPNAME}" ;;
382 *BSD | *bsd* | DragonFly)
383 LDSHARED=${LDSHARED-"$cc"}
384 LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1},--version-script,${SRCDIR}/${MAPNAME}"
385 LDCONFIG="ldconfig -m" ;;
386 CYGWIN* | Cygwin* | cygwin*)
387 ARFLAGS="rcs"
388 SFLAGS="${CFLAGS}"
389 shared_ext='.dll'
390 sharedlibdir='${bindir}'
391 if test $compat -eq 0; then
392 SHAREDLIB=cygz-ng$shared_ext
393 else
394 SHAREDLIB=cygz$shared_ext
395 fi
396 SHAREDLIBM=''
397 SHAREDLIBV=''
398 SHAREDTARGET=$SHAREDLIB
399 IMPORTLIB="${LIBNAME}.dll.a"
400 LDSHARED=${LDSHARED-"$cc"}
401 LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB},--version-script,${SRCDIR}/${MAPNAME}"
402 LDSHAREDLIBC=""
403 DEFFILE='win32/${LIBNAME2}.def'
404 RC="${CROSS_PREFIX}windres"
405 RCOBJS='zlibrc.o'
406 STRIP="${CROSS_PREFIX}strip"
407 EXE='.exe' ;;
408 MSYS* | msys*)
409 ARFLAGS="rcs"
410 SFLAGS="${CFLAGS}"
411 shared_ext='.dll'
412 sharedlibdir='${bindir}'
413 if test $compat -eq 0; then
414 SHAREDLIB=msys-z-ng$shared_ext
415 else
416 SHAREDLIB=msys-z$shared_ext
417 fi
418 SHAREDLIBM=''
419 SHAREDLIBV=''
420 SHAREDTARGET=$SHAREDLIB
421 IMPORTLIB="${LIBNAME}.dll.a"
422 LDSHARED=${LDSHARED-"$cc"}
423 LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB}"
424 LDSHAREDLIBC=""
425 DEFFILE='win32/${LIBNAME2}.def'
426 RC="${CROSS_PREFIX}windres"
427 RCOBJS='zlibrc.o'
428 STRIP="${CROSS_PREFIX}strip"
429 EXE='.exe' ;;
430 MINGW* | mingw*)
431 ARFLAGS="rcs"
432 CFLAGS="${CFLAGS} -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -Wno-pedantic-ms-format"
433 SFLAGS="${CFLAGS}"
434 shared_ext='.dll'
435 sharedlibdir='${bindir}'
436 SHAREDLIB=${LIBNAME}-$VER1$shared_ext
437 SHAREDLIBM=''
438 SHAREDLIBV=''
439 SHAREDTARGET=$SHAREDLIB
440 IMPORTLIB="${LIBNAME}.dll.a"
441 LDSHARED=${LDSHARED-"$cc"}
442 LDSHAREDFLAGS="-shared -Wl,--out-implib=${IMPORTLIB} -Wl,--version-script=${SRCDIR}/${MAPNAME}"
443 LDSHAREDLIBC=""
444 DEFFILE='win32/${LIBNAME2}.def'
445 RC="${CROSS_PREFIX}windres"
446 if [ "$CC" == "mingw32-gcc" ]; then
447 case $ARCH in
448 i386 | i486 | i586 | i686) RCFLAGS="${RCFLAGS} -F pe-i386";;
449 esac;
450 fi
451 RCOBJS='zlibrc.o'
452 STRIP="${CROSS_PREFIX}strip"
453 EXE='.exe' ;;
454 QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
455 # ([email protected])
456 LDSHARED=${LDSHARED-"$cc"}
457 LDSHAREDFLAGS="-shared -Wl,-h${LIBNAME}.so.${VER1}" ;;
458 HP-UX*)
459 LDSHARED=${LDSHARED-"$cc"}
460 LDSHAREDFLAGS="-shared"
461 case `(uname -m || echo unknown) 2>/dev/null` in
462 ia64)
463 shared_ext='.so'
464 SHAREDLIB='${LIBNAME}.so' ;;
465 *)
466 shared_ext='.sl'
467 SHAREDLIB='${LIBNAME}.sl' ;;
468 esac ;;
469 Darwin* | darwin*)
470 shared_ext='.dylib'
471 SHAREDLIB=${LIBNAME}$shared_ext
472 SHAREDLIBV=${LIBNAME}.$VER$shared_ext
473 SHAREDLIBM=${LIBNAME}.$VER1$shared_ext
474 SHAREDTARGET=$SHAREDLIBV
475 LDSHARED=${LDSHARED-"$cc"}
476 LDSHAREDFLAGS="-dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"
477 if libtool -V 2>&1 | grep Apple > /dev/null; then
478 AR="libtool"
479 else
480 AR="/usr/bin/libtool"
481 fi
482 ARFLAGS="-o" ;;
483 aarch64)
484 LDSHARED=${LDSHARED-"$cc"}
485 LDSHAREDFLAGS="-shared -Wl,-soname,${LIBNAME}.so.${VER1} -Wl,--version-script,${SRCDIR}/${MAPNAME}"
486 LDSHAREDLIBC="-Wl,--start-group -lc -lrdimon -Wl,--end-group" ;;
487 *)
488 LDSHARED=${LDSHARED-"$cc"}
489 LDSHAREDFLAGS="-shared" ;;
490 esac
491 else
492 # find system name and corresponding cc options
493 CC=${CC-cc}
494 gcc=0
495 echo "$CC" | tee -a configure.log
496 if test -z "$uname"; then
497 uname=`(uname -sr || echo unknown) 2>/dev/null`
498 fi
499 case "$uname" in
500 HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
501 CFLAGS=${CFLAGS-"-O"}
502 LDSHARED=${LDSHARED-"ld"}
503 LDSHAREDFLAGS="-b"
504 case `(uname -m || echo unknown) 2>/dev/null` in
505 ia64)
506 shared_ext='.so'
507 SHAREDLIB='${LIBNAME}.so' ;;
508 *)
509 shared_ext='.sl'
510 SHAREDLIB='${LIBNAME}.sl' ;;
511 esac ;;
512 AIX*) # Courtesy of [email protected]
513 SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
514 CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
515 LDSHARED=${LDSHARED-"xlc"}
516 LDSHAREDFLAGS="-G" ;;
517 # send working options for other systems to [email protected]
518 *) SFLAGS=${CFLAGS-"-O"}
519 CFLAGS=${CFLAGS-"-O"}
520 LDSHARED=${LDSHARED-"cc"}
521 LDSHAREDFLAGS="-shared" ;;
522 esac
523 fi
524
525 # Simplify some later conditionals
526 case "$uname" in
527 Linux* | linux*)
528 LINUX=1 ;;
529 *)
530 LINUX=0 ;;
531 esac
532
533 # destination names for shared library if not defined above
534 SHAREDLIB=${SHAREDLIB-"${LIBNAME}$shared_ext"}
535 SHAREDLIBV=${SHAREDLIBV-"${LIBNAME}$shared_ext.$VER"}
536 SHAREDLIBM=${SHAREDLIBM-"${LIBNAME}$shared_ext.$VER1"}
537 SHAREDTARGET=${SHAREDTARGET-"${LIBNAME}$shared_ext.$VER"}
538
539 echo >> configure.log
540
541 # define functions for testing compiler and library characteristics and logging the results
542
543 cat > $test.c <<EOF
544 #error error
545 EOF
546 if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
547 try()
548 {
549 show $*
550 test "`( $* ) 2>&1 | tee -a configure.log`" = ""
551 }
552 echo - using any output from compiler to indicate an error >> configure.log
553 else
554 try()
555 {
556 show $*
557 ( $* ) >> configure.log 2>&1
558 ret=$?
559 if test $ret -ne 0; then
560 echo "(exit code $ret)" >> configure.log
561 fi
562 return $ret
563 }
564 fi
565
566 cat > $test.c << EOF
567 int foo() { return 0; }
568 EOF
569 echo "Checking for obsessive-compulsive compiler options..." >> configure.log
570 if try $CC -c $CFLAGS $test.c; then
571 :
572 else
573 echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
574 leave 1
575 fi
576
577 echo >> configure.log
578
579 if test "$with_sanitizer" = "address"; then
580 echo -n "Checking for address sanitizer... " | tee -a configure.log
581 sanitizers=""
582 for san in address pointer-compare pointer-subtract; do
583 if try $CC -c $CFLAGS $test.c -fsanitize=$san ; then
584 if test -n "$sanitizers"; then
585 sanitizers="$sanitizers,$san"
586 else
587 sanitizers="$san"
588 fi
589 fi
590 done
591
592 if test -n "$sanitizers"; then
593 echo "-fsanitize=$sanitizers" | tee -a configure.log
594 CFLAGS="$CFLAGS -fsanitize=$sanitizers"
595 SFLAGS="$SFLAGS -fsanitize=$sanitizers"
596 LDFLAGS="$LDFLAGS -fsanitize=$sanitizers"
597 else
598 echo No | tee -a configure.log
599 fi
600
601 echo -n "Checking for leak sanitizer... " | tee -a configure.log
602 if try $CC -c $CFLAGS $test.c -fsanitize=leak; then
603 echo "-fsanitize=leak" | tee -a configure.log
604 CFLAGS="$CFLAGS -fsanitize=leak"
605 SFLAGS="$SFLAGS -fsanitize=leak"
606 LDFLAGS="$LDFLAGS -fsanitize=leak"
607 else
608 echo No | tee -a configure.log
609 fi
610
611 echo >> configure.log
612 fi
613
614 if test "$with_sanitizer" = "memory"; then
615 echo -n "Checking for memory sanitizer... " | tee -a configure.log
616 if try $CC -c $CFLAGS $test.c -fsanitize=memory ; then
617 echo "-fsanitize=memory" | tee -a configure.log
618 CFLAGS="$CFLAGS -fsanitize=memory"
619 SFLAGS="$SFLAGS -fsanitize=memory"
620 LDFLAGS="$LDFLAGS -fsanitize=memory"
621 else
622 echo No | tee -a configure.log
623 fi
624
625 echo >> configure.log
626 fi
627
628 if test "$with_sanitizer" = "undefined"; then
629 echo -n "Checking for undefined behavior sanitizer... " | tee -a configure.log
630 sanitizers=""
631 for san in array-bounds bool bounds builtin enum float-cast-overflow float-divide-by-zero function integer-divide-by-zero local-bounds null nonnull-attribute object-size pointer-overflow return returns-nonnull-attribute shift shift-base shift-exponent signed-integer-overflow undefined unsigned-integer-overflow unsigned-shift-base vla-bound vptr; do
632 if try $CC -c $CFLAGS $test.c -fsanitize=$san; then
633 if test -n "$sanitizers"; then
634 sanitizers="$sanitizers,$san"
635 else
636 sanitizers="$san"
637 fi
638 fi
639 done
640
641 if test -n "$sanitizers"; then
642 echo "-fsanitize=$sanitizers" | tee -a configure.log
643 CFLAGS="$CFLAGS -fsanitize=$sanitizers"
644 SFLAGS="$SFLAGS -fsanitize=$sanitizers"
645 LDFLAGS="$LDFLAGS -fsanitize=$sanitizers"
646 else
647 echo No | tee -a configure.log
648 fi
649
650 echo >> configure.log
651 fi
652
653 # see if shared library build supported
654 cat > $test.c <<EOF
655 extern int getchar();
656 int hello() {return getchar();}
657 EOF
658 if test $shared -eq 1; then
659 echo -n "Checking for shared library support... " | tee -a configure.log
660 # we must test in two steps (cc then ld), required at least on SunOS 4.x
661 if try $CC -w -c $SFLAGS $test.c &&
662 try $LDSHARED $LDSHAREDFLAGS $LDFLAGS -o $test$shared_ext $test.o $LDSHAREDLIBC; then
663 echo "Building shared library $SHAREDTARGET with $CC." | tee -a configure.log
664 elif test -z "$old_cc" -a -z "$old_cflags"; then
665 echo "No shared library support." | tee -a configure.log
666 shared=0;
667 else
668 echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
669 shared=0;
670 fi
671 fi
672 if test $shared -eq 0; then
673 LDSHARED="$CC"
674 LDSHAREDFLAGS=""
675 ALL="static"
676 SHAREDLIB=""
677 SHAREDLIBV=""
678 SHAREDLIBM=""
679 SHAREDTARGET=""
680 INSTALLTARGETS=install-static
681 UNINSTALLTARGETS=uninstall-static
682 echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
683 else
684 ALL="static shared"
685 TEST="${TEST} testshared"
686 fi
687
688 echo >> configure.log
689
690 # check for large file support, and if none, check for fseeko()
691 cat > $test.c <<EOF
692 #include <sys/types.h>
693 off64_t dummy = 0;
694 EOF
695 if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
696 CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
697 SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
698 echo "Checking for off64_t... Yes." | tee -a configure.log
699 echo "Checking for fseeko... Yes." | tee -a configure.log
700 else
701 echo "Checking for off64_t... No." | tee -a configure.log
702 echo >> configure.log
703 cat > $test.c <<EOF
704 #include <sys/types.h>
705 int main() {
706 _off64_t dummy = 0;
707 return 0;
708 }
709 EOF
710 if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
711 echo "Checking for _off64_t... Yes." | tee -a configure.log
712 else
713 echo "Checking for _off64_t... No." | tee -a configure.log
714 fi
715 echo >> configure.log
716 cat > $test.c <<EOF
717 #include <stdio.h>
718 int main(void) {
719 fseeko(NULL, 0, 0);
720 return 0;
721 }
722 EOF
723 if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
724 echo "Checking for fseeko... Yes." | tee -a configure.log
725 else
726 CFLAGS="${CFLAGS} -DNO_FSEEKO"
727 SFLAGS="${SFLAGS} -DNO_FSEEKO"
728 echo "Checking for fseeko... No." | tee -a configure.log
729 fi
730 fi
731 echo >> configure.log
732
733 cat > $test.c <<EOF
734 #define _POSIX_C_SOURCE 200112L
735 #include <stdlib.h>
736 int main(void) {
737 void *ptr = 0;
738 int ret = posix_memalign(&ptr, 64, 10);
739 if (ptr)
740 free(ptr);
741 return ret;
742 }
743 EOF
744 if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
745 echo "Checking for posix_memalign... Yes." | tee -a configure.log
746 CFLAGS="${CFLAGS} -DHAVE_POSIX_MEMALIGN"
747 SFLAGS="${SFLAGS} -DHAVE_POSIX_MEMALIGN"
748 else
749 echo "Checking for posix_memalign... No." | tee -a configure.log
750 fi
751 echo >> configure.log
752
753 cat > $test.c <<EOF
754 #define _ISOC11_SOURCE 1
755 #include <stdlib.h>
756 int main(void) {
757 void *ptr = aligned_alloc(64, 10);
758 if (ptr)
759 free(ptr);
760 return 0;
761 }
762 EOF
763 if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
764 echo "Checking for aligned_alloc... Yes." | tee -a configure.log
765 CFLAGS="${CFLAGS} -DHAVE_ALIGNED_ALLOC"
766 SFLAGS="${SFLAGS} -DHAVE_ALIGNED_ALLOC"
767 else
768 echo "Checking for aligned_alloc... No." | tee -a configure.log
769 fi
770 echo >> configure.log
771
772 # check for strerror() for use by gz* functions
773 cat > $test.c <<EOF
774 #include <string.h>
775 #include <errno.h>
776 int main() { return strlen(strerror(errno)); }
777 EOF
778 if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
779 echo "Checking for strerror... Yes." | tee -a configure.log
780 else
781 CFLAGS="${CFLAGS} -DNO_STRERROR"
782 SFLAGS="${SFLAGS} -DNO_STRERROR"
783 echo "Checking for strerror... No." | tee -a configure.log
784 fi
785
786 # We need to remove zconf.h from source directory if building outside of it
787 if [ "$SRCDIR" != "$BUILDDIR" ]; then
788 rm -f $SRCDIR/zconf${SUFFIX}.h
789 fi
790
791 # copy clean zconf.h for subsequent edits
792 cp -p $SRCDIR/zconf${SUFFIX}.h.in zconf${SUFFIX}.h
793
794 echo >> configure.log
795
796 # check for unistd.h and save result in zconf.h
797 cat > $test.c <<EOF
798 #include <unistd.h>
799 int main() { return 0; }
800 EOF
801 if try $CC -c $CFLAGS $test.c; then
802 sed < zconf${SUFFIX}.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf${SUFFIX}.temp.h
803 mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
804 echo "Checking for unistd.h... Yes." | tee -a configure.log
805 else
806 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
807 mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
808 echo "Checking for unistd.h... No." | tee -a configure.log
809 fi
810
811 echo >> configure.log
812
813 # check for ptrdiff_t and save result in zconf.h
814 echo -n "Checking for ptrdiff_t... " | tee -a configure.log
815 cat > $test.c <<EOF
816 #include <stddef.h>
817 int fun(ptrdiff_t *a) { (void)a; return 0; }
818 EOF
819 if try $CC -c $CFLAGS $test.c; then
820 echo "Yes." | tee -a configure.log
821 else
822 echo "No." | tee -a configure.log
823 sed < zconf${SUFFIX}.h "/^#ifdef NEED_PTRDIFF_T.* may be/s/def NEED_PTRDIFF_T\(.*\) may be/ 1\1 was/" > zconf${SUFFIX}.temp.h
824 mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
825
826 echo -n "Checking for sizeof(void *)... " | tee -a configure.log
827 cat > $test.c <<EOF
828 #include <stdint.h>
829 #define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; }
830 COMPILE_TIME_ASSERT(sizeof(int32_t) == sizeof(void *));
831 EOF
832 if try $CC -c $CFLAGS $test.c; then
833 echo "sizeof(int32_t)." | tee -a configure.log
834 sed < zconf${SUFFIX}.h "s/^typedef PTRDIFF_TYPE ptrdiff_t;/typedef int32_t ptrdiff_t;/g" > zconf${SUFFIX}.temp.h
835 mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
836 else
837 cat > $test.c <<EOF
838 #include <stdint.h>
839 #define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; }
840 COMPILE_TIME_ASSERT(sizeof(int64_t) == sizeof(void *));
841 EOF
842 if try $CC -c $CFLAGS $test.c; then
843 echo "sizeof(int64_t)." | tee -a configure.log
844 sed < zconf${SUFFIX}.h "s/^typedef PTRDIFF_TYPE ptrdiff_t;/typedef int64_t ptrdiff_t;/g" > zconf${SUFFIX}.temp.h
845 mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h
846 else
847 echo "unknown." | tee -a configure.log
848 exit 1
849 fi
850 fi
851 fi
852
853 # if --zlib-compat was requested
854 if test $compat -eq 1; then
855 gzfileops=1
856 CFLAGS="${CFLAGS} -DZLIB_COMPAT"
857 SFLAGS="${SFLAGS} -DZLIB_COMPAT"
858 case "$uname" in
859 CYGWIN* | Cygwin* | cygwin* | MSYS* | msys* | MINGW* | mingw*)
860 DEFFILE="win32/zlibcompat.def" ;;
861 esac
862 fi
863
864 # if --gzfileops was requested
865 if test $gzfileops -eq 1; then
866 CFLAGS="${CFLAGS} -DWITH_GZFILEOP"
867 SFLAGS="${SFLAGS} -DWITH_GZFILEOP"
868 OBJC="${OBJC} \$(OBJG)"
869 PIC_OBJC="${PIC_OBJC} \$(PIC_OBJG)"
870 fi
871
872 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
873 if test $cover -eq 1; then
874 CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
875 LDFLAGS="${LDFLAGS} -fprofile-arcs -ftest-coverage"
876 if test -n "$GCC_CLASSIC"; then
877 CC=$GCC_CLASSIC
878 fi
879 fi
880
881 echo >> configure.log
882
883 # Check for ANSI C compliant compiler
884 cat > $test.c <<EOF
885 #include <stdint.h>
886 #include <stdio.h>
887 #include <stdarg.h>
888 #include "zconf${SUFFIX}.h"
889 int main() {
890 #ifdef STDC
891 return 0;
892 #endif
893 return 1;
894 }
895 EOF
896 if try $CC -c $CFLAGS $test.c; then
897 echo "Checking for ANSI C compliant compiler... Yes." | tee -a configure.log
898 :
899 else
900 echo "Checking for ANSI C compliant compiler... No." | tee -a configure.log
901 echo "Error: ANSI C compatible compiler needed, cannot continue." | tee -a configure.log
902 leave 1
903 fi
904
905 # Check for -fno-semantic-interposition compiler support
906 echo "" > test.c
907 cat > $test.c <<EOF
908 int main() { return 0; }
909 EOF
910 if test "$gcc" -eq 1 && ($cc $CFLAGS -fno-semantic-interposition -c $test.c) >> configure.log 2>&1; then
911 echo "Checking for -fno-semantic-interposition... Yes." | tee -a configure.log
912 SFLAGS="$SFLAGS -fno-semantic-interposition"
913 else
914 echo "Checking for -fno-semantic-interposition... No." | tee -a configure.log
915 fi
916
917 # Check for -fno-lto compiler support
918 if test $gcc -eq 1 -a $without_optimizations -eq 0 -a $native -eq 0; then
919 cat > $test.c <<EOF
920 int main() { return 0; }
921 EOF
922 if $cc $CFLAGS -fno-lto -c $test.c >> configure.log 2>&1; then
923 echo "Checking for -fno-lto... Yes." | tee -a configure.log
924 else
925 echo "Checking for -fno-lto... No." | tee -a configure.log
926 noltoflag=""
927 fi
928 fi
929
930 # see if we can hide zlib internal symbols that are linked between separate source files using hidden
931 if test "$gcc" -eq 1; then
932 echo >> configure.log
933 cat > $test.c <<EOF
934 #define Z_INTERNAL __attribute__((visibility ("hidden")))
935 int Z_INTERNAL foo;
936 int main() { return 0; }
937 EOF
938 if try $CC $CFLAGS $test.c; then
939 CFLAGS="$CFLAGS -DHAVE_VISIBILITY_HIDDEN"
940 SFLAGS="$SFLAGS -DHAVE_VISIBILITY_HIDDEN"
941 echo >> configure.log
942 echo "Checking for attribute(visibility(hidden)) support... Yes." | tee -a configure.log
943 else
944 echo >> configure.log
945 echo "Checking for attribute(visibility(hidden)) support... No." | tee -a configure.log
946 fi
947 fi
948
949 # see if we can hide zlib internal symbols that are linked between separate source files using internal
950 if test "$gcc" -eq 1; then
951 echo >> configure.log
952 cat > $test.c <<EOF
953 #define Z_INTERNAL __attribute__((visibility ("internal")))
954 int Z_INTERNAL foo;
955 int main() { return 0; }
956 EOF
957 if try $CC $CFLAGS $test.c; then
958 CFLAGS="$CFLAGS -DHAVE_VISIBILITY_INTERNAL"
959 SFLAGS="$SFLAGS -DHAVE_VISIBILITY_INTERNAL"
960 echo >> configure.log
961 echo "Checking for attribute(visibility(internal)) support... Yes." | tee -a configure.log
962 else
963 echo >> configure.log
964 echo "Checking for attribute(visibility(internal)) support... No." | tee -a configure.log
965 fi
966 fi
967
968 # Check for __builtin_ctz() support in compiler
969 cat > $test.c << EOF
970 int main(void) {
971 unsigned int zero = 0;
972 long test = __builtin_ctz(zero);
973 (void)test;
974 return 0;
975 }
976 EOF
977 if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then
978 echo "Checking for __builtin_ctz ... Yes." | tee -a configure.log
979 CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZ"
980 SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZ"
981 else
982 echo "Checking for __builtin_ctz ... No." | tee -a configure.log
983 fi
984
985 # Check for __builtin_ctzll() support in compiler
986 cat > $test.c << EOF
987 int main(void) {
988 unsigned long long zero = 0;
989 long test = __builtin_ctzll(zero);
990 (void)test;
991 return 0;
992 }
993 EOF
994 if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then
995 echo "Checking for __builtin_ctzll ... Yes." | tee -a configure.log
996 CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZLL"
997 SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZLL"
998 else
999 echo "Checking for __builtin_ctzll ... No." | tee -a configure.log
1000 fi
1001
1002 # Check for SSE2 intrinsics
1003 case "${ARCH}" in
1004 i386 | i486 | i586 | i686 | x86_64)
1005 cat > $test.c << EOF
1006 #include <immintrin.h>
1007 int main(void) {
1008 __m128i zero = _mm_setzero_si128();
1009 (void)zero;
1010 return 0;
1011 }
1012 EOF
1013 if try ${CC} ${CFLAGS} ${sse2flag} $test.c; then
1014 echo "Checking for SSE2 intrinsics ... Yes." | tee -a configure.log
1015 HAVE_SSE2_INTRIN=1
1016 else
1017 echo "Checking for SSE2 intrinsics ... No." | tee -a configure.log
1018 HAVE_SSE2_INTRIN=0
1019 fi
1020 ;;
1021 esac
1022
1023 # Check for SSSE3 intrinsics
1024 case "${ARCH}" in
1025 i386 | i486 | i586 | i686 | x86_64)
1026 cat > $test.c << EOF
1027 #include <x86intrin.h>
1028 int main(void)
1029 {
1030 __m128i u, v, w;
1031 u = _mm_set1_epi32(1);
1032 v = _mm_set1_epi32(2);
1033 w = _mm_hadd_epi32(u, v);
1034 (void)w;
1035 return 0;
1036 }
1037 EOF
1038 if try ${CC} ${CFLAGS} ${ssse3flag} $test.c; then
1039 echo "Checking for SSSE3 intrinsics ... Yes." | tee -a configure.log
1040 HAVE_SSSE3_INTRIN=1
1041 else
1042 echo "Checking for SSSE3 intrinsics ... No." | tee -a configure.log
1043 HAVE_SSSE3_INTRIN=0
1044 fi
1045 ;;
1046 esac
1047
1048 # Check for SSE4.2 CRC inline assembly
1049 case "${ARCH}" in
1050 i386 | i486 | i586 | i686 | x86_64)
1051 cat > $test.c << EOF
1052 int main(void) {
1053 unsigned val = 0, h = 0;
1054 __asm__ __volatile__ ( "crc32 %1,%0" : "+r" (h) : "r" (val) );
1055 return (int) h;
1056 }
1057 EOF
1058 if try ${CC} ${CFLAGS} ${sse42flag} $test.c; then
1059 echo "Checking for SSE4.2 CRC inline assembly ... Yes." | tee -a configure.log
1060 HAVE_SSE42CRC_INLINE_ASM=1
1061 else
1062 echo "Checking for SSE4.2 CRC inline assembly ... No." | tee -a configure.log
1063 HAVE_SSE42CRC_INLINE_ASM=0
1064 fi
1065 ;;
1066 esac
1067
1068 # Check for SSE4.2 CRC intrinsics
1069 case "${ARCH}" in
1070 i386 | i486 | i586 | i686 | x86_64)
1071 cat > $test.c << EOF
1072 int main(void) {
1073 unsigned crc = 0;
1074 char c = 'c';
1075 crc = __builtin_ia32_crc32qi(crc, c);
1076 (void)crc;
1077 return 0;
1078 }
1079 EOF
1080 if try ${CC} ${CFLAGS} ${sse42flag} $test.c; then
1081 echo "Checking for SSE4.2 CRC intrinsics ... Yes." | tee -a configure.log
1082 HAVE_SSE42CRC_INTRIN=1
1083 else
1084 echo "Checking for SSE4.2 CRC intrinsics ... No." | tee -a configure.log
1085 HAVE_SSE42CRC_INTRIN=0
1086 fi
1087 ;;
1088 esac
1089
1090 # Check for SSE4.2 compare string intrinsics
1091 case "${ARCH}" in
1092 i386 | i486 | i586 | i686 | x86_64)
1093 cat > $test.c << EOF
1094 #include <immintrin.h>
1095 int main(void)
1096 {
1097 unsigned char a[64] = { 0 };
1098 unsigned char b[64] = { 0 };
1099 __m128i xmm_src0, xmm_src1;
1100 xmm_src0 = _mm_loadu_si128((__m128i *)(char *)a);
1101 xmm_src1 = _mm_loadu_si128((__m128i *)(char *)b);
1102 return _mm_cmpestri(xmm_src0, 16, xmm_src1, 16, 0);
1103 }
1104 EOF
1105 if try ${CC} ${CFLAGS} ${sse42flag} $test.c; then
1106 echo "Checking for SSE4.2 compare string intrinsics ... Yes." | tee -a configure.log
1107 HAVE_SSE42CMPSTR_INTRIN=1
1108 else
1109 echo "Checking for SSE4.2 compare string intrinsics ... No." | tee -a configure.log
1110 HAVE_SSE42CMPSTR_INTRIN=0
1111 fi
1112 ;;
1113 esac
1114
1115 # Check for PCLMULQDQ intrinsics
1116 case "${ARCH}" in
1117 i386 | i486 | i586 | i686 | x86_64)
1118 cat > $test.c << EOF
1119 #include <immintrin.h>
1120 #include <wmmintrin.h>
1121 int main(void) {
1122 __m128i a = _mm_setzero_si128();
1123 __m128i b = _mm_setzero_si128();
1124 __m128i c = _mm_clmulepi64_si128(a, b, 0x10);
1125 (void)c;
1126 return 0;
1127 }
1128 EOF
1129 if try ${CC} ${CFLAGS} ${pclmulflag} $test.c; then
1130 echo "Checking for PCLMULQDQ intrinsics ... Yes." | tee -a configure.log
1131 HAVE_PCLMULQDQ_INTRIN=1
1132 else
1133 echo "Checking for PCLMULQDQ intrinsics ... No." | tee -a configure.log
1134 HAVE_PCLMULQDQ_INTRIN=0
1135 fi
1136
1137 # Enable deflate_medium at level 1
1138 if test $without_new_strategies -eq 1; then
1139 CFLAGS="${CFLAGS} -DNO_QUICK_STRATEGY"
1140 SFLAGS="${SFLAGS} -DNO_QUICK_STRATEGY"
1141 fi
1142 # Enable deflate_medium at level 4-6
1143 if test $without_new_strategies -eq 1; then
1144 CFLAGS="${CFLAGS} -DNO_MEDIUM_STRATEGY"
1145 SFLAGS="${SFLAGS} -DNO_MEDIUM_STRATEGY"
1146 fi
1147 ;;
1148 esac
1149
1150 # Check for AVX2 intrinsics
1151 case "${ARCH}" in
1152 i386 | i486 | i586 | i686 | x86_64)
1153 cat > $test.c << EOF
1154 #include <immintrin.h>
1155 int main(void) {
1156 __m256i x = _mm256_set1_epi16(2);
1157 const __m256i y = _mm256_set1_epi16(1);
1158 x = _mm256_subs_epu16(x, y);
1159 (void)x;
1160 return 0;
1161 }
1162 EOF
1163 if try ${CC} ${CFLAGS} ${avx2flag} $test.c; then
1164 echo "Checking for AVX2 intrinsics ... Yes." | tee -a configure.log
1165 HAVE_AVX2_INTRIN=1
1166 else
1167 echo "Checking for AVX2 intrinsics ... No." | tee -a configure.log
1168 HAVE_AVX2_INTRIN=0
1169 fi
1170 ;;
1171 esac
1172
1173
1174 # Check whether -mfpu=neon is available on ARM processors.
1175 case "${ARCH}" in
1176 arm*)
1177 cat > $test.c << EOF
1178 int main() { return 0; }
1179 EOF
1180 if try $CC -c $CFLAGS -mfpu=neon $test.c; then
1181 MFPU_NEON_AVAILABLE=1
1182 echo "Check whether -mfpu=neon is available ... Yes." | tee -a configure.log
1183 else
1184 MFPU_NEON_AVAILABLE=0
1185 echo "Check whether -mfpu=neon is available ... No." | tee -a configure.log
1186 fi
1187 ;;
1188 esac
1189
1190 # Check whether features needed by POWER optimisations are available
1191 case "${ARCH}" in
1192 powerpc*)
1193 cat > $test.c << EOF
1194 #include <sys/auxv.h>
1195 int main() { return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07); }
1196 EOF
1197 if try $CC -c $CFLAGS -mcpu=power8 $test.c; then
1198 HAVE_POWER8=1
1199 echo "Check whether POWER8 instructions are available ... Yes." | tee -a configure.log
1200 else
1201 HAVE_POWER8=0
1202 echo "Check whether POWER8 instructions are available ... No." | tee -a configure.log
1203 fi
1204 esac
1205
1206 # Check whether sys/sdt.h is available
1207 cat > $test.c << EOF
1208 #include <sys/sdt.h>
1209 int main() { return 0; }
1210 EOF
1211 if try ${CC} ${CFLAGS} $test.c; then
1212 echo "Checking for sys/sdt.h ... Yes." | tee -a configure.log
1213 CFLAGS="$CFLAGS -DHAVE_SYS_SDT_H"
1214 SFLAGS="$SFLAGS -DHAVE_SYS_SDT_H"
1215 else
1216 echo "Checking for sys/sdt.h ... No." | tee -a configure.log
1217 fi
1218
1219 ARCHDIR='arch/generic'
1220 ARCH_STATIC_OBJS=''
1221 ARCH_SHARED_OBJS=''
1222
1223 # Set ARCH specific FLAGS
1224 case "${ARCH}" in
1225 # x86/amd64 specific optimizations
1226 i386 | i486 | i586 | i686 |x86_64)
1227 ARCHDIR=arch/x86
1228
1229 CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1230 SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1231
1232 # Enable arch-specific optimizations
1233 if test $without_optimizations -eq 0; then
1234 CFLAGS="${CFLAGS} -DX86_FEATURES"
1235 SFLAGS="${SFLAGS} -DX86_FEATURES"
1236
1237 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} x86.o"
1238 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} x86.lo"
1239
1240 if test ${HAVE_AVX2_INTRIN} -eq 1; then
1241 CFLAGS="${CFLAGS} -DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET"
1242 SFLAGS="${SFLAGS} -DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET"
1243 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} slide_avx.o chunkset_avx.o compare258_avx.o adler32_avx.o"
1244 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} slide_avx.lo chunkset_avx.lo compare258_avx.lo adler32_avx.lo"
1245 fi
1246
1247 if test ${HAVE_SSE42CRC_INTRIN} -eq 1 || test ${HAVE_SSE42CRC_INLINE_ASM} -eq 1; then
1248 CFLAGS="${CFLAGS} -DX86_SSE42_CRC_HASH"
1249 SFLAGS="${SFLAGS} -DX86_SSE42_CRC_HASH"
1250
1251 if test ${HAVE_SSE42CRC_INTRIN} -eq 1; then
1252 CFLAGS="${CFLAGS} -DX86_SSE42_CRC_INTRIN"
1253 SFLAGS="${SFLAGS} -DX86_SSE42_CRC_INTRIN"
1254 fi
1255
1256 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} insert_string_sse.o"
1257 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} insert_string_sse.lo"
1258 fi
1259
1260 if test ${HAVE_SSE42CMPSTR_INTRIN} -eq 1; then
1261 CFLAGS="${CFLAGS} -DX86_SSE42_CMP_STR"
1262 SFLAGS="${SFLAGS} -DX86_SSE42_CMP_STR"
1263
1264 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} compare258_sse.o"
1265 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} compare258_sse.lo"
1266 fi
1267
1268 if test ${HAVE_SSE2_INTRIN} -eq 1; then
1269 CFLAGS="${CFLAGS} -DX86_SSE2 -DX86_SSE2_CHUNKSET -DX86_SSE2_SLIDEHASH"
1270 SFLAGS="${SFLAGS} -DX86_SSE2 -DX86_SSE2_CHUNKSET -DX86_SSE2_SLIDEHASH"
1271 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} chunkset_sse.o slide_sse.o"
1272 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} chunkset_sse.lo slide_sse.lo"
1273
1274 if test $forcesse2 -eq 1; then
1275 CFLAGS="${CFLAGS} -DX86_NOCHECK_SSE2"
1276 SFLAGS="${SFLAGS} -DX86_NOCHECK_SSE2"
1277 fi
1278 fi
1279
1280 if test ${HAVE_SSSE3_INTRIN} -eq 1; then
1281 CFLAGS="${CFLAGS} -DX86_SSSE3 -DX86_SSSE3_ADLER32"
1282 SFLAGS="${SFLAGS} -DX86_SSSE3 -DX86_SSSE3_ADLER32"
1283 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_ssse3.o"
1284 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_ssse3.lo"
1285 fi
1286
1287 if test ${HAVE_PCLMULQDQ_INTRIN} -eq 1; then
1288 CFLAGS="${CFLAGS} -DX86_PCLMULQDQ_CRC"
1289 SFLAGS="${SFLAGS} -DX86_PCLMULQDQ_CRC"
1290 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc_folding.o"
1291 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc_folding.lo"
1292 fi
1293
1294 if test $forcetzcnt -eq 1; then
1295 CFLAGS="${CFLAGS} -DX86_NOCHECK_TZCNT"
1296 SFLAGS="${SFLAGS} -DX86_NOCHECK_TZCNT"
1297 fi
1298 fi
1299 ;;
1300
1301 # ARM specific optimizations
1302 arm*)
1303 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=arm
1304 ARCHDIR=arch/arm
1305
1306 if test $without_optimizations -eq 0; then
1307 CFLAGS="${CFLAGS} -DARM_FEATURES"
1308 SFLAGS="${SFLAGS} -DARM_FEATURES"
1309 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} armfeature.o"
1310 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} armfeature.lo"
1311
1312 if test $LINUX -eq 1; then
1313 cat > $test.c <<EOF
1314 #include <sys/auxv.h>
1315 int main() {
1316 return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
1317 }
1318 EOF
1319 if try $CC -c $CFLAGS $test.c; then
1320 CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32"
1321 SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32"
1322 else
1323 cat > $test.c <<EOF
1324 #include <sys/auxv.h>
1325 #include <asm/hwcap.h>
1326 int main() {
1327 return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
1328 }
1329 EOF
1330 if try $CC -c $CFLAGS $test.c; then
1331 CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32 -DARM_ASM_HWCAP"
1332 SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32 -DARM_ASM_HWCAP"
1333 else
1334 echo "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log
1335 fi
1336 fi
1337
1338 cat > $test.c <<EOF
1339 #include <sys/auxv.h>
1340 int main() {
1341 return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON);
1342 }
1343 EOF
1344 if try $CC -c $CFLAGS $test.c; then
1345 CFLAGS="${CFLAGS} -DARM_AUXV_HAS_NEON"
1346 SFLAGS="${SFLAGS} -DARM_AUXV_HAS_NEON"
1347 else
1348 cat > $test.c <<EOF
1349 #include <sys/auxv.h>
1350 int main() {
1351 return (getauxval(AT_HWCAP) & HWCAP_NEON);
1352 }
1353 EOF
1354 if try $CC -c $CFLAGS $test.c; then
1355 CFLAGS="${CFLAGS} -DARM_AUXV_HAS_NEON"
1356 SFLAGS="${SFLAGS} -DARM_AUXV_HAS_NEON"
1357 else
1358 echo "Neither HWCAP_ARM_NEON or HWCAP_NEON present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log
1359 fi
1360 fi
1361 fi
1362 fi
1363
1364 cat > $test.c << EOF
1365 int main() { return 0; }
1366 EOF
1367 if try $CC -w -c $SFLAGS $test.c -mfloat-abi=softfp &&
1368 try $LDSHARED $LDSHAREDFLAGS $LDFLAGS -o $test$shared_ext $test.o $LDSHAREDLIBC; then
1369 floatabi="-mfloat-abi=softfp"
1370 else
1371 if try $CC -w -c $SFLAGS $test.c -mfloat-abi=hard &&
1372 try $LDSHARED $LDSHAREDFLAGS $LDFLAGS -o $test$shared_ext $test.o $LDSHAREDLIBC; then
1373 floatabi="-mfloat-abi=hard"
1374 fi
1375 fi
1376
1377 if [ -z $floatabi ]; then
1378 echo "ARM floating point arch not auto-detected" | tee -a configure.log
1379 else
1380 echo "ARM floating point arch: ${floatabi}" | tee -a configure.log
1381
1382 CFLAGS="${CFLAGS} ${floatabi}"
1383 SFLAGS="${SFLAGS} ${floatabi}"
1384 fi
1385
1386 case "${ARCH}" in
1387 armv[345]*)
1388 if test $without_optimizations -eq 0; then
1389 if test $buildacle -eq 1; then
1390 echo ACLE support not available
1391 fi
1392
1393 if test $buildneon -eq 1; then
1394 echo NEON support not available
1395 fi
1396 fi
1397 ;;
1398 armv6l | armv6hl)
1399 CFLAGS="${CFLAGS} -DUNALIGNED_OK"
1400 SFLAGS="${SFLAGS} -DUNALIGNED_OK"
1401
1402 if test $without_optimizations -eq 0; then
1403 if test $buildacle -eq 1; then
1404 echo ACLE support not available
1405 fi
1406
1407 if test $buildneon -eq 1; then
1408 echo NEON support not available
1409 fi
1410 fi
1411 ;;
1412 arm | armv7*)
1413 CFLAGS="${CFLAGS} -DUNALIGNED_OK"
1414 SFLAGS="${SFLAGS} -DUNALIGNED_OK"
1415
1416 if test $without_optimizations -eq 0; then
1417 if test $buildacle -eq 1; then
1418 echo ACLE support not available
1419 fi
1420
1421 if test $buildneon -eq 1; then
1422 if test $MFPU_NEON_AVAILABLE -eq 1;then
1423 neonflag="-mfpu=neon"
1424 fi
1425
1426 CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1427 SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1428
1429 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o"
1430 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo"
1431 fi
1432 fi
1433 ;;
1434 armv8-a | armv8-a+simd)
1435 CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1436 SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1437
1438 if test $without_optimizations -eq 0; then
1439 if test $buildacle -eq 1; then
1440 echo ACLE support not available
1441 fi
1442
1443 if test $buildneon -eq 1; then
1444 if test $MFPU_NEON_AVAILABLE -eq 1;then
1445 neonflag="-mfpu=neon"
1446 fi
1447
1448 CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1449 SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1450
1451 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o"
1452 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo"
1453 fi
1454 fi
1455 ;;
1456 armv8-a+crc | armv8-a+crc+simd | armv8.[1234]-a | armv8.[1234]-a+simd)
1457 CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1458 SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1459
1460 acleflag="-march=${ARCH}"
1461
1462 if test $without_optimizations -eq 0; then
1463 CFLAGS="${CFLAGS} -DARM_ACLE_CRC_HASH"
1464 SFLAGS="${SFLAGS} -DARM_ACLE_CRC_HASH"
1465
1466 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o"
1467 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo"
1468
1469 if test $buildneon -eq 1; then
1470 if test $MFPU_NEON_AVAILABLE -eq 1;then
1471 neonflag="-mfpu=neon"
1472 fi
1473
1474 CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1475 SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1476
1477 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o"
1478 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo"
1479 fi
1480 fi
1481 ;;
1482 esac
1483
1484 ;;
1485 # 64-bit ARM specific optimizations
1486 aarch64 | arm64)
1487 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=aarch64
1488 ARCHDIR=arch/arm
1489
1490 if test $native -eq 0; then
1491 ARCH="armv8-a"
1492 else
1493 ARCH="native"
1494 fi
1495
1496 if test $without_optimizations -eq 0; then
1497 CFLAGS="${CFLAGS} -DARM_FEATURES"
1498 SFLAGS="${SFLAGS} -DARM_FEATURES"
1499 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} armfeature.o"
1500 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} armfeature.lo"
1501
1502 if test $LINUX -eq 1; then
1503 cat > $test.c <<EOF
1504 #include <sys/auxv.h>
1505 int main() {
1506 return (getauxval(AT_HWCAP) & HWCAP_CRC32);
1507 }
1508 EOF
1509 if try $CC -c $CFLAGS $test.c; then
1510 CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32"
1511 SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32"
1512 else
1513 echo "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log
1514 fi
1515 fi
1516
1517 if test $buildacle -eq 1; then
1518 if test $native -eq 0; then
1519 ARCH="${ARCH}+crc"
1520 fi
1521 CFLAGS="${CFLAGS} -DARM_ACLE_CRC_HASH"
1522 SFLAGS="${SFLAGS} -DARM_ACLE_CRC_HASH"
1523 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o"
1524 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo"
1525 fi
1526
1527 if test $buildneon -eq 1; then
1528 if test $native -eq 0; then
1529 ARCH="${ARCH}+simd"
1530 fi
1531 CFLAGS="${CFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1532 SFLAGS="${SFLAGS} -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH"
1533 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} adler32_neon.o chunkset_neon.o slide_neon.o"
1534 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} adler32_neon.lo chunkset_neon.lo slide_neon.lo"
1535 fi
1536 fi
1537
1538 neonflag="-march=${ARCH}"
1539 acleflag="-march=${ARCH}"
1540
1541 CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1542 SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1543 ;;
1544 powerpc*)
1545 case "${ARCH}" in
1546 powerpc)
1547 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc
1548 ;;
1549 powerpc64)
1550 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64
1551 ;;
1552 powerpc64le)
1553 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64le
1554 CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1555 SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
1556 ;;
1557 esac
1558
1559 ARCHDIR=arch/power
1560
1561 if test $without_optimizations -eq 0; then
1562 if test $HAVE_POWER8 -eq 1; then
1563 CFLAGS="${CFLAGS} -DPOWER8 -DPOWER_FEATURES -DPOWER8_VSX_ADLER32 -DPOWER8_VSX_SLIDEHASH"
1564 SFLAGS="${SFLAGS} -DPOWER8 -DPOWER_FEATURES -DPOWER8_VSX_ADLER32 -DPOWER8_VSX_SLIDEHASH"
1565
1566 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} power.o adler32_power8.o slide_hash_power8.o"
1567 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} power.lo adler32_power8.lo slide_hash_power8.lo"
1568 fi
1569 fi
1570 ;;
1571 s390x)
1572 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=s390x
1573 ARCHDIR=arch/s390
1574
1575 if test $without_optimizations -eq 0; then
1576 if test $builddfltccdeflate -eq 1 -o $builddfltccinflate -eq 1; then
1577 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_common.o"
1578 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_common.lo"
1579 fi
1580
1581 if test $builddfltccdeflate -eq 1; then
1582 CFLAGS="${CFLAGS} -DS390_DFLTCC_DEFLATE"
1583 SFLAGS="${SFLAGS} -DS390_DFLTCC_DEFLATE"
1584 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_deflate.o"
1585 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_deflate.lo"
1586 ARCH="${ARCH}+dfltcc-deflate"
1587 fi
1588
1589 if test $builddfltccinflate -eq 1; then
1590 CFLAGS="${CFLAGS} -DS390_DFLTCC_INFLATE"
1591 SFLAGS="${SFLAGS} -DS390_DFLTCC_INFLATE"
1592 ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} dfltcc_inflate.o"
1593 ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} dfltcc_inflate.lo"
1594 ARCH="${ARCH}+dfltcc-inflate"
1595 fi
1596 fi
1597 ;;
1598 *)
1599 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=$ARCH
1600 ;;
1601 esac
1602
1603 echo "ARCH: ${ARCH}"
1604 echo "Using arch directory: ${ARCHDIR}"
1605
1606 # show the results in the log
1607 echo >> configure.log
1608 echo ALL = $ALL >> configure.log
1609 echo AR = $AR >> configure.log
1610 echo ARFLAGS = $ARFLAGS >> configure.log
1611 echo CC = $CC >> configure.log
1612 echo CFLAGS = $CFLAGS >> configure.log
1613 echo EXE = $EXE >> configure.log
1614 echo LDCONFIG = $LDCONFIG >> configure.log
1615 echo LDFLAGS = $LDFLAGS >> configure.log
1616 echo LDSHARED = $LDSHARED >> configure.log
1617 echo LDSHAREDFLAGS = $LDSHAREDFLAGS >> configure.log
1618 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
1619 echo DEFFILE = $DEFFILE >> configure.log
1620 echo RC = $RC >> configure.log
1621 echo RCFLAGS = $RCFLAGS >> configure.log
1622 echo RCOBJS = $RCOBJS >> configure.log
1623 echo STRIP = $STRIP >> configure.log
1624 echo OBJC = $OBJC >> configure.log
1625 echo PIC_OBJC = $PIC_OBJC >> configure.log
1626 echo RANLIB = $RANLIB >> configure.log
1627 echo SFLAGS = $SFLAGS >> configure.log
1628 echo SHAREDLIB = $SHAREDLIB >> configure.log
1629 echo SHAREDLIBM = $SHAREDLIBM >> configure.log
1630 echo SHAREDLIBV = $SHAREDLIBV >> configure.log
1631 echo SHAREDTARGET = $SHAREDTARGET >> configure.log
1632 echo IMPORTLIB = $IMPORTLIB >> configure.log
1633 echo INSTALLTARGETS = $INSTALLTARGETS >> configure.log
1634 echo UNINSTALLTARGETS = $UNINSTALLTARGETS >> configure.log
1635 echo SRCDIR = $SRCDIR >> configure.log
1636 echo BUILDDIR = $BUILDDIR >> configure.log
1637 echo STATICLIB = $STATICLIB >> configure.log
1638 echo TEST = $TEST >> configure.log
1639 echo VER = $VER >> configure.log
1640 echo exec_prefix = $exec_prefix >> configure.log
1641 echo includedir = $includedir >> configure.log
1642 echo bindir = $bindir >> configure.log
1643 echo libdir = $libdir >> configure.log
1644 echo mandir = $mandir >> configure.log
1645 echo prefix = $prefix >> configure.log
1646 echo sharedlibdir = $sharedlibdir >> configure.log
1647 echo uname = $uname >> configure.log
1648 echo sse2flag = $sse2flag >> configure.log
1649 echo ssse3flag = $ssse3flag >> configure.log
1650 echo sse4flag = $sse4flag >> configure.log
1651 echo pclmulflag = $pclmulflag >> configure.log
1652 echo acleflag = $acleflag >> configure.log
1653 echo neonflag = $neonflag >> configure.log
1654 echo ARCHDIR = ${ARCHDIR} >> configure.log
1655 echo ARCH_STATIC_OBJS = ${ARCH_STATIC_OBJS} >> configure.log
1656 echo ARCH_SHARED_OBJS = ${ARCH_SHARED_OBJS} >> configure.log
1657
1658 # Handle sed incompatibilities when using -i
1659 replace_in_file() {
1660 if [ "$OS" = 'Darwin' ]; then
1661 sed -i '.tmp' -e "$1" "$2"
1662 else
1663 sed -i'.tmp' -e "$1" "$2"
1664 fi
1665 }
1666
1667 # update Makefile with the configure results
1668
1669 INCLUDES="-I$SRCDIR"
1670 if [ "$SRCDIR" != "$BUILDDIR" ]; then INCLUDES="-I$BUILDDIR ${INCLUDES}"; fi
1671
1672 sed < $SRCDIR/Makefile.in "
1673 /^CC *=/s#=.*#=$CC#
1674 /^CFLAGS *=/s#=.*#=$CFLAGS#
1675 /^WITH_FUZZERS *=/s#=.*#=$with_fuzzers#
1676 /^SFLAGS *=/s#=.*#=$SFLAGS#
1677 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
1678 /^LDSHARED *=/s#=.*#=$LDSHARED#
1679 /^LDSHAREDFLAGS *=/s#=.*#=$LDSHAREDFLAGS#
1680 /^LIBNAME1 *=/s#=.*#=$LIBNAME#
1681 /^LIBNAME2 *=/s#=.*#=$LIBNAME2#
1682 /^SUFFIX *=/s#=.*#=$SUFFIX#
1683 /^STATICLIB *=/s#=.*#=$STATICLIB#
1684 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
1685 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
1686 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
1687 /^SHAREDTARGET *=/s#=.*#=$SHAREDTARGET#
1688 /^IMPORTLIB *=/s#=.*#=$IMPORTLIB#
1689 /^VER *=/s#=.*#=$VER#
1690 /^VER1 *=/s#=.*#=$VER1#
1691 /^AR *=/s#=.*#=$AR#
1692 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
1693 /^RANLIB *=/s#=.*#=$RANLIB#
1694 /^LDCONFIG *=/s#=.*#=$LDCONFIG#
1695 /^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
1696 /^DEFFILE *=/s#=.*#=$DEFFILE#
1697 /^RC *=/s#=.*#=$RC#
1698 /^RCFLAGS *=/s#=.*#=$RCFLAGS#
1699 /^RCOBJS *=/s#=.*#=$RCOBJS#
1700 /^STRIP *=/s#=.*#=$STRIP#
1701 /^EXE *=/s#=.*#=$EXE#
1702 /^prefix *=/s#=.*#= $prefix#
1703 /^exec_prefix *=/s#=.*#= $exec_prefix#
1704 /^bindir *=/s#=.*#= $bindir#
1705 /^libdir *=/s#=.*#= $libdir#
1706 /^sharedlibdir *=/s#=.*#= $sharedlibdir#
1707 /^includedir *=/s#=.*#= $includedir#
1708 /^mandir *=/s#=.*#= $mandir#
1709 /^SRCDIR *=/s#=.*#=$SRCDIR#
1710 /^INCLUDES *=/s#=.*#=$INCLUDES#
1711 /^OBJC *=/s#=.*#= $OBJC#
1712 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
1713 /^all: */s#:.*#: $ALL#
1714 /^install-libs: */s#:.*#: $INSTALLTARGETS#
1715 /^uninstall-libs: */s#:.*#: $UNINSTALLTARGETS#
1716 /^ARCHDIR *=/s#=.*#=$ARCHDIR#
1717 /^ARCH_STATIC_OBJS *=/s#=.*#=$ARCH_STATIC_OBJS#
1718 /^ARCH_SHARED_OBJS *=/s#=.*#=$ARCH_SHARED_OBJS#
1719 " > Makefile
1720
1721 # Append header files dependences.
1722 for file in $(ls -1 $SRCDIR/*.c $SRCDIR/test/*.c $SRCDIR/test/fuzz/*.c $SRCDIR/$ARCHDIR/*.c $SRCDIR/tools/*.c); do
1723 short_name=$(echo $file | sed -e "s#$SRCDIR/##g")
1724 incs=$(grep -h include $file | sed -n 's/# *\include *"\(.*\.h\)".*/\1/p' | sort | uniq)
1725 includes=$(for i in $incs; do
1726 # Check that the include file exists in the current dir,
1727 # otherwise it may be one of the system include header.
1728 if test -e $SRCDIR/$i; then
1729 echo -n " \$(SRCDIR)/$i"
1730 fi
1731 # We also need to check whether the include file is in the ARCHDIR.
1732 if test -e $SRCDIR/$ARCHDIR/$i; then
1733 echo -n " \$(SRCDIR)/$ARCHDIR/$i"
1734 fi
1735 done)
1736 obj=$(basename $(echo $file | sed -e 's/\.c/\.o/g' -e 's#^\./##g'))
1737 lobj=$(basename $(echo $file | sed -e 's/\.c/\.lo/g' -e 's#^\./##g'))
1738
1739 if grep -q "^$obj:" Makefile; then
1740 # Replace the existing line with a line with all dependences.
1741 $(replace_in_file "s#$obj:.*#$obj: \$(SRCDIR)/$short_name $includes#g" Makefile)
1742 else
1743 # Append at the end of Makefile a new line with the header dependences.
1744 echo "$obj: \$(SRCDIR)/$short_name $includes" >> Makefile
1745
1746 # In case this is one of the ARCHDIR files, append a dependence line
1747 # that will force the `$(MAKE) -C $(ARCHDIR)` generic rule. Without this
1748 # we would only execute the copy rule from ARCHDIR to SRCDIR.
1749 if test -e $SRCDIR/$ARCHDIR/$(basename $file); then
1750 echo "$ARCHDIR/$obj: \$(SRCDIR)/$short_name $includes" >> Makefile
1751 fi
1752 fi
1753
1754 if grep -q "^$lobj:" Makefile; then
1755 # Replace the existing line with a line with all dependences.
1756 $(replace_in_file "s#$lobj:.*#$lobj: \$(SRCDIR)/$short_name $includes#g" Makefile)
1757 else
1758 # Append at the end of Makefile a new line with the header dependences.
1759 echo "$lobj: \$(SRCDIR)/$short_name $includes" >> Makefile
1760 fi
1761 done
1762
1763 # Generate Makefile in arch dir
1764 mkdir -p $ARCHDIR
1765
1766 ARCHINCLUDES="-I$SRCDIR/$ARCHDIR -I$SRCDIR"
1767 if [ "$SRCDIR" != "$BUILDDIR" ]; then ARCHINCLUDES="-I$BUILDDIR ${ARCHINCLUDES}"; fi
1768
1769 sed < $SRCDIR/$ARCHDIR/Makefile.in "
1770 /^CC *=/s#=.*#=$CC#
1771 /^CFLAGS *=/s#=.*#=$CFLAGS#
1772 /^SFLAGS *=/s#=.*#=$SFLAGS#
1773 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
1774 /^INCLUDES *=/s#=.*#=$ARCHINCLUDES#
1775 /^SUFFIX *=/s#=.*#=$SUFFIX#
1776 /^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR#
1777 /^SRCTOP *=/s#=.*#=$SRCDIR#
1778 /^TOPDIR *=/s#=.*#=$BUILDDIR#
1779 /^AVX2FLAG *=/s#=.*#=$avx2flag#
1780 /^SSE2FLAG *=/s#=.*#=$sse2flag#
1781 /^SSSE3FLAG *=/s#=.*#=$ssse3flag#
1782 /^SSE4FLAG *=/s#=.*#=$sse4flag#
1783 /^PCLMULFLAG *=/s#=.*#=$pclmulflag#
1784 /^ACLEFLAG *=/s#=.*#=$acleflag#
1785 /^NEONFLAG *=/s#=.*#=$neonflag#
1786 /^NOLTOFLAG *=/s#=.*#=$noltoflag#
1787 " > $ARCHDIR/Makefile
1788
1789 # Append header files dependences.
1790 for file in $(ls -1 $SRCDIR/$ARCHDIR/*.c); do
1791 incs=$(grep -h include $file | sed -n 's/# *\include *"\(.*\.h\)".*/\1/p' | sort | uniq)
1792 includes=$(for i in $incs; do
1793 # Check that the include file exists in the current dir,
1794 # otherwise it may be one of the system include header.
1795 if test -e $SRCDIR/$i; then
1796 echo -n " \$(SRCTOP)/$i"
1797 fi
1798 # We also need to check whether the include file is in the ARCHDIR.
1799 if test -e $SRCDIR/$ARCHDIR/$i; then
1800 echo -n " \$(SRCDIR)/$i"
1801 fi
1802 done)
1803 obj=$(basename $(echo $file | sed -e 's/\.c/\.o/g' -e 's#^\./##g'))
1804 lobj=$(basename $(echo $file | sed -e 's/\.c/\.lo/g' -e 's#^\./##g'))
1805 short_name=$(basename $file)
1806 if grep -q "^$obj:" $ARCHDIR/Makefile; then
1807 # Replace the existing line with a line with all dependences.
1808 $(replace_in_file "s#$obj:.*#$obj: \$(SRCDIR)/$short_name $includes#g" $ARCHDIR/Makefile)
1809 else
1810 # Append at the end of Makefile a new line with the header dependences.
1811 echo "$obj: \$(SRCDIR)/$short_name $includes" >> $ARCHDIR/Makefile
1812 fi
1813
1814 if grep -q "^$lobj:" $ARCHDIR/Makefile; then
1815 # Replace the existing line with a line with all dependences.
1816 $(replace_in_file "s#$lobj:.*#$lobj: \$(SRCDIR)/$short_name $includes#g" $ARCHDIR/Makefile)
1817 else
1818 # Append at the end of Makefile a new line with the header dependences.
1819 echo "$lobj: \$(SRCDIR)/$short_name $includes" >> $ARCHDIR/Makefile
1820 fi
1821 done
1822
1823 # Generate Makefile in test dir
1824 mkdir -p test
1825 if test $compat -eq 1; then COMPATTESTS="compattests"; fi
1826 if test $QEMU_ARCH; then QEMU_RUN="qemu-$QEMU_ARCH -L /usr/${CHOST}/"; fi
1827 sed < $SRCDIR/test/Makefile.in "
1828 /^CC *=/s#=.*#=$CC#
1829 /^CFLAGS *=/s#=.*#=$CFLAGS#
1830 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
1831 /^EXE *=/s#=.*#=$EXE#
1832 /^oldtests: */s#:.*#: $TEST#
1833 /^SRCDIR *=/s#=.*#=$SRCDIR/test#
1834 /^SRCTOP *=/s#=.*#=$SRCDIR#
1835 /^COMPATTESTS *=/s#=.*#=$COMPATTESTS#
1836 /^QEMU_RUN *=/s#=.*#=$QEMU_RUN#
1837 /^WITH_FUZZERS *=/s#=.*#=$with_fuzzers#
1838 /^LIBNAME *=/s#=.*#=$LIBNAME#
1839 " > test/Makefile
1840
1841 # create zlib.pc with the configure results
1842 sed < $SRCDIR/zlib.pc.in "
1843 /^CC *=/s#=.*#=$CC#
1844 /^CFLAGS *=/s#=.*#=$CFLAGS#
1845 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
1846 /^LDSHARED *=/s#=.*#=$LDSHARED#
1847 /^LDSHAREDFLAGS *=/s#=.*#=$LDSHAREDFLAGS#
1848 /^STATICLIB *=/s#=.*#=$STATICLIB#
1849 /^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
1850 /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
1851 /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
1852 /^IMPORTLIB *=/s#=.*#=$IMPORTLIB#
1853 /^AR *=/s#=.*#=$AR#
1854 /^ARFLAGS *=/s#=.*#=$ARFLAGS#
1855 /^RANLIB *=/s#=.*#=$RANLIB#
1856 /^EXE *=/s#=.*#=$EXE#
1857 /^prefix *=/s#=.*#=$prefix#
1858 /^exec_prefix *=/s#=.*#=$exec_prefix#
1859 /^bindir *=/s#=.*#=$bindir#
1860 /^libdir *=/s#=.*#=$libdir#
1861 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
1862 /^includedir *=/s#=.*#=$includedir#
1863 /^mandir *=/s#=.*#=$mandir#
1864 /^LDFLAGS *=/s#=.*#=$LDFLAGS#
1865 " | sed -e "
1866 s/\@VERSION\@/$VER/g;
1867 s/\@SUFFIX\@/$SUFFIX/g;
1868 " > ${LIBNAME2}.pc
1869
1870 # done
1871 leave 0