proper use of $(DESTDIR)
@rofl0r @ [1] "...still it's unusual/unexpected to embed DESTDIR in LIBPATH etc. where this could hickup is when for example hardcoded paths need to be embedded into the resulting binary. for example, in the netbsd-curses makefile i linked earlier, such a case would be reference to the terminfo DB location, which is derived from PREFIX. other possible cases might be stuff that dlopen()s its own libs using an absolute path, or uses other data files. for such a case a contributor would typically re-use DATAPATH oslt and put it into CPPFLAGS or write it into a header, to find the required files. when now these paths have DESTDIR in them too, this will not work. thus it is good practice to use $(DESTDIR) only in install targets, and keep it out of other vars." [1] https://github.com/libtom/libtomcrypt/commit/8e29a6061f3ad7bc7c5c2aeae73705e890ce1ea9#commitcomment-22678488 This closes #232
This commit is contained in:
+2
-2
@@ -47,8 +47,8 @@ $(LIBNAME): $(OBJECTS)
|
||||
|
||||
install: .common_install
|
||||
sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > libtomcrypt.pc
|
||||
install -d $(LIBPATH)/pkgconfig
|
||||
install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/
|
||||
install -d $(DESTDIR)/$(LIBPATH)/pkgconfig
|
||||
install -m 644 libtomcrypt.pc $(DESTDIR)/$(LIBPATH)/pkgconfig/
|
||||
|
||||
install_bins: .common_install_bins
|
||||
|
||||
|
||||
+12
-12
@@ -25,10 +25,10 @@
|
||||
#The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs"
|
||||
DESTDIR =
|
||||
PREFIX = /usr/local
|
||||
LIBPATH = $(DESTDIR)$(PREFIX)/lib
|
||||
INCPATH = $(DESTDIR)$(PREFIX)/include
|
||||
DATAPATH = $(DESTDIR)$(PREFIX)/share/doc/libtomcrypt/pdf
|
||||
BINPATH = $(DESTDIR)$(PREFIX)/bin
|
||||
LIBPATH = $(PREFIX)/lib
|
||||
INCPATH = $(PREFIX)/include
|
||||
DATAPATH = $(PREFIX)/share/doc/libtomcrypt/pdf
|
||||
BINPATH = $(PREFIX)/bin
|
||||
CC = cc
|
||||
AR = ar
|
||||
ARFLAGS = r
|
||||
@@ -272,17 +272,17 @@ clean:
|
||||
|
||||
#Install the library + headers
|
||||
install: $(LIBMAIN_S) $(HEADERS)
|
||||
@mkdir -p $(INCPATH) $(LIBPATH)/pkgconfig
|
||||
@cp $(LIBMAIN_S) $(LIBPATH)/
|
||||
@cp $(HEADERS) $(INCPATH)/
|
||||
@sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc
|
||||
@mkdir -p $(DESTDIR)/$(INCPATH) $(DESTDIR)/$(LIBPATH)/pkgconfig
|
||||
@cp $(LIBMAIN_S) $(DESTDIR)/$(LIBPATH)/
|
||||
@cp $(HEADERS) $(DESTDIR)/$(INCPATH)/
|
||||
@sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/$(LIBPATH)/pkgconfig/libtomcrypt.pc
|
||||
|
||||
#Install useful tools
|
||||
install_bins: hashsum
|
||||
@mkdir -p $(BINPATH)
|
||||
@cp hashsum $(BINPATH)/
|
||||
@mkdir -p $(DESTDIR)/$(BINPATH)
|
||||
@cp hashsum $(DESTDIR)/$(BINPATH)/
|
||||
|
||||
#Install documentation
|
||||
install_docs: doc/crypt.pdf
|
||||
@mkdir -p $(DATAPATH)
|
||||
@cp doc/crypt.pdf $(DATAPATH)/
|
||||
@mkdir -p $(DESTDIR)/$(DATAPATH)
|
||||
@cp doc/crypt.pdf $(DESTDIR)/$(DATAPATH)/
|
||||
|
||||
+10
-10
@@ -132,10 +132,10 @@ TIMINGS=demos/timing.o
|
||||
#BINPATH The directory to install the binaries provided.
|
||||
DESTDIR ?=
|
||||
PREFIX ?= /usr/local
|
||||
LIBPATH ?= $(DESTDIR)$(PREFIX)/lib
|
||||
INCPATH ?= $(DESTDIR)$(PREFIX)/include
|
||||
DATAPATH ?= $(DESTDIR)$(PREFIX)/share/doc/libtomcrypt/pdf
|
||||
BINPATH ?= $(DESTDIR)$(PREFIX)/bin
|
||||
LIBPATH ?= $(PREFIX)/lib
|
||||
INCPATH ?= $(PREFIX)/include
|
||||
DATAPATH ?= $(PREFIX)/share/doc/libtomcrypt/pdf
|
||||
BINPATH ?= $(PREFIX)/bin
|
||||
|
||||
#Who do we install as?
|
||||
ifdef INSTALL_USER
|
||||
@@ -362,18 +362,18 @@ install_all: install install_bins install_docs install_test
|
||||
INSTALL_OPTS ?= -m 644
|
||||
|
||||
.common_install: $(LIBNAME)
|
||||
install -d $(INCPATH)
|
||||
install -d $(LIBPATH)
|
||||
$(INSTALL_CMD) $(INSTALL_OPTS) $(LIBNAME) $(LIBPATH)/$(LIBNAME)
|
||||
install -m 644 $(HEADERS) $(INCPATH)
|
||||
install -d $(DESTDIR)/$(INCPATH)
|
||||
install -d $(DESTDIR)/$(LIBPATH)
|
||||
$(INSTALL_CMD) $(INSTALL_OPTS) $(LIBNAME) $(DESTDIR)/$(LIBPATH)/$(LIBNAME)
|
||||
install -m 644 $(HEADERS) $(DESTDIR)/$(INCPATH)
|
||||
|
||||
.common_install_bins: $(USEFUL_DEMOS)
|
||||
install -d $(BINPATH)
|
||||
$(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH)
|
||||
$(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(DESTDIR)/$(BINPATH)
|
||||
|
||||
install_docs: doc/crypt.pdf
|
||||
install -d $(DATAPATH)
|
||||
install -m 644 doc/crypt.pdf $(DATAPATH)
|
||||
install -m 644 doc/crypt.pdf $(DESTDIR)/$(DATAPATH)
|
||||
|
||||
install_hooks:
|
||||
for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done
|
||||
|
||||
Reference in New Issue
Block a user