diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-06-09 17:12:33 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-09 17:12:33 -0400 |
commit | d01b699fffc573e7653e00d608444735c04f9dca (patch) | |
tree | 8acfd9965f918b5f7a74b834f09d0f27a12b7216 | |
parent | 1a6b5e8e4c95426d6803d320160f864f3dd87caf (diff) |
build: Add DESTDIR to make
Add the variable DESTDIR that allows a user to install into
a directory that will later be moved to another host. This
facilitates the creation of distribution packages.
make DESTDIR=/tmp/build prefix=/usr install
Will install the program files into /tmp/build/usr/..
but the program will expect to find itself in the /usr/..
directories.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | Documentation/Makefile | 18 | ||||
-rw-r--r-- | Makefile | 34 |
2 files changed, 31 insertions, 21 deletions
diff --git a/Documentation/Makefile b/Documentation/Makefile index d161703..b7c17e7 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile | |||
@@ -12,7 +12,7 @@ else | |||
12 | Q = @ | 12 | Q = @ |
13 | print_asciidoc = echo ' ASCIIDOC '`basename $@`; | 13 | print_asciidoc = echo ' ASCIIDOC '`basename $@`; |
14 | print_xsltproc = echo ' XSLTPROC '`basename $@`; | 14 | print_xsltproc = echo ' XSLTPROC '`basename $@`; |
15 | print_install = echo ' INSTALL '`basename $1`' to '$2; | 15 | print_install = echo ' INSTALL '`basename $1`' to $(DESTDIR_SQ)'$2; |
16 | hide_xsltproc_output = 2> /dev/null | 16 | hide_xsltproc_output = 2> /dev/null |
17 | endif | 17 | endif |
18 | 18 | ||
@@ -69,21 +69,23 @@ MAN5 = $(patsubst %.5.txt,$(obj)/%.5, ${TEXT5}) | |||
69 | 69 | ||
70 | all: $(MAN1) $(MAN5) | 70 | all: $(MAN1) $(MAN5) |
71 | 71 | ||
72 | # Need to find out how to export a macro instead of | ||
73 | # copying this from the main Makefile. | ||
72 | define do_install | 74 | define do_install |
73 | $(print_install) \ | 75 | $(print_install) \ |
74 | if [ ! -d $2 ]; then \ | 76 | if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ |
75 | $(INSTALL) -d -m 755 $2 ; \ | 77 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ |
76 | fi; \ | 78 | fi; \ |
77 | $(INSTALL) $1 $2; | 79 | $(INSTALL) $1 '$(DESTDIR_SQ)$2' |
78 | endef | 80 | endef |
79 | 81 | ||
80 | MAN1_INSTALL = $(MAN1:%.1=%.1.install) | 82 | MAN1_INSTALL = $(MAN1:%.1=%.1.install) |
81 | MAN5_INSTALL = $(MAN5:%.5=%.5.install) | 83 | MAN5_INSTALL = $(MAN5:%.5=%.5.install) |
82 | 84 | ||
83 | $(MAN1_INSTALL): %.1.install : %.1 force | 85 | $(MAN1_INSTALL): %.1.install : %.1 force |
84 | $(Q)$(call do_install, $<, '$(man_dir_SQ)/man1') | 86 | $(Q)$(call do_install,$<,$(man_dir_SQ)/man1) |
85 | $(MAN5_INSTALL): %.5.install : %.5 force | 87 | $(MAN5_INSTALL): %.5.install : %.5 force |
86 | $(Q)$(call do_install, $<, '$(man_dir_SQ)/man5') | 88 | $(Q)$(call do_install,$<,$(man_dir_SQ)/man5) |
87 | 89 | ||
88 | install: $(MAN1_INSTALL) $(MAN5_INSTALL) | 90 | install: $(MAN1_INSTALL) $(MAN5_INSTALL) |
89 | 91 | ||
@@ -18,6 +18,13 @@ AR = $(CROSS_COMPILE)ar | |||
18 | EXT = -std=gnu99 | 18 | EXT = -std=gnu99 |
19 | INSTALL = install | 19 | INSTALL = install |
20 | 20 | ||
21 | # Use DESTDIR for installing into a different root directory. | ||
22 | # This is useful for building a package. The program will be | ||
23 | # installed in this directory as if it was the root directory. | ||
24 | # Then the build tool can move it later. | ||
25 | DESTDIR ?= | ||
26 | DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' | ||
27 | |||
21 | prefix ?= /usr/local | 28 | prefix ?= /usr/local |
22 | bindir_relative = bin | 29 | bindir_relative = bin |
23 | bindir = $(prefix)/$(bindir_relative) | 30 | bindir = $(prefix)/$(bindir_relative) |
@@ -25,6 +32,7 @@ man_dir = $(prefix)/share/man | |||
25 | man_dir_SQ = '$(subst ','\'',$(man_dir))' | 32 | man_dir_SQ = '$(subst ','\'',$(man_dir))' |
26 | 33 | ||
27 | export man_dir man_dir_SQ INSTALL | 34 | export man_dir man_dir_SQ INSTALL |
35 | export DESTDIR DESTDIR_SQ | ||
28 | 36 | ||
29 | ifeq ($(prefix),$(HOME)) | 37 | ifeq ($(prefix),$(HOME)) |
30 | plugin_dir = $(HOME)/.trace-cmd/plugins | 38 | plugin_dir = $(HOME)/.trace-cmd/plugins |
@@ -186,7 +194,7 @@ else | |||
186 | print_plugin_obj_compile = echo ' $(GUI)COMPILE PLUGIN OBJ '$(GOBJ); | 194 | print_plugin_obj_compile = echo ' $(GUI)COMPILE PLUGIN OBJ '$(GOBJ); |
187 | print_plugin_build = echo ' $(GUI)BUILD PLUGIN '$(GOBJ); | 195 | print_plugin_build = echo ' $(GUI)BUILD PLUGIN '$(GOBJ); |
188 | print_static_lib_build = echo ' $(GUI)BUILD STATIC LIB '$(GOBJ); | 196 | print_static_lib_build = echo ' $(GUI)BUILD STATIC LIB '$(GOBJ); |
189 | print_install = echo ' $(GUI)INSTALL '$(GSPACE)$1' to '$2; | 197 | print_install = echo ' $(GUI)INSTALL '$(GSPACE)$1' to $(DESTDIR_SQ)$2'; |
190 | endif | 198 | endif |
191 | 199 | ||
192 | do_fpic_compile = \ | 200 | do_fpic_compile = \ |
@@ -419,36 +427,36 @@ TAGS: force | |||
419 | PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS)) | 427 | PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS)) |
420 | 428 | ||
421 | define do_install | 429 | define do_install |
422 | $(print_install) \ | 430 | $(print_install) \ |
423 | if [ ! -d $2 ]; then \ | 431 | if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ |
424 | $(INSTALL) -d -m 755 $2 ; \ | 432 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ |
425 | fi; \ | 433 | fi; \ |
426 | $(INSTALL) $1 $2; | 434 | $(INSTALL) $1 '$(DESTDIR_SQ)$2' |
427 | endef | 435 | endef |
428 | 436 | ||
429 | $(PLUGINS_INSTALL): %.install : %.so force | 437 | $(PLUGINS_INSTALL): %.install : %.so force |
430 | $(Q)$(call do_install, $<, '$(plugin_dir_SQ)') | 438 | $(Q)$(call do_install,$<,$(plugin_dir_SQ)) |
431 | 439 | ||
432 | install_plugins: $(PLUGINS_INSTALL) | 440 | install_plugins: $(PLUGINS_INSTALL) |
433 | 441 | ||
434 | $(PYTHON_SO_INSTALL): %.install : %.so force | 442 | $(PYTHON_SO_INSTALL): %.install : %.so force |
435 | $(Q)$(call do_install, $<, '$(python_dir_SQ)') | 443 | $(Q)$(call do_install,$<,$(python_dir_SQ)) |
436 | 444 | ||
437 | $(PYTHON_PY_INSTALL): %.install : %.py force | 445 | $(PYTHON_PY_INSTALL): %.install : %.py force |
438 | $(Q)$(call do_install, $<, '$(python_dir_SQ)') | 446 | $(Q)$(call do_install,$<,$(python_dir_SQ)) |
439 | 447 | ||
440 | install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_INSTALL) | 448 | install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_INSTALL) |
441 | 449 | ||
442 | install_cmd: all_cmd install_plugins install_python | 450 | install_cmd: all_cmd install_plugins install_python |
443 | $(Q)$(call do_install, trace-cmd, '$(bindir_SQ)') | 451 | $(Q)$(call do_install,trace-cmd,$(bindir_SQ)) |
444 | 452 | ||
445 | install: install_cmd | 453 | install: install_cmd |
446 | @echo "Note: to install the gui, type \"make install_gui\"" | 454 | @echo "Note: to install the gui, type \"make install_gui\"" |
447 | 455 | ||
448 | install_gui: install_cmd gui | 456 | install_gui: install_cmd gui |
449 | $(Q)$(call do_install, trace-view, '$(bindir_SQ)') | 457 | $(Q)$(call do_install,trace-view,$(bindir_SQ)) |
450 | $(Q)$(call do_install, trace-graph, '$(bindir_SQ)') | 458 | $(Q)$(call do_install,trace-graph,$(bindir_SQ)) |
451 | $(Q)$(call do_install, kernelshark, '$(bindir_SQ)') | 459 | $(Q)$(call do_install,kernelshark,$(bindir_SQ)) |
452 | 460 | ||
453 | doc: | 461 | doc: |
454 | $(MAKE) -C $(src)/Documentation all | 462 | $(MAKE) -C $(src)/Documentation all |