aboutsummaryrefslogtreecommitdiff
path: root/extra/rc
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-08-25 04:25:44 +0300
committerCem Keylan <cem@ckyln.com>2020-08-25 04:25:44 +0300
commit5185a68c90fe0201525d47e2e5380c99ece48e82 (patch)
tree3883b9caeebfb6d98f4b14afad85c3da6ac67284 /extra/rc
parent6bc112a94569af234da2328d601d2588bec2744e (diff)
downloadrepository-5185a68c90fe0201525d47e2e5380c99ece48e82.tar.gz
rc: build with readline if available
Diffstat (limited to 'extra/rc')
-rwxr-xr-xextra/rc/build13
1 files changed, 12 insertions, 1 deletions
diff --git a/extra/rc/build b/extra/rc/build
index caaeb043..300caaf6 100755
--- a/extra/rc/build
+++ b/extra/rc/build
@@ -7,9 +7,20 @@ 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 \
@@ -27,7 +38,7 @@ mkdir -p "$1/usr/bin"
y.tab.c \
unix.c \
havefork.c \
- prompt-null.c
+ "prompt-$readline.c" $LIBS
install -Dm644 rc.1 "$1/usr/share/man/man1/rc.1"
install -Dm644 rcmain.unix "$1/etc/rcmain"