3 # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
4 # Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
6 # This file is part of LVM2.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 CLDFLAGS += @CLDFLAGS@
37 LIB_SUFFIX = @LIB_SUFFIX@
39 # Setup directory variables
41 exec_prefix = @exec_prefix@
42 udev_prefix = @udev_prefix@
43 bindir = $(DESTDIR)@bindir@
44 confdir = $(DESTDIR)@CONFDIR@/lvm
45 includedir = $(DESTDIR)@includedir@
46 libdir = $(DESTDIR)@libdir@
47 usrlibdir = $(DESTDIR)@usrlibdir@
48 sbindir = $(DESTDIR)@sbindir@
49 usrsbindir = $(DESTDIR)@usrsbindir@
50 infodir = $(DESTDIR)@infodir@
51 mandir = $(DESTDIR)@mandir@
52 localedir = $(DESTDIR)@LOCALEDIR@
53 staticdir = $(DESTDIR)@STATICDIR@
54 udevdir = $(DESTDIR)@udevdir@
56 interface = @interface@
57 interfacedir = $(top_srcdir)/libdm/$(interface)
59 # setup misc variables
60 # define the ownership variables for the binaries and man pages
64 # The number of jobs to run, if blank, defaults to the make standard
69 .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
71 CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security
73 #CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual
74 #CFLAGS += -pedantic -std=gnu99
76 CFLAGS += @COPTIMISE_FLAG@
78 ifeq ("@DEBUG@", "yes")
79 CFLAGS += -g -fno-omit-frame-pointer
84 ifeq ("@INTL@", "yes")
85 DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
88 LDFLAGS += -L$(top_builddir)/libdm -L$(top_builddir)/lib
89 CLDFLAGS += -L$(top_builddir)/libdm -L$(top_builddir)/lib
91 ifeq ("@DMEVENTD@", "yes")
92 LDFLAGS += -L$(top_builddir)/daemons/dmeventd
93 CLDFLAGS += -L$(top_builddir)/daemons/dmeventd
96 ifeq ("@DM_COMPAT@", "yes")
100 ifeq ("@DM_IOCTLS@", "yes")
104 #DEFS += -DDEBUG_POOL
105 #DEFS += -DBOUNDS_CHECK
113 LVM_VERSION := $(shell cat $(top_srcdir)/VERSION)
115 LIB_VERSION_LVM := $(shell cat $(top_srcdir)/VERSION | \
116 awk -F '.' '{printf "%s.%s",$$1,$$2}')
118 LIB_VERSION_DM := $(shell cat $(top_srcdir)/VERSION_DM | \
119 awk -F '.' '{printf "%s.%s",$$1,$$2}')
121 LIB_VERSION_APP := $(shell cat $(top_srcdir)/VERSION | \
122 awk -F '[(). ]' '{printf "%s.%s",$$1,$$4}')
124 INCLUDES += -I. -I$(top_builddir)/include
126 INC_LNS = $(top_builddir)/include/.symlinks_created
128 DEPS = $(top_builddir)/make.tmpl $(top_srcdir)/VERSION \
129 $(top_builddir)/Makefile $(INC_LNS)
131 OBJECTS = $(SOURCES:%.c=%.o)
132 POTFILES = $(SOURCES:%.c=%.pot)
134 .PHONY: all install install_cluster pofile distclean clean cflow device-mapper
135 .PHONY: install_device-mapper install_lvm2
136 .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
137 .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
138 .PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
140 SUBDIRS.device-mapper := $(SUBDIRS:=.device-mapper)
141 SUBDIRS.install := $(SUBDIRS:=.install)
142 SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster)
143 SUBDIRS.install_device-mapper := $(SUBDIRS:=.install_device-mapper)
144 SUBDIRS.install_lvm2 := $(SUBDIRS:=.install_lvm2)
145 SUBDIRS.pofile := $(SUBDIRS:=.pofile)
146 SUBDIRS.cflow := $(SUBDIRS:=.cflow)
147 SUBDIRS.clean := $(SUBDIRS:=.clean)
148 SUBDIRS.distclean := $(SUBDIRS:=.distclean)
150 TARGETS += $(LIB_SHARED) $(LIB_STATIC) $(VERSIONED_SHLIB)
152 all: $(SUBDIRS) $(TARGETS)
154 install: all $(SUBDIRS.install)
155 install_cluster: all $(SUBDIRS.install_cluster)
156 install_device-mapper: $(SUBDIRS.install_device-mapper)
157 install_lvm2: $(SUBDIRS.install_lvm2)
159 $(SUBDIRS): $(SUBDIRS.device-mapper)
162 $(SUBDIRS.device-mapper):
163 $(MAKE) -C $(@:.device-mapper=) device-mapper
165 $(SUBDIRS.install): $(SUBDIRS)
166 $(MAKE) -C $(@:.install=) install
168 $(SUBDIRS.install_cluster): $(SUBDIRS)
169 $(MAKE) -C $(@:.install_cluster=) install_cluster
171 $(SUBDIRS.install_device-mapper): device-mapper
172 $(MAKE) -C $(@:.install_device-mapper=) install_device-mapper
174 $(SUBDIRS.install_lvm2): $(SUBDIRS)
175 $(MAKE) -C $(@:.install_lvm2=) install_lvm2
178 -$(MAKE) -C $(@:.clean=) clean
180 $(SUBDIRS.distclean):
181 -$(MAKE) -C $(@:.distclean=) distclean
183 ifeq ("@INTL@", "yes")
184 pofile: $(SUBDIRS.pofile) $(POTFILES)
187 $(MAKE) -C $(@:.pofile=) pofile
190 ifneq ("@CFLOW_CMD@", "")
191 cflow: $(SUBDIRS.cflow)
194 $(MAKE) -C $(@:.cflow=) cflow
197 $(TARGETS): $(OBJECTS)
200 $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
203 $(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
204 $(DEFS) $(CFLAGS) $< > $@
207 $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $(CLDFLAGS) $< $(LIBS) -o $@
209 ifeq ("@LIB_SUFFIX@","so")
210 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
211 $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
212 $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
215 ifeq ("@LIB_SUFFIX@","dylib")
216 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
217 $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
218 $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
222 $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
223 $(CFLAGS) $(CLDFLAGS) $(LIBS) -o $@ \
224 @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@
226 $(LIB_STATIC): $(OBJECTS)
228 $(AR) rs $@ $(OBJECTS)
231 $(MKDIR_P) $(dir $@); \
233 FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
234 DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
235 $(CC) -MM $(INCLUDES) $(DEFS) $(CFLAGS) -o $@ $<; \
236 sed -i "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" $@; \
237 [ -s $@ ] || $(RM) $@
242 clean: $(SUBDIRS.clean)
243 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
244 $(SOURCES2:%.c=%.d) $(SOURCES:%.c=%.pot) $(SOURCES:%.c=%.gcno) \
245 $(SOURCES:%.c=%.gcda) $(LDDEPS)
247 distclean: $(SUBDIRS.distclean)
248 $(RM) -rf $(DISTCLEAN_DIRS)
249 $(RM) $(DISTCLEAN_TARGETS) \
250 $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
251 $(SOURCES2:%.c=%.d) $(SOURCES:%.c=%.pot) $(SOURCES:%.c=%.gcno) \
252 $(SOURCES:%.c=%.gcda) $(LDDEPS) \
253 config.cache config.log config.status \
254 Makefile make.tmpl core \
257 .export.sym: .exported_symbols
258 set -e; (echo "Base {"; echo " global:"; \
259 sed "s/^/ /;s/$$/;/" < $<; \
260 echo " local:"; echo " *;"; echo "};") > $@
262 ifneq ($(MAKECMDGOALS),clean)
263 ifneq ($(MAKECMDGOALS),distclean)
265 -include $(SOURCES:.c=.d)
268 -include $(SOURCES2:.c=.d)