correct usage of DESTDIR, PREFIX, etc. for the install make-target [skip ci]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
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
#