#!/bin/bash
set -e

export DEBIAN_FRONTEND=noninteractive

OUTPUT_FILES="abi-breaks lfs-sensitive no-change failed-compilation uninstallable"

log_msg() {
    echo "[$(date --iso-8601=seconds)]" "$@"
}

init() {
    # makes things better for parallel runs
    (which abi-compliance-checker && which eatmydata && which ctags \
     && which grep-dctrl && which killall && which lockfile) >/dev/null\
    || apt-get -qq -y install --no-install-recommends \
      abi-compliance-checker dctrl-tools eatmydata procmail psmisc \
      universal-ctags

    dpkg_arch=$(dpkg --print-architecture)

    case "$dpkg_arch" in
        i386)
            multiarch=i386-linux-gnu
            ;;
        armhf)
            multiarch=arm-linux-gnueabihf
            ;;
        *)
            log_msg "Unknown or non-32-bit architecture"
            exit 2
            ;;
    esac

    suite=lunar
    gcc_major=$(gcc -dumpversion)
}

clean_up() {
    log_msg "Clean up (called from line ${BASH_LINENO[0]})"
    # Restore devpkg to the value that the rest of the script expects
    if [ -n "${devpkg_no_virtual:-}" ]; then
        devpkg=$devpkg_no_virtual
    fi
    killall abi-compliance-checker || true
    rm -f workarounds.h
    # - wrap_apt takes $apt_lock; the script would deadlock if the lock is
    # already held
    # - we empty $devpkg and $devpkg_no_virtual after being done so that if
    # clean_up is called again with no package installation in between, we know
    # there's nothing to do
    if [ -z "$apt_lock" ] && [ -n "$devpkg" ]; then
        wrap_apt autoremove --purge $devpkg $extra_deps
        unset devpkg
        unset devpkg_no_virtual
    fi
    if [ -n "$a_c_c_lock" ]; then
       rm -fv $a_c_c_lock
       a_c_c_lock=''
    fi
    if [ -n "$apt_lock" ]; then
        rm -fv $apt_lock
        apt_lock=''
    fi
}

wrap_apt() {
    case $1 in
        *remove*)
            if $no_clean; then
                return 0
            fi
            ;;
        *)
            apt-get -qq update
            ;;
    esac
    lockfile apt-lock
    apt_lock=apt-lock
    retval=0
    eatmydata apt-get -qq -o APT::AutoRemove::RecommendsImportant="false" \
                      -y --no-install-recommends $@ || retval=$?
    apt-get autoclean
    rm -f apt-lock
    apt_lock=''
    return $retval
}

# recursively finds headers in a given directory matching a pattern
# while excluding specified list of subdirectories
# note: exclude list should not contain trailing slashes
find_headers(){
    dir=$1
    shift
    pattern=$1
    shift
    exclude=$@
    find "$dir" -maxdepth 1 -type f -name "$pattern" -print | sort -u
    find "$dir" -maxdepth 1 -not -wholename "$dir" -type d | sort -u | while read -r name; do
        for x in $exclude; do
            if [ "$name" == "$x" ]; then
                break 2
            fi
        done
        find_headers "$name" "$pattern" "$exclude"
    done
}

# skip
skip_header(){
    header_to_move=$1
    shift
    header_list=$@
    for x in $header_list
    do
        if [ "$x" != "$header_to_move" ]; then
            echo $x
        fi
    done
}

# move the header to the back of the list
move_to_back(){
    header_to_move=$1
    shift
    header_list=$@
    skip_header ${header_to_move} ${header_list}
    echo $header_to_move
}

# Run a-c-c's library ABI dump
a_c_c() {
    # uses global variables: $devpkg, $extra_args
    v1="$1"
    filename_stem="$2"
    log_msg "Run a-c-c ${v1}"
    abi-compliance-checker -l $devpkg $extra_args --v1="${v1}" --headers-only \
        -dump "${filename_stem}.xml" -dump-path "${filename_stem}.dump"
}

# Run a-c-c's diff
a_c_c_diff() {
    # uses global variables: $devpkg, $extra_args
    filter="$1"
    old="$2"
    new="$3"
    v1="$4"
    log_msg "Diff a-c-c ${old} / ${new}"
    abi-compliance-checker -s -l $devpkg \
        -filter "${filter}.xml" \
        -old "${old}.dump" \
        -new "${new}.dump" \
    || test -z "$(grep -E "class='(failed|chg)'" \
                  "compat_reports/${devpkg}/${old}_to_${v1}/compat_report.html" \
               | grep -v 'Removed Symbols')"
}

failed() {
    log_msg Failed compiling $1
    echo $1 >> failed-compilation
}

# A virtual package contains a '=' in its name
is_virtual_package() {
    case $1 in
        *=*) echo true ;;
        *) echo false ;;
    esac
}

# Output the real name of a package
# NOTE: doesn't change non-virtual package names and is safe to use on them
unvirtual_package() {
    echo ${1/=*}
}

# The outcome of the ABI dump of all virtual sub-packages can be computed as
# soon as there is a compile failure or a report of time_t-related changes.
# Return true if the outcome can already be computed.
virtual_packages_can_short_circuit() {
    case ${virtual_failed}${virtual_time_t} in
        # True if $virtual_failed or $virtual_time_t contain ':'
        *:*) true;;
        # False in all other cases
        *) false ;;
    esac
}

# Return true if virtual sub-packages have been processed and we are currently
# processing the actual package which is used as the marker that ends the list
# of virtual sub-packages.
virtual_packages_reducing() {
    local is_virtual
    is_virtual="$(is_virtual_package $devpkg)"
    if ! $is_virtual && $processing_virtual_packages; then
        echo true
    else
        echo false
    fi
}

# Summarize in-memory data relative to virtual packages, write the result to
# disk and clean up in-memory data
virtual_packages_reduce() {
    case ${virtual_failed},${virtual_time_t},${virtual_lfs} in
        *:*,*,*)
            failed $1
            ;;
        *,*:*,*)
            echo $1 >> abi-breaks
            ;;
        *,*,*:*)
            echo $1 >> lfs-sensitive
            ;;
        *)
            echo $1 >> no-change
            ;;
    esac

    # Clean the in-memory data for the virtual packages
    processing_virtual_packages=false
    virtual_failed=false
    virtual_lfs=false
    virtual_time_t=false
}

read_headers_list_file() {
    # args: $1: file name
    while read -r LINE; do
        if [[ "$LINE" != './'* && "$LINE" != '/usr/include'* ]]; then
            echo /usr/include/$LINE
        else
            echo $LINE
        fi
    done < "$1"
}

show_cli_help() {
    cat << EOF
Usage: check-armhf-time_t [OPTION]... [SOURCE_PACKAGE]...
-c, --continue        ???
    --help            print this message and exit
    --mode=batch      Default to settings optimized for batch processing;
                      later command-line options can override these settings
    --mode=dev        Default to settings optimized for development
                      later command-line options can override these settings
    --no-clean        don't remove packages installed for a package after having
                      processed it
    --parallel        do the ABI dumps in parallel; uses three times as much
                      peak memory at once but speeds up the script by a factor
                      of 2x to 3x
EOF
}

dev_mode() {
    parallel=true
    set -u
}

batch_mode() {
    parallel=false
    set +u
}

a_c_c_lock=''
apt_lock=''
virtual_failed=false
virtual_lfs=false
virtual_time_t=false

continue=false
no_clean=false
parallel=false

# Default to batch mode which the user can override on the command-line
batch_mode

trap clean_up INT TERM ERR EXIT

packages=''
while [ $# -gt 0 ]; do
    case $1 in
        -c|--continue)
            continue=:
            ;;
        --mode=dev)
            dev_mode
            ;;
        --mode=batch)
            batch_mode
            ;;
        --help)
            show_cli_help
            exit
            ;;
        --no-clean)
            no_clean=:
            ;;
        --parallel)
            parallel=true
            ;;
        *)
            packages="$packages $1"
            ;;
    esac
    shift
done

init

if [ -z "$packages" ]; then
    packages="$(grep-dctrl -r -FPackage .*-dev$ -sPackage -n /var/lib/apt/lists/*${suite}_*${dpkg_arch}*Packages \
                | grep -vE '(golang|libghc|ocaml).*dev' | sort -u)"

    if ! $continue; then
        # if we're doing a full run, clear the state.  If we're just
        # re-checking a single package or resuming an interrupted run,
        # leave as-is.
        for file in $OUTPUT_FILES; do
            :> $file
        done
    fi
fi

# Ensure all these files are present since them missing can trigger
# non-serious warnings
touch $OUTPUT_FILES

urcu_patch_transparent_unions()
{
    # transparent unions are not supported when compiling as C++ code.
    perl -i -pe 'BEGIN{undef $/;} s/static inline struct __cds_wfcq_head \*__cds_wfcq_head_cast\(struct __cds_wfcq_head \*head\)\n\{\n.*return head;\n\}/static inline cds_wfcq_head_ptr_t __cds_wfcq_head_cast(struct __cds_wfcq_head \*head)\{ cds_wfcq_head_ptr_t ret = \{ ._h = head \}; return  ret; \}/g' \
        "/usr/include/$multiarch/urcu/wfcqueue.h"
    perl -i -pe 'BEGIN{undef $/;} s/static inline struct cds_wfcq_head \*cds_wfcq_head_cast\(struct cds_wfcq_head \*head\)\n\{\n.*return head;\n\}/static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast(struct cds_wfcq_head \*head)\{ cds_wfcq_head_ptr_t ret = \{ .h = head \}; return  ret; \}/g' \
        "/usr/include/$multiarch/urcu/wfcqueue.h"
    sed -i \
        -e 's/retnode = ___cds_wfs_pop_with_state_blocking(s, state);/retnode = ___cds_wfs_pop_with_state_blocking({}, state);/g' \
        -e 's/___cds_\(l\|w\)fs_pop\(\|_all\)(s);/___cds_\1fs_pop\2({});/g' \
        "/usr/include/$multiarch/urcu/static"/{l,w}fstack.h
}

patch_qhull()
{
    # compile errors caused by spurious define matches
    sed -i 's/#define\sqh\sqh_qh\.//g' /usr/include/libqhull/libqhull.h
    # header not included in namespace
    sed -i 's/friend void         ::qh_fprintf/friend void         qh_fprintf/g' /usr/include/libqhullcpp/QhullQh.h
    sed -i 's/friend void ::qh_fprintf_rbox/friend void qh_fprintf_rbox/g' /usr/include/libqhullcpp/RboxPoints.h
    # implicit cast (alternatively can be solved through headers reordering)
    sed -i 's/qh_pointid(qh_qh, point_coordinates);/qh_pointid(nullptr);/g' /usr/include/libqhullcpp/QhullPoint.h
}

virtual_packages_list() {
    # uses global variables: $devpkg
    printf "$devpkg=%s " "$@"; printf "$devpkg\n"
}

float_typedefs="typedef float _Float32;
typedef long double _Float64;
typedef double _Float32x;"

# Insert virtual packages: it is required to add the actual package after the
# virtual ones as a marker that the set of virtual packages for it is over.
packages_tmp=''
for devpkg in $packages; do
    case $devpkg in
        # libclang-1[45]-dev are too big to be analyzed at once (requires > 4GB
        # of memory space); however the 'clang-tidy' subset is small enough and
        # since it contains ABI that depends on time_t, it is enough to
        # conclude the whole library contains ABI that depends on time_t
        libclang-1?-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list clang-tidy-abseil-time the-rest)"
            ;;
        llvm-13-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list  analytics code debug execution-engine transforms the-rest)"
            ;;
        llvm-14-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list  analytics code debug execution-engine transforms the-rest)"
            ;;
        llvm-15-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list transforms analytics code debug execution-engine the-rest)"
            ;;
        libogre-1.12-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list  plugins gl gles2 gl3plus the-rest)"
            ;;
        libmlir-15-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list all-dialects mlir support dialect-gpu mlir-c dialect dialect-linalg dialect-tosa dialect-spirv dialect-llvmir)"
            ;;
        libmapnik-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list base svg1)"
            ;;
        # freerdp2-dev has headers for client and server roles which use the
        # same symbol names
        freerdp2-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list client server)"
            ;;
        liblog4cpp5-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list boostthreads dummythreads omnithreads pthreads)"
            ;;
        voms-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list c cpp)"
            ;;
        qtbase5-private-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list chunk-1 chunk-2 chunk-3)"
            ;;
        qt6-base-private-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list chunk-1 chunk-2 chunk-3)"
            ;;
        libboost1.74-dev)
            chunks=(chunk-{0..9})
            packages_tmp="$packages_tmp $(virtual_packages_list "${chunks[@]}")"
            ;;
        libniftiio-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list nifti-1 nifti-2)"
            ;;
        libmedc-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list api23 normal)"
            ;;
        libscotchparmetis-dev)
            packages_tmp="$packages_tmp $(virtual_packages_list int32 int64 long normal)"
            ;;
        *)
            packages_tmp="$packages_tmp $devpkg"
    esac
done
packages="$packages_tmp"

processing_virtual_packages=false

