configure: fix cross-compilation best practices #6803
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| pull_request: | |
| branches: | |
| - dev | |
| types: [opened, synchronize, reopened] | |
| release: | |
| types: [created] | |
| jobs: | |
| python-bindings: | |
| name: Python Bindings (ubuntu-latest) | |
| runs-on: ubuntu-latest | |
| env: | |
| CFLAGS: -Werror | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python 3.9 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.9" | |
| - name: Install Ubuntu Prerequisites | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev | |
| - name: Build nDPI library | |
| run: | | |
| ./autogen.sh && ./configure | |
| make -j | |
| sudo make install | |
| - name: Generate Python bindings | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r python/requirements.txt | |
| cd python | |
| python setup.py install | |
| cd .. | |
| - name: Test Python Bindings | |
| run: | | |
| cd python | |
| python tests.py | |
| test-scripts: | |
| name: Test Utils (ubuntu-latest) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Ubuntu Prerequisites | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install python3-netaddr git whois libxml2-utils | |
| - name: Run Scripts | |
| run: | | |
| #This site is no more reachable and we are not really using any info from it anyway, yet | |
| #--> disable it for the time being; TODO | |
| #echo 'Running ./utils/bitcoinnodes.sh' | |
| #./utils/bitcoinnodes.sh >/dev/null | |
| echo 'Running ./utils/get_routes_by_asn.sh AS714' | |
| ./utils/get_routes_by_asn.sh AS714 >/dev/null | |
| echo 'Running ./utils/update_every_lists.sh' | |
| ./utils/update_every_lists.sh | |
| echo 'Checking for changes in the git tree..' | |
| git update-index --refresh || echo "::warning file=utils/update_every_lists.sh::Please re-run utils/update_every_lists.sh and commit any changes." | |
| git diff-index --quiet HEAD -- || true | |
| test: | |
| name: ${{ matrix.os }} ${{ matrix.compiler }} ${{ matrix.cflags }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} ${{ matrix.msan }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| CC: ${{ matrix.compiler }} | |
| CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS ${{ matrix.cflags }} | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| # Only most "important" OS; the other ones are tested only via scheduled job | |
| os: ["ubuntu-22.04", "ubuntu-24.04", "macOS-15", "macOS-26"] | |
| compiler: ["cc"] | |
| pcre: [""] | |
| maxminddb: [""] | |
| msan: [""] | |
| cflags: ["-g -O2"] # Default value if you do not specify CFLAGS variable | |
| include: | |
| #Try "newest/oldest" compilers with various optimization flags | |
| - compiler: "gcc-4.9" # "Oldest" gcc easily available. To simulate RHEL7 | |
| os: ubuntu-22.04 | |
| cflags: "-O0" | |
| - compiler: "gcc-14" # "Newest" gcc easily available | |
| os: ubuntu-24.04 | |
| cflags: "-O1" | |
| - compiler: "clang-12" # "Oldest" clang easily available | |
| os: ubuntu-22.04 | |
| cflags: "-Os" | |
| - compiler: "clang-18" # "Newest" clang easily available. See also below... | |
| os: ubuntu-24.04 | |
| cflags: "-O3" | |
| #Sanitizer | |
| - compiler: "clang" | |
| os: ubuntu-latest | |
| pcre: "--with-pcre2" | |
| maxminddb: "--with-maxminddb" | |
| msan: "--with-sanitizer" | |
| - compiler: "cc" | |
| os: macOS-latest | |
| pcre: "--with-pcre2" | |
| maxminddb: "--with-maxminddb" | |
| msan: "" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Install Ubuntu Prerequisites | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install autoconf automake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev | |
| sudo apt-get install rrdtool librrd-dev parallel | |
| - name: Install Ubuntu Prerequisites (libpcre2) | |
| if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.pcre, '--with-pcre2') | |
| run: | | |
| sudo apt-get install libpcre3-dev | |
| - name: Install Ubuntu Prerequisites (maxminddb) | |
| if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.maxminddb, '--with-maxminddb') | |
| run: | | |
| sudo apt-get install libmaxminddb-dev | |
| - name: Setup Ubuntu specified compiler | |
| if: startsWith(matrix.os, 'ubuntu-22.04') && ! startsWith(matrix.compiler, 'cc') | |
| run: | | |
| # For gcc-4.9 (on ubuntu-22.04) | |
| echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" | sudo tee -a /etc/apt/sources.list | |
| echo "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" | sudo tee -a /etc/apt/sources.list | |
| sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 | |
| sudo apt-get update | |
| sudo apt-get install ${{ matrix.compiler }} | |
| - name: Installing MacOS prerequisites | |
| if: startsWith(matrix.os, 'macOS') | |
| run: | | |
| # Avoid (re)installing pkg-config. See: https://github.com/actions/runner-images/issues/10984 | |
| # Avoid (re)installing gettext 1.0, to avoid "gettext 1.0 is already installed and up-to-date. | |
| # To reinstall 1.0, run: brew reinstall gettext" warning | |
| brew install coreutils wdiff colordiff autoconf automake libtool json-c rrdtool parallel | |
| - name: Install MacOS Prerequisites (libpcre2) | |
| if: startsWith(matrix.os, 'macOS') && startsWith(matrix.pcre, '--with-pcre2') | |
| run: | | |
| brew install pcre | |
| - name: Install MacOS Prerequisites (maxminddb) | |
| if: startsWith(matrix.os, 'macOS') && startsWith(matrix.maxminddb, '--with-maxminddb') | |
| run: | | |
| brew install libmaxminddb | |
| - name: Configure nDPI | |
| run: | | |
| ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages ${{ matrix.msan }} ${{ matrix.pcre }} ${{ matrix.maxminddb }} | |
| - name: Build nDPI | |
| run: | | |
| make -j all | |
| make -C example | |
| make -C rrdtool | |
| - name: Print nDPI long help | |
| run: | | |
| cd ./example && ./ndpiReader -H | |
| - name: Install nDPI | |
| run: | | |
| DESTDIR=/tmp/ndpi make install | |
| ls -alhHR /tmp/ndpi | |
| file /tmp/ndpi/usr/include/ndpi/ndpi_api.h | |
| test ! -r /tmp/ndpi/usr/include/ndpi/ndpi_private.h | |
| file /tmp/ndpi/usr/lib/libndpi.a | |
| file /tmp/ndpi/usr/lib/libndpi.so* | |
| - name: Tests | |
| run: | | |
| NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_FORCE_PARALLEL_CONFIGS=1 NDPI_SKIP_PARALLEL_BAR=1 ./tests/do.sh | |
| ./tests/do-unit.sh | |
| ./tests/do-dga.sh | |
| test-windows: | |
| name: ${{ matrix.os }} (msys2) | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS -g -O2 | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: ["windows-latest"] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Install Windows msys2 prerequisites | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool make mingw-w64-x86_64-json-c mingw-w64-x86_64-crt-git mingw-w64-x86_64-pcre mingw-w64-x86_64-libpcap parallel | |
| - name: Configure nDPI on Windows msys2 | |
| run: | | |
| msys2 -c './autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --disable-npcap' | |
| - name: Build nDPI on Windows msys2 | |
| run: | | |
| msys2 -c 'make -j all' | |
| msys2 -c 'ldd ./example/ndpiReader.exe' | |
| - name: Tests | |
| run: | | |
| # Don't know why but lately the script in parallel mode is stuck... | |
| #msys2 -c 'NDPI_FORCE_PARALLEL_UTESTS=1 NDPI_FORCE_PARALLEL_CONFIGS=1 NDPI_SKIP_PARALLEL_BAR=1 ./tests/do.sh' | |
| msys2 -c './tests/do.sh' | |
| msys2 -c './tests/do-unit.sh' | |
| msys2 -c './tests/do-dga.sh' | |
| mingw-64: | |
| name: Mingw-64 (ubuntu-latest) | |
| runs-on: ubuntu-latest | |
| env: | |
| CC: | |
| CFLAGS: -Werror -DNDPI_EXTENDED_SANITY_CHECKS -g -O2 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Ubuntu Prerequisites | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install autoconf automake libtool pkg-config gettext flex bison libjson-c-dev libpcap-dev gcc-mingw-w64 libc6-dev | |
| - name: Configure nDPI | |
| run: | | |
| ./autogen.sh && ./configure --enable-option-checking=fatal --enable-debug-messages --host=x86_64-w64-mingw32 | |
| - name: Build nDPI | |
| run: | | |
| make -j $(nproc) all | |
| make -j $(nproc) -C example | |
| #make -j $(nproc) -C rrdtool | |
| # No tests, only build | |
| tarball-and-package: | |
| name: Tarball/Package/Symbols checks (ubuntu-latest) | |
| runs-on: ubuntu-latest | |
| env: | |
| CFLAGS: | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Ubuntu Prerequisites | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install autoconf debhelper automake libtool pkg-config gettext flex bison libjson-c-dev libpcap-dev rrdtool librrd-dev | |
| - name: Configure nDPI | |
| run: | | |
| ./autogen.sh && ./configure | |
| - name: Build nDPI | |
| run: | | |
| make -j $(nproc) all | |
| make -j $(nproc) -C example | |
| make -j $(nproc) -C rrdtool | |
| # No need to run tests on this job | |
| - name: Generate/Verify tarball | |
| run: | | |
| make dist | |
| ./utils/verify_dist_tarball.sh | |
| - name: Build Debian/Ubuntu package | |
| run: | | |
| cd packages/ubuntu | |
| ./configure --enable-no-sign | |
| make | |
| cd ../.. | |
| - name: Test nDPI [SYMBOLS] | |
| run: | | |
| ./utils/check_symbols.sh || { FAILED=$?; echo "::error file=${NDPI_LIB}::Unwanted libc symbols found: ${FAILED}. Please make sure to use only ndpi_malloc/ndpi_calloc/ndpi_realloc/ndpi_free wrapper instead of malloc/calloc/realloc/free."; false; } | |
| env: | |
| NDPI_LIB: src/lib/libndpi.a | |