comparison Makefile @ 275:776a076d1afa

Makefile: Allow DESTDIR for distribution package creation Build infrastructures for distribution package management like Debian and Redhat use DESTDIR to designate a virtual root directory for the package contents, as per the GNU convention: http://www.gnu.org/prep/standards/html_node/DESTDIR.html To specify a simple installation directory target, use INSTALLDIR instead. Also use "install" to create the directory if needed. Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
author Tormod Volden <debian.tormod@gmail.com>
date Wed, 05 Jun 2013 19:57:09 -0600
parents cfeb196251e4
children 1dcc0b174e3b
comparison
equal deleted inserted replaced
274:d9d02dbf76a6 275:776a076d1afa
5 # BUILDTPREFIX: prefix added to build utilities (cc, etc.) for xcompile 5 # BUILDTPREFIX: prefix added to build utilities (cc, etc.) for xcompile
6 # can also set them when invoking "make" 6 # can also set them when invoking "make"
7 #PROGSUFFIX := .exe 7 #PROGSUFFIX := .exe
8 #BUILDTPREFIX=i586-mingw32msvc- 8 #BUILDTPREFIX=i586-mingw32msvc-
9 9
10 DESTDIR ?= /usr/local/bin 10 ifneq ($(DESTDIR),)
11 INSTALLDIR = $(DESTDIR)/usr/bin
12 else
13 INSTALLDIR ?= /usr/local/bin
14 endif
11 15
12 # this are probably pointless but they will make sure 16 # this are probably pointless but they will make sure
13 # the variables are set without overriding the environment 17 # the variables are set without overriding the environment
14 # or automatic values from make itself. 18 # or automatic values from make itself.
15 CC ?= cc 19 CC ?= cc
132 print-%: 136 print-%:
133 @echo $* = $($*) 137 @echo $* = $($*)
134 138
135 .PHONY: install 139 .PHONY: install
136 install: 140 install:
137 mkdir -p $(DESTDIR) 141 install -d $(INSTALLDIR)
138 cp $(MAIN_TARGETS) $(DESTDIR) 142 install $(MAIN_TARGETS) $(INSTALLDIR)
139 143
140 .PHONY: test 144 .PHONY: test
141 test: all test/runtests 145 test: all test/runtests
142 @test/runtests 146 @test/runtests
143 147