for devpkg in $packages; do
    lfs=false
    time_t=false
    extra_args=
    extra_deps=
    defines=
    includes=
    preamble=
    exclude_types=

    devpkg_no_virtual="$(unvirtual_package $devpkg)"
    if $continue && [ -d "logs/$devpkg_no_virtual" ]; then
        log_msg "Skip $devpkg_no_virtual since its result is already known"
        continue
    fi

    is_reducing="$(virtual_packages_reducing $devpkg)"
    processing_virtual_packages="$(is_virtual_package $devpkg)"
    devpkg_maybe_virtual=$devpkg

    if $processing_virtual_packages && virtual_packages_can_short_circuit; then
        log_msg "Skip $devpkg_maybe_virtual since its result does not matter for $devpkg_no_virtual"
        # no call to clean_up since nothing has been set up so far
        continue
    fi

    log_msg "Process $devpkg_maybe_virtual"

    # remove any previous records regarding this package
    sed -i -e"/^$devpkg_no_virtual$/d" $OUTPUT_FILES

    # If this is not a virtual package but the marker of virtual package is
    # still set, this means we just finished processing the virtual packages
    # and now need to store the results on disk
    if $is_reducing; then
        # Store the result on disk
        virtual_packages_reduce $devpkg

        # Don't do any ABI dump on the real package since it has been done on
        # the virtual ones instead
        clean_up
        continue
    fi

    case $devpkg in
        # breaks the container; check later with a larger VM
        libbsd-dev)
            continue
            ;;
        # we know the ABI
        libc6-dev|libgcc-11-dev|libgcc-12-dev|libgcc-${gcc_major}-dev)
            continue
            ;;
        # this just plain doesn't compile, no concerns
        libappstream-compose-dev)
            continue
            ;;
        # requires kernel module compilation; skip for now
        nvidia-384-dev)
            continue
            ;;
        # not a library package and uses unreasonable disk
        gosa-dev)
            continue
            ;;
        # for a foreign-arch ABI
        *mingw*dev)
            continue
            ;;
        # The set of public symbols is empty
        xserver-xorg-input-evdev-dev)
            continue
            ;;
        # No shared library; it cannot matter
        libeigen3-dev|libcgal-dev|puredata-dev|linux-libc-dev|libasio-dev|\
        gsettings-desktop-schemas-dev|mesa-common-dev|libcereal-dev|\
        libmupen64plus-dev|libwebsocketpp-dev|libseqan2-dev|libnifti2-dev|\
        modemmanager-dev|xserver-xorg-input-libinput-dev|\
        gnome-settings-daemon-dev|libspice-protocol-dev|\
        libwayland-egl-backend-dev|libtoon-dev|publib-dev|\
        ableton-link-dev|xserver-xorg-input-synaptics-dev|tao-json-dev)
            continue
            ;;
        # ObjC, can't be analyzed as either C or C++
        libgnustep-*-dev)
            continue
            ;;
        # Another libc (intended for static linkage only)
        dietlibc-dev)
            continue
            ;;
        # Not valid C/C++ headers
        iraf-noao-dev)
            continue
            ;;
    esac

    case $devpkg in
        bind9-dev|blt-dev|freerdp2-dev*|guile-3.0-dev|libapparmor-dev|\
        libasound2-dev|libasyncns-dev|libblockdev-nvdimm-dev|libbogl-dev|\
        libbpf-dev|libbtrfs-dev|libbtrfsutil-dev|libc-ares-dev|libcdb-dev|\
        libcephfs-dev|libclutter-1.0-dev|libdebconfclient0-dev|\
        libdebian-installer4-dev|libdmraid-dev|libdrm-dev|libelf-dev|\
        libext2fs-dev|libfdt-dev|libfprint-2-tod-dev|libfuse3-dev|\
        libgdbm-compat-dev|libgf-complete-dev|libglib2.0-dev|libglusterfs-dev|\
        libxt-dev|libkrb5-dev|libwayland-dev|libxaw7-dev|libmhash-dev|\
        libkeyutils-dev|libwebkit2gtk-4.1-dev|libneon27-gnutls-dev|\
        libmpich-dev|libmotif-dev|libatlas-base-dev|tk8.6-dev|pidgin-dev|\
        libxcb-xkb-dev|libpipewire-0.3-dev|libosmocore-dev|liballegro4-dev|\
        proftpd-dev|libpurple-dev|libminizip-dev|x11proto-dev|libsnmp-dev|\
        apache2-dev|libxfont-dev|libwlroots-dev|libvarnishapi-dev|\
        libspandsp-dev|libsvn-dev|libnfs-dev|liblirc-dev|libwmf-dev|\
        xaw3dg-dev|xserver-xorg-dev|ppp-dev|libosmo-sigtran-dev|\
        libglobus-gass-transfer-dev|libgsoap-dev|libsepol-dev|libwcstools-dev|\
        cluster-glue-dev|libplumb2-dev|libosmo-sccp-dev|libc-client2007e-dev|\
        libtingea-dev|libsylph-dev|libsmi2-dev|libpils2-dev|rhythmbox-dev|\
        xmms2-dev|vflib3-dev)
            extra_args="-cxx-incompatible --lang=C"
            defines="$float_typedefs"
            ;;
    esac
    # per-package quirks for missing -dev depends
    case $devpkg in
        apertium-lex-tools-dev)
            extra_deps="libirstlm-dev libxml2-dev"
            ;;
        bind9-dev)
            extra_deps="libuv1-dev libcmocka-dev"
            ;;
        binutils-dev|libminizip-dev|libzzip-dev|libmsgpack-cxx-dev|\
        libmsgpack-dev|libcapnp-dev)
            extra_deps=zlib1g-dev
            ;;
        coinor-libosi-dev)
            extra_deps=coinor-libcoinutils-dev
            ;;
        fftw-dev|libptscotch-dev|libarpack2-dev|libhypre-dev|libsuperlu-dist-dev)
            includes="/usr/include/$multiarch/mpi/"
            extra_deps=mpi-default-dev
            ;;
        libabsl-dev)
            extra_deps="libgtest-dev libgmock-dev"
            ;;
        libavc1394-dev)
            extra_deps=libraw1394-dev
            ;;
        libblockdev-crypto-dev|libblockdev-dev)
            extra_deps=libblockdev-utils-dev
            ;;
        libblockdev-fs-dev)
            extra_deps="libblockdev-utils-dev libglib2.0-dev"
            ;;
        libblockdev-part-dev|libkeybinder-3.0-dev|libfprint-2-dev|\
        libmm-glib-dev|libical-dev|libudisks2-dev|libsunpinyin-dev|\
        cluster-glue-dev|liblqr-1-0-dev|libayatana-common-dev|libxmlb-dev|\
        libwhoopsie-dev|libwhoopsie-preferences-dev|libopenhpi-dev|\
        libgmenuharness-dev|libgarcon-1-dev|libsylph-dev)
            extra_deps=libglib2.0-dev
            ;;
        libkkc-dev)
            extra_deps="libglib2.0-dev libjson-glib-dev libgee-0.8-dev"
            ;;
        libcephfs-dev|firebird-dev|libmaeparser-dev)
            extra_deps=libboost-dev
            ;;
        xmms2-dev)
            extra_deps=libglib2.0-dev
            preamble=glib.h
            ;;
        libcupsfilters-dev|libppd-dev)
            extra_deps=libcups2-dev
            ;;
        libdb5.3-stl-dev)
            extra_deps=libdb5.3++-dev
            ;;
        libdebconfclient0-dev)
            extra_deps="libgtk-3-dev libdebian-installer4-dev libnewt-dev"
            ;;
        libefiboot-dev)
            extra_deps=libefivar-dev
            ;;
        libfcitx5-qt-dev)
            extra_deps="qtbase5-private-dev libfcitx5utils-dev"
            ;;
        libglusterfs-dev)
            extra_deps="liburcu-dev libssl-dev uuid-dev"
            ;;
        libglx-dev|libgl2ps-dev)
            extra_deps=libgl-dev
            ;;
        libqt5svg5-dev|libkf5contacteditor-dev|libqt5waylandclient5-dev|\
        libquazip5-dev|libqtdbustest1-dev|libqhull-dev|qtquickcontrols2-5-dev|\
        libkf5holidays-dev|libgsettings-qt-dev|libphonon4qt5-dev|\
        libukui-log4qt-dev|libdframeworkdbus-dev|libkf5akonadiserver-dev|\
        libqt5xdg-dev|libfcitx-qt5-dev|libkf5kexiv2-dev|libkcolorpicker-dev|\
        libdtkcore-dev|libkimageannotator-dev|libkf5kdcraw-dev|\
        kscreenlocker-dev|qtpim5-dev|qtkeychain-qt5-dev|libudisks2-qt5-dev|\
        libusermetricsinput-dev|liblxqt-globalkeys1-dev|\
        liblxqt-globalkeys-ui1-dev|libkpublictransport-dev|\
        libsingleapplication-dev|libquotient-dev|libqtermwidget5-1-dev|\
        libqt5gamepad5-dev|libqmenumodel-dev|libmpris-qt5-dev|libmolequeue-dev|\
        libkpmcore-dev|libgwengui-qt5-dev|libgio-qt-dev)
            extra_deps=qtbase5-dev
            ;;
        libkf5config-dev|kirigami2-dev|libkf5iconthemes-dev|qt3d5-dev|\
        qcoro-qt5-dev|libqt5gstreamer-dev|libkreport3-dev)
            extra_deps=qtdeclarative5-dev
            ;;
        libpq-dev)
            extra_deps="postgresql-server-dev-15 libkrb5-dev"
            ;;
        qtbase5-private-dev*)
            extra_deps="libicu-dev libdouble-conversion-dev"
            extra_deps="$extra_deps default-jdk-headless"
            extra_deps="$extra_deps libharfbuzz-dev libdrm-dev libatspi2.0-dev"
            extra_deps="$extra_deps libssl-dev libqt5opengl5-dev libcups2-dev"
            extra_deps="$extra_deps libxcb-randr0-dev libxcb-xfixes0-dev"
            extra_deps="$extra_deps libxcb-xinerama0-dev libxcb-image0-dev"
            extra_deps="$extra_deps libxcb-keysyms1-dev libxcb-xkb-dev"
            extra_deps="$extra_deps libxkbcommon-x11-dev libxcb-sync-dev"
            ;;
        qt6-base-private-dev*)
            extra_deps="libicu-dev libdouble-conversion-dev libegl-dev"
            extra_deps="$extra_deps default-jdk-headless libgbm-dev"
            extra_deps="$extra_deps libharfbuzz-dev libdrm-dev libatspi2.0-dev"
            extra_deps="$extra_deps libssl-dev libqt6opengl6-dev libcups2-dev"
            extra_deps="$extra_deps libxcb-randr0-dev libxcb-xfixes0-dev"
            extra_deps="$extra_deps libxcb-xinerama0-dev libxcb-image0-dev"
            extra_deps="$extra_deps libxcb-keysyms1-dev libxcb-xkb-dev"
            extra_deps="$extra_deps libxkbcommon-x11-dev libxcb-sync-dev"
            ;;
        qtdeclarative5-private-dev)
            extra_deps="qtbase5-private-dev libkf5kjs-dev"
            ;;
        qt6-quick3d-dev)
            extra_deps="qt6-declarative-dev qt6-declarative-private-dev"
            ;;
        libavcodec-dev)
            extra_deps=libvdpau-dev
            ;;
        libbullet-dev)
            extra_deps=opencl-c-headers
            ;;
        libkf5templateparser-dev)
            extra_deps="qtbase5-dev libkf5config-dev libkf5mime-dev"
            extra_deps="$extra_deps libkf5i18n-dev libkf5pimtextedit-dev"
            ;;
        yorick-dev|libm17n-dev|libxshmfence-dev|libspnav-dev|libxnvctrl-dev)
            extra_deps=libx11-dev
            ;;
        libspdlog-dev)
            extra_deps="qtbase5-dev libsystemd-dev"
            ;;
        libgstreamer-plugins-bad1.0-dev)
            extra_deps="libva-dev libvulkan-dev libnice-dev"
            ;;
        libvtk9-dev)
            extra_deps="libmpich-dev default-jdk libvtk9-qt-dev libxml2-dev"
            ;;
        libkf5webengineviewer-dev)
            extra_deps=libkf5pimcommon-dev
            ;;
        libhdf5-openmpi-dev|libflann-dev)
            extra_deps="libopenmpi-dev libhdf5-dev"
            ;;
        libhwloc-dev)
            extra_deps="opencl-c-headers libibverbs-dev"
            ;;
        libiso9660++-dev)
             extra_deps=libiso9660-dev
             ;;
        libclxclient-dev)
            extra_deps=libclthreads-dev
            ;;
        libclang-14-dev*|libllvmspirvlib-14-dev)
            extra_deps=llvm-14-dev
            ;;
        libclang-15-dev*|libllvmspirvlib-15-dev)
            extra_deps=llvm-15-dev
            ;;
        libqwt-qt5-dev)
            extra_deps="qtbase5-dev libqt5opengl5-dev"
            ;;
        libpoppler-private-dev)
            extra_deps="libcairo2-dev libboost-dev"
            ;;
        libkf5mimetreeparser-dev)
            extra_deps="qtbase5-dev libgpgmepp-dev libgpg-error-dev"
            extra_deps="$extra_deps libkf5mime-dev"
            ;;
        libisl-dev|libntl-dev|libgivaro-dev|libppl-dev|libiml-dev)
            extra_deps=libgmp-dev
            ;;
        libsuitesparse-dev)
            extra_deps="libgmp-dev libmpfr-dev"
            ;;
        libphonon4qt5experimental-dev)
            extra_deps="qtbase5-dev libphonon4qt5-dev"
            ;;
        libindi-dev)
            extra_deps="libnova-dev libgsl-dev"
            ;;
        pybind11-dev)
            extra_deps="libpython3-dev libeigen3-dev"
            ;;
        libkf5plasma-dev)
            extra_deps="qtdeclarative5-dev libkf5declarative-dev"
            ;;
        libva-dev)
            extra_deps="mesa-common-dev libxfixes-dev"
            ;;
        libvulkan-dev)
            extra_deps="libdirectfb-dev libxcb1-dev libx11-dev libxrandr-dev"
            ;;
        libxerces-c-dev)
            extra_deps=libcurl4-openssl-dev
            ;;
        libosmocore-dev)
            extra_deps="libmnl-dev libusb-1.0-0-dev libtalloc-dev"
            ;;
        libkf5messagecomposer-dev)
            extra_deps="libkf5messagecore-dev libkf5messageviewer-dev"
            ;;
        libgpgmepp-dev|libksba-dev)
            extra_deps=libgpg-error-dev
            ;;
        libassimp-dev)
            extra_deps=libpugixml-dev
            ;;
        wcslib-dev)
            extra_deps=libcfitsio-dev
            ;;
        libpurple-dev)
            extra_deps=libgstreamer1.0-dev
            ;;
        libtirpc-dev|libshibsp-dev|libkrad-dev)
            extra_deps=libkrb5-dev
            ;;
        python-dbus-dev|python-gi-dev|libdlib-dev)
            extra_deps=libpython3-dev
            ;;
        gnuradio-dev)
            extra_deps="qtbase5-dev libqwt-qt5-dev libsoapysdr-dev libuhd-dev"
            extra_deps="$extra_deps libcodec2-dev"
            ;;
        libwebsockets-dev)
            extra_deps=libdbus-1-dev
            ;;
        libkf5parts-dev)
            extra_deps=qt5-qmake
            ;;
        libkf5pimcommon-dev)
            extra_deps=libkf5libkdepim-dev
            ;;
        libobs-dev)
            extra_deps="libpulse-dev libavcodec-dev libcurl4-gnutls-dev"
            ;;
        libopenmpi-dev)
            extra_deps=default-jdk-headless
            ;;
        libkf5kdelibs4support-dev)
            extra_deps=libkf5newstuff-dev
            ;;
        fcitx-libs-dev)
            extra_deps="libcairo2-dev libdbus-1-dev"
            ;;
        libhiredis-dev)
            extra_deps="libivykis-dev libev-dev libevent-dev libuv1-dev"
            extra_deps="$extra_deps qtbase5-dev libglib2.0-dev"
            ;;
        libavutil-dev)
            extra_deps="opencl-c-headers libva-dev libvdpau-dev libvulkan-dev"
            ;;
        libwxgtk3.2-dev|libgtk-layer-shell-dev|libreofficekit-dev)
            extra_deps=libgtk-3-dev
            ;;
        qt6-base-dev)
            extra_deps="khronos-api libgles-dev"
            ;;
        libvarnishapi-dev)
            extra_deps=libpcre2-dev
            ;;
        libuhd-dev)
            extra_deps="libboost-dev libflatbuffers-dev pybind11-dev"
            extra_deps="$extra_deps libpython3-dev"
            ;;
        libyaz-dev|lttoolbox-dev|libgwenhywfar-core-dev)
            extra_deps=libxml2-dev
            ;;
        tao-pegtl-dev|libphonenumber-dev|libsword-dev)
            extra_deps=libicu-dev
            ;;
        libplist++-dev)
             extra_deps=libplist-dev
            ;;
        libflint-dev)
            extra_deps=libntl-dev
            ;;
        fcitx5-modules-dev)
            extra_deps="libwayland-dev libxcb1-dev libxcb-ewmh-dev"
            ;;
        waylandpp-dev)
            extra_deps="libegl-dev libwayland-dev"
            ;;
        xtrans-dev)
            extra_deps=x11proto-dev
            ;;
        libkf5ldap-dev|libkf5cddb-dev)
            extra_deps=libkf5config-dev
            ;;
        libfltk1.1-dev)
            extra_deps="libgl-dev libglu1-mesa-dev"
            ;;
        libdtkgui-dev)
            extra_deps="libdtkcore-dev qtbase5-dev"
            ;;
        libsuil-dev)
            extra_deps=lv2-dev
            ;;
        libspandsp-dev|libcsound64-dev)
            extra_deps=libsndfile1-dev
            ;;
        libresid-builder-dev|libsidutils-dev)
            extra_deps=libsidplay2-dev
            ;;
        libktp-dev)
            extra_deps=libkf5kcmutils-dev
            ;;
        libsvn-dev)
            extra_deps=apache2-dev
            ;;
        libpoco-dev)
            extra_deps="unixodbc-dev libpq-dev"
            ;;
        libopenbabel-dev)
            extra_deps="libeigen3-dev libcairo2-dev libinchi-dev rapidjson-dev"
            extra_deps="$extra_deps libxml2-dev"
            ;;
        libfm-qt-dev|libqt5xdgiconloader-dev)
            extra_deps=qtbase5-private-dev
            ;;
        libosmo-abis-dev|osmo-libasn1c-dev|libosmo-mgcp-client-dev)
            extra_deps=libosmocore-dev
            ;;
        libvlccore-dev)
            extra_deps="libgcrypt20-dev libx11-dev"
            ;;
        libkf5messageviewer-dev)
            extra_deps="libkf5mimetreeparser-dev libkf5config-dev"
            extra_deps="$extra_deps libkf5mime-dev libkf5akonadi-dev"
            extra_deps="$extra_deps libkf5akonadimime-dev libkf5pimcommon-dev"
            extra_deps="$extra_deps libkf5webengineviewer-dev libgpgmepp-dev"
            extra_deps="$extra_deps libgpg-error-dev"
            ;;
        libaudio-dev)
            extra_deps=libxt-dev
            ;;
        python3-cairo-dev)
            extra_deps="libpython3-dev libcairo2-dev"
            ;;
        libaccounts-qt5-dev)
            extra_deps="qtbase5-dev libaccounts-glib-dev"
            ;;
        qtlocation5-dev)
            extra_deps=qtpositioning5-dev
            ;;
        libqtdbusmock1-dev)
            extra_deps="libqtdbustest1-dev qtbase5-dev"
            ;;
        libticcutils-dev)
            extra_deps="libtar-dev libicu-dev libxml2-dev libbz2-dev zlib1g-dev"
            ;;
        liblog4cpp5-dev*)
            extra_deps="libboost-dev libomnithread4-dev libomniorb4-dev"
            ;;
       llvm-13-dev*|llvm-14-dev*|llvm-15-dev*)
            extra_deps="googletest oprofile"
            ;;
        liblomiri-api-dev)
            extra_deps="qtbase5-dev qtdeclarative5-dev qtbase5-private-dev"
            defines="#define QT_NO_SIGNALS_SLOTS_KEYWORDS"
            ;;
        libnode-dev)
            extra_deps="libgtest-dev libc-ares-dev"
            ;;
        libocct-data-exchange-dev)
            extra_deps="rapidjson-dev libfl-dev"
            ;;
        libkf5messagelist-dev)
            extra_deps="libkf5akonadi-dev libkf5akonadimime-dev"
            ;;
        libkf5messagecore-dev)
            extra_deps="libkf5mime-dev libkf5coreaddons-dev libgpgmepp-dev"
            extra_deps="$extra_deps libgpg-error-dev libkf5mimetreeparser-dev"
            extra_deps="$extra_deps libkf5configwidgets-dev"
            extra_deps="$extra_deps libkf5identitymanagement-dev"
            ;;
        libkf5eventviews-dev)
            extra_deps=libkf5holidays-dev
            ;;
        libopenimageio-dev)
            extra_deps=libtiff-dev
            ;;
        libopencolorio-dev)
            extra_deps=libopenimageio-dev
            ;;
        libogre-1.12-dev*)
            extra_deps="qtbase5-dev libboost-dev libpoco-dev libimgui-dev"
            extra_deps="$extra_deps libglu1-mesa-dev"
            ;;
        libocct-ocaf-dev|libocct-foundation-dev)
            extra_deps=libocct-visualization-dev
            ;;
        libocct-modeling-algorithms-dev)
            extra_deps="libocct-modeling-data-dev libocct-visualization-dev"
            ;;
        libcodec2-dev)
            extra_deps=libkissfft-dev
            ;;
        libgavl-dev)
            extra_deps="libegl-dev libva-dev"
            ;;
        libosmium2-dev)
            extra_deps="libgdal-dev libgeos++-dev"
            ;;
        libocct-visualization-dev)
            extra_deps=libocct-draw-dev
            ;;
        libimgui-dev)
            extra_deps="directx-headers-dev libvulkan-dev"
            ;;
        xtl-dev)
            extra_deps=nlohmann-json3-dev
            ;;
        qt6-svg-dev)
            extra_deps=qt6-base-dev
            ;;
        libplib-dev)
            extra_deps="libfltk1.3-dev libsdl1.2-dev"
            ;;
        librbd-dev)
            extra_deps=libradospp-dev
            ;;
        libpodofo-dev)
            extra_deps="libjpeg-dev libtiff-dev libfontconfig-dev"
            ;;
        libplplot-dev)
            extra_deps="qtbase5-dev libqt5svg5-dev"
            ;;
        libmlt++-dev)
            extra_deps=libmlt-dev
            ;;
        libsquashfuse-dev)
            extra_deps=libfuse3-dev
             ;;
        libmlir-15-dev*)
            extra_deps="llvm-15-dev pybind11-dev libpython3-dev"
            ;;
        libmlir-16-dev)
            extra_deps="llvm-16-dev pybind11-dev libpython3-dev"
            ;;
        libmlir-14-dev)
            extra_deps="llvm-14-dev pybind11-dev libpython3-dev"
            ;;
        libmlir-13-dev)
            extra_deps="llvm-13-dev pybind11-dev libpython3-dev"
            ;;
        libmapnik-dev*)
            extra_deps=libpolyclipping-dev
            ;;
        libzephyr-dev)
            extra_deps=comerr-dev
            ;;
        libwpd-dev|libqxp-dev)
            extra_deps=librevenge-dev
            ;;
        libtimbl-dev)
            extra_deps="libticcutils-dev libxml2-dev"
            preamble=timbl/TimblAPI.h
            ;;
        festival-dev)
            extra_deps="libestools-dev"
            preamble="speech_tools/siod.h"
            ;;
        libjellyfish-2.0-dev)
            extra_deps=libhts-dev
            ;;
        libimath-dev)
            extra_deps="libgl-dev libglu1-mesa-dev libpython3-dev libboost-dev"
            ;;
        libdirectfb-dev)
            extra_deps="libgbm-dev libdrm-dev"
            ;;
        libaudclient-dev)
            extra_deps=libdbus-glib-1-dev
            ;;
        libgdcm-dev|libcjose-dev)
            extra_deps=libssl-dev
            ;;
        qtwayland5-private-dev)
            extra_deps="libwayland-dev qtbase5-private-dev"
            extra_deps="$extra_deps qtdeclarative5-private-dev"
            ;;
        libtelepathy-logger-dev)
            extra_deps=libtelepathy-glib-dev
            ;;
        libkf5kipi-dev)
            extra_deps="qtbase5-dev libkf5xmlgui-dev libkf5service-dev"
            ;;
        libimecore-dev)
            extra_deps="libfcitx5utils-dev libboost-dev"
            ;;
        libguichan-dev)
            extra_deps=liballeggl4-dev
            ;;
        libboost1.74-dev*)
            extra_deps="libssl-dev opencl-c-headers libpng-dev libeigen3-dev"
            extra_deps="$extra_deps libraw-dev libtiff-dev libopenmpi-dev"
            extra_deps="$extra_deps libicu-dev libpython3.11-dev"
            extra_deps="$extra_deps libmpfi-dev-common libtommath-dev"
            extra_deps="$extra_deps libclblas-dev libgmp-dev libmpfr-dev"
            extra_deps="$extra_deps libmpc-dev libgl-dev libfftw3-dev"
            ;;
        libniftiio-dev*)
            extra_deps=libnifti2-dev
            ;;
        libdynamic-reconfigure-config-init-mutex-dev)
            extra_deps=libroscpp-dev
            ;;
        libbotan-2-dev)
            extra_deps=libtspi-dev
            ;;
        unity-settings-daemon-dev)
            extra_deps="libgtk-3-dev gsettings-desktop-schemas-dev"
            extra_deps="$extra_deps libgnome-desktop-3-dev"
            ;;
        libgvm-dev)
            extra_deps=libpaho-mqtt-dev
            ;;
        libgenometools0-dev)
            extra_deps="libcairo2-dev libbz2-dev"
            ;;
        libceres-dev)
            extra_deps=libgmock-dev
            ;;
        libmedc-dev|libscotchparmetis-dev=*|sfftw-dev)
            extra_deps=libopenmpi-dev
            ;;
        libmediastreamer-dev)
            extra_deps="openjdk-17-jdk-headless libegl-dev libglew-dev libgles-dev"
            includes="/usr/lib/jvm/java-17-openjdk-$dpkg_arch/include/"
            ;;
        liboop-dev)
            extra_deps="libadns1-dev libglib2.0-dev"
            preamble="oop.h
adns.h
glib.h"
            ;;
        librime-dev)
            extra_deps="libboost-dev libgoogle-glog-dev darts libmarisa-dev x11proto-dev"
            ;;
        libplumb2-dev)
            extra_deps="libglib2.0-dev cluster-glue-dev libgnutls28-dev"
            ;;
        libvtkgdcm-dev)
            extra_deps=libvtk9-dev
            ;;
        libvirt-glib-1.0-dev)
            extra_deps="libglib2.0-dev libxml2-dev"
            ;;
        libvigraimpex-dev)
            extra_deps="libfftw3-dev libpython3-dev python3-numpy libboost-python-dev"
            ;;
        libzita-alsa-pcmi-dev)
            extra_deps=libasound2-dev
            ;;
        qt6-shadertools-dev)
            extra_deps="qt6-base-dev qt6-base-private-dev"
            ;;
        libotcl1-dev)
            extra_deps="tcl8.6-dev"
            ;;
	tcl-snack-dev)
	    extra_deps="tcl8.6-dev"
	    preamble="tcl.h"
	    ;;
        svdrpservice-dev)
            extra_deps="vdr-dev"
	    ;;
        tkblt-dev)
            extra_deps="tcl8.6-dev"
            preamble="tkbltVector.h"
            ;;
        libpetsc64-real3.18-dev|libpetsc-real3.18-dev|libpetsc64-complex3.18-dev|\
        libpetsc-complex3.18-dev)
            extra_deps="libhypre-dev libviennacl-dev"
            includes="/usr/lib/$multiarch/openmpi/include/"
            ;;
        libvmdk-dev)
            extra_deps=libbfio-dev
            ;;
        libverto-dev)
            extra_deps="libevent-dev libglib2.0-dev"
            ;;
        libvalapanel-dev)
            extra_deps="libglib2.0-dev libgtk-3-dev"
            ;;
        gemmi-dev)
            extra_deps="tao-pegtl-dev libstb-dev zlib1g-dev libmmdb2-dev"
            ;;
        android-libziparchive-dev)
            extra_deps=android-libbase-dev
            ;;
        eog-dev)
            extra_deps=libexif-dev
            ;;
        libpanel-dev)
            extra_deps=libadwaita-1-dev
            includes=/usr/include/libadwaita-1
            ;;
        libedataserverui1.2-dev)
            extra_deps=libedataserverui4-dev
            includes=/usr/include/evolution-data-server
            ;;
        libapache2-mod-perl2-dev)
            extra_deps="apache2-dev libperl-dev"
            ;;
        libagg2-dev)
            extra_deps="libfreetype-dev"
            ;;
        libapogee-dev)
            extra_deps="libcurl4-openssl-dev"
            ;;
        libplacebo-dev)
            extra_deps="libdav1d-dev libavformat-dev"
            ;;
        libtracefs-dev)
            extra_deps=libtraceevent-dev
            ;;
        libtogl-dev)
            extra_deps="tcl8.6-dev tk8.6-dev libgl-dev"
            ;;
        libt4k-common0-dev)
            extra_deps=libsdl-mixer1.2-dev
            ;;
        libtimblserver-dev)
            extra_deps="libtimbl-dev libticcutils-dev libxml2-dev"
            preamble=ticcutils/ServerBase.h
            ;;
        librttopo-dev)
            extra_deps=libgeos-dev
            ;;
        librocksdb-dev)
            extra_deps=liblua5.4-dev
            ;;
        libshrinkwrap-dev)
            extra_deps="liblzma-dev libzstd-dev zlib1g-dev"
            ;;
        libsoci-dev)
            extra_deps="default-libmysqlclient-dev libboost-dev libpq-dev"
            extra_deps="$extra_deps libsqlite3-dev firebird-dev unixodbc-dev"
            ;;
        libraft-dev)
            extra_deps=libuv1-dev
            ;;
        libpolly-14-dev)
            extra_deps="llvm-14-dev libgmp-dev"
            ;;
        libpils2-dev)
            extra_deps="cluster-glue-dev libglib2.0-dev"
            ;;
        libotf-dev)
            extra_deps=libfreetype-dev
            ;;
        libnids-dev)
            extra_deps=libpcap0.8-dev
            ;;
        libnodelet-topic-tools-dev)
            extra_deps="libroscpp-dev libnodeletlib-dev libmessage-filters-dev"
            ;;
        libocct-draw-dev)
            extra_deps="libocct-foundation-dev libocct-modeling-algorithms-dev"
            extra_deps="$extra_deps libocct-modeling-data-dev libocct-ocaf-dev"
            extra_deps="$extra_deps libocct-visualization-dev libocct-data-exchange-dev"
            ;;
        libmiroil-dev)
            extra_deps="libmircore-dev libmiral-dev libmirplatform-dev libmirserver-dev"
            ;;
        libmbt-dev)
            extra_deps="libticcutils-dev libtimbl-dev libxml2-dev"
            ;;
        libnauty2-dev)
            extra_deps=libcliquer-dev
            ;;
        libmathic-dev)
            extra_deps=libmemtailor-dev
            ;;
        libldacbt-abr-dev)
            extra_deps=libldacbt-enc-dev
            ;;
        libhmmer2-dev)
            extra_deps=libsquid-dev
            ;;
        libglewmx-dev)
            extra_deps=libglu1-mesa-dev
            ;;
        libm4rie-dev)
            extra_deps=libm4ri-dev
            ;;
        libhx-dev)
            extra_deps="libfcitx5utils-dev libxml2-dev"
            ;;
        libgrpc++-dev)
            extra_deps="libprotobuf-dev libgmock-dev"
            ;;
        libglvnd-core-dev)
            extra_deps="libgl-dev libegl-dev"
            ;;
        libkmfl-dev)
            extra_deps=libkmflcomp-dev
            ;;
        libtotem-dev)
            extra_deps=libpeas-dev
            includes=/usr/include/libpeas-1.0
            ;;
        rhythmbox-dev)
            extra_deps="libgstreamer-plugins-base1.0-dev libtdb-dev libpeas-dev"
            ;;
        libtext-engine-dev)
            extra_deps="libgraphene-1.0-dev libgtk-4-dev libpango1.0-dev"
            ;;
    esac

    # With virtual sub-packages, the actual package is left in the package list
    # only as the marker for the end of the sub-packages list: there is no
    # ABI dump to do and no package to install
    if ! $is_reducing; then
        # uninstallable package in unstable? skip
        if ! wrap_apt install $devpkg_no_virtual $extra_deps \
                              abi-compliance-checker
        then
            echo $devpkg >> uninstallable
            continue
        fi
        headers=$(dpkg -L $devpkg_no_virtual | grep -E '\.h(pp|xx|h)?$' \
                  | grep -v usr/share/doc || true)
        libs=$(dpkg -L $devpkg_no_virtual | grep '\.so$' || true)
        if [ -z "$headers" ]; then
            wrap_apt autoremove --purge $devpkg_no_virtual $extra_deps
            continue
        fi
    fi

    case $devpkg in
        apertium-lex-tools-dev)
            includes=/usr/include/libxml2/
            ;;
        bind9-dev)
            # crazy workaround for C vs C++
            headers="/usr/lib/gcc/$multiarch/$gcc_major/include/stdatomic.h
