#!/bin/bash set -e set -o pipefail die() { echo "$@" exit 1 } # generates the linker version script src/core/NetworkManager.ver # by looking at the symbols needed by the device and settings # plugins. Note that this depends on how NetworkManager and # the plugins are build. For example, compiling without # --with-more-asserts will yield less symbols. _sort() { LANG=C sort -u } call_nm() { if [ -n "$from_meson" ]; then "${NM:-nm}" "$1" | sed -n 's/.* \([^ ]\) \([^ ]*\)$/\1 \2/p' else libtool=(${LIBTOOL:-libtool}) ${libtool[@]} --mode=execute "${NM:-nm}" "$1" | sed -n 's/.* \([^ ]\) \([^ ]*\)$/\1 \2/p' fi } get_symbols_nm () { base=./src/core/NetworkManager-all-sym call_nm "$base" | sed -n 's/^[tTDGRBS] //p' | _sort } get_symbols_explicit() { cat </dev/null); do call_nm "$f" | sed -n 's/^\([U]\) \(\(nm_\|nmp_\|_nm\|NM\|_NM\|nmtst_\|c_siphash_\|c_list_\).*\)$/\2/p' done) | _sort | grep -Fx -f <(get_symbols_explicit) -v | grep -Fx -f <(get_symbols_nm) } pretty() { sed 's/.*/\t&;/' } do_update() { do_generate > ./src/core/NetworkManager.ver } if [ -f "build.ninja" ]; then from_meson=1 libs= else from_meson= libs=.libs/ fi SYMBOLS_MISSING="$(get_symbols_missing | pretty)" SYMBOLS_EXPLICIT="$(get_symbols_explicit | pretty)" do_generate() { cat <