aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-06-09 17:12:33 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-06-09 17:12:33 -0400
commitd01b699fffc573e7653e00d608444735c04f9dca (patch)
tree8acfd9965f918b5f7a74b834f09d0f27a12b7216
parent1a6b5e8e4c95426d6803d320160f864f3dd87caf (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/Makefile18
-rw-r--r--Makefile34
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
17endif 17endif
18 18
@@ -69,21 +69,23 @@ MAN5 = $(patsubst %.5.txt,$(obj)/%.5, ${TEXT5})
69 69
70all: $(MAN1) $(MAN5) 70all: $(MAN1) $(MAN5)
71 71
72# Need to find out how to export a macro instead of
73# copying this from the main Makefile.
72define do_install 74define 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'
78endef 80endef
79 81
80MAN1_INSTALL = $(MAN1:%.1=%.1.install) 82MAN1_INSTALL = $(MAN1:%.1=%.1.install)
81MAN5_INSTALL = $(MAN5:%.5=%.5.install) 83MAN5_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
88install: $(MAN1_INSTALL) $(MAN5_INSTALL) 90install: $(MAN1_INSTALL) $(MAN5_INSTALL)
89 91
diff --git a/Makefile b/Makefile
index a358f82..fb06e26 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,13 @@ AR = $(CROSS_COMPILE)ar
18EXT = -std=gnu99 18EXT = -std=gnu99
19INSTALL = install 19INSTALL = 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.
25DESTDIR ?=
26DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
27
21prefix ?= /usr/local 28prefix ?= /usr/local
22bindir_relative = bin 29bindir_relative = bin
23bindir = $(prefix)/$(bindir_relative) 30bindir = $(prefix)/$(bindir_relative)
@@ -25,6 +32,7 @@ man_dir = $(prefix)/share/man
25man_dir_SQ = '$(subst ','\'',$(man_dir))' 32man_dir_SQ = '$(subst ','\'',$(man_dir))'
26 33
27export man_dir man_dir_SQ INSTALL 34export man_dir man_dir_SQ INSTALL
35export DESTDIR DESTDIR_SQ
28 36
29ifeq ($(prefix),$(HOME)) 37ifeq ($(prefix),$(HOME))
30plugin_dir = $(HOME)/.trace-cmd/plugins 38plugin_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';
190endif 198endif
191 199
192do_fpic_compile = \ 200do_fpic_compile = \
@@ -419,36 +427,36 @@ TAGS: force
419PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS)) 427PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS))
420 428
421define do_install 429define 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'
427endef 435endef
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
432install_plugins: $(PLUGINS_INSTALL) 440install_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
440install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_INSTALL) 448install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_INSTALL)
441 449
442install_cmd: all_cmd install_plugins install_python 450install_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
445install: install_cmd 453install: 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
448install_gui: install_cmd gui 456install_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
453doc: 461doc:
454 $(MAKE) -C $(src)/Documentation all 462 $(MAKE) -C $(src)/Documentation all