$headers"
            ;;
        coinor-libclp-dev)
            preamble="/usr/include/coin/CoinHelperFunctions.hpp
/usr/include/coin/ClpSimplex.hpp
/usr/include/coin/OsiSolverInterface.hpp
/usr/include/coin/OsiClpSolverInterface.hpp
"
            ;;
        coinor-libipopt-dev)
            defines="#define HAVE_CSTDDEF"
            ;;
        cluster-glue-dev|libsmf-dev|libwhoopsie-dev)
            preamble=glib.h
            ;;
        kwin-dev|qcoro-qt5-dev)
            extra_args="-gcc-options -std=c++20"
            ;;
        liblog4cpp5-dev*)
            # Include _one_ of these headers in each virtual package
            case $devpkg in
                *=boostthreads)
                    preamble=/usr/include/log4cpp/threading/BoostThreads.hh ;;
                *=dummythreads)
                    preamble=/usr/include/log4cpp/threading/DummyThreads.hh ;;
                *=omnithreads)
                    preamble=/usr/include/log4cpp/threading/OmniThreads.hh ;;
                *=pthreads)
                    preamble=/usr/include/log4cpp/threading/PThreads.hh ;;
            esac
            # This file is referenced by other headers and defaults to PThreads
            # which prevents analyzing other headers above
            : > /usr/include/log4cpp/threading/Threading.hh
            ;;
        freerdp2-dev*)
            defines="$defines
#define _Noreturn __attribute__ ((__noreturn__))"
            preamble="string.h
freerdp2/freerdp/freerdp.h"
            ;;
        libatspi2.0-dev)
            headers="/usr/include/glib-2.0/glib-object.h
$headers"
            ;;
        libcdio-dev)
            preamble=cdio/cdio.h
            ;;
        libcephfs-dev|libgpgme-dev|libupnp-dev|libgvm-dev)
            # only compatible with LFS mode but doesn't set this itself
            defines="$defines
#define _FILE_OFFSET_BITS 64"
            ;;
        xmms2-dev)
            sed -i 's/#include "xmms_configuration\.h"//' /usr/include/xmms2/xmms/xmms_plugin.h
            ;;
        libglm-dev)
            # the upstream got confused by the vector types
            sed -i 's|vget_high_f32|vget_high_u32|g' /usr/include/glm/detail/type_vec4_simd.inl
            sed -i 's|vget_low_f32|vget_low_u32|g' /usr/include/glm/detail/type_vec4_simd.inl
            defines="$defines
#define GLM_FORCE_NEON
#define GLM_ENABLE_EXPERIMENTAL
#define GLM_CONFIG_ALIGNED_GENTYPES 1"
            extra_args="-gcc-options -march=armv7-a+neon+simd"
            ;;
        libchewing3-dev)
            preamble=chewing/global.h
            ;;
        libclucene-dev)
            preamble="tr1/functional
tr1/unordered_set
CLucene/SharedHeader.h
CLucene/debug/error.h
CLucene/analysis/standard/StandardFilter.h
CLucene/analysis/de/GermanStemmer.h"
            defines="namespace lucene { namespace util { class StringBuffer{}; } }"
            # Duplicate name
            sed -i 's/struct stemmer_encoding/struct stemmer_encoding_struct/g' /usr/include/CLucene/snowball/libstemmer/modules.h
            ;;
        libdebconfclient0-dev)
            preamble=newt.h
            # -cxx-incompatible is supposed to figure this out
            sed -i 's|struct template\b|struct permaplate|g' \
                   /usr/include/cdebconf/template.h
            ;;
        libdlmcontrol-dev)
            preamble=linux/dlm.h
            ;;
        libdmx-dev|libxv-dev|libxvmc-dev)
            preamble=X11/Xlib.h
            ;;
        libm17n-dev)
            preamble="X11/Xlib.h
m17n.h"
            ;;
        libespeak-ng-dev)
            preamble=espeak-ng/espeak_ng.h
            ;;
        libext2fs-dev)
            preamble=et/com_err.h
            ;;
        libfdt-dev)
            preamble=libfdt_env.h
            ;;
        libfontconfig-dev)
            preamble=fontconfig/fontconfig.h
            ;;
        libfuse3-dev)
            defines="#define FUSE_USE_VERSION 30
# define _Static_assert(expr, diagnostic) ;"
            ;;
        libgck-1-dev|libgck-2-dev)
            defines="#define GCK_API_SUBJECT_TO_CHANGE"
            ;;
        libgcr-3-dev|libgcr-4-dev)
            defines="#define GCR_API_SUBJECT_TO_CHANGE"
            ;;
        libglib2.0-dev)
            defines="#define G_SETTINGS_ENABLE_BACKEND
$defines"
            ;;
        libglusterfs-dev)
            defines="#define GF_LINUX_HOST_OS
            #define this __this
            #define SIZEOF_LONG 4
$defines"
urcu_patch_transparent_unions
# patch compile errors that can not be resolved otherwise
# variable-sized array in the middle of the structure
sed -i 's/char d_name\[\]/char* d_name/g' /usr/include/glusterfs/gf-dirent.h
sed -i 's/if (caa_unlikely(!cds_wfcq_enqueue(&gf_async_ctrl.queue.head/if (caa_unlikely(!cds_wfcq_enqueue({}/g' \
    /usr/include/glusterfs/async.h
# patch tirpc typedef followed by a struct
sed -i 's/typedef rp__list rpcblist;//g' \
    /usr/include/tirpc/rpc/rpcb_prot.h
sed -i 's/typedef struct rp__list rpcblist;//g' \
    /usr/include/tirpc/rpc/rpcb_prot.h
            ;;
        libgnome-bg-4-dev|libgnome-desktop-3-dev|libgnome-desktop-4-dev|libgnome-rr-4-dev)
            defines="#define GNOME_DESKTOP_USE_UNSTABLE_API"
            ;;
        libgnome-menu-3-dev)
            defines="#define GMENU_I_KNOW_THIS_IS_UNSTABLE"
            ;;
        libgnomekbd-dev)
            sed -i '/^#define GKBD_TYPE_CONFIGURATION/ i G_BEGIN_DECLS' /usr/include/libgnomekbd/gkbd-configuration.h
            ;;
        libboost1.74-dev*)
            # boost is a C++-only library, defining __STDC_VERSION__ breaks stuff
            # -- common settings
            defines="#define BOOST_ENDIAN_DEPRECATED_NAMES
#define BOOST_MP_USE_QUAD
#define BOOST_CHRONO_VERSION 2
#define BOOST_SERIALIZATION_VECTOR_VERSION 4
#undef __STDC_VERSION__"
            includes="/usr/include/eigen3/
/usr/include/$multiarch/mpi/"
            preamble='iostream
/usr/include/boost/config/platform/linux.hpp
/usr/include/boost/config/compiler/gcc.hpp
/usr/include/boost/config/stdlib/libstdcpp3.hpp'
            # HACK: avoid namespace collisions
            sed -i 's|namespace mpl$|namespace mpl_09112011_1842|g' /usr/include/boost/fusion/adapted/std_tuple/tag_of.hpp
            # Fix API changes introduced in CPython v3.11
            sed -i 's|Py_TYPE(&unspecified) = &PyType_Type|Py_SET_TYPE(\&unspecified, \&PyType_Type)|g' \
                /usr/include/boost/parameter/python.hpp
            # -- per-chunk settings
            case "$devpkg" in
                *=chunk-*)
                    chunk="${devpkg##*=}"
                    headers="$(read_headers_list_file lists/boost-"${chunk}".list)"
                    # requires some weird header pre-compilation tuning
                    extra_args="-gcc-options -xc++-header"
                ;;
                *)
                    echo 'This does not make sense. Please check if libboost1.74-dev has the correct splits.'
                    exit 1
                ;;
            esac
            ;;
        libxt-dev)
            preamble="X11/Xmd.h
X11/extensions/XResproto.h
X11/Xfuncproto.h
X11/Intrinsic.h
X11/IntrinsicP.h
X11/CoreP.h
X11/ConvertI.h
X11/IntrinsicI.h"
            sed -i /usr/include/X11/Intrinsic.h -e'/X11\/Xfuncproto.h/a\
#undef _X_RESTRICT_KYWD\
#define _X_RESTRICT_KYWD'
            ;;
        libkf5kio-dev|libkf5parts-dev|libkf5khtml-dev|libkf5pimcommon-dev|\
        libkf5mailcommon-dev)
            includes="/usr/lib/$multiarch/qt5/mkspecs/linux-g++-32/"
            ;;
        libkrb5-dev)
            preamble=gssrpc/types.h
            ;;
        qtbase5-private-dev*)
            includes="/usr/lib/$multiarch/qt5/mkspecs/linux-g++-32/
/usr/lib/jvm/default-java/include/"
            defines="#define QT_GUI_LIB
#define QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
#define QT_NO_URL_CAST_FROM_STRING
#define QT_STRICT_ITERATORS
#define QT_USE_QSTRINGBUILDER
#define _GNU_SOURCE
#define _LARGEFILE64_SOURCE
#undef __STDC_VERSION__"
            exclude_types="_ns_flagdata"
            # -- per-chunk settings
            case "$devpkg" in
                *=chunk-1)
                    headers="$(read_headers_list_file lists/qt5base-chunk-1.list)"
                ;;
                *=chunk-2)
                    echo "#undef ifr_name" > workaround.h
                    headers="$(read_headers_list_file lists/qt5base-chunk-2.list)"
                ;;
                *=chunk-3)
                    headers="$(read_headers_list_file lists/qt5base-chunk-3.list)"
                ;;
                *)
                    echo 'This does not make sense. Please check if qtbase5-private-dev has the correct splits.'
                    exit 1
                ;;
            esac
            ;;
        qt6-base-private-dev*)
            includes="/usr/lib/$multiarch/qt6/mkspecs/linux-g++-32/"
            exclude_types="_ns_flagdata"
            defines="#define QT_GUI_LIB
#define QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
#define QT_NO_URL_CAST_FROM_STRING
#define QT_STRICT_ITERATORS
#define QT_IMPLICIT_QCHAR_CONSTRUCTION
#define _GNU_SOURCE
#define _LARGEFILE64_SOURCE
#undef QT_USE_QSTRINGBUILDER
#undef __STDC_VERSION__"
            # -- per-chunk settings
            case "$devpkg" in
                *=chunk-1)
                    echo "#undef ifr_name" > workaround.h
                    headers="$(read_headers_list_file lists/qt6-base-chunk-1.list)"
                ;;
                *=chunk-2)
                    echo "#undef ifr_name" > workaround.h
                    headers="$(read_headers_list_file lists/qt6-base-chunk-2.list)"
                ;;
                *=chunk-3)
                    headers="$(read_headers_list_file lists/qt6-base-chunk-3.list)"
                ;;
                *)
                    echo 'This does not make sense. Please check if qt6-base-private-dev has the correct splits.'
                    exit 1
                ;;
            esac
            ;;
        libpcre2-dev)
            defines="#define PCRE2_CODE_UNIT_WIDTH 0"
            ;;
        libgstreamer-plugins-base1.0-dev)
            preamble=gstreamer-1.0/gst/gl/gstglfuncs.h
            ;;
        libxaw7-dev|libmotif-dev)
            preamble="X11/Xfuncproto.h
X11/IntrinsicP.h
X11/CoreP.h"
            sed -i /usr/include/X11/Intrinsic.h -e'/X11\/Xfuncproto.h/a\
#undef _X_RESTRICT_KYWD\
#define _X_RESTRICT_KYWD'
            ;;
        libkf5notifications-dev)
            preamble=qt5/QtWidgets/qframe.h
            ;;
        librsvg2-dev)
            preamble="glib-2.0/glib.h
librsvg/rsvg.h"
            ;;
        libhdf5-dev|libhdf5-openmpi-dev)
            preamble="hdf5/serial/H5Classes.h
hdf5/serial/H5api_adpt.h
hdf5/serial/H5version.h
hdf5/serial/H5Epublic.h
hdf5/serial/H5Include.h
hdf5/serial/H5Exception.h
hdf5/serial/H5Tpublic.h
hdf5/serial/H5IdComponent.h
hdf5/serial/H5PropList.h
hdf5/serial/H5LaccProp.h
hdf5/serial/H5DaccProp.h
hdf5/serial/H5LcreatProp.h
hdf5/serial/H5OcreatProp.h
hdf5/serial/H5DcreatProp.h
hdf5/serial/H5Location.h
hdf5/serial/H5Object.h
hdf5/serial/H5DataType.h"
            case $devpkg in
                libhdf5-openmpi-dev)
                    includes="/usr/lib/$multiarch/openmpi/include"
                    ;;
            esac
            ;;
        libpolkit-agent-1-dev)
            defines="#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE"
            ;;
        yorick-dev)
            preamble=/usr/share/yorick/include/pstdio.h
            ;;
        libspdlog-dev)
            # workaround for absolutely insane a-c-c behavior (bug #1035369)
            rm -f /usr/include/spdlog/details/*-windows.h
            preamble="spdlog/details/file_helper.h
spdlog/sinks/base_sink.h
spdlog/sinks/basic_file_sink.h
spdlog/sinks/rotating_file_sink.h
spdlog/sinks/stdout_color_sinks.h
spdlog/sinks/stdout_sinks.h"
            ;;
        libgstreamer-plugins-bad1.0-dev)
            preamble=/usr/include/xcb/xcb.h
            ;;
        libvtk9-dev)
            includes="/usr/lib/jvm/default-java/include/linux/
/usr/lib/jvm/default-java/include/
/usr/include/$multiarch/mpich/
/usr/include/libxml2/"
            preamble="vector
GL/glew.h
GL/gl.h
vtk-9.1/octree/octree_node.h
vtk-9.1/octree/octree_path.h
vtk-9.1/octree/octree_iterator.h
vtk-9.1/octree/octree_cursor.h
vtk-9.1/vtkJavaUtil.h
vtk-9.1/vtksys/Configure.h
vtk-9.1/vtkfmt/core.h
"
            sed -i -e'/vtkParseAttributes/d' \
                /usr/include/vtk-9.1/vtkParseData.h
            ;;
        libtelepathy-qt5-dev)
            headers=$(find /usr/include/telepathy-qt5/ -type f '!' -name '*.h')
            ;;
        libmodplug-dev)
            preamble="stdint.h
libmodplug/stdafx.h"
            ;;
        libgoa-1.0-dev)
            defines="#define GOA_API_IS_SUBJECT_TO_CHANGE"
            ;;
        libclang-14-dev*)
            touch /usr/include/clang-tidy-config.h
            includes=/usr/include/llvm-14/
            ;;
        libclang-15-dev*)
            touch /usr/include/clang-tidy-config.h
            includes=/usr/include/llvm-15/
            ;;
        libwebkit2gtk-4.1-dev|libdevhelp-dev|libyelp-dev)
            preamble=gtk/gtk.h
            includes=/usr/include/gtk-3.0
            ;;
        libnet1-dev)
            preamble=/usr/include/libnet.h
            exclude_types=libnet_stats
            ;;
        libopus-dev)
            defines="#define restrict"
            ;;
        liborc-0.4-dev)
            defines="#define ORC_RESTRICT"
            ;;
        nlohmann-json3-dev)
            preamble="nlohmann/detail/macro_unscope.hpp
nlohmann/thirdparty/hedley/hedley.hpp"
            ;;
        libxklavier-dev)
            preamble=glib-2.0/glib-object.h
            ;;
        libcddb2-dev)
            headers=/usr/include/cddb/cddb.h
            ;;
        libgtop2-dev)
            defines="#define glibtop_debug(...)"
            ;;
        libbfio-dev)
            preamble=/usr/include/features.h
            ;;
        libforms-dev)
            preamble=forms.h
            ;;
        libfox-1.6-dev)
            headers=$(find /usr/include/fox-1.6/ -type f -name 'fx*' | sort)
            defines="#define FLOAT_MATH_FUNCTIONS"
            ;;
        libgoa-backend-1.0-dev)
            defines="#define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
#define GOA_API_IS_SUBJECT_TO_CHANGE"
            ;;
        libgsasl-dev)
            preamble=gsasl.h
            ;;
        libgtkglext1-dev)
            preamble="gtkglext-1.0/gdk/x11/gdkglx.h
gtkglext-1.0/gdk/x11/gdkglglxext.h"
            ;;
        libgtkspell-dev)
            preamble=gtk/gtk.h
            includes=/usr/include/gtk-2.0
            ;;
        libical-dev)
            defines="#define LIBICAL_GLIB_UNSTABLE_API 1"
            preamble="glib-2.0/glib-object.h
libical/icalgauge.h"
            ;;
        erlang-dev)
            defines="#define ETHR_PTHREADS 1
#define ETHR_SIZEOF_AO_T 4"
            headers="/usr/lib/erlang/erts-13.1.5/include/internal/ethread_header_config.h
/usr/lib/erlang/erts-13.1.5/include/erl_driver.h
/usr/lib/erlang/erts-13.1.5/include/erl_drv_nif.h
/usr/lib/erlang/erts-13.1.5/include/erl_fixed_size_int_types.h
/usr/lib/erlang/erts-13.1.5/include/erl_int_sizes_config.h
/usr/lib/erlang/erts-13.1.5/include/erl_nif.h
/usr/lib/erlang/erts-13.1.5/include/internal/erl_errno.h
/usr/lib/erlang/erts-13.1.5/include/internal/erl_misc_utils.h
/usr/lib/erlang/erts-13.1.5/include/internal/erl_printf.h
/usr/lib/erlang/erts-13.1.5/include/internal/erl_printf_format.h
/usr/lib/erlang/erts-13.1.5/include/internal/ethr_mutex.h
/usr/lib/erlang/erts-13.1.5/include/internal/ethr_optimized_fallbacks.h
/usr/lib/erlang/erts-13.1.5/include/internal/ethread.h
/usr/lib/erlang/erts-13.1.5/include/internal/ethread_inline.h
/usr/lib/erlang/erts-13.1.5/include/internal/gcc/ethr_atomic.h
/usr/lib/erlang/erts-13.1.5/include/internal/gcc/ethr_dw_atomic.h
/usr/lib/erlang/erts-13.1.5/include/internal/gcc/ethr_membar.h
/usr/lib/erlang/erts-13.1.5/include/internal/gcc/ethread.h
/usr/lib/erlang/lib/erl_interface-5.3/include/ei.h
/usr/lib/erlang/lib/erl_interface-5.3/include/ei_connect.h
/usr/lib/erlang/lib/erl_interface-5.3/include/eicode.h
/usr/include/ei.h
/usr/include/ei_connect.h
/usr/include/eicode.h
/usr/include/erl_driver.h
/usr/include/erl_drv_nif.h
/usr/include/erl_fixed_size_int_types.h
/usr/include/erl_int_sizes_config.h
/usr/include/erl_nif.h"
            ;;
        libisl-dev)
            preamble=isl/arg.h
            exclude_types="isl_arg_choice
isl_arg_flags"
            ;;
        libxslt1-dev)
            preamble=xsltInternals.h
            ;;
        libsasl2-dev)
            # For some reason MD5_H is checked for by other headers in the package, but never defined in md5.h...
            defines="#define MD5_H 1"
            preamble="md5global.h
md5.h"
            ;;
        libxxf86vm-dev)
            preamble="X11/Xdefs.h
X11/Xlib.h"
            ;;
        libwrap0-dev)
            exclude_types=tcpd_context
            ;;
        libcfitsio-dev)
            preamble=fitsio.h
            ;;
        libvulkan-dev)
            preamble="directfb/directfb.h
xcb/xcb.h
X11/Xlib.h
X11/extensions/Xrandr.h"
            ;;
        libpolkit-gobject-1-dev)
            defines="#define _POLKIT_COMPILATION
#define _POLKIT_INSIDE_POLKIT_H"
            ;;
        libatlas-base-dev)
            preamble="clapack.h
atlas/atlas_cr2.h"
            defines="$defines
#define TYPE float
#define ATL_rone 1.0f
#define ATL_rnone -1.0f
#define ATL_rzero 0.0f
#define ATL_Cachelen 32
"
            ;;
        libbullet-dev)
            defines="#define __kernel
#define __global
#define CL_TARGET_OPENCL_VERSION 300
#define float4 b3Float4
$defines
"
preamble="
/usr/include/bullet/Bullet3Common/shared/b3PlatformDefinitions.h
/usr/include/bullet/Bullet3Common/shared/b3Float4.h
/usr/include/bullet/Bullet3Common/shared/b3Int2.h
/usr/include/bullet/Bullet3Common/shared/b3Int4.h
/usr/include/bullet/Bullet3Common/shared/b3Mat3x3.h
/usr/include/bullet/Bullet3Common/shared/b3Quat.h
/usr/include/bullet/Bullet3Common/b3AlignedAllocator.h
/usr/include/bullet/Bullet3Common/b3AlignedObjectArray.h
/usr/include/bullet/Bullet3Common/b3CommandLineArgs.h
/usr/include/bullet/Bullet3Common/b3FileUtils.h
/usr/include/bullet/Bullet3Common/b3HashMap.h
/usr/include/bullet/Bullet3Common/b3Logging.h
/usr/include/bullet/Bullet3Common/b3Matrix3x3.h
/usr/include/bullet/Bullet3Common/b3MinMax.h
/usr/include/bullet/Bullet3Common/b3PoolAllocator.h
/usr/include/bullet/Bullet3Common/b3QuadWord.h
/usr/include/bullet/Bullet3Common/b3Quaternion.h
/usr/include/bullet/Bullet3Common/b3Random.h
/usr/include/bullet/Bullet3Common/b3ResizablePool.h
/usr/include/bullet/Bullet3Common/b3StackAlloc.h
/usr/include/bullet/Bullet3Common/b3Transform.h
/usr/include/bullet/Bullet3Common/b3TransformUtil.h
/usr/include/bullet/Bullet3Common/b3Vector3.h
/usr/include/bullet/Bullet3OpenCL/NarrowphaseCollision/b3BvhInfo.h
/usr/include/bullet/Bullet3OpenCL/NarrowphaseCollision/b3QuantizedBvh.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/b3Config.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3BvhSubtreeInfoData.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3BvhTraversal.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3FindSeparatingAxis.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3QuantizedBvhNodeData.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3ReduceContacts.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3UpdateAabbs.h
/usr/include/bullet/Bullet3Collision/NarrowPhaseCollision/shared/b3ContactConvexConvexSAT.h
"
# bullet contains a lot of headers without guards
# add pragma once to avoid tweaking guard names
find /usr/include/bullet/ -type f -name '*.h' -exec sed -i '1i#pragma once' {} \;
# comment out enum that is defined in /usr/include/bullet/Bullet3OpenCL/NarrowphaseCollision/b3StridingMeshInterface.h
sed -i 's/typedef enum PHY_ScalarType/\/\*/g' /usr/include/bullet/BulletCollision/CollisionShapes/btConcaveShape.h
sed -i 's/\} PHY_ScalarType;/\*\//g' /usr/include/bullet/BulletCollision/CollisionShapes/btConcaveShape.h
# rename duplicate types
sed -i 's/NodeArray/NodeArray1/g' /usr/include/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
sed -i 's/QuantizedNodeArray/QuantizedNodeArray1/g' /usr/include/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
sed -i 's/BvhSubtreeInfoArray/BvhSubtreeInfoArray1/g' /usr/include/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
sed -i 's/IndexedMeshArray/IndexedMeshArray1/g' /usr/include/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
            ;;
        libavfilter-dev)
            defines="#define __STDC_CONSTANT_MACROS"
            ;;
        libunwind-dev)
            preamble=sys/types.h
            ;;
        libzip-dev)
            exclude_types=zip_stat
            ;;
        libapt-pkg-dev)
            exclude_types="_ns_flagdata
