Commit 237b49ad4a38a0fe8d11e8852d849558e2831cd9

Steffen Jaeckel 2017-08-28T15:56:12

correct usage of DESTDIR, PREFIX, etc. for the install make-target [skip ci]

diff --git a/makefile b/makefile
index d412997..0e305d6 100644
--- a/makefile
+++ b/makefile
@@ -83,10 +83,10 @@ profiled_single:
 	ranlib $(LIBNAME)
 
 install: $(LIBNAME)
-	install -d $(LIBPATH)
-	install -d $(INCPATH)
-	install -m 644 $(LIBNAME) $(LIBPATH)
-	install -m 644 $(HEADERS_PUB) $(INCPATH)
+	install -d $(DESTDIR)$(LIBPATH)
+	install -d $(DESTDIR)$(INCPATH)
+	install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)
+	install -m 644 $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
 
 test: $(LIBNAME) demo/demo.o
 	$(CC) $(CFLAGS) demo/demo.o $(LIBNAME) $(LFLAGS) -o test
diff --git a/makefile.shared b/makefile.shared
index 8842dc9..b92c1ea 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -53,13 +53,13 @@ $(LIBNAME):  $(OBJECTS)
 	$(LT) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO)
 
 install: $(LIBNAME)
-	install -d $(LIBPATH)
-	install -d $(INCPATH)
-	$(LT) --mode=install install -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME)
-	install -m 644 $(HEADERS_PUB) $(INCPATH)
-	sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtommath.pc.in > libtommath.pc
-	install -d $(LIBPATH)/pkgconfig
-	install -m 644 libtommath.pc $(LIBPATH)/pkgconfig/
+	install -d $(DESTDIR)$(LIBPATH)
+	install -d $(DESTDIR)$(INCPATH)
+	$(LT) --mode=install install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
+	install -m 644 $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
+	sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION),' libtommath.pc.in > libtommath.pc
+	install -d $(DESTDIR)$(LIBPATH)/pkgconfig
+	install -m 644 libtommath.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
 
 test: $(LIBNAME) demo/demo.o
 	$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
diff --git a/makefile_include.mk b/makefile_include.mk
index 9890348..adeb032 100644
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -68,13 +68,14 @@ HEADERS=tommath_private.h $(HEADERS_PUB)
 
 test_standalone: CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
 
-#LIBPATH-The directory for libtommath to be installed to.
-#INCPATH-The directory to install the header files for libtommath.
-#DATAPATH-The directory to install the pdf docs.
-DESTDIR  ?= /usr/local
-LIBPATH  ?= $(DESTDIR)/lib
-INCPATH  ?= $(DESTDIR)/include
-DATAPATH ?= $(DESTDIR)/share/doc/libtommath/pdf
+#LIBPATH  The directory for libtommath to be installed to.
+#INCPATH  The directory to install the header files for libtommath.
+#DATAPATH The directory to install the pdf docs.
+DESTDIR  ?=
+PREFIX   ?= /usr/local
+LIBPATH  ?= $(PREFIX)/lib
+INCPATH  ?= $(PREFIX)/include
+DATAPATH ?= $(PREFIX)/share/doc/libtommath/pdf
 
 #make the code coverage of the library
 #