aboutsummaryrefslogtreecommitdiff
path: root/extra/rc/build
blob: 300caaf6ede00c7842a6dee1ca717887d48d3645 (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
#!/bin/sh -e

for patch in *.patch; do
    patch -p1 < "$patch"
done

# Change the location of rcmain to the /etc directory.
sed -i 's|/lib/rcmain|/etc/rcmain|;s|PREFIX||' unix.c

# If readline is available, build with it.
if cpt-list readline >/dev/null 2>&1; then
    readline=readline LIBS="$LIBS $(pkg-config --static --libs readline)"
else
    readline=null
fi

mkdir -p "$1/usr/bin"

# Since CFLAGS and LIBS need to be seperated, there are no double quotes.
# shellcheck disable=2086
"${CC:-cc}" -o "$1/usr/bin/rc" \
    $CFLAGS -static \
    -D_XOPEN_SOURCE=500 \
    code.c \
    exec.c \
    getflags.c \
    glob.c \
    here.c \
    io.c \
    lex.c \
    pcmd.c \
    pfnc.c \
    simple.c \
    subr.c \
    trap.c \
    tree.c \
    var.c \
    y.tab.c \
    unix.c \
    havefork.c \
    "prompt-$readline.c" $LIBS

install -Dm644 rc.1        "$1/usr/share/man/man1/rc.1"
install -Dm644 rcmain.unix "$1/etc/rcmain"