SubstVar"
            ;;
        coinor-libcoinutils-dev)
            preamble=/usr/include/coin/CoinPresolveMatrix.hpp
            ;;
        libflatpak-dev)
            preamble=/usr/include/flatpak/flatpak.h
            ;;
        libfluidsynth-dev)
            preamble=/usr/include/fluidsynth.h
            ;;
        libxxf86dga-dev|libxres-dev)
            preamble="X11/X.h
X11/Xdefs.h
X11/Xlib.h"
            ;;
        libvlc-dev)
            preamble="vlc/libvlc.h
vlc/libvlc_media.h
vlc/libvlc_events.h
vlc/libvlc_media_player.h
vlc/libvlc_media_discoverer.h"
            ;;
        libgtkmm-2.4-dev)
            preamble="/usr/include/gtkmm-2.4/gtkmm/progressbar.h
/usr/include/gtkmm-2.4/gtkmm/toggleaction.h
/usr/include/gtkmm-2.4/gtkmm/toggletoolbutton.h
/usr/include/gtkmm-2.4/gtkmm/range.h
/usr/include/gtkmm-2.4/gtkmm/recentaction.h
/usr/include/gtkmm-2.4/gtkmm/recentchooser.h
/usr/include/gtkmm-2.4/gtkmm/recentchoosermenu.h
/usr/include/gtkmm-2.4/gtkmm/recentchooserwidget.h
/usr/include/gtkmm-2.4/gtkmm/recentfilter.h
/usr/include/gtkmm-2.4/gtkmm/ruler.h
/usr/include/gtkmm-2.4/gtkmm/recentchooserdialog.h
/usr/include/gtkmm-2.4/gtkmm/recentmanager.h
/usr/include/gtkmm-2.4/gtkmm/scale.h
/usr/include/gtkmm-2.4/gtkmm/scalebutton.h
/usr/include/gtkmm-2.4/gtkmm/scrollbar.h
/usr/include/gtkmm-2.4/gtkmm/separator.h
/usr/include/gtkmm-2.4/gtkmm/separatortoolitem.h
/usr/include/gtkmm-2.4/gtkmm/socket.h
/usr/include/gtkmm-2.4/gtkmm/spinbutton.h
/usr/include/gtkmm-2.4/gtkmm/spinner.h
/usr/include/gtkmm-2.4/gtkmm/statusbar.h
/usr/include/gtkmm-2.4/gtkmm/statusicon.h
/usr/include/gtkmm-2.4/gtkmm/textchildanchor.h
/usr/include/gtkmm-2.4/gtkmm/textmark.h
/usr/include/gtkmm-2.4/gtkmm/texttag.h
/usr/include/gtkmm-2.4/gtkmm/texttagtable.h
/usr/include/gtkmm-2.4/gtkmm/textview.h
/usr/include/gtkmm-2.4/gtkmm/toolbar.h
/usr/include/gtkmm-2.4/gtkmm/toolbutton.h
/usr/include/gtkmm-2.4/gtkmm/toolitemgroup.h
/usr/include/gtkmm-2.4/gtkmm/toolpalette.h
/usr/include/gtkmm-2.4/gtkmm/toolshell.h
/usr/include/gtkmm-2.4/gtkmm/treemodelfilter.h
/usr/include/gtkmm-2.4/gtkmm/treestore.h
/usr/include/gtkmm-2.4/gtkmm/uimanager.h
/usr/include/gtkmm-2.4/gtkmm/viewport.h
/usr/include/gtkmm-2.4/gtkmm/volumebutton.h"
            ;;
        libtelepathy-glib-dev)
            preamble="glib.h
telepathy-glib/tls-certificate.h
telepathy-glib/_gen/tp-cli-tls-cert.h"
            ;;
        libosmocore-dev)
            includes=/usr/include/libusb-1.0
            preamble="stdint.h
/usr/include/talloc.h
core/linuxlist.h
gsm/protocol/gsm_08_08.h"
            ;;
        libmate-panel-applet-dev)
            preamble=glib-object.h
            ;;
        libmate-desktop-dev)
            defines="#define MATE_DESKTOP_USE_UNSTABLE_API"
            ;;
        libcdio++-dev)
            headers="/usr/include/cdio++/cdio.hpp
/usr/include/cdio++/devices.hpp"
            ;;
        libassimp-dev)
            preamble=/usr/include/assimp/Compiler/pushpack1.h
            ;;
        proftpd-dev)
            preamble="stdlib.h
proftpd/pool.h
proftpd/configdb.h
proftpd/mod_sftp/keys.h"
            defines="$defines
#define _Noreturn __attribute__ ((__noreturn__))"
            ;;
        libpurple-dev)
            preamble=libpurple/dbus-server.h
            defines="$defines
#define _Static_assert(expr, diagnostic, ...) ;"
            ;;
        libpipewire-0.3-dev|libdlib-dev|rhythmbox-dev)
            defines="$defines
#define _Static_assert(expr, diagnostic, ...) ;"
            ;;
        libgoogle-perftools-dev|libtorrent-rasterbar-dev|libradospp-dev|\
        libmeschach-dev)
            exclude_types=mallinfo2
            ;;
        libegl1-mesa-dev)
            preamble="EGL/egl.h
EGL/eglext.h"
            defines="#define EGL_EGLEXT_PROTOTYPES"
            ;;
        libstartup-notification0-dev)
            defines="#define SN_API_NOT_YET_FROZEN"
            ;;
        libgimp2.0-dev)
            defines="#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION"
            ;;
        libwebsockets-dev)
            headers="/usr/include/libwebsockets.h
/usr/include/libwebsockets/lws-dbus.h"
            exclude_types="lws_tokenize
lws_dll2_owner"
            ;;
        libwnck-3-dev)
            defines="#define WNCK_I_KNOW_THIS_IS_UNSTABLE"
            ;;
        libxkbfile-dev)
           preamble="X11/Xfuncproto.h
X11/Xlib.h
X11/extensions/XKBstr.h"
           ;;
        x11proto-dev)
           defines="$float_typedefs
#define _X_RESTRICT_KYWD"
           preamble=X11/fonts/fontstruct.h
           ;;
        libnss3-dev)
            preamble="nss/nssckmdt.h
nss/jar.h"
            ;;
        libscim-dev)
            preamble="scim-1.0/scim.h
scim-1.0/scim_config_base.h
scim-1.0/scim_module.h
scim-1.0/scim_config_module.h
scim-1.0/scim_event.h
scim-1.0/scim_attribute.h
scim-1.0/scim_lookup_table.h
scim-1.0/scim_property.h
scim-1.0/scim_socket.h
scim-1.0/scim_transaction.h
scim-1.0/scim_imengine.h"
            ;;
        libiberty-dev)
            preamble=stdint.h
            ;;
        libxcb-image0-dev)
            preamble=xcb_image.h
            ;;
        libobs-dev)
            preamble=obs/obs.h
            ;;
        liblttng-ust-dev)
            exclude_types="lttng_ust_sigbus_state
lttng_ust_tracepoint_destructors_syms
lttng_ust_tracepoint_dlopen
lttng_ust_type_array
lttng_ust_type_enum
lttng_ust_type_float
lttng_ust_type_integer
lttng_ust_type_sequence
lttng_ust_type_string
lttng_ust_type_struct
lttng_ust_urcu_gp
lttng_ust_urcu_reader"
            ;;
        libdbustest1-dev)
            preamble=libdbustest/dbus-test.h
            ;;
        libarpack2-dev)
            includes="/usr/include/$multiarch/mpi/"
            ;;
        libtbb-dev)
            defines="#define TBB_PREVIEW_BLOCKED_RANGE_ND 1
#define TBB_PREVIEW_CONCURRENT_LRU_CACHE 1
#define TBB_PREVIEW_MEMORY_POOL 1"
            preamble="oneapi/tbb/detail/_pipeline_filters.h
oneapi/tbb/detail/_waitable_atomic.h
oneapi/tbb/flow_graph.h"
            ;;
        libopenmpi-dev)
            includes="/usr/lib/$multiarch/openmpi/include
$(ls -1d /usr/lib/jvm/*openjdk*/include/ | head -1)"
            preamble="workarounds.h
mpi.h
openmpi/ompi_config.h
openmpi/opal_config.h
openmpi/ompi/mpi/cxx/mpicxx.h
/usr/lib/$multiarch/openmpi/include/openmpi/opal/mca/event/event.h
/usr/lib/$multiarch/openmpi/include/openmpi/opal/mca/event/external/external.h
event2/event_struct.h"
            defines="#define DO_DEBUG(INST)"
            ;;
        libgdal-dev)
            preamble=/usr/include/zlib.h
            ;;
        fcitx-libs-dev)
            preamble=/usr/include/dbus-1.0/dbus/dbus.h
            includes=/usr/include/cairo
            ;;
        libhiredis-dev)
            preamble=glib-2.0/glib.h
            ;;
        libsnmp-dev)
            preamble="
net-snmp/net-snmp-config.h
net-snmp/library/container.h
net-snmp/agent/snmp_agent.h
net-snmp/agent/agent_handler.h
net-snmp/agent/snmp_vars.h
net-snmp/agent/var_struct.h"
            defines="$defines
#define _Noreturn
#define UCD_COMPATIBLE"
            ;;
        libkf5akonadisearch-dev|libxapian-dev)
            preamble=xapian.h
            ;;
        libkf5kdelibs4support-dev)
            includes="/usr/lib/$multiarch/qt5/mkspecs/linux-g++-32/
/usr/include/KF5/KNewStuff3/"
            preamble=/usr/include/KF5/KParts/kparts/readwritepart.h
            ;;
        libmatio-dev)
            defines="$defines
#define _Noreturn"
            ;;
        libmpg123-dev)
            defines="#define MPG123_RESTRICT"
            exclude_types="mpg123_fmt"
            ;;
        libsmbclient-dev|libfuse-dev)
            defines="#define _FILE_OFFSET_BITS 64"
            exclude_types="statfs
statfs64
statvfs
statvfs64"
            ;;
        libosmium2-dev|libsquashfuse-dev)
            exclude_types="statvfs
statvfs64"
             ;;
        firebird-dev)
            preamble="cstdint
firebird/Interface.h"
            ;;
        apache2-dev)
            preamble=apr-1.0/apr_dbd.h
            ;;
        libwxgtk3.2-dev)
            headers=$(dpkg -L wx3.2-headers | grep -E '\.h(pp|xx)?$' \
                      | grep -v usr/share/doc || true)
            defines="#define _FILE_OFFSET_BITS 64
#define WXUSINGDLL
#define __WXGTK__"
            preamble="wx/setup.h
wx/fontmap.h
wx/headerctrl.h
wx/hyperlink.h
wx/infobar.h
wx/msgdlg.h
wx/notifmsg.h
wx/progdlg.h
wx/richmsgdlg.h
wx/spinctrl.h
wx/srchctrl.h
wx/timectrl.h
wx/wizard.h
gtk/gtk.h
wx/popupwin.h
wx/radiobox.h
wx/radiobut.h
wx/scrolbar.h
wx/slider.h
wx/statbox.h
wx/statline.h
wx/taskbar.h
wx/tglbtn.h
wx/richtext/richtextbuffer.h
wx/taskbar.h"
            ;;
        libselinux1-dev)
            exclude_types=avc_cache_stats
            ;;
        qt6-base-dev)
            preamble="
GLES2/gl2.h
khronos-api/GLES2/gl2ext.h"
            ;;
        libxfont-dev)
            preamble=X11/fonts/fontstruct.h
            ;;
        libyaz-dev)
            defines="#define YAZ_HAVE_XML2 1
$defines"
            ;;
        libwlroots-dev)
            defines="$defines
#define WLR_USE_UNSTABLE"
            preamble=pixman-1/pixman.h
            exclude_types="wl_buffer_interface
wl_compositor_interface
wl_data_device_interface
wl_data_device_manager_interface
wl_data_offer_interface
wl_data_source_interface
wl_display_interface
wl_keyboard_interface
wl_output_interface
wl_pointer_interface
wl_region_interface
wl_registry_interface
wl_seat_interface
wl_shell_interface
wl_shell_surface_interface
wl_shm_interface
wl_shm_pool_interface
wl_subcompositor_interface
wl_subsurface_interface
wl_surface_interface
wl_touch_interface"
            sed -i -e's/static \([0-9]\+\)/\1/g' \
                   /usr/include/wlr/render/wlr_renderer.h \
                   /usr/include/wlr/render/interface.h \
                   /usr/include/wlr/types/wlr_matrix.h \
                   /usr/include/wlr/types/wlr_scene.h
            ;;
        libvarnishapi-dev)
            preamble="sys/socket.h
varnish/cache/cache.h"
            sed -i -e'/^#.*error.*included/d' \
                /usr/include/varnish/cache/cache.h /usr/include/varnish/vrt.h
            ;;
        liburcu-dev)
            preamble="/usr/include/$multiarch/urcu.h"
            exclude_types="urcu_bp_gp
urcu_bp_reader
urcu_qsbr_reader"
            urcu_patch_transparent_unions
            ;;
        libsensor-msgs-dev)
            preamble=/usr/include/sensor_msgs/point_cloud2_iterator.h
            ;;
        libomxil-bellagio-dev)
            preamble=pthread.h
            ;;
        libopenipmi-dev)
            preamble=/usr/include/OpenIPMI/ipmiif.h
            exclude_types="_ns_flagdata"
            ;;
        libflint-dev|libflint-arb-dev)
            # The headers try to use "_Thread_local" which doesn't exist/isn't
            # found (because maybe it's for C rather than C++ ?) but rather
            # than making _Thread_local available, we can simply skip it since
            # it has no impact on the library's ABI
            sed -i 's/\<FLINT_USES_TLS\>/0/' /usr/include/flint/flint.h
            sed -i '/#include "fmpz_mod_poly.h"/ a #include "fmpz_mod_polyxx.h"' /usr/include/flint/fmpz_mod_poly_factorxx.h
            ;;
        libscotch-dev)
            preamble=scotch/scotch.h
            ;;
        libgeotiff-dev)
            preamble="geotiff/geotiffio.h
geotiff/geo_tiffp.h"
            ;;
        libenet-dev)
            preamble=enet/enet.h
            ;;
        librdkafka-dev)
            exclude_types=rd_kafka_metadata
            ;;
        libspandsp-dev)
            preamble="inttypes.h
spandsp/telephony.h
spandsp/complex.h
spandsp/test_utils.h"
            ;;
        libsoxr-dev)
            exclude_types="soxr_io_spec
soxr_quality_spec
soxr_runtime_spec"
            ;;
        libotr5-dev)
            preamble="cstddef
libotr/tlv.h
libotr/proto.h"
            ;;
        libpoco-dev)
            defines="$defines
#define POCO_NO_WINDOWS_H"
            preamble="Poco/Net/PollSet.h
Poco/Net/UDPHandler.h
Poco/Net/UDPServerParams.h
Poco/Net/UDPSocketReader.h"
            ;;
        libplymouth-dev)
            exclude_types=ply_keymap_metadata
            ;;
        libnfs-dev)
            preamble=nfsc/libnfs.h
            ;;
        libzbar-dev)
            preamble=zbar.h
            ;;
        libspatialite-dev)
            preamble="sqlite3.h
spatialite.h"
            ;;
        libproc2-dev)
            sed -i 's/"C "/"C"/' \
                /usr/include/libproc2/slabinfo.h
            ;;
        libpangomm-1.4-dev)
            preamble=pangomm-1.4/pangomm/renderer.h
            ;;
        libosmo-netif-dev)
            preamble="stdint.h
sys/socket.h
linux/sctp.h"
            ;;
        libvlccore-dev)
            defines="#define N_(str) str
#define restrict"
            preamble="vlc/plugins/vlc_common.h
gcrypt.h"
            ;;
        xserver-xorg-dev)
           defines="$float_typedefs
#define _X_RESTRICT_KYWD"
            preamble="X11/Xfuncproto.h
X11/extensions/XIproto.h
X11/fonts/font.h
xorg/dix.h
xorg/xf86str.h
xorg/xorg-server.h
xorg/sarea.h"
            sed -i -e's/\b\(xor\|and\)\b/\1dior/g' /usr/include/xorg/fb.h
            ;;
        libhdf4-alt-dev)
            preamble="hdf/hdfi.h
hdf/hfile.h"
            ;;
        libaudio-dev)
            preamble="X11/Intrinsic.h
audio/audiolib.h"
            ;;
        glslang-dev)
            preamble=workarounds.h
            defines="#ifdef PACKED
#undef PACKED
#endif"
            ;;
        ppp-dev)
            # fsm.h needs to be included before ccp.h and ecp.h
            preamble="pppd/pppd.h
pppd/fsm.h"
            defines="$defines
#define INET6
#define _Noreturn __attribute__ ((__noreturn__))"
            ;;
        libqtdbusmock1-dev)
            # Declare type to work around error: macro "Q_DECLARE_METATYPE" passed 2 arguments, but takes just 1
            sed -i 's/Q_DECLARE_METATYPE(QMap<QString,QVariantMap>)/typedef QMap<QString,QVariantMap> QMapQStringQVariantMap;\nQ_DECLARE_METATYPE(QMapQStringQVariantMap)/' \
                /usr/include/libqtdbusmock-1/libqtdbusmock/DeclareMetatypes.h
            ;;
        libticcutils-dev)
            printf "#define VERSION \"0.24\"\n#define PACKAGE_NAME \"ticcutils\"\n" > /usr/include/ticcutils/config.h
            ;;
        xaw3dg-dev)
            defines="$float_typedefs
#define _X_RESTRICT_KYWD"
            preamble=X11/Xmu/WidgetNode.h
            ;;
        libax25-dev)
            preamble=netax25/ax25.h
            # Fix typo
            sed -i "s/ _cplusplus/ __cplusplus/g" /usr/include/netax25/procutils.h
            ;;
        libxmlsec1-dev)
            defines="#define IN_XMLSEC"
            includes=/usr/include/xmlsec1
            ;;
        libzzip-dev)
            echo '#define ZZIP_GNUC_CONST __attribute__((__const__))
#define ZZIP_GNUC_DEPRECATED __attribute__((deprecated))
#define ZZIP_GNUC_PACKED __attribute__((packed))
' > /usr/include/zzip/__hints.h
            # Fix closing extern C bracket
            sed -zi "s@extern \"C\" {\n}@}@" /usr/include/zzip/fseeko.h
            ;;
        libtspi-dev)
            preamble="tss/platform.h
tss/tss_structs.h"
            ;;
        libopencc-dev)
            sed -i '1i #pragma once' /usr/include/opencc/UTF8StringSlice.hpp
            ;;
        libopenbabel-dev)
            preamble="LBFGS/Param.h
openbabel/stereo/squareplanar.h
openbabel/stereo/cistrans.h
openbabel/stereo/tetrahedral.h"
            ;;
        octave-dev)
            defines="#ifndef HAVE_ZLIB
#define HAVE_ZLIB 1
#endif"
            preamble="memory
zlib.h
octave/mxarray.h"
            ;;
        libhfst-dev)
            preamble=hfst/HfstTransducer.h
            ;;
        libpari-dev)
            exclude_types=pari_mainstack
            ;;
        libnode-dev)
            preamble=nodejs/src/util.h
            defines="#define V8_TARGET_ARCH_ARM
