summaryrefslogtreecommitdiffstats
path: root/config/pkg.sh
blob: 4ebea64b68f3e62bfa1c056540cfebbdffaad995 (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
#!/bin/sh

# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD

# pkg-config wrapper that outputs a makefile fragment

set -eu

NAME=$(printf '%s' "$1" | tr 'a-z' 'A-Z')
eval "XUSE=\"\${USE_$NAME:-}\""

if [ "$XUSE" ]; then
    USE="$XUSE"
elif config/pkgconf.sh "$1"; then
    USE=y
else
    USE=n
fi

if [ "$USE" = y ]; then
    printf 'PKGS += %s\n' "$1"
    printf 'CPPFLAGS += -DBFS_USE_%s=1\n' "$NAME"
else
    printf 'CPPFLAGS += -DBFS_USE_%s=0\n' "$NAME"
fi