From d390d9a7074029be5842959939e63beaf12c4f31 Mon Sep 17 00:00:00 2001 From: Nico Sonack Date: Sat, 1 Oct 2022 17:56:07 +0200 Subject: [PATCH] Add install target --- Makefile | 5 ++++- build.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6589edd1..74fbfca2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean check +.PHONY: all clean check install all: ./build.sh @@ -8,3 +8,6 @@ clean: check: ./build.sh check + +install: + PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" ./build.sh install diff --git a/build.sh b/build.sh index 79c47951..76af78c0 100755 --- a/build.sh +++ b/build.sh @@ -320,6 +320,34 @@ build_test_programs() build_test_program tests/pgen-tests } +################################################################################# +# Install target +################################################################################# +doinstall() +{ + [ -x ./gcli ] || die "You need to build gcli first" + + [ "x$PREFIX" != "x" ] || PREFIX="/usr/local" + [ "x$DESTDIR" != "x" ] || DESTDIR="/" + + BINDIR=${DESTDIR}${PREFIX}/bin + MANDIR=${DESTDIR}${PREFIX}/man + + [ -d $BINDIR ] || mkdir -p $BINDIR + [ -d $MANDIR ] || mkdir -p $MANDIR + [ -d $MANDIR/man1 ] || mkdir -p $MANDIR/man1 + + echo "Installing gcli" + echo " cp gcli $BINDIR" + cp gcli $BINDIR || die "install command failed" + + for MANPAGE in docs/gcli*.1; do + echo "Installing ${MANPAGE#docs/}" + echo " gzip < $MANPAGE > $MANDIR/man1/${MANPAGE#docs/}.gz" + gzip < $MANPAGE > $MANDIR/man1/${MANPAGE#docs/}.gz || die "install command failed" + done +} + # Start it! case $1 in @@ -333,6 +361,9 @@ case $1 in kyua test || die "Tests failed" cd .. ;; + install) + doinstall + ;; *) die "unknown subcommand" ;;