#define NODE_WANT_INTERNALS 1
#define HAVE_INSPECTOR 1
#define __POSIX__ 1"
            exclude_types=_ns_flagdata
            ;;
        libneon27-dev)
            exclude_types=ne_lock
            ;;
        liboctomap-dev)
            sed -i '1i #pragma once' /usr/include/octomap/MapNode.hxx \
                /usr/include/octomap/OcTreeBaseImpl.hxx \
                /usr/include/octomap/MapCollection.hxx \
                /usr/include/octomap/OcTreeDataNode.hxx \
                /usr/include/octomap/OccupancyOcTreeBase.hxx
            ;;
        tk-itk4-dev)
            sed -i '1i #pragma once' \
                /usr/include/itcl/itk-private/generic/itk.h \
                /usr/include/itcl/itk-private/generic/itkDecls.h \
                /usr/include/itcl/itk-private/generic/itkInt.h \
                /usr/include/itcl/itk-private/generic/itkIntDecls.h \
                /usr/include/itcl/itk.h \
                /usr/include/itcl/itkInt.h
            ;;
        tkblt-dev)
            sed -i '1i #pragma once' \
                /usr/include/tkbltDecls.h
            ;;
        libhdf4-dev)
            preamble="hdf/hdfi.h
hdf/hfile.h"
            ;;
        libgda-5.0-dev)
            preamble="libgda-5.0/libgda/gda-transaction-status.h
libgda-report/gda-report-engine.h"
            ;;
        libfstrm-dev)
            preamble=fstrm.h
            ;;
        libfeedback-dev)
            defines="#define LIBFEEDBACK_USE_UNSTABLE_API"
            ;;
        libcdd-dev)
            preamble=cddlib/setoper.h
            sed -i '1i#pragma once' /usr/include/cddlib/*.h
            ;;
        libbulletml-dev)
            preamble=bulletml/bulletmlparser.h
            ;;
        libgavl-dev)
            preamble="inttypes.h
gavl/gavl.h
GL/gl.h
va/va.h"
            ;;
        libibmad-dev)
            exclude_types=ib_vendor_call
            ;;
        libodb-dev)
            preamble=odb/tr1/memory.hxx
            ;;
        iraf-dev)
            defines="#define XINT            int
#define XLONG           int
#define XCHAR           short
#define XSHORT          short"
            preamble='/usr/include/stdlib.h'
            sed -i 's|handle_t new|handle_t new_|' /usr/lib/iraf/include/votParse.h
            sed -i 's|char \*template|char *template_|' /usr/lib/iraf/unix/hlib/libc/libc.h
            ;;
        libargtable2-dev)
            preamble='/usr/include/argtable2.h
workarounds.h'
            ;;
        libplib-dev)
            preamble=plib/pw.h
            ;;
        librtmp-dev)
            preamble=stddef.h
            ;;
        librbd-dev)
            exclude_types=mallinfo2
            preamble=/usr/include/features.h
            ;;
        libquicktime-dev)
            preamble=quicktime.h
            ;;
        libprelude-dev)
            defines="#define PRELUDE_ALIGNED_ACCESS"
            ;;
        libpqxx-dev)
            preamble="pqxx/pipeline.hxx
pqxx/stream_from.hxx
pqxx/stream_to.hxx
pqxx/tablewriter.hxx
pqxx/subtransaction.hxx"
            ;;
        libpodofo-dev)
            defines="#define BUILDING_PODOFO"
            preamble=fontconfig/fontconfig.h
            ;;
        libplplot-dev)
            preamble="plplot/plplotP.h
plplot/qt.h"
            ;;
        libsphinxbase-dev)
            sed -i 's/^extern "C"$/& {/' \
                "/usr/include/$multiarch/sphinxbase/yin.h"
            ;;
        libmate-menu-dev)
            defines="#define MATEMENU_I_KNOW_THIS_IS_UNSTABLE"
            ;;
        lua-lpeg-dev)
            headers=/usr/include/lua5.1/lua-lpeg.h
            defines="class lua_State;
$defines"
            ;;
        libzim-dev)
            defines="#undef unix
$defines"
            ;;
        libxsimd-dev)
            headers=/usr/include/xsimd/xsimd.hpp
            ;;
        libstaden-read-dev)
            preamble=io_lib/ztr.h
            ;;
        libsundials-dev)
            includes="/usr/lib/$multiarch/openmpi/include"
            ;;
        liblpsolve55-dev)
            defines="#define LPSOLVEAPIFROMLIBDEF"
            preamble=lpsolve/lp_types.h
            ;;
        libflann-dev)
            includes="/usr/include/hdf5/openmpi
/usr/lib/$multiarch/openmpi/include"
            preamble=workarounds.h
            ;;
        libfm-qt-dev)
            defines="#define QT_NO_SIGNALS_SLOTS_KEYWORDS"
            ;;
        libwebrtc-audio-processing-dev)
            defines="#define WEBRTC_POSIX
#define WEBRTC_AUDIO_PROCESSING_ONLY_BUILD"
            ;;
        libwbclient-dev)
            exclude_types="wbcDomainInfo
wbcInterfaceDetails
wbcLibraryDetails"
            ;;
        libstk-dev)
            defines="#define __OS_LINUX__"
            ;;
        libticonv-dev|libtifiles-dev)
            defines="#define restrict"
            ;;
        libjellyfish-2.0-dev)
            preamble=ostream
            ;;
        libdirectfb-dev)
            preamble="++dfb.h
workarounds.h"
            ;;
        libcinnamon-desktop-dev)
            defines="#define GNOME_DESKTOP_USE_UNSTABLE_API
/* The enum header only works in C but we can't force C, the request is ignore, so hack around it*/
#define __CDesktop_enums_h__
typedef int CDesktopBackgroundStyle;
typedef int CDesktopBackgroundShading;
typedef CDesktopBackgroundStyle;
typedef int CDesktopBackgroundShading;
#"
            ;;
        libcifpp-dev)
            preamble=cif++/exports.hpp
            ;;
        libbg-dev)
            preamble=workarounds.h
            exclude_types=dns_mx
            ;;
        libantlr3c-dev)
            exclude_types="mallinfo2
_ns_flagdata"
            ;;
        gauche-dev)
            preamble=gauche.h
            ;;
        libdumbnet-dev)
            preamble=dumbnet.h
            ;;
        xfslibs-dev)
            headers=/usr/include/xfs/handle.h
            ;;
        libarmadillo-dev)
            sed -i '1i#pragma once' /usr/include/armadillo_bits/*.hpp
            preamble=armadillo
            ;;
        qtwayland5-private-dev)
            preamble="qt5/QtWaylandCompositor/qwaylandtextinput.h
qt5/QtWaylandCompositor/5.15.10/QtWaylandCompositor/private/qwaylandtextinput_p.h
qt5/QtWaylandCompositor/5.15.10/QtWaylandCompositor/private/qwaylandinputmethodcontrol_p.h
qt5/QtWaylandCompositor/qwaylandshellsurface.h"
            ;;
        libwnck-dev)
            defines="#define WNCK_I_KNOW_THIS_IS_UNSTABLE"
            ;;
        libwolfssl-dev)
            preamble=wolfssl/options.h
            ;;
        libkmflcomp-dev|libcmocka-dev)
            preamble=setjmp.h
            ;;
        libhackrf-dev)
            exclude_types=hackrf_device_list
            ;;
        libqhull-dev)
            patch_qhull
            preamble="/usr/include/libqhull/libqhull.h"
            ;;
        libguestfs-dev)
            exclude_types="guestfs_add_domain_argv
guestfs_add_drive_opts_argv
guestfs_add_drive_scratch_argv
guestfs_add_libvirt_dom_argv
guestfs_aug_transform_argv
guestfs_btrfs_filesystem_defragment_argv
guestfs_btrfs_filesystem_resize_argv
guestfs_btrfs_fsck_argv
guestfs_btrfs_image_argv
guestfs_btrfs_subvolume_create_opts_argv
guestfs_btrfs_subvolume_snapshot_opts_argv
guestfs_compress_device_out_argv
guestfs_compress_out_argv
guestfs_copy_attributes_argv
guestfs_copy_device_to_device_argv
guestfs_copy_device_to_file_argv
guestfs_copy_file_to_device_argv
guestfs_copy_file_to_file_argv
guestfs_cpio_out_argv
guestfs_cryptsetup_open_argv
guestfs_disk_create_argv
guestfs_download_blocks_argv
guestfs_e2fsck_argv
guestfs_fstrim_argv
guestfs_glob_expand_opts_argv
guestfs_grep_opts_argv
guestfs_hivex_open_argv
guestfs_inspect_get_icon_argv
guestfs_is_blockdev_opts_argv
guestfs_is_chardev_opts_argv
guestfs_is_dir_opts_argv
guestfs_is_fifo_opts_argv
guestfs_is_file_opts_argv
guestfs_is_socket_opts_argv
guestfs_isoinfo
guestfs_md_create_argv
guestfs_mke2fs_argv
guestfs_mkfs_btrfs_argv
guestfs_mkfs_opts_argv
guestfs_mksquashfs_argv
guestfs_mkswap_opts_argv
guestfs_mktemp_argv
guestfs_mount_9p_argv
guestfs_mount_local_argv
guestfs_ntfsclone_out_argv
guestfs_ntfsfix_argv
guestfs_ntfsresize_opts_argv
guestfs_remount_argv
guestfs_rsync_argv
guestfs_rsync_in_argv
guestfs_rsync_out_argv
guestfs_selinux_relabel_argv
guestfs_set_e2attrs_argv
guestfs_stat
guestfs_statns
guestfs_statvfs
guestfs_syslinux_argv
guestfs_tar_in_opts_argv
guestfs_tar_out_opts_argv
guestfs_tune2fs_argv
guestfs_umount_local_argv
guestfs_umount_opts_argv
guestfs_utsname
guestfs_version
guestfs_xfs_admin_argv
guestfs_xfs_growfs_argv
guestfs_xfs_repair_argv"
        ;;
        ntfs-3g-dev)
            preamble="/usr/include/ntfs-3g/layout.h"
            defines="#define __timespec_defined
#define HAVE_DAEMON"
            ;;
        libido3-0.1-dev)
            # unmatched curly brace. Probably those headers are supposed
            # to be compiled as C-only code
            sed -i 's/G_END_DECLS//g' /usr/include/libido3-0.1/libido/idomessagedialog.h
            preamble="/usr/include/libido3-0.1/libido/libido.h"
            ;;
        libniftiio-dev*)
            case "$devpkg" in
                *=nifti-1)
                    headers="/usr/include/nifti/nifti1_io.h"
                    ;;
                *=nifti-2)
                    headers="/usr/include/nifti/nifti2_io.h"
                    ;;
                *)
                    echo "libniftiio-dev-virtual-packages: $devpkg is unknown."
                    exit 1
                ;;
            esac
            ;;
        llvm-13-dev*)
            defines="#define DEBUG_TYPE \"test\"
$defines"
            includes="/usr/src/googletest"
            case "$devpkg" in
                *=code)
                    headers="$(find_headers /usr/include/llvm-13/llvm/CodeGen/ '*.h')"
                    ;;
                *=debug)
                    headers="$(find_headers /usr/include/llvm-13/llvm/DebugInfo/ '*.h')"
                    headers="$(move_to_back /usr/include/llvm-13/llvm/DebugInfo/GSYM/DwarfTransformer.h $headers)"
                    ;;
                *=analytics)
                    headers="$(find_headers /usr/include/llvm-13/llvm/Analysis/ '*.h')"
                    ;;
                *=transforms)
                    headers="/usr/include/llvm-13/llvm/LinkAllPasses.h"
                    headers="$headers $(find_headers /usr/include/llvm-13/llvm/Transforms/ '*')"
                    headers="$(move_to_back /usr/include/llvm-13/llvm/Transforms/Utils/InstructionWorklist.h $headers)"
                    ;;
                *=execution-engine)
                    headers="$(find_headers /usr/include/llvm-13/llvm/ExecutionEngine/ '*.h')"
                    ;;
                *=the-rest)
                    headers="$(find_headers /usr/include/llvm-13/ '*.h' \
/usr/include/llvm-13/llvm/CodeGen \
/usr/include/llvm-13/llvm/Analysis \
/usr/include/llvm-13/llvm/DebugInfo \
/usr/include/llvm-13/llvm/Transforms \
/usr/include/llvm-13/llvm/ExecutionEngine)"
                    headers="$(move_to_back /usr/include/llvm-13/llvm/Analysis/InstructionSimplify.h $headers)"
                    headers="$(skip_header /usr/include/llvm-13/llvm/LinkAllPasses.h $headers)"
                    ;;
                *)
                    echo "llvm-virtual-packages: $devpkg is unknown."
                    exit 1
                    ;;
            esac
            ;;
        llvm-14-dev*)
            defines="#define DEBUG_TYPE \"test\"
$defines"
            includes="/usr/src/googletest"
            case "$devpkg" in
                *=code)
                    headers="$(find_headers /usr/include/llvm-14/llvm/CodeGen/ '*.h')"
                    ;;
                *=debug)
                    headers="$(find_headers /usr/include/llvm-14/llvm/DebugInfo/ '*.h')"
                    headers="$(move_to_back /usr/include/llvm-14/llvm/DebugInfo/GSYM/DwarfTransformer.h $headers)"
                    ;;
                *=analytics)
                    headers="$(find_headers /usr/include/llvm-14/llvm/Analysis/ '*.h')"
                    ;;
                *=transforms)
                    headers="/usr/include/llvm-14/llvm/LinkAllPasses.h"
                    headers="$headers $(find_headers /usr/include/llvm-14/llvm/Transforms/ '*')"
                    headers="$(move_to_back /usr/include/llvm-14/llvm/Transforms/Utils/InstructionWorklist.h $headers)"
                    ;;
                *=execution-engine)
                    headers="$(find_headers /usr/include/llvm-14/llvm/ExecutionEngine/ '*.h')"
                    ;;
                *=the-rest)
                    headers="$(find_headers /usr/include/llvm-14/ '*.h' \
/usr/include/llvm-14/llvm/CodeGen \
/usr/include/llvm-14/llvm/Analysis \
/usr/include/llvm-14/llvm/DebugInfo \
/usr/include/llvm-14/llvm/Transforms \
/usr/include/llvm-14/llvm/ExecutionEngine)"
                    headers="$(move_to_back /usr/include/llvm-14/llvm/Analysis/InstructionSimplify.h $headers)"
                    headers="$(skip_header /usr/include/llvm-14/llvm/LinkAllPasses.h $headers)"
                    ;;
                *)
                    echo "llvm-virtual-packages: $devpkg is unknown."
                    exit 1
                    ;;
            esac
            ;;
        llvm-15-dev*)
            defines="#define DEBUG_TYPE \"test\"
$defines"
            includes="/usr/src/googletest"
            case "$devpkg" in
                *=code)
                    headers="$(find_headers /usr/include/llvm-15/llvm/CodeGen/ '*.h')"
                    ;;
                *=debug)
                    headers="$(find_headers /usr/include/llvm-15/llvm/DebugInfo/ '*.h')"
                    headers="$(move_to_back /usr/include/llvm-15/llvm/DebugInfo/GSYM/DwarfTransformer.h $headers)"
                    ;;
                *=analytics)
                    headers="$(find_headers /usr/include/llvm-15/llvm/Analysis/ '*.h')"
                    ;;
                *=transforms)
                    headers="/usr/include/llvm-15/llvm/LinkAllPasses.h"
                    headers="$headers
$(find_headers /usr/include/llvm-15/llvm/Transforms/ '*')"
                    headers="$(move_to_back /usr/include/llvm-15/llvm/Transforms/Utils/InstructionWorklist.h $headers)"
                    ;;
                *=execution-engine)
                    headers="$(find_headers /usr/include/llvm-15/llvm/ExecutionEngine/ '*.h')"
                    ;;
                *=the-rest)
                    headers="$(find_headers /usr/include/llvm-15/ '*.h' \
/usr/include/llvm-15/llvm/CodeGen \
/usr/include/llvm-15/llvm/Analysis \
/usr/include/llvm-15/llvm/DebugInfo \
/usr/include/llvm-15/llvm/Transforms \
/usr/include/llvm-15/llvm/WindowsDriver \
/usr/include/llvm-15/llvm/ExecutionEngine)"
                    headers="$(move_to_back /usr/include/llvm-15/llvm/Analysis/InstructionSimplify.h $headers)"
                    headers="$(skip_header /usr/include/llvm-15/llvm/LinkAllPasses.h $headers)"
                    ;;
                *)
                    echo "llvm-virtual-packages: $devpkg is unknown."
                    exit 1
                    ;;
            esac
            ;;
        libmlir-15-dev*)
            defines="#define _Static_assert(...); \
$defines"
            case $devpkg in
                *=dialect)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/Dialect/ '*.h' \
/usr/lib/llvm-15/include/mlir/Dialect/GPU \
/usr/lib/llvm-15/include/mlir/Dialect/LLVMIR \
/usr/lib/llvm-15/include/mlir/Dialect/Tosa \
/usr/lib/llvm-15/include/mlir/Dialect/SPIRV \
/usr/lib/llvm-15/include/mlir/Dialect/Linalg)"
                    ;;
                *=dialect-linalg)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/Dialect/Linalg '*.h')"
                    ;;
                *=dialect-gpu)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/Dialect/GPU '*.h')"
                    ;;
                *=dialect-llvmir)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/Dialect/LLVMIR '*.h')"
                    ;;
                *=dialect-tosa)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/Dialect/Tosa '*.h')"
                    ;;
                *=dialect-spirv)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/Dialect/SPIRV '*.h')"
                    ;;
                *=support)
                    headers="/usr/lib/llvm-15/include/mlir/InitAllTranslations.h"
                    headers="$headers
                        $(find_headers /usr/lib/llvm-15/include/mlir/Support/ '*.h')"
                    headers="$headers
                        $(find_headers /usr/lib/llvm-15/include/mlir/Tools/ '*.h')"
                    ;;
                *=all-dialects)
                    headers="/usr/lib/llvm-15/include/mlir/InitAllDialects.h"
                    ;;
                *=mlir)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir/ '*.h' \
/usr/lib/llvm-15/include/mlir/Dialect \
/usr/lib/llvm-15/include/mlir/Support \
/usr/lib/llvm-15/include/mlir/Tools)"
                    headers="$(move_to_back /usr/lib/llvm-15/include/mlir/Bindings/Python/PybindAdaptors.h $headers)"
                    headers="$(skip_header /usr/lib/llvm-15/include/mlir/InitAllDialects.h $headers)"
                    headers="$(skip_header /usr/lib/llvm-15/include/mlir/InitAllTranslations.h $headers)"
                    ;;
                *=mlir-c)
                    headers="$(find_headers /usr/lib/llvm-15/include/mlir-c/ '*.h')"
                    ;;
            esac
            ;;
        libmapnik-dev*)
            case $devpkg in
                *=base)
                    headers="$(find_headers /usr/include/mapnik/ '*')"
                    headers="$(skip_header /usr/include/mapnik/svg/geometry_svg_generator.hpp $headers)"
                    # mapnik/geometry_container.hpp is missing from the package. This header is unusable
                    headers="$(skip_header /usr/include/mapnik/util/geometry_to_svg.hpp $headers)"
                    ;;
                *=svg1)
                    headers="/usr/include/mapnik/svg/geometry_svg_generator.hpp"
                    ;;
            esac
            ;;
        libogre-1.12-dev*)
            case $devpkg in
                *=plugins)
                    headers="$(find_headers /usr/include/OGRE/Plugins/ '*.h')"
                    ;;
                *=gl)
                    preamble="/usr/include/OGRE/RenderSystems/GL/ts1.0_inst.h
/usr/include/OGRE/RenderSystems/GL/ts1.0_inst_list.h
/usr/include/OGRE/RenderSystems/GL/vs1.0_inst.h
/usr/include/OGRE/RenderSystems/GL/vs1.0_inst_list.h"
                    headers="$(find_headers /usr/include/OGRE/RenderSystems/GL/ '*.h')"
                    ;;
                *=gles2)
                    preamble="/usr/include/OGRE/OgrePixelFormat.h"
                    headers="$(find_headers /usr/include/OGRE/RenderSystems/GLES2/ '*.h')"
                    # does not compile, see https://github.com/OGRECave/ogre/issues/1712
                    headers="$(skip_header /usr/include/OGRE/RenderSystems/GLES2/GLSLES/OgreGLSLESCgProgramFactory.h $headers)"
                    ;;
                *=gl3plus)
                    headers="$(find_headers /usr/include/OGRE/RenderSystems/GL3Plus/ '*.h')"
                    ;;
                *=the-rest)
                    headers="$(find_headers /usr/include/OGRE/Plugins/ '*.h' \
/usr/include/OGRE/Plugins \
/usr/include/OGRE/RenderSystems)"
                    ;;
            esac
            ;;
        libhypre-dev)
            # define types from the missing headers
            defines="typedef void *HYPRE_DistributedMatrix;
typedef void *HYPRE_DistributedMatrixPilutSolver;
typedef void *hypre_ParMultiVector;
$defines"
            # windows development artifact
            sed -i 's/seq_Multivector\.h/seq_multivector\.h/g' /usr/include/hypre/par_multivector.h
            # missing headers
            sed -i 's/HYPRE_distributed_matrix_mv\.h/stdint\.h/g'  /usr/include/hypre/distributed_matrix.h
            sed -i 's/internal_protos\.h/stdint\.h/g'  /usr/include/hypre/distributed_matrix.h
            # alternative to virtual package, rename duplicate function
            sed -i 's/hypre_ParMultiVectorCreate/hypre_ParMultiVectorCreate2/g' /usr/include/hypre/_hypre_parcsr_mv.h
            preamble="/usr/include/hypre/HYPRE_utilities.h
/usr/include/hypre/distributed_matrix.h
/usr/include/hypre/par_multivector.h
"
            ;;
        libctl-dev)
            preamble=ctlgeom.h
            ;;
        libcryptui-dev)
            defines="#define LIBCRYPTUI_API_SUBJECT_TO_CHANGE"
            ;;
        libbson-dev)
            defines="#define BSON_INSIDE
#define BSON_COMPILATION"
            ;;
        libcpp-httplib-dev)
            exclude_types=_ns_flagdata
            ;;
        libefl-all-dev)
            defines="#define ELM_INTERNAL_API_ARGESFSDFEFC
#define EFL_BETA_API_SUPPORT"
            exclude_types="wl_buffer_interface
wl_compositor_interface
wl_data_device_interface
wl_data_device_manager_interface
wl_data_offer_interface
wl_data_source_interface
wl_display_interface
wl_keyboard_interface
wl_output_interface
wl_pointer_interface
wl_region_interface
wl_registry_interface
wl_seat_interface
wl_shell_interface
wl_shell_surface_interface
wl_shm_interface
wl_shm_pool_interface
wl_subcompositor_interface
wl_subsurface_interface
wl_surface_interface
wl_touch_interface"
            preamble="eo-1/Eo.h
eina-1/eina/eina_list.h
ecore-wl2-1/Ecore_Wl2.h
elementary-1/Elementary.h
elementary-1/elm_code_common.h
elementary-1/elm_code_line.h
elementary-1/elm_code_file.h
elementary-1/elm_widget.h
elementary-1/elm_gen_common.h
elementary-1/efl_ui_textpath.eo.h
edje-1/Edje.h
edje-1/efl_canvas_layout_part_invalid.eo.h
"
            # Dozens of headers lack the guard
            sed -i '1i#pragma once' /usr/include/edje-1/*.h /usr/include/eio-1/*.h \
                /usr/include/evas-1/canvas/*.h /usr/include/evas-1/*.h /usr/include/elementary-1/*.h
            # Only legacy headers are available
            sed -i 's/\(elm_widget_item_container_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget.h
            sed -i 's/\(elm_widget_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget.h
            sed -i 's/\(elm_multibuttonentry_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elc_multibuttonentry_eo.h
            sed -i 's/\(elm_multibuttonentry_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elc_multibuttonentry_eo.h
            sed -i 's/\(elm_color_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_colorselector.h
            sed -i 's/\(elm_colorselector_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_colorselector.h
            sed -i 's/\(elm_dayselector_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_dayselector.h
            sed -i 's/\(elm_dayselector_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_dayselector.h
            sed -i 's/\(elm_glview_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_glview.h
            sed -i 's/\(elm_hover_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_hover.h /usr/include/elementary-1/elm_widget_menu.h
            sed -i 's/\(elm_index_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_index.h
            sed -i 's/\(elm_index_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_index.h
            sed -i 's/\(elm_label_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_label.h
            sed -i 's/\(elm_list_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_list.h
            sed -i 's/\(elm_list_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_list.h
            sed -i 's/\(elm_menu_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_menu.h
            sed -i 's/\(elm_menu_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_menu.h
            sed -i 's/\(elm_notify_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_notify.h /usr/include/elementary-1/elm_widget_popup.h
            sed -i 's/\(elm_panel_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_panel.h
            sed -i 's/\(elm_player_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_player.h
            sed -i 's/\(elm_plug_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_plug.h
            sed -i 's/\(elm_popup_item_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_popup.h
            sed -i 's/\(elm_popup_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_popup.h
            sed -i 's/\(elm_route_eo\)\.h/\1.legacy.h/g' /usr/include/elementary-1/elm_widget_route.h
            # Wrong typedef order
            sed -i 's/^typedef enum _Ecore_Wl2_Buffer_Type Ecore_Wl2_Buffer_Type;$//' /usr/include/ecore-wl2-1/Ecore_Wl2.h
            sed -i 's/^typedef enum _Conformant_Part_Type Conformant_Part_Type;$//' /usr/include/elementary-1/elm_widget_conform.h
            # Duplicate definitions
            sed -i '/EAPI extern Eina_Error EFL_UI_THEME_APPLY_ERROR_NONE;/d' /usr/include/elementary-1/elm_widget.h
            sed -i 's/struct Elm_Gen_Item_Type/struct Elm_Gen_Item_Type_two/g' /usr/include/elementary-1/elm_widget_genlist.h
            sed -i '/typedef struct _Item_Cache Item_Cache;/d;s/struct _Item_Cache/struct _Item_Cache_two/g' /usr/include/elementary-1/elm_widget_genlist.h
            ;;
        libzfslinux-dev)
            preamble=cstring
            exclude_types="utsname
uu_avl_walk
uu_dprintf
uu_list_walk
zfs_deleg_perm_tab"
            ;;
        libvips-dev)
            sed -i '99d; $a\
#endif' /usr/include/vips/dbuf.h
            sed -i '78d; $a\
#endif' /usr/include/vips/gate.h
            preamble="vips/vips8
vips/vips7compat.h"
            ;;
        libgraphicsmagick1-dev)
            preamble="cstddef
cstdio
magick/common.h
magick/image.h
magick/magick.h
wand/wand_api.h"
        ;;
        libgit2-glib-1.0-dev|libdframeworkdbus-dev)
            preamble=workarounds.h
            ;;
        libfann-dev)
            exclude_types=fann_error
            ;;
        libgivaro-dev)
            sed -i -e'/givaro\/givconfig.h/a\
using namespace std;' /usr/include/givaro/givarithmetics.h
            preamble=givaro/givmatrix.h
            ;;
        libdazzle-1.0-dev)
            preamble=dazzle.h
            ;;
        libdap-dev)
            extra_args="-gcc-options -std=c++14"
            preamble="string
signal.h
libdap/Error.h"
            defines="using namespace std;"
            ;;
        libcsound64-dev)
            preamble="csound/csdl.h
csound/csound.h"
            ;;
        libcork-dev)
            sed -i -e's/struct cork_uid/struct _cork_uid/' \
                   /usr/include/libcork/core/id.h
            ;;
        libck-dev)
            sed -i -e'/_ck_ring_enqueue_reserve_mp/,/^}/ { s/false/NULL/ }' \
                   /usr/include/ck_ring.h
            exclude_types="ck_barrier_centralized
ck_barrier_combining
ck_barrier_dissemination
ck_barrier_mcs
ck_barrier_tournament
ck_hs_stat
ck_ht_hash
ck_ht_stat
ck_rhs_stat"
            ;;
        libmd4c-dev)
            exclude_types=MD_SPAN_WIKILINK
            ;;
        libmedc-dev*)
            defines="#define MED_API_23 1
#define MESGERR 1"
            includes="/usr/include/$multiarch/mpi/"
            ;;
        liblqr-1-0-dev)
            preamble="glib.h
lqr_base.h
lqr_vmap_pub.h
lqr_cursor_pub.h
lqr_gradient_pub.h
lqr_rwindow_pub.h
lqr_energy_pub.h
lqr_cursor_pub.h
lqr_progress_pub.h
lqr_vmap_list_pub.h"
            ;;
        libmariadb-dev)
            preamble=mariadb/mysql.h
            defines="#define LIBMARIADB 1"
            ;;
        libnitrokey-dev)
            exclude_types=NK_status
            ;;
        libmpd-dev)
            preamble=libmpd-1.0/libmpd/libmpd.h
            ;;
        libmuscle-dev)
            preamble=muscle.h
            ;;
        libminc-dev)
            preamble="minc.h
volume_io.h"
            ;;
        libtranscript-dev)
            preamble=transcript/transcript.h
            ;;
        libticalcs-dev)
            preamble=ticalcs.h
            defines="#define restrict"
            ;;
        libsquid-dev)
            preamble=squid.h
            ;;
        libspatialindex-dev)
            preamble="SpatialIndex.h
capi/sidx_config.h"
            ;;
        libscotchparmetis-dev=*)
            includes="/usr/include/$multiarch/mpi/"
            ;;
        libplumb2-dev)
            preamble="gnutls.h"
            sed -i '/typedef enum _replytrack_completion_type/ienum _replytrack_completion_type: short;' /usr/include/clplumbing/replytrack.h
            sed -i 's/enum _replytrack_completion_type {/enum _replytrack_completion_type: short {/' /usr/include/clplumbing/replytrack.h
            sed -i '/typedef enum _nodetrack_change/ienum _nodetrack_change: short;' /usr/include/clplumbing/replytrack.h
            sed -i 's/enum _nodetrack_change {/enum _nodetrack_change: short {/' /usr/include/clplumbing/replytrack.h
            ;;
        libxine2-dev)
            defines="typedef struct demux_plugin_s demux_plugin_t;"
            ;;
        libwinpr2-dev)
            preamble=string.h
            ;;
        libwings-dev)
            defines="#define _Noreturn"
            ;;
        libxdp-dev)
            # defines taken from /usr/include/bpf/bpf_helpers.h
            defines="#define __uint(name, val) int (*name)[val]
#define __type(name, val) typeof(val) *name
#define SEC(name) __attribute__((section(name), used))
enum libbpf_pin_type {
        LIBBPF_PIN_NONE,
        LIBBPF_PIN_BY_NAME,
};
static void *(*bpf_map_lookup_elem)(void *map, const void *key) = (void *) 1;"
            preamble="linux/types.h
xdp/xdp_stats_kern_user.h"
            sed -i '1i#pragma once' /usr/include/bpf/*.h
            exclude_types="bpf_obj_get_opts
bpf_prog_attach_opts
bpf_prog_query_opts"
            # Drop mismatching bpf_map_lookup_elem definition
            sed -i '/bpf_map_lookup_elem(/d' /usr/include/bpf/bpf.h
            ;;
        libxen-dev)
            sed -i 's@public/xen.h@../xen.h@' /usr/include/xen/arch-arm/smccc.h
            sed -i '1i#pragma once' /usr/include/xen/io/libxenvchan.h
            preamble="xenctrl.h
libxl.h"
            # These struct names are also used as function name.
            sed -i 's/\(struct xc_get_cpufreq_para\)/\1_s/g' /usr/include/xenctrl.h
            sed -i 's/\(struct xc_resource_op\)/\1_s/g' /usr/include/xenctrl.h
            sed -i 's/\(struct xsd_errors\)/\1_s/g' /usr/include/xen/io/xs_wire.h
            ;;
        libvigraimpex-dev)
            sed -i '1i#pragma once' /usr/include/vigra/delegate/detail/delegate_list.hxx \
                /usr/include/vigra/random_forest/rf_online_prediction_set.hxx \
                /usr/include/vigra/transform_iterator.hxx
            # boost is a C++-only library, defining __STDC_VERSION__ breaks stuff
            defines="#undef __STDC_VERSION__"
            preamble="vigra/random_forest.hxx"
            ;;
        libcapnp-dev)
            rm /usr/include/kj/async-win32.h
            ;;
        libvcdinfo-dev)
            preamble=cdio/iso9660.h
            ;;
        libuvc-dev)
            exclude_types=uvc_stream_ctrl
            ;;
        libusermetricsinput-dev)
            preamble=libusermetrics-1/libusermetricsinput/usermetricsinput.h
            ;;
        libvolk2-dev)
            defines="#define LV_HAVE_GENERIC 1"
            ;;
        libvcflib-dev)
            defines='#define VCFLIB_VERSION "some version"'
            ;;
         coinor-libcbc-dev)
            preamble=coin/CbcModel.hpp
            ;;
        libportal-dev)
            preamble=libportal/portal.h
            ;;
        libvala-*-dev|libvaladoc-*-dev)
            # replace a non-C++-compatible name
            sed -i -e 's/\(ValaAssignmentOperator operator\)\b/\1_/g' /usr/include/vala-*/vala.h
            ;;
        libebackend1.2-dev)
            preamble=libebackend/libebackend.h
            ;;
        libgoocanvasmm-2.0-dev)
            includes=/usr/include/goocanvasmm-2.0
            preamble=goocanvasmm.h
            ;;
        libjsonrpc-glib-1.0-dev)
            includes=/usr/include/jsonrpc-glib-1.0
            preamble=jsonrpc-glib.h
            ;;
        libdex-dev)
            includes=/usr/include/libdex-1
            preamble=libdex.h
            ;;
        libretro-gtk-1-dev)
            defines="#define RETRO_GTK_USE_UNSTABLE_API"
            ;;
        libshumate-dev)
            includes=/usr/include/shumate-1.0
            preamble=shumate/shumate.h
            ;;
        libsysprof-4-dev)
            includes="/usr/include/sysprof-4
