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