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