/usr/include/sysprof-ui-5"
            preamble="sysprof.h
sysprof-ui.h"
            ;;
        libtepl-6-dev)
            includes=/usr/include/tepl-6
            preamble=tepl/tepl.h
            ;;
        libgepub-0.7-dev)
            : > /usr/include/libgepub-0.7/config.h
            ;;
        libgovirt-dev)
            # missing G_END_DECLS
            sed -i -e '/#endif/ i G_END_DECLS' \
                /usr/include/govirt-1.0/govirt/ovirt-error.h \
                /usr/include/govirt-1.0/govirt/ovirt-proxy.h
            ;;
        libgdamm5.0-dev)
            preamble=libgdamm.h
            ;;
        libcec-dev)
            preamble=iostream
            ;;
        libafflib-dev)
            preamble=ctime
            ;;
        libagg2-dev)
            preamble=agg2/agg_renderer_base.h
            ;;
        libapache2-mod-perl2-dev)
            includes=/usr/lib/arm-linux-gnueabihf/perl/5.36/CORE/
            sed -i 's|*new)|*new_)|' /usr/include/apache2/modperl_options.h
            ;;
        guile-2.2-dev)
            sed -i 's|*new,|*new_,|' /usr/include/guile/2.2/libguile/debug-malloc.h
            includes=/usr/include/guile/2.2/
            headers="/usr/include/guile/2.2/libguile.h
/usr/include/guile/2.2/libguile/bdw-gc.h
/usr/include/guile/2.2/libguile/control.h
/usr/include/guile/2.2/libguile/debug-malloc.h
/usr/include/guile/2.2/libguile/deprecation.h
/usr/include/guile/2.2/libguile/dynstack.h
/usr/include/guile/2.2/libguile/expand.h
/usr/include/guile/2.2/libguile/frames.h
/usr/include/guile/2.2/libguile/gc-inline.h
/usr/include/guile/2.2/libguile/gettext.h
/usr/include/guile/2.2/libguile/hooks.h
/usr/include/guile/2.2/libguile/iselect.h
/usr/include/guile/2.2/libguile/loader.h
/usr/include/guile/2.2/libguile/memoize.h
/usr/include/guile/2.2/libguile/poll.h
/usr/include/guile/2.2/libguile/programs.h
/usr/include/guile/2.2/libguile/pthread-threads.h
/usr/include/guile/2.2/libguile/regex-posix.h
/usr/include/guile/2.2/libguile/scmconfig.h
/usr/include/guile/2.2/libguile/srfi-1.h
/usr/include/guile/2.2/libguile/srfi-60.h
/usr/include/guile/2.2/libguile/unicode.h
/usr/include/guile/2.2/libguile/vm-builtins.h
/usr/include/guile/2.2/libguile/vm-expand.h
/usr/include/guile/2.2/libguile/vm.h
/usr/include/guile/2.2/readline.h"
            ;;
        libadplug-dev)
            defines="#define strcasecmp(a,b) stricmp(a,b)"
            ;;
        libccp4-dev)
            sed -i 's|^#include <math.h>|//#include <cmath>|g' /usr/include/ccp4/ccp4_unitcell.h
            preamble="/usr/include/ccp4/cmaplib.h
workaround.h"
            echo "using namespace CMap_io;" > workaround.h
            ;;
        libc-client2007e-dev)
            sed -i '1i#pragma once' /usr/include/c-client/env_unix.h
            defines="#define SSLBUFLEN 8192
typedef float _Float32;
typedef double _Float64;
typedef float _Float32x;
typedef long double _Float64x;
typedef void SSLSTREAM;"
            headers="/usr/include/c-client/c-client.h
/usr/include/c-client/env.h
/usr/include/c-client/fdstring.h
/usr/include/c-client/flocksim.h
/usr/include/c-client/flstring.h
/usr/include/c-client/imap4r1.h
/usr/include/c-client/netmsg.h
/usr/include/c-client/newsrc.h
/usr/include/c-client/os_lnx.h
/usr/include/c-client/pseudo.h
/usr/include/c-client/sslio.h
/usr/include/c-client/tcp_unix.h
/usr/include/c-client/unix.h"
            ;;
        libplacebo-dev)
            defines="#define __cplusplus 201103L"
            ;;
        libosp-dev)
            defines="#define SP_NEW_H_MISSING"
            ;;
        libt4k-common0-dev)
            preamble="stdbool.h
t4k_common.h"
            sed -i 's/#ifndef bool/#ifndef __bool_true_false_are_defined/' \
                /usr/include/t4k_common.h
            ;;
        ofono-dev)
            defines="#define OFONO_API_SUBJECT_TO_CHANGE"
            exclude_types=ofono_error
            ;;
        libspf2-dev)
            exclude_types="_ns_flagdata"
            preamble=netinet/in.h
            ;;
        libsearpc-dev)
            sed -i '1i#pragma once' /usr/include/searpc-utils.h
            ;;
        libsingleapplication-dev)
            includes="/usr/include/$multiarch/qt5/QtCore"
            ;;
        libsimbody-dev)
            extra_args="-gcc-options -std=c++11"
            preamble=simbody/SimTKcommon/internal/DecorativeGeometry.h
            ;;
        libraft-dev)
            exclude_types="raft_apply
raft_barrier
raft_transfer"
            ;;
        libre-dev)
            exclude_types="mod_export
re_printf
rtcp_stats
stun_conf"
            preamble=cstring
            sed -i '1i#pragma once' /usr/include/re/re_*.h
            ;;
        libquvi-0.9-dev)
            preamble="quvi/qoption.h
quvi/qinfo.h
quvi/qscript.h
quvi/qmediaprop.h
quvi/qplaylistprop.h
quvi/qmediaprop.h
quvi/qhttpmiprop.h
quvi/qsubtprop.h
quvi/qsupp.h
quvi/qversion.h"
            ;;
        libpolly-14-dev)
            exclude_types="isl_arg_choice
isl_arg_flags"
            ;;
        libp8-platform-dev)
            sed -i 's/OA//' /usr/include/p8-platform/util/atomic.h
            ;;
        libopenmpt-modplug-dev)
            defines="#define HAVE_STDINT_H"
            preamble=libmodplug/stdafx.h
            ;;
        libopenhpi-dev)
            preamble="openhpi/SaHpi.h
openhpi/sahpi_struct_utils.h"
            ;;
        libnfft3-dev)
            defines="#define NFFT_PRECISION_SINGLE"
            ;;
        libopendht-dev)
            defines="#define OPENDHT_JSONCPP"
            ;;
        libmupdf-dev)
            sed -i '1i#pragma once' /usr/include/mupdf/pdf/name-table.h \
                /usr/include/mupdf/memento.h
            ;;
        libnewmat10-dev)
            extra_args="-gcc-options -std=gnu++98"
            defines="#define WANT_MATH
#define WANT_STREAM"
            preamble="newmat/config.h
newmat/myexcept.h"
            ;;
        libnauty2-dev)
            # nauty is built with `--disable-tls` on armhf
            sed -i '/#define USE_TLS/d' /usr/include/arm-linux-gnueabihf/nauty/nauty.h
            sed -i 's/new\([;,=]\)/new_\1/g' /usr/include/cliquer/set.h
            ;;
        libmateweather-dev)
            defines="#define MATEWEATHER_I_KNOW_THIS_IS_UNSTABLE"
            ;;
        liblognorm-dev)
            preamble=liblognorm.h
            ;;
        libleatherman-dev)
            defines="#define LEATHERMAN_LOGGING_NAMESPACE \"leatherman\""
            ;;
        libhbaapi-dev)
            preamble=ctime
            ;;
        libhandy-0.0-dev)
            defines="#define HANDY_USE_UNSTABLE_API"
            ;;
        libgloox-dev)
            touch /usr/include/gloox/config.h
            ;;
        libhdhomerun-dev)
            sed -i '1i#pragma once' /usr/include/libhdhomerun/hdhomerun*.h
            ;;
        libkmfl-dev)
            preamble=kmfl/kmfl.h
            ;;
        libiml-dev)
            preamble=gmp.h
            ;;
        libchamplain-0.12-dev)
            preamble="gtk/gtk.h
champlain/champlain.h"
            includes=/usr/include/gtk-3.0
            ;;
        libtext-engine-dev)
            sed -i '1i#pragma once' /usr/include/text-engine/layout/types.h
            ;;
        eog-dev)
            preamble=gtk/gtk.h
            ;;
        libsword-dev)
            preamble=sword/zverse4.h
            exclude_types=ftpparse
            ;;
        sfftw-dev)
            includes="/usr/lib/$multiarch/openmpi/include/"
            ;;
    esac

    lockfile a-c-c-lock
    a_c_c_lock=a-c-c-lock
    cat > base.xml <<EOF
<version>v1</version>
<headers>
EOF
    OLD_IFS="$IFS"
    IFS="
