| # Copyright 2025 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| set -e |
| set -x |
| set -o pipefail |
| |
| PREFIX="$1" |
| DEPS_PREFIX="$2" |
| |
| EXTRA_LDFLAGS="-pthread" |
| |
| _CONFIG_ARGS=( |
| "--enable-maintainer-mode" |
| "--enable-static" |
| "--disable-shared" |
| "--prefix=${PREFIX}" |
| "CPPFLAGS=-I${DEPS_PREFIX}/include" |
| "CFLAGS=-I${DEPS_PREFIX}/include" |
| "LDFLAGS=-L${DEPS_PREFIX}/lib ${EXTRA_LDFLAGS}" |
| ) |
| |
| |
| td="$(mktemp -d)" |
| mkdir -p "$td"/bin |
| cat <<'EOFEOF' > "$td"/bin/config-mimic |
| #!/usr/bin/env python3 |
| |
| import argparse |
| |
| def main(): |
| parser = argparse.ArgumentParser(description='A script for replacing broken [[library-name]]-config scripts') |
| |
| parser.add_argument('--set-prefix', type=str, help='Print the prefix') |
| parser.add_argument('--set-exec-prefix', type=str, help='Print the exec-prefix') |
| parser.add_argument('--set-version', type=str, help='Print the version') |
| parser.add_argument('--set-api-version', type=str, help='Print the api-version') |
| parser.add_argument('--set-libs', type=str, help='Print the libs') |
| parser.add_argument('--set-cflags', type=str, help='Print the cflags') |
| parser.add_argument('--set-host', type=str, help='Print the host') |
| |
| parser.add_argument('--prefix', action='store_true', help='Print the prefix') |
| parser.add_argument('--exec-prefix', action='store_true', help='Print the exec-prefix') |
| parser.add_argument('--version', action='store_true', help='Print the version') |
| parser.add_argument('--api-version', action='store_true', help='Print the api-version') |
| parser.add_argument('--libs', action='store_true', help='Print the libs') |
| parser.add_argument('--cflags', action='store_true', help='Print the cflags') |
| parser.add_argument('--host', action='store_true', help='Print the host') |
| |
| args = parser.parse_args() |
| |
| if args.prefix: |
| assert args.set_prefix, "need --set-prefix" |
| print(args.set_prefix.replace('@', ' ')) |
| elif args.exec_prefix: |
| assert args.set_exec_prefix, "need --set-exec-prefix" |
| print(args.set_exec_prefix.replace('@', ' ')) |
| elif args.version: |
| assert args.set_version, "need --set-version" |
| print(args.set_version.replace('@', ' ')) |
| elif args.api_version: |
| assert args.set_api_version, "need --set-api-version" |
| print(args.set_api_version.replace('@', ' ')) |
| elif args.libs: |
| assert args.set_libs, "need --set-libs" |
| print(args.set_libs.replace('@', ' ')) |
| elif args.cflags: |
| assert args.set_cflags, "need --set-cflags" |
| print(args.set_cflags.replace('@', ' ')) |
| elif args.host: |
| assert args.set_host, "need --set-host" |
| print(args.set_host.replace('@', ' ')) |
| |
| |
| if __name__ == '__main__': |
| main() |
| EOFEOF |
| chmod +x "${td}/bin/config-mimic" |
| |
| |
| # Try to help libassuan find libgpg-error (already packaged). |
| export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${DEPS_PREFIX}/lib/pkgconfig" |
| |
| # Point to the hacked-up, relocatable gpg-error-config that we wrote for gpg-error. |
| export GPG_ERROR_CONFIG="${DEPS_PREFIX}"/bin/gpg-error-config |
| test -f "$GPG_ERROR_CONFIG" |
| test -x "$GPG_ERROR_CONFIG" |
| |
| # Point to the hacked-up, relocatable libassuan-config that we wrote for libassuan. |
| export LIBASSUAN_CONFIG="${DEPS_PREFIX}"/bin/libassuan-config |
| test -f "$LIBASSUAN_CONFIG" |
| test -x "$LIBASSUAN_CONFIG" |
| |
| # TODO(b/448910248): don't use the mimic. |
| export KSBA_CONFIG="${td}/bin/config-mimic --set-libs=-L${DEPS_PREFIX}/lib@-lksba@-lgpg-error --set-cflags=-I${DEPS_PREFIX}/include --set-prefix=${DEPS_PREFIX} --set-version=1.6.7" |
| |
| # TODO(b/448910248): don't use the mimic. |
| export NPTH_CONFIG="${td}/bin/config-mimic --set-libs=-L${DEPS_PREFIX}/lib@-lnpth --set-cflags=-I${DEPS_PREFIX}/include --set-prefix=${DEPS_PREFIX} --set-version=1.8" |
| |
| # TODO(b/448910248): don't use the mimic. |
| export LIBGCRYPT_CONFIG="${td}/bin/config-mimic --set-libs=-L${DEPS_PREFIX}/lib@-lgcrypt@-lgpg-error --set-cflags=-I${DEPS_PREFIX}/include --set-prefix=${DEPS_PREFIX} --set-version=1.11.2" |
| |
| |
| if [[ -n "${CROSS_TRIPLE}" ]]; then |
| _CONFIG_ARGS=( "${_CONFIG_ARGS[@]}" "--host=${CROSS_TRIPLE}" ) |
| fi |
| |
| sh autogen.sh |
| ./configure "${_CONFIG_ARGS[@]}" |
| make -j"$(nproc || echo 3)" |
| make install |