]>
Commit | Line | Data |
---|---|---|
1 | # @configure_input@ | |
2 | # | |
3 | # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. | |
4 | # Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved. | |
5 | # | |
6 | # This file is part of LVM2. | |
7 | # | |
8 | # This copyrighted material is made available to anyone wishing to use, | |
9 | # modify, copy, or redistribute it subject to the terms and conditions | |
10 | # of the GNU General Public License v.2. | |
11 | # | |
12 | # You should have received a copy of the GNU General Public License | |
13 | # along with this program; if not, write to the Free Software Foundation, | |
14 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
15 | ||
16 | ||
17 | V ?= $(if ("@SILENT_RULES@","yes"),,1) | |
18 | Q := $(if $(V),,@) | |
19 | SHOW := $(if $(V),@true,@echo) | |
20 | ||
21 | SHELL = @SHELL@ | |
22 | ||
23 | @SET_MAKE@ | |
24 | ||
25 | # Allow environment to override any built-in default value for CC. | |
26 | # If there is a built-in default, CC is NOT set to @CC@ here. | |
27 | CC ?= @CC@ | |
28 | ||
29 | # If $(CC) holds the usual built-in default value of 'cc' then replace it with | |
30 | # the configured value. | |
31 | # (To avoid this and force the use of 'cc' from the environment, supply its | |
32 | # full path.) | |
33 | ifeq ($(CC), cc) | |
34 | CC = @CC@ | |
35 | endif | |
36 | ||
37 | RANLIB = @RANLIB@ | |
38 | INSTALL = @INSTALL@ | |
39 | MKDIR_P = @MKDIR_P@ | |
40 | MSGFMT = @MSGFMT@ | |
41 | LCOV = @LCOV@ | |
42 | GENHTML = @GENHTML@ | |
43 | LN_S = @LN_S@ | |
44 | SED = @SED@ | |
45 | CFLOW_CMD = @CFLOW_CMD@ | |
46 | AWK = @AWK@ | |
47 | CHMOD = @CHMOD@ | |
48 | EGREP = @EGREP@ | |
49 | GREP = @GREP@ | |
50 | SORT = @SORT@ | |
51 | WC = @WC@ | |
52 | AR = @AR@ | |
53 | RM = rm -f | |
54 | ||
55 | PYTHON2 = @PYTHON2@ | |
56 | PYTHON3 = @PYTHON3@ | |
57 | PYCOMPILE = $(top_srcdir)/autoconf/py-compile | |
58 | ||
59 | LIBS += @LIBS@ $(SELINUX_LIBS) $(UDEV_LIBS) $(RT_LIBS) $(M_LIBS) | |
60 | LVMLIBS = $(DMEVENT_LIBS) $(READLINE_LIBS) $(EDITLINE_LIBS) $(LIBSYSTEMD_LIBS) $(BLKID_LIBS) $(AIO_LIBS) $(LIBS) | |
61 | # Extra libraries always linked with static binaries | |
62 | STATIC_LIBS = $(PTHREAD_LIBS) $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS) $(M_LIBS) | |
63 | DEFS += @DEFS@ | |
64 | # FIXME set this only where it's needed, not globally? | |
65 | CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@ | |
66 | CPPFLAGS ?= @CPPFLAGS@ | |
67 | LDFLAGS ?= @LDFLAGS@ | |
68 | STATIC_LDFLAGS += @STATIC_LDFLAGS@ | |
69 | CLDFLAGS += @CLDFLAGS@ | |
70 | ELDFLAGS += @ELDFLAGS@ | |
71 | LDDEPS += @LDDEPS@ | |
72 | LIB_SUFFIX = @LIB_SUFFIX@ | |
73 | USE_TRACKING = @USE_TRACKING@ | |
74 | ||
75 | DL_LIBS = @DL_LIBS@ | |
76 | RT_LIBS = @RT_LIBS@ | |
77 | M_LIBS = @M_LIBS@ | |
78 | AIO_CFLAGS = @AIO_CFLAGS@ | |
79 | AIO_LIBS = @AIO_LIBS@ | |
80 | BLKID_CFLAGS = @BLKID_CFLAGS@ | |
81 | BLKID_LIBS = @BLKID_LIBS@ | |
82 | BLKID_STATIC_LIBS = @BLKID_STATIC_LIBS@ | |
83 | CPG_CFLAGS = @CPG_CFLAGS@ | |
84 | CPG_LIBS = @CPG_LIBS@ | |
85 | EDITLINE_CFLAGS = @EDITLINE_CFLAGS@ | |
86 | EDITLINE_LIBS = @EDITLINE_LIBS@ | |
87 | LIBDLM_CFLAGS = @LIBDLM_CFLAGS@ | |
88 | LIBDLM_LIBS = @LIBDLM_LIBS@ | |
89 | LIBDLMCONTROL_CFLAGS = @LIBDLMCONTROL_CFLAGS@ | |
90 | LIBDLMCONTROL_LIBS = @LIBDLMCONTROL_LIBS@ | |
91 | LIBSANLOCKCLIENT_CFLAGS = @LIBSANLOCKCLIENT_CFLAGS@ | |
92 | LIBSANLOCKCLIENT_LIBS = @LIBSANLOCKCLIENT_LIBS@ | |
93 | LIBSEAGATEILM_CFLAGS = @LIBSEAGATEILM_CFLAGS@ | |
94 | LIBSEAGATEILM_LIBS = @LIBSEAGATEILM_LIBS@ | |
95 | LIBSYSTEMD_CFLAGS = @LIBSYSTEMD_CFLAGS@ | |
96 | LIBSYSTEMD_LIBS = @LIBSYSTEMD_LIBS@ | |
97 | PTHREAD_LIBS = @PTHREAD_LIBS@ | |
98 | READLINE_CFLAGS = @READLINE_CFLAGS@ | |
99 | READLINE_LIBS = @READLINE_LIBS@ | |
100 | SELINUX_LIBS = @SELINUX_LIBS@ | |
101 | SELINUX_STATIC_LIBS = @SELINUX_STATIC_LIBS@ | |
102 | UDEV_CFLAGS = @UDEV_CFLAGS@ | |
103 | UDEV_LIBS = @UDEV_LIBS@ | |
104 | UDEV_STATIC_LIBS = @UDEV_STATIC_LIBS@ | |
105 | VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ | |
106 | VALGRIND_LIBS = @VALGRIND_LIBS@ | |
107 | ||
108 | # Setup directory variables | |
109 | prefix = @prefix@ | |
110 | exec_prefix = @exec_prefix@ | |
111 | udev_prefix = @udev_prefix@ | |
112 | sysconfdir = @sysconfdir@ | |
113 | rootdir = $(DESTDIR)/ | |
114 | bindir = $(DESTDIR)@bindir@ | |
115 | confdir = $(DESTDIR)@CONFDIR@/lvm | |
116 | profiledir = $(confdir)/@DEFAULT_PROFILE_SUBDIR@ | |
117 | includedir = $(DESTDIR)@includedir@ | |
118 | libdir = $(DESTDIR)@libdir@ | |
119 | libexecdir = $(DESTDIR)@libexecdir@ | |
120 | usrlibdir = $(DESTDIR)@usrlibdir@ | |
121 | sbindir = $(DESTDIR)@sbindir@ | |
122 | usrsbindir = $(DESTDIR)@usrsbindir@ | |
123 | datarootdir = @datarootdir@ | |
124 | datadir = $(DESTDIR)@datadir@ | |
125 | infodir = $(DESTDIR)@infodir@ | |
126 | mandir = $(DESTDIR)@mandir@ | |
127 | localedir = $(DESTDIR)@localedir@ | |
128 | staticdir = $(DESTDIR)@STATICDIR@ | |
129 | udevdir = $(DESTDIR)@udevdir@ | |
130 | pkgconfigdir = $(usrlibdir)/pkgconfig | |
131 | initdir = $(DESTDIR)$(sysconfdir)/rc.d/init.d | |
132 | dbusconfdir = $(DESTDIR)$(sysconfdir)/dbus-1/system.d | |
133 | dbusservicedir = $(datadir)/dbus-1/system-services | |
134 | systemd_unit_dir = $(DESTDIR)@systemdsystemunitdir@ | |
135 | systemd_generator_dir = $(DESTDIR)$(SYSTEMD_GENERATOR_DIR) | |
136 | systemd_dir = $(DESTDIR)@systemdutildir@ | |
137 | tmpfiles_dir = $(DESTDIR)@tmpfilesdir@ | |
138 | ocf_scriptdir = $(DESTDIR)@OCFDIR@ | |
139 | PYTHON_PREFIX = $(prefix) | |
140 | ||
141 | # N.B. No $(DESTDIR) prefix here. | |
142 | python2dir = @PYTHON2DIR@ | |
143 | python3dir = @PYTHON3DIR@ | |
144 | ||
145 | # Define macro NewLine for use in $(foreach) with 2 blank lines | |
146 | ifeq (1, $(firstword $(V))) | |
147 | define newline | |
148 | ||
149 | ||
150 | endef | |
151 | else | |
152 | define newline | |
153 | ; | |
154 | endef | |
155 | endif | |
156 | ||
157 | USRLIB_RELPATH = $(shell echo $(abspath $(usrlibdir) $(libdir)) | \ | |
158 | $(AWK) -f $(top_srcdir)/scripts/relpath.awk) | |
159 | ||
160 | SYSTEMD_GENERATOR_DIR = @systemdutildir@/system-generators | |
161 | DEFAULT_SYS_DIR = @DEFAULT_SYS_DIR@ | |
162 | DEFAULT_ARCHIVE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_ARCHIVE_SUBDIR@ | |
163 | DEFAULT_BACKUP_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_BACKUP_SUBDIR@ | |
164 | DEFAULT_CACHE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_CACHE_SUBDIR@ | |
165 | DEFAULT_PROFILE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_PROFILE_SUBDIR@ | |
166 | DEFAULT_LOCK_DIR = @DEFAULT_LOCK_DIR@ | |
167 | DEFAULT_RUN_DIR = @DEFAULT_RUN_DIR@ | |
168 | DEFAULT_PID_DIR = @DEFAULT_PID_DIR@ | |
169 | DEFAULT_MANGLING = @MANGLING@ | |
170 | DEFAULT_DMEVENTD_EXIT_ON_PATH = @DEFAULT_DMEVENTD_EXIT_ON_PATH@ | |
171 | ||
172 | #---------------------------------------------------------------------- | |
173 | # From http://blog.melski.net/tag/debugging-makefiles/ | |
174 | # | |
175 | # Usage: make print-CC print-CXX print-LD | |
176 | #---------------------------------------------------------------------- | |
177 | print-%: | |
178 | @echo '$*=$($*)' | |
179 | @echo ' origin = $(origin $*)' | |
180 | @echo ' flavor = $(flavor $*)' | |
181 | @echo ' value = $(value $*)' | |
182 | ||
183 | # Setup vpath search paths for some suffixes | |
184 | vpath %.c $(srcdir) | |
185 | vpath %.cpp $(srcdir) | |
186 | vpath %.in $(srcdir) | |
187 | vpath %.po $(srcdir) | |
188 | vpath %.exported_symbols $(srcdir) | |
189 | ||
190 | interface = @interface@ | |
191 | interfacebuilddir = $(top_builddir)/libdm/$(interface) | |
192 | rpmbuilddir = $(abs_top_builddir)/build | |
193 | ||
194 | # The number of jobs to run, if blank, defaults to the make standard | |
195 | ifndef MAKEFLAGS | |
196 | MAKEFLAGS = @JOBS@ | |
197 | endif | |
198 | ||
199 | # Hiding dir entering makes hard for editors to look for files | |
200 | #ifneq (1, $(firstword $(V))) | |
201 | #MAKEFLAGS += --no-print-directory | |
202 | #endif | |
203 | ||
204 | # Handle installation of files | |
205 | ifeq ("@WRITE_INSTALL@", "yes") | |
206 | # leaving defaults | |
207 | M_INSTALL_SCRIPT = -m 755 | |
208 | M_INSTALL_DATA = -m 644 | |
209 | else | |
210 | M_INSTALL_PROGRAM = -m 555 | |
211 | M_INSTALL_DATA = -m 444 | |
212 | endif | |
213 | INSTALL_PROGRAM = $(INSTALL) $(M_INSTALL_PROGRAM) $(STRIP) | |
214 | INSTALL_DATA = $(INSTALL) -p $(M_INSTALL_DATA) | |
215 | INSTALL_WDATA = $(INSTALL) -p -m 644 | |
216 | ||
217 | INSTALL_DIR = $(INSTALL) -m 755 -d | |
218 | INSTALL_ROOT_DIR = $(INSTALL) -m 700 -d | |
219 | INSTALL_ROOT_DATA = $(INSTALL) -m 600 | |
220 | INSTALL_SCRIPT = $(INSTALL) -p $(M_INSTALL_PROGRAM) | |
221 | ||
222 | .SUFFIXES: | |
223 | .SUFFIXES: .c .cpp .d .o .so .a .po .pot .mo .dylib | |
224 | ||
225 | ifeq ("$(notdir $(CC))", "gcc") | |
226 | WFLAGS +=\ | |
227 | -Wall\ | |
228 | -Wcast-align\ | |
229 | -Wfloat-equal\ | |
230 | -Wformat-security\ | |
231 | -Winline\ | |
232 | -Wmissing-format-attribute\ | |
233 | -Wmissing-include-dirs\ | |
234 | -Wmissing-noreturn\ | |
235 | -Wpointer-arith\ | |
236 | -Wredundant-decls\ | |
237 | -Wshadow\ | |
238 | -Wundef\ | |
239 | -Wwrite-strings | |
240 | ||
241 | WCFLAGS +=\ | |
242 | -Wmissing-declarations\ | |
243 | -Wmissing-prototypes\ | |
244 | -Wnested-externs\ | |
245 | -Wold-style-definition\ | |
246 | -Wstrict-prototypes\ | |
247 | -Wuninitialized | |
248 | ||
249 | ifeq ("@HAVE_WJUMP@", "yes") | |
250 | WCFLAGS += -Wjump-misses-init | |
251 | endif | |
252 | ||
253 | ifeq ("@HAVE_WCLOBBERED@", "yes") | |
254 | WFLAGS +=\ | |
255 | -Wclobbered\ | |
256 | -Wempty-body\ | |
257 | -Wignored-qualifiers\ | |
258 | -Wlogical-op\ | |
259 | -Wtype-limits | |
260 | ||
261 | WCFLAGS +=\ | |
262 | -Wmissing-parameter-type\ | |
263 | -Wold-style-declaration\ | |
264 | -Woverride-init | |
265 | endif | |
266 | ||
267 | ifeq ("@HAVE_WSYNCNAND@", "yes") | |
268 | WFLAGS += -Wsync-nand | |
269 | endif | |
270 | endif | |
271 | ||
272 | ifeq ("@HAVE_FULL_RELRO@", "yes") | |
273 | comma := , | |
274 | ifneq ("@STATIC_LINK@", "yes") | |
275 | ifeq (,$(findstring -z$(comma)relro,$(LDFLAGS))) | |
276 | LDFLAGS += -Wl,-z,relro | |
277 | endif | |
278 | ifeq (,$(findstring -z$(comma)now,$(LDFLAGS))) | |
279 | LDFLAGS += -Wl,-z,now | |
280 | endif | |
281 | # TODO: think about configure option for this flag | |
282 | # for now leave decision on distro maintainer | |
283 | #ifeq (,$(findstring -z$(comma)pack-relative-relocs,$(LDFLAGS))) | |
284 | # LDFLAGS += -Wl,-z,pack-relative-relocs | |
285 | #endif | |
286 | # For systems with old readline library that requires extra libs to link with | |
287 | # we stick to default --no-as-needed and we avoid adding --as-needed flag | |
288 | ifneq (-l,$(findstring -l,$(filter-out %readline,$(READLINE_LIBS)))) | |
289 | ifeq (,$(findstring --as-needed,$(LDFLAGS))) | |
290 | LDFLAGS += -Wl,--as-needed | |
291 | endif | |
292 | endif | |
293 | ||
294 | ifeq ("@HAVE_PIE@", "yes") | |
295 | EXTRA_EXEC_CFLAGS += -fPIE | |
296 | EXTRA_EXEC_LDFLAGS += -pie -fPIE | |
297 | endif | |
298 | endif | |
299 | endif | |
300 | ||
301 | #WFLAGS += -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers | |
302 | #WFLAGS += -Wsign-compare -Wunused-parameter -Wmissing-field-initializers | |
303 | #WFLAGS += -Wconversion -Wbad-function-cast -Wcast-qual -Waggregate-return -Wpacked | |
304 | #WFLAGS += -pedantic -std=gnu99 | |
305 | #DEFS += -DDEBUG_CRC32 | |
306 | ||
307 | # | |
308 | # Avoid recursive extension of CFLAGS | |
309 | # by checking whether CFLAGS already has fPIC string | |
310 | # | |
311 | ifeq (,$(findstring fPIC,$(CFLAGS))) | |
312 | ||
313 | CFLAGS += -fPIC | |
314 | ||
315 | ifeq ("@DEBUG@", "yes") | |
316 | ifeq (,$(findstring -g,$(CFLAGS))) | |
317 | CFLAGS += -g | |
318 | endif | |
319 | CFLAGS += -fno-omit-frame-pointer | |
320 | DEFS += -DDEBUG | |
321 | # memory debugging is not thread-safe yet | |
322 | ifneq ("@BUILD_DMEVENTD@", "yes") | |
323 | ifneq ("@BUILD_LVMLOCKD@", "yes") | |
324 | ifneq ("@BUILD_LVMPOLLD@", "yes") | |
325 | DEFS += -DDEBUG_MEM | |
326 | endif | |
327 | endif | |
328 | endif | |
329 | endif | |
330 | ||
331 | # end of fPIC protection | |
332 | endif | |
333 | ||
334 | ifeq ("@BUILD_DMEVENTD@", "yes") | |
335 | DMEVENT_LIBS = -L$(top_builddir)/daemons/dmeventd -ldevmapper-event -L$(interfacebuilddir) -ldevmapper | |
336 | endif | |
337 | ||
338 | # Combination of DEBUG_POOL and DEBUG_ENFORCE_POOL_LOCKING is not supported. | |
339 | #DEFS += -DDEBUG_POOL | |
340 | # Default pool locking is using the crc checksum. With mprotect memory | |
341 | # enforcing compilation faulty memory write could be easily found. | |
342 | #DEFS += -DDEBUG_ENFORCE_POOL_LOCKING | |
343 | #DEFS += -DBOUNDS_CHECK | |
344 | ||
345 | # LVM is not supposed to use mmap while devices are suspended. | |
346 | # This code causes a core dump if gets called. | |
347 | #DEFS += -DDEBUG_MEMLOCK | |
348 | ||
349 | #CFLAGS += -pg | |
350 | #LDFLAGS += -pg | |
351 | ||
352 | STRIP= | |
353 | #STRIP = -s | |
354 | ||
355 | LVM_VERSION := $(shell cat $(top_srcdir)/VERSION) | |
356 | ||
357 | LIB_VERSION_LVM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)/VERSION) | |
358 | ||
359 | LIB_VERSION_DM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)/VERSION_DM) | |
360 | ||
361 | LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_srcdir)/VERSION) | |
362 | ||
363 | INCLUDES += -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)/include -include configure.h | |
364 | ||
365 | #VDO_INCLUDES=-I@VDO_INCLUDE@ | |
366 | ||
367 | DEPS = $(top_builddir)/make.tmpl $(top_srcdir)/VERSION \ | |
368 | $(top_builddir)/Makefile | |
369 | ||
370 | OBJECTS = $(SOURCES:%.c=%.o) $(CXXSOURCES:%.cpp=%.o) | |
371 | POTFILES = $(SOURCES:%.c=%.pot) | |
372 | ||
373 | .PHONY: all pofile distclean clean cleandir cflow device-mapper | |
374 | .PHONY: install install_cluster install_device-mapper install_lvm2 | |
375 | .PHONY: install_dbus_service | |
376 | .PHONY: install_lib_shared install_dm_plugin install_lvm2_plugin | |
377 | .PHONY: install_ocf install_systemd_generators install_all_man all_man man help | |
378 | .PHONY: python_bindings install_python_bindings | |
379 | .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean) | |
380 | .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow) | |
381 | .PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper) | |
382 | .PHONY: $(SUBDIRS.generate) generate | |
383 | ||
384 | SUBDIRS.device-mapper := $(SUBDIRS:=.device-mapper) | |
385 | SUBDIRS.install := $(SUBDIRS:=.install) | |
386 | SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster) | |
387 | SUBDIRS.install_device-mapper := $(SUBDIRS:=.install_device-mapper) | |
388 | SUBDIRS.install_lvm2 := $(SUBDIRS:=.install_lvm2) | |
389 | SUBDIRS.install_ocf := $(SUBDIRS:=.install_ocf) | |
390 | SUBDIRS.pofile := $(SUBDIRS:=.pofile) | |
391 | SUBDIRS.cflow := $(SUBDIRS:=.cflow) | |
392 | SUBDIRS.clean := $(SUBDIRS:=.clean) | |
393 | SUBDIRS.distclean := $(SUBDIRS:=.distclean) | |
394 | ||
395 | TARGETS += $(LIB_STATIC) | |
396 | ifeq ("@SHARED_LINK@", "yes") | |
397 | TARGETS += $(LIB_SHARED) | |
398 | endif | |
399 | ||
400 | INTERNAL_LIBS = \ | |
401 | $(top_builddir)/libdaemon/client/libdaemonclient.a \ | |
402 | $(top_builddir)/device_mapper/libdevice-mapper.a \ | |
403 | $(top_builddir)/base/libbase.a | |
404 | LVMINTERNAL_LIBS = $(top_builddir)/lib/liblvm-internal.a $(INTERNAL_LIBS) | |
405 | ||
406 | all: $(SUBDIRS) $(TARGETS) | |
407 | ||
408 | install: $(SUBDIRS.install) | |
409 | install_cluster: $(SUBDIRS.install_cluster) | |
410 | install_device-mapper: $(SUBDIRS.install_device-mapper) | |
411 | install_device_mapper: install_device-mapper | |
412 | install_lvm2: $(SUBDIRS.install_lvm2) | |
413 | install_ocf: $(SUBDIRS.install_ocf) | |
414 | cflow: $(SUBDIRS.cflow) | |
415 | ||
416 | $(SUBDIRS): $(SUBDIRS.device-mapper) | |
417 | $(MAKE) -C $@ | |
418 | ||
419 | $(SUBDIRS.device-mapper): | |
420 | $(MAKE) -C $(@:.device-mapper=) device-mapper | |
421 | ||
422 | $(SUBDIRS.install): $(SUBDIRS) | |
423 | $(MAKE) -C $(@:.install=) install | |
424 | ||
425 | $(SUBDIRS.install_cluster): $(SUBDIRS) | |
426 | $(MAKE) -C $(@:.install_cluster=) install_cluster | |
427 | ||
428 | $(SUBDIRS.install_device-mapper): device-mapper | |
429 | $(MAKE) -C $(@:.install_device-mapper=) install_device-mapper | |
430 | ||
431 | $(SUBDIRS.install_lvm2): $(SUBDIRS) | |
432 | $(MAKE) -C $(@:.install_lvm2=) install_lvm2 | |
433 | ||
434 | $(SUBDIRS.install_ocf): | |
435 | $(MAKE) -C $(@:.install_ocf=) install_ocf | |
436 | ||
437 | $(SUBDIRS.clean): | |
438 | -$(MAKE) -C $(@:.clean=) clean | |
439 | ||
440 | $(SUBDIRS.distclean): | |
441 | -$(MAKE) -C $(@:.distclean=) distclean | |
442 | ||
443 | $(SUBDIRS.cflow): | |
444 | $(MAKE) -C $(@:.cflow=) cflow | |
445 | ||
446 | ifeq ("@INTL@", "yes") | |
447 | pofile: $(SUBDIRS.pofile) $(POTFILES) | |
448 | ||
449 | $(SUBDIRS.pofile): | |
450 | $(MAKE) -C $(@:.pofile=) pofile | |
451 | endif | |
452 | ||
453 | $(SUBDIRS.generate): | |
454 | $(MAKE) -C $(@:.generate=) generate | |
455 | ||
456 | ifneq ("$(CFLOW_LIST_TARGET)", "") | |
457 | CLEAN_CFLOW += $(CFLOW_LIST_TARGET) | |
458 | $(CFLOW_LIST_TARGET): $(CFLOW_LIST) | |
459 | echo "CFLOW_SOURCES += $(addprefix $(abs_srcdir)/, $(CFLOW_LIST))" > $@ | |
460 | cflow: $(CFLOW_LIST_TARGET) | |
461 | endif | |
462 | ||
463 | ifneq ("$(CFLOW_TARGET)", "") | |
464 | CLEAN_CFLOW += \ | |
465 | $(CFLOW_TARGET).cflow \ | |
466 | $(CFLOW_TARGET).xref \ | |
467 | $(CFLOW_TARGET).tree \ | |
468 | $(CFLOW_TARGET).rtree \ | |
469 | $(CFLOW_TARGET).rxref | |
470 | ||
471 | ifneq ("$(CFLOW_CMD)", "") | |
472 | CFLOW_FLAGS +=\ | |
473 | --cpp="$(CC) -E $(INCLUDES) $(VALGRIND_CFLAGS) $(BLKID_CFLAGS) $(DEFS)" \ | |
474 | --symbol _ISbit:wrapper \ | |
475 | --symbol __asm__:wrapper \ | |
476 | --symbol __attribute__:wrapper \ | |
477 | --symbol __inline:=inline \ | |
478 | --symbol __inline__:=inline \ | |
479 | --symbol __const:type \ | |
480 | --symbol __const__:wrapper \ | |
481 | --symbol __extension__:wrapper \ | |
482 | --symbol __leaf__:wrapper \ | |
483 | --symbol __nonnull:wrapper \ | |
484 | --symbol __nothrow__:wrapper \ | |
485 | --symbol __pure__:wrapper \ | |
486 | --symbol __REDIRECT:wrapper \ | |
487 | --symbol __REDIRECT_NTH:wrapper \ | |
488 | --symbol __restrict:=restrict \ | |
489 | --symbol __wur:wrapper | |
490 | ||
491 | $(CFLOW_TARGET).cflow: $(CFLOW_SOURCES) | |
492 | $(CFLOW_CMD) -o$@ $(CFLOW_FLAGS) $(CFLOW_SOURCES) | |
493 | $(CFLOW_TARGET).rxref: $(CFLOW_SOURCES) | |
494 | $(CFLOW_CMD) -o$@ $(CFLOW_FLAGS) -r --omit-arguments $(CFLOW_SOURCES) | |
495 | $(CFLOW_TARGET).tree: $(CFLOW_SOURCES) | |
496 | $(CFLOW_CMD) -o$@ $(CFLOW_FLAGS) --omit-arguments -T -b $(CFLOW_SOURCES) | |
497 | $(CFLOW_TARGET).xref: $(CFLOW_SOURCES) | |
498 | $(CFLOW_CMD) -o$@ $(CFLOW_FLAGS) --omit-arguments -x $(CFLOW_SOURCES) | |
499 | #$(CFLOW_TARGET).rtree: $(CFLOW_SOURCES) | |
500 | # $(CFLOW_CMD) -o$@ $(CFLOW_FLAGS) -r --omit-arguments -T -b $(CFLOW_SOURCES) | |
501 | cflow: $(CFLOW_TARGET).cflow $(CFLOW_TARGET).tree $(CFLOW_TARGET).rxref $(CFLOW_TARGET).xref | |
502 | #$(CFLOW_TARGET).rtree | |
503 | endif | |
504 | endif | |
505 | ||
506 | .LIBPATTERNS = lib%.so lib%.a | |
507 | ||
508 | DEPFLAGS=-MT $@ -MMD -MP -MF $*.d | |
509 | ||
510 | # still needed in 2018 for 32bit builds | |
511 | DEFS+=-D_FILE_OFFSET_BITS=64 | |
512 | ||
513 | %.o: %.c $(DEPS) | |
514 | $(SHOW) " [CC] $(<F)" | |
515 | @mkdir -p $(@D) | |
516 | $(Q) $(CC) $(DEPFLAGS) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $(CPPFLAGS) $< -o $@ | |
517 | ||
518 | %.o: %.cpp $(DEPS) | |
519 | $(SHOW) " [CXX] $(<F)" | |
520 | @mkdir -p $(@D) | |
521 | $(Q) $(CXX) $(DEPFLAGS) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(CXXFLAGS) $(CXXFLAGS_$@) $< -o $@ | |
522 | ||
523 | %.pot: %.c $(DEPS) | |
524 | $(SHOW) " [CC] $(<F)" | |
525 | @mkdir -p $(@D) | |
526 | $(Q) $(CC) -E $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) -include $(top_builddir)/po/pogen.h $(DEFS) $(WFLAGS) $(CFLAGS) $(CPPFLAGS) $< >$@ | |
527 | ||
528 | %.so: %.o | |
529 | $(SHOW) " [CC] $(<F)" | |
530 | $(Q) $(CC) -c $(CFLAGS) $(LDFLAGS) $(CLDFLAGS) $< $(LIBS) -o $@ | |
531 | ||
532 | ifneq (,$(LIB_SHARED)) | |
533 | ||
534 | TARGETS += $(LIB_SHARED).$(LIB_VERSION) | |
535 | $(LIB_SHARED).$(LIB_VERSION): $(OBJECTS) $(LDDEPS) | |
536 | $(SHOW) " [CC] $@" | |
537 | ifeq ("@LIB_SUFFIX@","so") | |
538 | $(Q) $(CC) -shared -Wl,-soname,$(notdir $@) \ | |
539 | $(CFLAGS) $(LDFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ | |
540 | endif | |
541 | ifeq ("@LIB_SUFFIX@","dylib") | |
542 | $(Q) $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \ | |
543 | $(CFLAGS) $(LDFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ | |
544 | endif | |
545 | ||
546 | $(LIB_SHARED): $(LIB_SHARED).$(LIB_VERSION) | |
547 | $(SHOW) " [LN] $@" | |
548 | $(Q) $(LN_S) -f $(<F) $@ | |
549 | ||
550 | CLEAN_TARGETS += $(LDDEPS) .exported_symbols_generated | |
551 | ||
552 | install_lib_shared: $(LIB_SHARED) | |
553 | $(SHOW) " [INSTALL] $<" | |
554 | $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION) | |
555 | $(Q) $(INSTALL_DIR) $(usrlibdir) | |
556 | $(Q) $(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F) | |
557 | ||
558 | # FIXME: plugins are installed to subdirs | |
559 | # and for compatibility links in libdir are created | |
560 | # when the code is fixed links could be removed. | |
561 | install_dm_plugin: $(LIB_SHARED) | |
562 | $(SHOW) " [INSTALL] $<" | |
563 | $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/device-mapper/$(<F) | |
564 | $(Q) $(LN_S) -f device-mapper/$(<F) $(libdir)/$(<F) | |
565 | ||
566 | install_lvm2_plugin: $(LIB_SHARED) | |
567 | $(SHOW) " [INSTALL] $<" | |
568 | $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/lvm2/$(<F) | |
569 | $(Q) $(LN_S) -f lvm2/$(<F) $(libdir)/$(<F) | |
570 | $(Q) $(LN_S) -f $(<F) $(libdir)/$(<F).$(LIB_VERSION) | |
571 | endif | |
572 | ||
573 | $(LIB_STATIC): $(OBJECTS) | |
574 | $(SHOW) " [AR] $@" | |
575 | $(Q) $(RM) $@ | |
576 | $(Q) $(AR) rsv $@ $(OBJECTS) > /dev/null | |
577 | ||
578 | %.d: | |
579 | .PRECIOUS: %.d | |
580 | ||
581 | %.mo: %.po | |
582 | $(SHOW) " [MSGFMT] $(<F)" | |
583 | $(Q) $(MSGFMT) -o $@ $< | |
584 | ||
585 | CLEAN_TARGETS += \ | |
586 | $(SOURCES:%.c=%.d) $(SOURCES:%.c=%.gcno) $(SOURCES:%.c=%.gcda) \ | |
587 | $(SOURCES2:%.c=%.o) $(SOURCES2:%.c=%.d) $(SOURCES2:%.c=%.gcno) $(SOURCES2:%.c=%.gcda) \ | |
588 | $(POTFILES) $(CLEAN_CFLOW) | |
589 | ||
590 | cleandir: | |
591 | $(SHOW) " [CLEANDIR]" | |
592 | ifneq (,$(firstword $(CLEAN_DIRS))) | |
593 | $(Q) $(RM) -r $(CLEAN_DIRS) | |
594 | endif | |
595 | $(Q) $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) core | |
596 | ||
597 | clean: $(SUBDIRS.clean) cleandir | |
598 | ||
599 | distclean: cleandir $(SUBDIRS.distclean) | |
600 | $(SHOW) " [DISTCLEAN]" | |
601 | ifneq (,$(firstword $(DISTCLEAN_DIRS))) | |
602 | $(Q) $(RM) -r $(DISTCLEAN_DIRS) | |
603 | endif | |
604 | $(Q) $(RM) $(DISTCLEAN_TARGETS) Makefile | |
605 | ||
606 | .exported_symbols_generated: $(EXPORTED_HEADER) .exported_symbols $(DEPS) | |
607 | $(Q) set -e; \ | |
608 | ( cat $(srcdir)/.exported_symbols; \ | |
609 | if test -n "$(EXPORTED_HEADER)"; then \ | |
610 | $(CC) -E -P $(INCLUDES) $(DEFS) $(EXPORTED_HEADER) | \ | |
611 | $(SED) -ne "/^typedef|}/!s/.*[ *]\($(EXPORTED_FN_PREFIX)_[a-z0-9_]*\)(.*/\1/p"; \ | |
612 | fi \ | |
613 | ) > $@ | |
614 | ||
615 | EXPORTED_UC := $(shell echo $(EXPORTED_FN_PREFIX) | tr '[a-z]' '[A-Z]') | |
616 | EXPORTED_SYMBOLS := $(wildcard $(srcdir)/.exported_symbols.Base $(srcdir)/.exported_symbols.$(EXPORTED_UC)_[0-9_]*[0-9]) | |
617 | ||
618 | .export.sym: .exported_symbols_generated $(EXPORTED_SYMBOLS) | |
619 | ifeq (,$(firstword $(EXPORTED_SYMBOLS))) | |
620 | $(Q) set -e; (echo "Base {"; echo " global:";\ | |
621 | $(SED) "/^#/d;s/^/ /;s/$$/;/" $<;\ | |
622 | echo " local:"; echo " *;";\ | |
623 | echo "};";\ | |
624 | ) > $@ | |
625 | else | |
626 | $(Q) set -e;\ | |
627 | R=$$($(SORT) $^ | $(GREP) -v "^#" | uniq -u);\ | |
628 | test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\ | |
629 | LAST=;\ | |
630 | for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | $(SORT) -nt_ -k5 ); do\ | |
631 | echo "$${i##*.} {"; echo " global:";\ | |
632 | $(SED) "/^#/d;s/^/ /;s/$$/;/" $$i;\ | |
633 | if test -z "$$LAST"; then echo " local:"; echo " *;";fi;\ | |
634 | echo "}$$LAST;";\ | |
635 | LAST=" $${i##*.}";\ | |
636 | done > $@ | |
637 | endif | |
638 | ||
639 | ifeq ("$(USE_TRACKING)","yes") | |
640 | ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov lcov-reset \ | |
641 | help check check_local check_cluster check_lvmpolld run-unit-test tags)) | |
642 | .SECONDARY: | |
643 | # Note: no tabs before -include | |
644 | -include $(SOURCES:.c=.d) $(SOURCES2:.c=.d) $(CXXSOURCES:.cpp=.d) | |
645 | endif | |
646 | endif |