]>
Commit | Line | Data |
---|---|---|
1 | # | |
2 | # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. | |
3 | # Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved. | |
4 | # | |
5 | # This file is part of LVM2. | |
6 | # | |
7 | # This copyrighted material is made available to anyone wishing to use, | |
8 | # modify, copy, or redistribute it subject to the terms and conditions | |
9 | # of the GNU General Public License v.2. | |
10 | # | |
11 | # You should have received a copy of the GNU General Public License | |
12 | # along with this program; if not, write to the Free Software Foundation, | |
13 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
14 | ||
15 | srcdir = @srcdir@ | |
16 | top_srcdir = @top_srcdir@ | |
17 | top_builddir = @top_builddir@ | |
18 | abs_top_builddir = @abs_top_builddir@ | |
19 | abs_top_srcdir = @abs_top_srcdir@ | |
20 | ||
21 | SUBDIRS = libdm conf daemons include lib libdaemon man scripts tools | |
22 | ||
23 | ifeq ("@UDEV_RULES@", "yes") | |
24 | SUBDIRS += udev | |
25 | endif | |
26 | ||
27 | ifeq ("@INTL@", "yes") | |
28 | SUBDIRS += po | |
29 | endif | |
30 | ||
31 | ifeq ($(MAKECMDGOALS),clean) | |
32 | SUBDIRS += test | |
33 | endif | |
34 | # FIXME Should use intermediate Makefiles here! | |
35 | ifeq ($(MAKECMDGOALS),distclean) | |
36 | SUBDIRS = conf include man test scripts \ | |
37 | libdaemon lib tools daemons libdm \ | |
38 | udev po | |
39 | tools.distclean: test.distclean | |
40 | endif | |
41 | DISTCLEAN_DIRS += lcov_reports* autom4te.cache | |
42 | DISTCLEAN_TARGETS += config.cache config.log config.status make.tmpl | |
43 | ||
44 | include make.tmpl | |
45 | ||
46 | include $(top_srcdir)/base/Makefile | |
47 | include $(top_srcdir)/device_mapper/Makefile | |
48 | include $(top_srcdir)/test/unit/Makefile | |
49 | ||
50 | lib: include libdaemon $(BASE_TARGET) $(DEVICE_MAPPER_TARGET) | |
51 | daemons: lib libdaemon tools | |
52 | scripts: lib | |
53 | tools: lib libdaemon | |
54 | po: tools daemons | |
55 | man: tools | |
56 | all_man: tools | |
57 | test: tools daemons | |
58 | unit-test run-unit-test: test libdm | |
59 | ||
60 | daemons.device-mapper: libdm.device-mapper | |
61 | tools.device-mapper: libdm.device-mapper | |
62 | device-mapper: tools.device-mapper daemons.device-mapper man.device-mapper | |
63 | device_mapper: device-mapper | |
64 | ||
65 | ifeq ("@INTL@", "yes") | |
66 | lib.pofile: include.pofile | |
67 | tools.pofile: lib.pofile | |
68 | daemons.pofile: lib.pofile | |
69 | po.pofile: tools.pofile daemons.pofile | |
70 | pofile: po.pofile | |
71 | endif | |
72 | ||
73 | ifneq ("$(CFLOW_CMD)", "") | |
74 | tools.cflow: libdm.cflow lib.cflow | |
75 | daemons.cflow: tools.cflow | |
76 | cflow: include.cflow | |
77 | endif | |
78 | ||
79 | CSCOPE_DIRS = base daemons device_mapper include lib libdaemon scripts tools libdm test | |
80 | ifneq ("@CSCOPE_CMD@", "") | |
81 | cscope.out: | |
82 | @CSCOPE_CMD@ -b -R $(patsubst %,-s%,$(addprefix $(srcdir)/,$(CSCOPE_DIRS))) | |
83 | all: cscope.out | |
84 | endif | |
85 | DISTCLEAN_TARGETS += cscope.out | |
86 | CLEAN_DIRS += autom4te.cache | |
87 | ||
88 | check check_system check_cluster check_local check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock: test | |
89 | $(MAKE) -C test $(@) | |
90 | ||
91 | conf.generate man.generate: tools | |
92 | ||
93 | # how to use parenthesis in makefiles | |
94 | leftparen:=( | |
95 | LVM_VER := $(firstword $(subst $(leftparen), ,$(LVM_VERSION))) | |
96 | VER := LVM2.$(LVM_VER) | |
97 | # release file name | |
98 | FILE_VER := $(VER).tgz | |
99 | CLEAN_TARGETS += $(FILE_VER) | |
100 | CLEAN_DIRS += $(rpmbuilddir) | |
101 | ||
102 | dist: | |
103 | @echo "Generating $(FILE_VER)";\ | |
104 | (cd $(top_srcdir); git ls-tree -r HEAD --name-only | xargs tar --transform "s,^,$(VER)/," -c) | gzip >$(FILE_VER) | |
105 | ||
106 | rpm: dist | |
107 | $(RM) -r $(rpmbuilddir)/SOURCES | |
108 | $(MKDIR_P) $(rpmbuilddir)/SOURCES | |
109 | $(LN_S) -f $(abs_top_builddir)/$(FILE_VER) $(rpmbuilddir)/SOURCES | |
110 | $(LN_S) -f $(abs_top_srcdir)/spec/build.inc $(rpmbuilddir)/SOURCES | |
111 | $(LN_S) -f $(abs_top_srcdir)/spec/macros.inc $(rpmbuilddir)/SOURCES | |
112 | $(LN_S) -f $(abs_top_srcdir)/spec/packages.inc $(rpmbuilddir)/SOURCES | |
113 | DM_VER=$$(cut -d- -f1 $(top_srcdir)/VERSION_DM);\ | |
114 | GIT_VER=$$(cd $(top_srcdir); git describe | cut -d- --output-delimiter=. -f2,3 || echo 0);\ | |
115 | $(SED) -e "s,\(device_mapper_version\) [0-9.]*$$,\1 $$DM_VER," \ | |
116 | -e "s,^\(Version:[^0-9%]*\)[0-9.]*$$,\1 $(LVM_VER)," \ | |
117 | -e "s,^\(Release:[^0-9%]*\)[0-9.]\+,\1 $$GIT_VER," \ | |
118 | $(top_srcdir)/spec/source.inc >$(rpmbuilddir)/SOURCES/source.inc | |
119 | V=$(V) rpmbuild -v --define "_topdir $(rpmbuilddir)" -ba $(top_srcdir)/spec/lvm2.spec | |
120 | ||
121 | generate: conf.generate man.generate | |
122 | $(MAKE) -C conf generate | |
123 | $(MAKE) -C man generate | |
124 | ||
125 | all_man: | |
126 | $(MAKE) -C man all_man | |
127 | ||
128 | install_system_dirs: | |
129 | $(INSTALL_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR) | |
130 | $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR)/devices | |
131 | $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_ARCHIVE_DIR) | |
132 | $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_BACKUP_DIR) | |
133 | $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_CACHE_DIR) | |
134 | $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_LOCK_DIR) | |
135 | $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_RUN_DIR) | |
136 | $(INSTALL_ROOT_DATA) /dev/null $(DESTDIR)$(DEFAULT_CACHE_DIR)/.cache | |
137 | ||
138 | install_initscripts: | |
139 | $(MAKE) -C scripts install_initscripts | |
140 | ||
141 | install_systemd_generators: | |
142 | $(MAKE) -C scripts install_systemd_generators | |
143 | $(MAKE) -C man install_systemd_generators | |
144 | ||
145 | install_systemd_units: | |
146 | $(MAKE) -C scripts install_systemd_units | |
147 | ||
148 | install_all_man: | |
149 | $(MAKE) -C man install_all_man | |
150 | ||
151 | install_tmpfiles_configuration: | |
152 | $(MAKE) -C scripts install_tmpfiles_configuration | |
153 | ||
154 | help: | |
155 | @echo -e "\nAvailable targets:" | |
156 | @echo " all Default target." | |
157 | @echo " all_man Build all man pages with generators." | |
158 | @echo " clean Remove all compile files." | |
159 | @echo " device-mapper Device mapper part of lvm2." | |
160 | @echo " dist Generate distributable file." | |
161 | @echo " distclean Remove all build files." | |
162 | @echo " generate Generate man pages for sources." | |
163 | @echo " help Display callable targets." | |
164 | @echo " install Install all files." | |
165 | @echo " install_all_man Install all man pages." | |
166 | @echo " install_cluster Install cmirrord." | |
167 | @echo " install_device-mapper Install device mapper files." | |
168 | @echo " install_initscripts Install initialization scripts." | |
169 | @echo " install_lvm2 Install lvm2 files." | |
170 | @echo " install_systemd_units Install systemd units." | |
171 | @echo " lcov Generate lcov output." | |
172 | @echo " lcov-dated Generate lcov with timedate suffix." | |
173 | @echo " lcov-reset Reset lcov counters" | |
174 | @echo " man Build man pages." | |
175 | @echo " print-VARIABLE Resolve make variable." | |
176 | @echo " rpm Build rpm." | |
177 | @echo " run-unit-test Run unit tests." | |
178 | @echo " tags Generate c/etags." | |
179 | ||
180 | ifneq ("$(LCOV)", "") | |
181 | .PHONY: lcov-reset lcov lcov-dated | |
182 | ||
183 | ifeq ($(MAKECMDGOALS),lcov-dated) | |
184 | LCOV_REPORTS_DIR := lcov_reports-$(shell date +%Y%m%d%k%M%S) | |
185 | lcov-dated: lcov | |
186 | else | |
187 | LCOV_REPORTS_DIR := lcov_reports | |
188 | endif | |
189 | ||
190 | lcov-reset: | |
191 | $(LCOV) --zerocounters --directory $(top_builddir) | |
192 | ||
193 | ifneq ("$(GENHTML)", "") | |
194 | lcov: | |
195 | $(RM) -rf $(LCOV_REPORTS_DIR) | |
196 | $(MKDIR_P) $(LCOV_REPORTS_DIR) | |
197 | $(LCOV) --capture --directory $(top_builddir) --ignore-errors source \ | |
198 | --output-file $(LCOV_REPORTS_DIR)/out.info | |
199 | -test ! -s $(LCOV_REPORTS_DIR)/out.info || \ | |
200 | $(GENHTML) -o $(LCOV_REPORTS_DIR) --ignore-errors source \ | |
201 | $(LCOV_REPORTS_DIR)/out.info | |
202 | endif | |
203 | ||
204 | endif | |
205 | ||
206 | ifneq ($(shell which ctags 2>/dev/null),) | |
207 | .PHONY: tags | |
208 | tags: | |
209 | test -z "$(shell find $(addprefix $(top_srcdir)/,$(CSCOPE_DIRS)) -type f -name '*.[ch]' -newer tags 2>/dev/null | head -1)" || $(RM) tags | |
210 | test -f tags || find $(addprefix $(top_srcdir)/,$(CSCOPE_DIRS)) -maxdepth 5 -type f -name '*.[ch]' -exec ctags -a '{}' + | |
211 | ||
212 | CLEAN_TARGETS += tags | |
213 | endif |