1#!/bin/sh -e 2 3# This script runs one build with setup environment variables: CC, CMAKE, IPV6 4# and REMOTE. 5: "${CC:=gcc}" 6: "${CMAKE:=no}" 7: "${IPV6:=no}" 8: "${REMOTE:=no}" 9: "${LIBPCAP_TAINTED:=no}" 10: "${LIBPCAP_CMAKE_TAINTED:=no}" 11: "${MAKE_BIN:=make}" 12# At least one OS (AIX 7) where this software can build does not have at least 13# one command (mktemp) required for a successful run of "make releasetar". 14: "${TEST_RELEASETAR:=yes}" 15 16. ./build_common.sh 17# Install directory prefix 18if [ -z "$PREFIX" ]; then 19 PREFIX=`mktempdir libpcap_build` 20 echo "PREFIX set to '$PREFIX'" 21 DELETE_PREFIX=yes 22fi 23 24print_cc_version 25 26# The norm is to compile without any warnings, but libpcap builds on some OSes 27# are not warning-free for one or another reason. If you manage to fix one of 28# these cases, please remember to remove respective exemption below to help any 29# later warnings in the same matrix subset trigger an error. 30# shellcheck disable=SC2221,SC2222 31case `cc_id`/`os_id` in 32tcc-*/*) 33 # At least one warning is expected because TCC does not implement 34 # thread-local storage. 35 LIBPCAP_TAINTED=yes 36 ;; 37*) 38 ;; 39esac 40[ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags` 41 42case `cc_id`/`os_id` in 43clang-*/SunOS-5.11) 44 # Work around https://www.illumos.org/issues/16369 45 [ "`uname -o`" = illumos ] && grep -Fq OpenIndiana /etc/release && CFLAGS="-Wno-fuse-ld-path${CFLAGS:+ $CFLAGS}" 46 ;; 47esac 48 49# If necessary, set LIBPCAP_CMAKE_TAINTED here to exempt particular cmake from 50# warnings. Use as specific terms as possible (e.g. some specific version and 51# some specific OS). 52 53[ "$LIBPCAP_CMAKE_TAINTED" != yes ] && CMAKE_OPTIONS='-Werror=dev' 54 55if [ "$CMAKE" = no ]; then 56 run_after_echo ./autogen.sh 57 run_after_echo ./configure --prefix="$PREFIX" --enable-ipv6="$IPV6" --enable-remote="$REMOTE" 58else 59 # Remove the leftovers from any earlier in-source builds, so this 60 # out-of-source build does not break because of that. 61 # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#what-is-an-out-of-source-build 62 # (The contents of build/ remaining after an earlier unsuccessful attempt 63 # can fail subsequent build attempts too, sometimes in non-obvious ways, 64 # so remove that directory as well.) 65 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/ 66 run_after_echo mkdir build 67 run_after_echo cd build 68 run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \ 69 ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \ 70 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DINET6="$IPV6" -DENABLE_REMOTE="$REMOTE" .. 71fi 72run_after_echo "$MAKE_BIN" -s clean 73if [ "$CMAKE" = no ]; then 74 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"} 75 run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"} 76else 77 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above. 78 run_after_echo "$MAKE_BIN" 79 run_after_echo "$MAKE_BIN" testprogs 80fi 81run_after_echo "$MAKE_BIN" install 82 83run_after_echo "$PREFIX/bin/pcap-config" --help 84run_after_echo "$PREFIX/bin/pcap-config" --version 85run_after_echo "$PREFIX/bin/pcap-config" --cflags 86run_after_echo "$PREFIX/bin/pcap-config" --libs 87run_after_echo "$PREFIX/bin/pcap-config" --additional-libs 88run_after_echo "$PREFIX/bin/pcap-config" --libs --static 89run_after_echo "$PREFIX/bin/pcap-config" --additional-libs --static 90run_after_echo "$PREFIX/bin/pcap-config" --libs --static-pcap-only 91run_after_echo "$PREFIX/bin/pcap-config" --additional-libs --static-pcap-only 92 93# VALGRIND_CMD is meant either to collapse or to expand. 94# shellcheck disable=SC2086 95if [ "$CMAKE" = no ]; then 96 run_after_echo $VALGRIND_CMD testprogs/findalldevstest 97 [ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar 98else 99 run_after_echo $VALGRIND_CMD run/findalldevstest 100fi 101handle_matrix_debug 102if [ "$DELETE_PREFIX" = yes ]; then 103 run_after_echo rm -rf "$PREFIX" 104fi 105# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent : 106