"

    rm -f workarounds.h
    for header in $headers; do
        case $devpkg,$header in

            # For the clang-tidy virtual package, include the headers under
            # clang-tidy/
            libclang-1?-dev=*,*/clang-tidy/abseil/Time*)
                # This can be simplified but I'm leaving it as an example of
                # how to have more than two sub-packages without duplicating
                # ad-nauseum the same glob for $header in the 'case' above.
                #
                # The first branch below does nothing if we're processing the
                # 'clang-tidy' virtual sub-package while the second one skips
                # the files matched through the glob above for all others.
                case $devpkg in
                    *=clang-tidy-abseil-time)
                        ;;
                    *)
                        continue
                        ;;
                esac
                ;;
            # For the clang-tidy virtual package, skip all headers not already
            # included
            libclang-1?-dev=clang-tidy-abseil-time,*)
                continue
                ;;

            # For freerdp2-dev, skip the server headers for the client
            # sub-package and the client ones for the server sub-package
            freerdp2-dev=client,*/freerdp2/freerdp/server/*)
                continue
                ;;
            freerdp2-dev=server,*/freerdp2/freerdp/client/*)
                continue
                ;;

            voms-dev=c,*/voms/voms_api.h)
                continue
                ;;
            voms-dev=cpp,*/voms/voms_apic.h)
                continue
                ;;

            libmedc-dev=api23,*/include/med*)
                continue
                ;;
            libmedc-dev=normal,*/2.3.6/*)
                continue
                ;;

            libscotchparmetis-dev=*,*/parmetis-int32*)
                case $devpkg in
                    *=int32)
                        ;;
                    *)
                        continue
                        ;;
                esac
                ;;
            libscotchparmetis-dev=*,*/parmetis-int64*)
                case $devpkg in
                    *=int64)
                        ;;
                    *)
                        continue
                        ;;
                esac
                ;;
            libscotchparmetis-dev=*,*/parmetis-long*)
                case $devpkg in
                    *=long)
                        ;;
                    *)
                        continue
                        ;;
                esac
                ;;
            libscotchparmetis-dev=*,*/parmetis/*)
                case $devpkg in
                    *=normal)
                        ;;
                    *)
                        continue
                        ;;
                esac
                ;;

            # Don't filter headers further than the above
            *)
                ;;
        esac

        # exclude some broken non-public headers
        case $header in
            */flint/flintxx/expression.h|\
            */flint/flintxx/flint_classes.h|\
            */urcu/*/arm.h)
                # These files will NOT be skipped:
                # - flint headers need to be included in a fairly specific order
                # - liburcu-dev has headers for 12+1 archs; we want to exclude
                # all of them below _except_ arm.
                ;;
            */coin/IpReturnCodes_inc.h|\
            */flann/algorithms/*cuda*.h|*/flann/util/cuda/*.h|\
            */flint/fmpz_mod_poly*xx.h|*/flint/arith*xx.h|*/flint/flintxx/*|\
            */urcu/arch/*.h|*/urcu/uatomic/*.h|*/gdalpansharpen.h|\
            */gdal/cpl_minizip_*zip.h|*/cholmod_gpu_kernels.h|\
            */suitesparse/spqr.hpp|*/QtQml/private/*|*/QtQuick/private/*|\
            */QtQmlDom/private/*|*/QtQuickTemplates2/private/*|\
            */QtQmlDebug/private/*|*/QtQuickControlsTestUtils/private/*|\
            */system/darwin.h|*/system/kfreebsd.h|*/system/mingw32.h|\
            */system/mingw32msvc.h|*/net-snmp/library/winservice.h|\
            */mib_module_includes.h|*/ucd-snmp/snmp_vars.h|\
            */net-snmp/agent/set_helper.h|*stdint-msvc2008.h|*sunos.h|\
            */uv/win.h|*/apt-pkg/cachefilter-patterns.h|\
            */apt-pkg/debsrcrecords.h|*/apt-pkg/header-is-private.h|*/odbcss.h|\
            */libadwaita-1/adw-spring-params.h|\
            */atkmm-1.6/atkmm/private/streamablecontent_p.h|\
            */guile/3.0/libguile/instructions.h|*/bpf/bpf_helper*.h|\
            */bpf/bpf_tracing.h|*/bpf/skel_internal.h|*/bpf/usdt.bpf.h|\
            */brltty/brldefs-bn.h|*/cdio/audio.h|*/CLucene/LuceneThreads.h|\
            */CLucene/util/Reader.h|*/CLucene/util/arrayinputstream.h|\
            */CLucene/util/byteinputstream.h|*/CLucene/search/FilterResultCache.h|\
            */CLucene/highlighter/Encoder.h|*/CLucene/highlighter/SimpleHTMLEncoder.h|\
            */clutter-1.0/clutter/evdev/clutter-evdev.h|*/isc/stdatomic.h|\
            */guile/3.0/libguile/null-threads.h|*/cogl/cogl/cogl-*.h|\
            */cogl/gl-prototypes/*|*/alsa/sound/*asoc.h|\
            */cephfs/metrics/Types.h|\
            */clutter-gst-3.0/clutter-gst/clutter-gst-*.h|*/colord/cd-*.h|\
            */cups/i18n.h|*/cupsfilters/pdfutils.h|*/db_185.h|\
            */dbstl_base_iterator.h|*/dee-1.0/dee-*.h|*/absl/*/internal/*.h|\
            */libdrm/via_drm.h|*/libdrm/r600_pci_ids.h|*/efivar/efiboot-*.h|\
            */efivar/efivar-*.h|*/evince/3.0/libdocument/ev-portal.h|\
            */ext2fs/bitops.h|*/fontembed/embed.h|\
            */freetype2/config/ftmodule.h|*/freetype2/freetype/ftmac.h|\
            */freetype2/freetype/fterrdef.h|\
            */freetype2/freetype/config/ftmodule.h|\
            */gdbm-ndbm.h|*/gdm/gdm-pam-extensions.h|*/glib/gi18n-lib.h|\
            */glibmm/i18n-lib.h|*/giomm/private/*|*/glusterfs/byte-order.h|\
            */glusterfs/parse-utils.h|\
            */glusterfs/template-component-messages.h|*/boost/accumulators/*|\
            */qt?/*/qt_windows.h|*/qt?/*/qdbusmacros.h|\
            */qt5/*/qwglnativecontext.h|*/qt?/*/qcocoanativecontext.h|\
            */qt?/*/qatomic_bootstrap.h|*/qt5/*/qatomic_msvc.h|\
            */qt?/*/qobject*_impl.h|*/qt?/*/qsharedpointer_impl.h|\
            */qt5/*/qopenglext.h|*/qt5/*/qeglnativecontext.h|\
            */qt5/*/qabstractprintdialog.h|*/qt5/*/qprintdialog.h|\
            */qt5/*/qprinter.h|*/qt5/*/qprintengine.h|*/qt5/*/qprinterinfo.h|\
            */qt5/*/qtestkeyboard.h|*/qt5/qtest_gui.h|*/qt5/*/qstyleoption.h|\
            */qt5/*/qglxnativecontext.h|*/qt6/QtCore/qfuture_impl.h|\
            */X11/ImUtil.h|*/openssl/asn1_mac.h|*/gtktextlayout.h|\
            */gtktextdisplay.h|*/extensions/MITMisc.h|*/extensions/XEVI.h|\
            */extensions/extutil.h|*/X11/CallbackI.h|*/X11/TranslateI.h|\
            */nc_tparm.h|*/tic.h|*/_sd-common.h|*/tirpc/rpc/xdr.h|\
            */private/qcfsocketnotifier_p.h|*/private/qcore_mac_p.h|\
            */private/qeventdispatcher_cf_p.h|*/private/q*_win*_p.h|\
            */private/qfilesystemwatcher_fsevents_p.h|\
            */private/qppsobjectprivate_p.h|*/private/qwindowspipe*_p.h|\
            */private/qwineventnotifier_p.h|*/private/qwinregistry_p.h|\
            */private/qwindowsguieventdispatcher_p.h|\
            */private/qcoretextfontdatabase_p.h|\
            */private/qfontengine_coretext_p.h|*/private/qmacmime_p.h|\
            */private/qwindowsfontdatabase*_p.h|*/private/qapplekeymapper_p.h|\
            */private/qwindowsfontengine_p.h|*/private/qwindowsnativeimage_p.h|\
            */private/qcoregraphics_p.h|*/private/qrhid3d11_p_p.h|\
            */private/qt_gui_pch.h|*/private/qt_mips_asm_dsp_p.h|\
            */private/qhttp2protocolhandler_p.h|*/private/qsslsocket_mac_p.h|\
            */private/qsslsocket_schannel_p.h|*/private/qcupsjobwidget_p.h|\
            */private/qpagesetupdialog_unix_p.h|*/private/qappletestlogger_p.h|\
            */private/qxctestlogger_p.h|*/private/qt_widgets_pch.h|\
            */private/qstdweb_p.h|*/private/qnetworkreplywasmimpl_p.h|\
            */private/qcborcommon_p.h|*/private/qfunctions_fake_env_p.h|\
            */private/qiconvcodec_p.h|*/private/q*calendar_data_p.h|\
            */private/qauthenticator_p.h|*/private/qfcursor_p.h|\
            */private/qdrawhelper_p.h|\
            */private/qblendfunctions_p.h|/usr/share/libtool/*|*/d3d11va.h|\
            */dxva2.h|*/qsv.h|*/videotoolbox.h|\
            */gstreamer-1.0/gst/gl/glprototypes/*.h|\
            */kpimtextedit/emoticonunicodetab.h|*/spdlog/*win*|\
            */sinks/mongo_sink.h|*/cuda-gst.h|*/gstcuda*.h|*/gsttranscoder*|\
            */DWidget/dinputdialog.h|*/vtk_pegtl.h|*/vtk_verdict.h|\
            */vtksys/SharedForward.h|*/vtkLineWidget.h|\
            */vtkLoopBooleanPolyDataFilter.h|*/vtkMPI.h|\
            */vtk*Representation*.h|*/vtkdiy2/*|*/vtk_diy2.h|\
            */vtkTemporalFractal.h|*/vtkDIY*Utilities.h|*/vtkJavaAwt.h|\
            */libvirt-common.h|*/hwloc/cuda*.h|*/hwloc/levelzero.h|\
            */hwloc/nvml.h|*/hwloc/rsmi.h|*/llvm/DebugInfo/PDB/DIA/*.h|\
            */llvm/Support/Solaris/*|*/llvm/Support/Windows/*|\
            */llvm/WindowsResource/ResourceScriptTokenList.h|\
            */webkit/Web*.h|*/webkitdom/Web*.h|*/webkitdom/webkitdom[ad]*.h|\
            */webkit2/webkit-web-extension.h|\
            */unity/lttng-component-provider.h|\
            */libtracker-sparql/tracker-[eruv]*.h|\
            */libtracker-sparql/tracker-sparql-enum-types.h|\
            */poppler/JPEG2000Stream.h|*/poppler/UnicodeC*Tables.h|\
            */cpp/poppler-font-private.h|*/orc/orcbytecodes.h|\
            */neon/ne_acl3744.h|*/mpich/mpicxx.h|*/mpich/mpi*f.h|\
            */geos/geom/DefaultCoordinateSequenceFactory.h|\
            */dcmtk/oflog/internal/*.h|*/dcmtk/oflog/thread/impl/*.h|\
            */dcmtk/ofstd/variadic/tuple*.h|*/dcmtk/ofstd/variadic/variant.h|\
            */glext/wglext*.h|*/isl/hmap.h|*/isl/maybe_templ.h|\
            */tcl-private/generic/regerrs.h|*/tcl-private/compat/*|\
            */QtCore/private/qntdll_p.h|*/private/qwindows*_p.h|\
            */private/uia*interfaces_p.h|*/private/qcocoa*|\
            */private/q*_mac_p.h|*/private/q*_macos_p.h|*/private/qsimd_x86*|\
            */private/qevdevtouchfilter_p.h|*/private/qandroidextras_p.h|\
            */private/jqnihelpers_p.h|*/Xm/Print*.h|*/atlas_cher2*.h|\
            */atlas_*_L*.h|*/atlas_*syr*.h|*/atlas_[dsz]mv[nt].h|\
            */atlas_dmv[nt]_*.h|*/atlas_dr[12].h|*/atlas_dr[12]_*.h|\
            */atlas_[sz]r[12].h|*/atlas_zher2.h|*/vulkan/vulkan_win32.h|\
            */vulkan/vulkan_fuchsia.h|*/vulkan/vulkan_ggp.h|*/gdpp.h|\
            */libunwind-common.h|*/libunwind-dynamic.h|*/tk-private/generic/*|\
            */utf8cpp/utf8/cpp11.h|*/telepathy-glib/_gen/*.h|\
            */telepathy-glib/dbus-daemon.h|*/protobuf/compiler/cpp/file.h|\
            */protobuf/compiler/cpp/helpers.h|*/osmocom/gsm/gan.h|\
            */kpathsea/mingw32.h|*/kpathsea/win32lib.h|\
            */KF5/KRunner/krunner/abstractrunnertest.h|\
            */qgpgme/hierarchicalkeylistjob.h|*/libedataserver/e-source-*.h|\
            */allegro/platform/aintbeos.h|*/allegro/platform/aintqnx.h|\
            */allegro/platform/al*.h|*/allegro/3d*.h|*/allegro/al*.h|\
            */proftpd/acconfig.h|*/proftpd/mod_wrap2.h|\
            */proftpd/mod_sftp/channel.h|*/std_msgs/header_deprecated_def.h|\
            */libpurple/dbus-define-api.h|*/KF5/*/akonadi/*/protocol_gen.h|\
            */lzo/minilzo/*|*/g[dt]kmm/private/*_p.h|\
            */gnuradio/rpcserver_booter_thrift.h|\
            */gnuradio/thrift_server_template.h|*/gnuradio/pycallback_object.h|\
            */exiv2/asfvideo.hpp|*/pixman-1/pixman-version.h|\
            */rapidjson/msinttypes/*.h|*/netcdf_filter_build.h|\
            */apertium/deserialiser.h|*/apertium/serialiser.h|\
            */apertium/tagger.h|*/apertium/getopt_long.h|*/nss/key.h|\
            */nss/keyt.h|*/nss/pkcs11f.h|*/obs/obs-internal.h|*/obs/obs-nix.h|\
            */obs/obs-nix-wayland.h|*/obs/obs-nix-x11.h|*/obs/obs-hotkeys.h|\
            */msgpack/*_template.h|*/msgpack/gcc_atomic.h|\
            */lttng/ust-tracepoint-event.h|*/lttng/tp/lttng-ust-trace*.h|\
            /usr/include/tag_enum.h|*/libdbustest/dbus-mock.h|\
            */atomic_ops/ao_version.h|*/atomic_ops/generalize.h|\
            */atomic_ops/sysdeps/*|*/arpack/debug.h|*/arpack/stat.h|\
            */arpack/*.hpp|*/arpack++/ar[bdlu]*.h|\
            */oneapi/tbb/detail/_string_resource.h|\
            */openmpi/orte/mca/iof/base/base.h|\
            */openmpi/orte/mca/iof/base/iof_base_setup.h|\
            */openmpi/orte/mca/odls/base/odls_private.h|\
            */openmpi/ompi/mca/fcoll/base/fcoll_base_coll_array.h|\
            */openmpi/opal/sys/atomic_impl.h|*/openmpi/ompi/mpi/cxx/*.h|\
            */openmpi/ompi/mpi/tool/mpit-internal.h|\
            */openmpi/ompi/mca/vprotocol/base/vprotocol_base_request.h|\
            */openmpi/ompi/mca/vprotocol/base/base.h|\
            */openmpi/ompi/mca/vprotocol/vprotocol.h|\
            */openmpi/ompi/mca/pml/base/pml_base_recvreq.h|\
            */openmpi/ompi/mca/pml/base/pml_base_sendreq.h|\
            */openmpi/ompi/peruse/peruse-internal.h|\
            */openmpi/ompi/mca/coll/base/coll_base_util.h|\
            */openmpi/ompi/mca/osc/base/osc_base_obj_convert.h|\
            */openmpi/ompi/mpi/fortran/mpif-h/prototypes_mpi.h|\
            */openmpi/ompi/mpi/fortran/mpif-h/bindings.h|\
            */openmpi/ompi/op/op.h|*/openmpi/include/mpif*.h|\
            */openmpi/mpiext/mpiext_pcollreq_mpifh.h|\
            */openmpi/opal/datatype/opal_datatype_copy.h|\
            */openmpi/opal/util/qsort.h|*/openmpi/mpiext/mpiext_affinity_c.h|\
            */openmpi/opal/sys/*/timer.h|*/openmpi/opal/sys/timer.h|\
            "/usr/lib/$multiarch/fortran"/*|\
            */KF5/KDELibs4Support/solid/networking.h|\
            */hiredis/adapters/macosx.h|*/hiredis/adapters/ae.h|\
            */firebird/UdrCppEngine.h|/usr/include/perf.h|\
            */apache2/mod_xml2enc.h|*/gsk/broadway/gskbroadwayrenderer.h|\
            */gsk/gl/gskglrenderer.h|*/gtk/deprecated/gtklockbutton.h|\
            */libavutil/hwcontext_cuda.h|*/libavutil/hwcontext_d3d11va.h|\
            */libavutil/hwcontext_dxva2.h|*/libavutil/hwcontext_qsv.h|\
            */libavutil/hwcontext_videotoolbox.h|*/wx/dde.h|\
            */wx/generic/bmpcbox.h|*/wx/generic/dataview.h|\
            */wx/generic/dvrenderer*.h|*/wx/generic/notebook.h|\
            */wx/generic/scrolwin.h|*/wx/generic/spinctlg.h|\
            */wx/generic/srchctlg.h|*/wx/unix/app.h|*/wx/unix/fontutil.h|\
            */wx/unix/glegl.h|*/wx/unix/taskbarx11.h|*/mpf2mpfr.h|*/GL/wglew.h|\
            */xmlrpcpp/base64.h|*/wlr/types/wlr_fullscreen_shell_v1.h|\
            */wlr/types/wlr_layer_shell_v1.h|*/wlr/types/wlr_tablet_v2.h|\
            */wlr/types/wlr_output_power_management_v1.h|\
            */wlr/types/wlr_pointer_constraints_v1.h|\
            */wlr/types/wlr_xdg_decoration_v1.h|*/wlr/types/wlr_xdg_shell.h|\
            */varnish/cache/cache.h|*/varnish/common/common_param.h|\
            */varnish/vdef.h|*/varnish/cache/cache_varnishd.h|*/varnish/vrt.h|\
            */varnish/tbl/*.h|*/varnish/vapi/vsl.h|*/varnish/vut.h|\
            */uhd/features/trig_io_mode_iface.hpp|\
            */uhd/rfnoc/traffic_counter.hpp|*/uhd/cal/*_generated.h|\
            */uhd/utils/pybind_adaptors.hpp|\
            */tao/pegtl/internal/file_mapper_win32.hpp|\
            */tao/pegtl/contrib/internal/endian_win.hpp|\
            */yaz/stemmer.h|*/upnp/TemplateSource.h|*/upnp/TemplateInclude.h|\
            */scotch*/*scotchf.h|*/enet/win32.h|*/Poco/*_WIN*.h|\
            */Poco/*_VX.h|*/Poco/FPEnvironment_*.h|*/Poco/*HPUX.h|\
            */Poco/Data/ODBC/Unicode_UNIXODBC.h|*/Poco/*_Android.h|\
            */Poco/EventLogChannel.h|*/Poco/Util/WinService.h|\
            */Poco/WindowsConsoleChannel.h|*/Poco/PipeImpl_DUMMY.h|\
            */Poco/Util/WinRegistry*.h|*/ply/ply-array.h|*/netpbm/ppmcmap.h|\
            */lirc/line_buffer.h|*/vlc/plugins/vlc_objects.h|\
            */vlc/plugins/vlc_main.h|*/xxh3.h|*/audio/mutex.h|\
            */audio/Alibint.h|*/ksysguard/sensors/SensorInfo_p.h|\
            */octave/defun-dld.h|*/octave/defun.h|*/octave/mex.h|\
            */octave/ov-intx.h|*/hfst/implementations/XfsmTransducer.h|\
            */hfst/parsers/Alphabet.h|*/hfst/parsers/OtherSymbolTransducer.h|\
            */hfst/parsers/Rule.h|*/hfst/parsers/*ArrowRule.h|\
            */hfst/parsers/*RuleContainer.h|*/hfst/parsers/TwolCGrammar.h|\
            */hfst/HfstTransition*.h|*/hfst/hfst_apply_schemas.h|\
            */hfst/implementations/HfstTransition*.h|\
            */hfst/HfstStrings2FstTokenizer.h|*/log4cpp/IdsaAppender.hh|\
            */log4cpp/NTEventLogAppender.hh|*/log4cpp/Win32DebugAppender.hh|\
            */log4cpp/config-win32.h|*/phonenumbers/base/memory/singleton_*.h|\
            */phonenumbers/base/synchronization/lock_*.h|*/pari/mpinl.h|\
            */pari/paricom.h|*/pari/paridecl.h|*/pari/parierr.h|\
            */pari/parigen.h|*/pari/pariinl.h|*/pari/parinf.h|\
            */pari/paristio.h|*/nodejs/*/v8-inspector-protocol.h|\
            */nodejs/*/v8-wasm-trap-handler-win.h|*/nodejs/src/base64-inl.h|\
            */nodejs/src/histogram*.h|*/nodejs/src/node_perf.h|\
            */nodejs/src/node_http2.h|*/nodejs/src/node_wasi.h|\
            */nodejs/*win32*.h|*/nodejs/src/crypto/crypto_cipher.h|\
            */nodejs/src/crypto/crypto_keys.h|*/nodejs/src/node_crypto.h|\
            */nodejs/src/crypto/crypto_[abdehkpr]*.h|\
            */nodejs/src/crypto/crypto_common.h|\
            */nodejs/src/crypto/crypto_scrypt.h|\
            */nodejs/src/crypto/crypto_sig.h|*/nodejs/src/node_root_certs.h|\
            */NTL/PD.h|*/NTL/REPORT_ALL_FEATURES.h|\
            */mysql/mysqlx_ername.h|*/mongoc/mongoc-*.h|\
            */kdl/utilities/rallNd.h|*/OGRE/*OgreThreadHeadersTBB.h|\
            */OGRE/RenderSystems/GL/OgreGLSL*Program.h|\
            */OGRE/RenderSystems/GL/OgreGLSLLinkProgramManager.h|\
            */OGRE/RenderSystems/GL3Plus/OgreSPIRVShaderFactory.h|\
            */OGRE/RenderSystems/GLES2/GLSLES/OgreGLSLES*Program.h|\
            */OGRE/RenderSystems/GLES2/GLSLES/OgreGLSLESProgram[CMP]*.h|\
            */OGRE/RenderSystems/GLES2/OgreGLES2HardwareBufferManager.h|\
            */OGRE/RenderSystems/GLES2/OgreGLES2RenderSystem.h|\
            */OGRE/RenderSystems/GLES2/OgreGLES2Texture*.h|\
            */OGRE/*OgreDefaultWorkQueueTBB.h|\
            */msgpack/preprocessor/slot/detail/shared.hpp|\
            */msgpack/preprocessor/slot/detail/slot*.hpp|\
            */msgpack/preprocessor/iteration/detail/*.hpp|\
            */msgpack/predef/detail/test_def.h|\
            */msgpack/v[123]/*detail/cpp03_*.hpp|\
            */libgda-5.0/libgda/gda-server-provider-private.h|\
            */bulletml/bulletmlparser-ygg.h|*/osmium/geom/projection.hpp|\
            */opencascade/NCollection_Haft.h|*/opencascade/OSD_WNT.hxx|\
            */opencascade/ExprIntrp.tab.h|\
            */opencascade/AIS_DataMapIteratorOfDataMapOfSelStat.hxx|\
            */opencascade/AIS_DataMapOfSelStat.hxx|*/opencascade/WNT_Dword.hxx|\
            */opencascade/OpenGl_GLESExtensions.hxx|\
            */MediaInfoDLL/MediaInfoDLL_Static.h|*/log4shib/IdsaAppender.hh|\
            */log4shib/NTEventLogAppender.hh|*/log4shib/Win32DebugAppender.hh|\
            */log4shib/config-win32.h|*/log4shib/threading/*Threads.hh|\
            */imgui/backends/imgui_impl_metal.h|\
            */imgui/backends/imgui_impl_osx.h|\
            */imgui/backends/imgui_impl_wgpu.h|*/rpcsvc/yp.h|*/plib/pcx.h|\
            */plib/ssgaFire.h|*/plib/ssgaLensFlare.h|\
            */plib/ssgaParticleSystem.h|\
            */plib/ssgaWaveSystem.h|*/SFML/System/NativeActivity.hpp|\
            */recode.h|*/libprelude/idmef-tree-data.h|\
            */podofo/base/util/PdfMutexImpl_win32.h|\
            */podofo/base/util/PdfMutexImpl_noop.h|*/plplot/csa.h|\
            */plplot/nn.h|*/plplot/wxPLplotwindow.h|*/xmlrpc-c/abyss_winsock.h|\
            */xmlrpc-c/server_w32httpsys.h|*/xmlrpc_server_w32httpsys.h|\
            */xmlrpc-c/abyss_unixsock.h|*/mapnik/agg/agg_conv_gpc.h|\
            */mapnik/grid_vertex_converter.hpp|\
            */mapnik/cairo/render_polygon_pattern.hpp|\
            */mapnik/markers_placements/interior.hpp|*/mapnik/sse.hpp|\
            */mapnik/markers_placement.hpp|*/mapnik/marker_helpers.hpp|\
            */mapnik/*_impl.hpp|*/sunpinyin-2.0/pinyin/datrie_impl.h|\
            */core/posix/linux/proc/process/*.h|*/kinsol/kinsol_impl.h|\
            */kinsol/kinsol_ls_impl.h|*/m4ri/*_template.h|\
            */lpsolve/lp_solveDLL.h|*/lpsolve/lp_rlp.h|\
            */log4cxx/helpers/aprinitializer.h|*/log4cxx/helpers/tchar.h|\
            */log4cxx/private/*|*/log4cxx/filter/expressionfilter.h|\
            */log4cxx/rolling/*|*/KF5/kjs/grammar.h|*/z3_v1.h|\
            */xapp/libxapp/xapp-icon-chooser-button.h|*/jellyfish/int128.hpp|\
            */directfb-internal/media/idirectfbimageprovider_client.h|\
            */directfb-internal/dummy/dummy.h|\
            */directfb-internal/core/*_includes.h|\
            */directfb-internal/core/wm_module.h|\
            */directfb/direct/interface_implementation.h|\
            */Inventor/elements/SoGLNormalizeElement.h|\
            */Inventor/elements/SoGLShadeModelElement.h|\
            */Inventor/elements/SoGLTexture3EnabledElement.h|\
            */Inventor/elements/SoLongElement.h|\
            */Inventor/elements/SoTexture3EnabledElement.h|\
            */Inventor/oivwin32.h|*/Inventor/fields/SoMFLong.h|\
            */Inventor/fields/SoMFULong.h|*/Inventor/fields/SoSFLong.h|\
            */Inventor/fields/SoSFULong.h|*/gauche/win-compat.h|\
            */gauche/wthread.h|*/gauche/uthread.h|\
            */gauche-*/*/package-templates/extension.h|\
            */gap/src/boehm_gc.h|*/gap/src/baltree.h|*/gap/src/dynarray.h|\
            */gap/src/sortbase.h|\
            */gdcm-3.0/gdcmCAPICryptographicMessageSyntax.h|\
            */gdcm-3.0/gdcmConstCharWrapper.h|*/gdcm-3.0/gdcmDeflateStream.h|\
            */gdcm-3.0/zipstreamimpl.h|*/gdcm-3.0/gdcmBaseCompositeMessage.h|\
            */gdcm-3.0/gdcmCEchoMessages.h|*/gdcm-3.0/gdcm_j2k.h|\
            */gdcm-3.0/gdcm_jp2.h|*/gdcm-3.0/gdcmjpeg/*|*/kj/async-win32.h|\
            */private/qwaylandinputcontext_p.h|\
            */private/qwayland-server-xdg-shell-unstable-v5_p.h|\
            */private/wayland-xdg-shell-unstable-v5-server-protocol_p.h|\
            */webkit/webkit-web-process-extension.h|*/tomcrypt_*.h|\
            */libtorrent/aux_/route.h|*/libtorrent/aux_/windows.hpp|\
            */libtorrent/aux_/torrent_impl.hpp|*/libtorrent/aux_/win_util.hpp|\
            */libtorrent/storage.hpp|*/cyassl/*|*/wolfssl/wolfcrypt/wc_kyber.h|\
            */wolfssl/wolfcrypt/tfm.h|*/libirc_[eo]*.h|*/guichan/glut.hpp|\
            */glm/detail/*.hpp|*/glm/ext/*.hpp|*/glm/gtc/*.hpp|*/glm/gtx/*.hpp|\
            */iraf/lib/*|*/iraf/include/votParse_spp.h|\
            */iraf/unix/hlib/iraf*.h|*/iraf/unix/hlib/swap*.h|\
            */iraf/unix/hlib/mach*.h|*/iraf/unix/hlib/config.h|\
            */iraf/unix/hlib/knet.h|*/iraf/unix/hlib/math.h|\
            */fpvm3*.h|*/yara/parser.h|*/xmms2/xmmsclient/xmmsclient-cf.h|\
            */xmms2/xmmsclient/xmmsclient-qt.h|\
            */xmltooling/impl/ManagedResource.h|\
            */hypre/HYPRE_matrix_matrix_protos.h|*/hypre/HYPREf.h|\
            /usr/include/hypre/HYPRE*_f.h|\
            */Bpp/Phyl/Likelihood/SitePartitionTreeLikelihood.h|\
            */elementary-1/*_private.h|*/elementary-1/elm_part_helper.h|\
            */elementary-1/elm_widget_menu.h|\
            */libzfs/libzfs_impl.h|*/libzfs/sys/*.h|*/libspl/assert.h|\
            */libspl/rpc/xdr.h|*/libspl/umem.h|*/libspl/sys/*.h|\
            */gtksourceviewmm-3.0/gtksourceviewmm/private/styleschememanager_p.h|\
            */givaro/gfqkronecker.h|*/givaro/givarrayallocator.h|\
            */givaro/givmatdenseops.inl|*/givaro/givarrayfixed.h|\
            */givaro/givgenarith.h|*/recint/reclonglong.h|\
            */fplll/pruner/pruner_simplex.h|*/fixedfann.h|*/floatfann.h|\
            */dlib/bits/c++config.h|*/dlib/cuda/cuda_utils.h|*/dlib/gui*|\
            */dlib/matrix/mkl_fft.h|*/dlib/image_keypoint/draw_surf_points.h|\
            */dlib/image_processing/render_face_detections.h|\
            */dlib/*_kernel_1.h|*/dlib/java/*|*/dlib/python/numpy_image.h|\
            */dlib/python.h|*/dlib/test/*|*/libdap/D4FilterClause.h|\
            */libdap/PipeResponse.h|*/courier-unicode-script-tab.h|\
            */libcork/config/*|*/gcc/*|*/cgns*_f*.h|\
            */mariadb/mysql/client_plugin.h|*/ndctl/ndctl.h|\
            */mjpegtools/frequencies.h|*/ni/Linux-*/*.h|*/ni/XnCyclicQueueT.h|\
            */ni/XnDerivedCast.h|*/ni/XnQueueT.h|*/oop-www.h|\
            */libMUSCLE/dpregionlist.h|*/libMUSCLE/gapscoredimer.h|\
            */libMUSCLE/enums.h|*/minc_io_4d_volume.h|*/mimetic/os/directory.h|\
            */rime/gear/contextual_translation.h|\
            */rime/gear/key_binding_processor_impl.h|\
            */pmix2/include/pmix/src/*|*/xdp/*.bpf.h|*/xen/dom0_ops.h|\
            */libxl_json.h|*/_libxl_types_json.h|*/xen/arch-x86/*.h|\
            */xen/arch-x86_*.h|*/vigra/matlab.hxx|*/vigra/*fftw.hxx|\
            */vigra/delegate/detail/delegate_template.hxx|\
            */vigra/multi_opencl.hxx|*/vigra/random_forest/features.hxx|\
            */vigra/polytope.hxx|*/petscdmmoab.h|*/petscdmplexceed.h|\
            */petscviewersaws.h|*/openni2/Win32/*|*/vid.stab/transformfloat.h|\
            */vala-panel/panel-layout.h|*/volk/volk_avx*_intrinsics.h|\
            */volk/volk_sse*_intrinsics.h|*/vcflib/vec128int.h|\
            */vcflib/veclib_types.h|*/vcflib/BedReader.h|\
            */android/cutils/properties.h|*/android/cutils/sched_policy.h|\
            */coin/CbcParam.hpp|*/signond/signontrace.h|\
            */libplacebo/utils/*_internal.h|*/libplacebo/utils/dav1d.h|\
            */libplacebo/utils/libav.h|*/tsk/auto/tsk_is_image_supported.h|\
            */tsk/fs/tsk_exfatfs.h|*/tsk/fs/tsk_fatfs.h|*/tsk/fs/tsk_fatxxfs.h|\
            */tsk/util/detect_encryption.h|\
            */rocksdb/utilities/customizable_util.h|*/plotcompat.h|\
            */opencollada/COLLADASaxFrameworkLoader/COLLADASaxFWLCOLLADACsymbol.h|\
            */opencollada/COLLADASaxFrameworkLoader/COLLADASaxFWLPolygons.h|\
            */opencollada/COLLADAFramework/COLLADAFWShaderConstantFX.h|\
            */opencollada/COLLADAFramework/COLLADAFWShaderBlinn.h|\
            */opencollada/COLLADAFramework/COLLADAFWShaderLambert.h|\
            */opencollada/COLLADAFramework/COLLADAFWShaderPhong.h|\
            */opencollada/COLLADAStreamWriter/COLLADASWBuffer.h|\
            */rcutils/rcutils/stdatomic_helper/win32/stdatomic.h|\
            */rcutils/rcutils/stdatomic_helper.h|*/Qt5GStreamer/QGlib/*impl.h|\
            */polly/Support/LinkGPURuntime.h|*/pgm-*/pgm/in.h|*/pgm-*/pgm/winint.h|\
            */openhpi/oh_clients.h|*/netcdf/mpi/include/netcdf_par.h|\
            */mutter-12/clutter/clutter/clutter-mutter.h|\
            */mutter-12/clutter/clutter/deprecated/clutter-timeline.h|\
            */newmat/boolean.h|*/inotifytools/inotify-nosys.h|\
            */libhdhomerun/hdhomerun_os_windows.h|\
            */gstreamermm-1.0/gstreamermm/private/*.h)
                continue ;;
            */openmpi/ompi/frameworks.h|*/openmpi/opal/frameworks.h|\
            */openmpi/orte/frameworks.h|*/openmpi/opal/mca/base/mca_base_var.h|\
            */Bullet3Collision/NarrowPhaseCollision/shared/b3ClipFaces.h|\
            */Bullet3Collision/NarrowPhaseCollision/shared/b3ContactSphereSphere.h)
                # These are missing extern 'C'.
                echo 'extern "C" {' >> workarounds.h
                echo "#include \"$header\"" >> workarounds.h
                echo '}' >> workarounds.h
                continue
                ;;
            */bglibs/sysdeps.h)
                # Redeclares system functions without (wrong in C++) arguments
                grep -v ^extern $header >> workarounds.h
                continue
                ;;
            */netpbm/runlength.h|*/libgit2-glib-1.0/libgit2-glib/ggit-branch-enumerator.h)
                # and this is missing the closing of the extern C
                echo "#include \"$header\"" >> workarounds.h
                echo '}' >> workarounds.h
                continue
                ;;
            */libdframeworkdbus-2.0/com_deepin_appstore_metadata.h)
                #  Both __Metadata and __AppStore are typedefed to AppStore
                echo "#define AppStore Metadata" >> workarounds.h
                echo "#include \"$header\"" >> workarounds.h
                echo "#undef AppStore" >> workarounds.h
                continue
                ;;
            */libdframeworkdbus-2.0/types/defenderprocesslist.h)
                # Both DefenderProcessList and ArrayInt are QList<int> typedefs and
                # hence the metatypes are declared twice
                grep -v Q_DECLARE_METATYPE $header >> workarounds.h
                continue
                ;;
            */openmpi/ompi/mca/common/ompio/common_ompio_print_queue.h)
                # So this header has a END_C_DECLS but no BEGIN_C_DECLS so we have to hack that into it.
                # embedding it into our workarounds.h such that we pick it up first in the preamble.
                sed "s/#define MCA_COMMON_OMPIO_QUEUESIZE.*/\0\nBEGIN_C_DECLS/" $header >> workarounds.h
                ;;
            */glslang/SPIRV/GLSL.ext.NV.h)
                echo '#include "glslang/SPIRV/spirv.hpp"' >> workarounds.h
                echo 'namespace spv {' >> workarounds.h
                echo "#include \"$header\"" >> workarounds.h
                echo '}' >> workarounds.h
                continue
                ;;
            */directfb/fusion/object.h)
                # See it starts with } and then gets an extern "C" later which then again misses the }
                sed 's/FusionObjectID;$/FusionObjectID; extern "C" {/' $header >> workarounds.h
                echo '}' >> workarounds.h
                continue
                ;;
            */directfb-internal/core/*_driver.h)
                # All the headers declare the same variable I guess it's an entry point
                sed "s/driver_funcs =/driver_funcs_$RANDOM =/" $header >> workarounds.h
                continue
                ;;
            */orthanc-framework/Pkcs11.h|\
            */orthanc-framework/DicomParsing/DicomModification_*.impl.h)
                # - PKCS#11 is disabled in the build and the header is unusable
                # - DicomModification_*.impl.h are not public headers and can't
                #   be used directly
                continue
                ;;
            */include/argtable2.h)
                cat << EOF > workarounds.h
