From 5dd926e2257c83898b83f0f839fb1f7617101ba6 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 27 Jun 2024 18:22:13 +0800 Subject: [PATCH] Add make install and uninstall tasks --- Makefile | 19 +++++++++++++++++-- README.md | 27 +++++++++++++++++++++------ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index de4f11e..75a44ea 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ PREFIX := /usr +BINDIR := ${PREFIX}/bin +DATADIR := ${PREFIX}/share -# The directory to store the assets in. -ASSETS := ${PREFIX}/share/idoc/assets +# The directory to install the asset files (CSS, JS, etc) in. +ASSETS := ${DATADIR}/idoc/assets .check-version: @test $${VERSION?The VERSION variable must be set} @@ -10,6 +12,19 @@ build: inko pkg sync inko build --define 'idoc.cmd.ASSETS=${ASSETS}' -o ./build/idoc +${DESTDIR}${BINDIR}/idoc: + install -D --mode=755 build/idoc "${@}" + +${DESTDIR}${ASSETS}: + mkdir -p "${@}" + cp --recursive assets/* "${@}" + +install: build ${DESTDIR}${BINDIR}/idoc ${DESTDIR}${ASSETS} + +uninstall: + rm --force ${BINDIR}/idoc + rm --recursive --force ${ASSETS} + release/version: .check-version sed -E -i -e "s/^let VERSION = '([^']+)'$$/let VERSION = '${VERSION}'/" \ src/idoc/cmd.inko diff --git a/README.md b/README.md index 83d14f6..b588cce 100644 --- a/README.md +++ b/README.md @@ -18,25 +18,40 @@ at `./build/idoc/public`. For more information, run `idoc --help`. Building from source: ```bash -make build +make install PREFIX=~/.local ``` -This assumes the assets used by the website (e.g. the CSS files) are located at -`/usr/share/idoc/assets`. You can change this path by settings the `ASSETS` make -variable. For example, to use the local `assets` directory you'd run the -following: +This installs `idoc` into `~/.local`, with the executable being found at +`~/.local/bin`, and the assets located at `~/.local/share/idoc/assets`. To +uninstall, run the following: + +```bash +make uninstall PREFIX=~/.local +``` + +For testing changes locally, run the following ```bash make build ASSETS=$PWD/assets ``` -You can also use the provided Docker image: +This builds the executable such that it uses the `assets/` directory directly +from the repository. In this case the executable is found at `./build/idoc`. + +You can also use the provided [Docker](https://www.docker.com/) image: ```bash docker pull ghcr.io/inko-lang/idoc:latest docker run --rm --volume $PWD:$PWD:z --workdir $PWD idoc:latest ``` +Or when using [Podman](http://podman.io/): + +```bash +podman pull ghcr.io/inko-lang/idoc:latest +podman run --rm --volume $PWD:$PWD:z --workdir $PWD idoc:latest +``` + ## License All source code in this repository is licensed under the Mozilla Public License