From: Gerhard Sittig Date: Sun, 2 Oct 2022 12:08:00 +0000 (+0200) Subject: Makefile: use PREFIX in "make install", use DESTDIR in traditional ways X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-dumps.git;a=commitdiff_plain;h=7cfd7aa928edc23f02a28ffa1a5065e2a0209c08 Makefile: use PREFIX in "make install", use DESTDIR in traditional ways Commit 4fafe8159940 as of 2012-05-14 introduced a simple "make install" target. Unfortunately it used the DESTDIR variable to mean the location where captures get installed to (relative to the target filesystem's root). But traditionally DESTDIR is an optional "root directory" owned by packagers or used for cross build installs. While the install location within the filesystem should be relative to a --prefix spec which users can control during build. Use DESTDIR during installation in its traditional meaning, accept when it's specified externally, but don't modify it locally. Use PREFIX to mean the in-filesystem base directory which share/... gets appended to. Provide a backwards compatible builtin, accept an external override. $ make PREFIX=${HOME} install $ make DESTDIR=$( pwd )/rootfs install Add a developer comment. Ideally we would not have to roll DIY shell commands, and use a higher level build tool instead. The reason that this has not been done yet might be the portable construction of the list of directories to install at compile time (a guess). --- diff --git a/Makefile b/Makefile index 76458ae..9820eaa 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,14 @@ VERSION = "0.1.0" -DESTDIR ?= /usr/local/share/sigrok-dumps +# TODO Ideally instructions would use autotools, cmake, or some other +# higher level abstraction instead of DIY shell commands. Which would +# improve portability and robustness (by picking the most appropriate +# install tool that is available on the target), and would transparently +# enable support for --prefix and DESTDIR et al, including out of source +# builds when desired. +PREFIX ?= /usr/local +INSTALL_DIR = $(PREFIX)/share/sigrok-dumps # Be explicit about which files or subdirectories to install. # Update this list when adding a new top level subdirectory to the @@ -62,5 +69,5 @@ dist: ChangeLog @rm -f ChangeLog install: - @mkdir -p $(DESTDIR) - @cp -r $(FILES_DIRS) $(DESTDIR) + @mkdir -p $(DESTDIR)$(INSTALL_DIR) + @cp -r $(FILES_DIRS) $(DESTDIR)$(INSTALL_DIR)