blob: decf7069bd76397b3ad5552656c6dc3bbc477be5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/bin/sh
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
# pkg-config wrapper with hardcoded fallbacks
set -eu
MODE=
case "${1:-}" in
--*)
MODE="$1"
shift
esac
if [ $# -lt 1 ]; then
exit
fi
case "$XNOLIBS" in
y|1)
exit 1
esac
if [ -z "$MODE" ]; then
# Check whether the libraries exist at all
for LIB; do
# Check ${WITH_$LIB}
WITH_LIB="WITH_$(printf '%s' "$LIB" | tr 'a-z-' 'A-Z_')"
eval "WITH=\"\${$WITH_LIB:-}\""
case "$WITH" in
y|1) continue ;;
n|0) exit 1 ;;
esac
XCFLAGS="$XCFLAGS $("$0" --cflags "$LIB")" || exit 1
XLDFLAGS="$XLDFLAGS $("$0" --ldflags "$LIB")" || exit 1
XLDLIBS="$("$0" --ldlibs "$LIB") $XLDLIBS" || exit 1
build/cc.sh "build/with/$LIB.c" -o "gen/with/.$LIB.out" || exit 1
done
fi
# Defer to pkg-config if possible
if command -v "${XPKG_CONFIG:-}" >/dev/null 2>&1; then
case "$MODE" in
--cflags)
"$XPKG_CONFIG" --cflags "$@"
;;
--ldflags)
"$XPKG_CONFIG" --libs-only-L --libs-only-other "$@"
;;
--ldlibs)
"$XPKG_CONFIG" --libs-only-l "$@"
;;
esac
exit
fi
# pkg-config unavailable, emulate it ourselves
CFLAGS=""
LDFLAGS=""
LDLIBS=""
for LIB; do
case "$LIB" in
libacl)
LDLIB=-lacl
;;
libcap)
LDLIB=-lcap
;;
libselinux)
LDLIB=-lselinux
;;
liburing)
LDLIB=-luring
;;
oniguruma)
LDLIB=-lonig
;;
*)
printf 'error: Unknown package %s\n' "$LIB" >&2
exit 1
;;
esac
LDLIBS="$LDLIBS$LDLIB "
done
case "$MODE" in
--ldlibs)
printf '%s\n' "$LDLIBS"
;;
esac
|