typedef struct arg_end arg_end_t;
typedef struct arg_rem arg_rem_t;

#define arg_end arg_end_t
#define arg_rem arg_rem_t
EOF
                ;;
            */flann/mpi/index.h)
                sed 's|flann::mpi::load_from_file|flann::load_from_file|g' $header > workarounds.h
                ;;
            */log4cpp/threading/*)
                # These files cannot be included all at the same time; instead
                # we use virtual packages to include each implementation header
                # at a time
                continue
                ;;
            */liblangtag/lt-messages.h|*/liblangtag/lt-utils.h|*/liblangtag/lt-xml.h)
                continue
                ;;
            */mariadb/ma_tls.h|*/mariadb/mariadb_com.h|*/mariadb/mariadb_ctype.h|\
            */mariadb/mariadb_stmt.h|mariadb/mariadb_version.h)
                continue
                ;;
            */KPropertyWidgets3/linestyleedit.h)
                continue
                ;;
            */iraf/noao/lib/*)
                continue
                ;;
            */adplug/fmopl.h|*/adplug/adlibemu.h|*/adplug/woodyopl.h)
                continue
                ;;
            */libapogee/AspenFx2.h)
                continue
                ;;
        esac

        echo $header >> base.xml
    done

    IFS="$OLD_IFS"
    cat >> base.xml <<EOF
</headers>
<include_preamble>
$preamble
</include_preamble>
<add_include_paths>
$includes
</add_include_paths>
<skip_include_paths>
/usr/include/isc
/usr/include/$multiarch/sys
/usr/include/$multiarch/bits
/usr/include/absl/base/internal
/usr/include/postgresql/15/server/port/win32_msvc
/usr/include/postgresql/15/server/port/win32
/usr/include/tcl8.6/tcl-private/compat
/usr/include/google/protobuf
/usr/include/xmlsec1/xmlsec
/usr/include/wx-3.2/wx
/usr/lib/gauche-0.97/0.9.10/include/gauche
/usr/include/boost/compatibility/cpp_c_headers
/usr/include/boost/hana/ext
/usr/include/libewf
/usr/include/dlib
/usr/include/dlib/string
/usr/include/gcc
/usr/include/gcc/x86_64
/usr/include/commoncpp
/usr/include/ucommon
/usr/include/xen
/usr/include/libvmdk
/usr/include/libvhdi
/usr/include/nop/utility
</skip_include_paths>
<skip_types>
$exclude_types
</skip_types>
<skip_symbols>
pselect
select
fgetpos
fopen
freopen
fseeko
fsetpos
ftello
tmpfile
sigtimedwait
getsockopt
recvmmsg
recvmsg
sendmmsg
sendmsg
setsockopt
adjtime
futimes
futimesat
getitimer
gettimeofday
lutimes
setitimer
settimeofday
utimes
clock_adjtime
clock_getres
clock_gettime
clock_nanosleep
clock_settime
ctime
ctime_r
difftime
gmtime
gmtime_r
localtime
localtime_r
mktime
nanosleep
time
timegm
timelocal
timer_gettime
timer_settime
timespec_get
timespec_getres
ftruncate
lockf
lseek
pread
pwrite
truncate
mkostemp
mkostemps
mkstemp
mkstemps
pthread_clockjoin_np
pthread_cond_clockwait
pthread_cond_timedwait
pthread_mutex_clocklock
pthread_mutex_timedlock
pthread_rwlock_clockrdlock
pthread_rwlock_clockwrlock
pthread_rwlock_timedrdlock
pthread_rwlock_timedwrlock
pthread_timedjoin_np
sched_rr_get_interval
fstat64
fstatat64
futimens
lstat64
stat64
utimensat
fstat
fstatat
lstat
stat
gai_suspend
fcntl64
ppoll
fallocate
creat
fcntl
open
openat
posix_fadvise
posix_fallocate
</skip_symbols>
<defines>
#define __STDC_VERSION__ 201710L
#define _GXX_NULLPTR_T
#define CLUTTER_ENABLE_COMPOSITOR_API 1
#define _REGEX_NELTS(n)
#define _Atomic
#define PACKED
#ifdef __cplusplus
// C17 compat layer
#define _Alignof(type) alignof(type)
#endif
#define getaddrinfo_a(a,b,c,d) /* */
$defines
</defines>
<libs>
EOF

    devpkg=$devpkg_no_virtual

    for lib in $libs; do
        echo $lib >> base.xml
    done
    echo '</libs>' >> base.xml
    sed -e's/>v1</>v1_lfs</; /STDC/a\
#define _FILE_OFFSET_BITS 64
' base.xml > lfs.xml
    sed -e's/v1_lfs/v1_timet/; /STDC/a\
#define _TIME_BITS 64' lfs.xml > time_t.xml
    rm -f base.dump lfs.dump time_t.dump

    log_msg Build $devpkg_maybe_virtual

    # Run the ABI dump in background. All jobs will be started in the
    # background but if not in parallel mode, jobs will be waited for
    # immediately, effectively serializing them.
    a_c_c "base" "base"&
    job_acc_base=$!;

    # If ! $parallel, wait for this job immediately
    if ! $parallel; then
        if wait $job_acc_base; then
            job_acc_base_ret=true
        else
            job_acc_base_ret=false
        fi
        unset job_acc_base
    fi

    # Run other jobs, either after the first a-c-c call has succeeded, or in
    # parallel with it.
    # We don't do the same dance before starting the second a-c-c call because
    # we assume that if the first one succeeds, the other two will also
    # succeed. There's no guarantee about that but in the worst case, the
    # script will error out someone will take a look at the package.
    #
    # NOTE: if $parallel, there's no good default value for job_acc_base_ret
    # but bash and zsh don't care about the syntax below even though you'd get
    # a syntax error if you were substituting $job_acc_base_ret for nothing
    # manually while keeping the '&&'
    if { ! $parallel && $job_acc_base_ret ; } || $parallel; then
        # If running jobs in parallel, sleep a second in order to stagger jobs
        # and make logs a bit more readable
        $parallel && sleep 1
        a_c_c "lfs" "lfs"&
        job_acc_lfs=$!
        if ! $parallel; then wait $job_acc_lfs; unset job_acc_lfs; fi

        $parallel && sleep 1
        a_c_c "timet" "time_t"&
        job_acc_time_t=$!
        if ! $parallel; then wait $job_acc_time_t; unset job_acc_time_t; fi
    fi

    # If the a-c-c run for "base" fails, mark the package as failed-compilation
    # and continue
    if { ! $parallel && ! $job_acc_base_ret ; } \
       || { $parallel && ! wait $job_acc_base; }
    then
        log_msg Failed compiling $devpkg_maybe_virtual
        killall abi-compliance-checker || true
        rm -f a-c-c-lock
        if $parallel; then
            wait ${job_acc_lfs} ${job_acc_time_t} || true
        fi

        # If this package is virtual, store the results in memory only for now
        if $processing_virtual_packages; then
            virtual_failed="${virtual_failed}:"
        else
            failed $devpkg
        fi

        wrap_apt autoremove --purge $devpkg $extra_deps
        continue
    fi

    if $parallel; then
        # We need two separate calls to 'wait' in order to reflect the
        # corresponding return codes: "wait $job1 $job2" returns the same code
        # as $job2 and ignores the one from $job1.
        wait ${job_acc_lfs}
        wait ${job_acc_time_t}
    fi

    # Run the diffs in parallel; a diff takes around 5 times less memory than
    # an ABI dump and therefore two diffs take less than half the memory of an
    # ABI dump. IOW, if there was enough memory for the ABI dumps, there is
    # enough memory for two diffs at the same time.
    a_c_c_diff "base" "lfs" "time_t" "timet" &
    job_acc_diff_lfs_time_t=$!
    sleep 1
    a_c_c_diff "base" "base" "lfs" "lfs" &
    job_acc_diff_base_lfs=$!

    wait ${job_acc_diff_lfs_time_t} || time_t=:
    wait ${job_acc_diff_base_lfs} || lfs=:

    killall abi-compliance-checker || true
    rm -f a-c-c-lock

    log_msg "$devpkg_maybe_virtual: time_t=[$time_t] lfs=[$lfs]"

    # If this package is virtual, store the results in memory only for now
    if $processing_virtual_packages; then
        virtual_time_t="${virtual_time_t}${time_t}"
        virtual_lfs="${virtual_lfs}${lfs}"
    else
        if $time_t; then
            echo $devpkg >> abi-breaks
        elif $lfs; then
            echo $devpkg >> lfs-sensitive
        else
            echo $devpkg >> no-change
        fi
    fi

    wrap_apt autoremove --purge $devpkg $extra_deps
done
