3 # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
4 # Copyright (C) 2004, 2008 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 bindir = $(DESTDIR)@bindir@
43 confdir = $(DESTDIR)@CONFDIR@/lvm
44 includedir = $(DESTDIR)@includedir@
45 libdir = $(DESTDIR)@libdir@
46 usrlibdir = $(DESTDIR)@usrlibdir@
47 sbindir = $(DESTDIR)@sbindir@
48 usrsbindir = $(DESTDIR)@usrsbindir@
49 infodir = $(DESTDIR)@infodir@
50 mandir = $(DESTDIR)@mandir@
51 localedir = $(DESTDIR)@LOCALEDIR@
52 staticdir = $(DESTDIR)@STATICDIR@
54 interface = @interface@
55 interfacedir = $(top_srcdir)/libdm/$(interface)
57 # setup misc variables
58 # define the ownership variables for the binaries and man pages
62 # The number of jobs to run, if blank, defaults to the make standard
67 .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
69 CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security
71 #CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual
72 #CFLAGS += -pedantic -std=gnu99
74 CFLAGS += @COPTIMISE_FLAG@
76 ifeq ("@DEBUG@", "yes")
77 CFLAGS += -g -fno-omit-frame-pointer
82 ifeq ("@INTL@", "yes")
83 DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
86 LDFLAGS += -L$(top_srcdir)/libdm -L$(top_srcdir)/lib
87 CLDFLAGS += -L$(top_srcdir)/libdm -L$(top_srcdir)/lib
89 ifeq ("@DMEVENTD@", "yes")
90 LDFLAGS += -L$(top_srcdir)/daemons/dmeventd
91 CLDFLAGS += -L$(top_srcdir)/daemons/dmeventd
94 ifeq ("@DM_COMPAT@", "yes")
98 ifeq ("@DM_IOCTLS@", "yes")
102 #DEFS += -DDEBUG_POOL
103 #DEFS += -DBOUNDS_CHECK
111 LVM_VERSION := $(shell cat $(top_srcdir)/VERSION)
113 LIB_VERSION_LVM := $(shell cat $(top_srcdir)/VERSION | \
114 awk -F '.' '{printf "%s.%s",$$1,$$2}')
116 LIB_VERSION_DM := $(shell cat $(top_srcdir)/VERSION_DM | \
117 awk -F '.' '{printf "%s.%s",$$1,$$2}')
119 INCLUDES += -I. -I$(top_srcdir)/include
122 INCLUDES += -I$(DESTDIR)/usr/include
125 INC_LNS = $(top_srcdir)/include/.symlinks_created
127 DEPS = $(top_srcdir)/make.tmpl $(top_srcdir)/VERSION Makefile $(INC_LNS)
129 OBJECTS = $(SOURCES:%.c=%.o)
130 POTFILES = $(SOURCES:%.c=%.pot)
132 .PHONY: all install install_cluster pofile distclean clean cflow device-mapper
133 .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
134 .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
135 .PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
137 SUBDIRS.device-mapper := $(SUBDIRS:=.device-mapper)
138 SUBDIRS.install := $(SUBDIRS:=.install)
139 SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster)
140 SUBDIRS.install_device-mapper := $(SUBDIRS:=.install_device-mapper)
141 SUBDIRS.pofile := $(SUBDIRS:=.pofile)
142 SUBDIRS.cflow := $(SUBDIRS:=.cflow)
143 SUBDIRS.clean := $(SUBDIRS:=.clean)
144 SUBDIRS.distclean := $(SUBDIRS:=.distclean)
146 TARGETS += $(LIB_SHARED) $(LIB_STATIC) $(VERSIONED_SHLIB)
148 all: $(SUBDIRS) $(TARGETS)
150 install: all $(SUBDIRS.install)
151 install_cluster: all $(SUBDIRS.install_cluster)
152 install_device-mapper: $(SUBDIRS.install_device-mapper)
157 $(SUBDIRS.device-mapper):
158 $(MAKE) -C $(@:.device-mapper=) device-mapper
160 $(SUBDIRS.install): $(SUBDIRS)
161 $(MAKE) -C $(@:.install=) install
163 $(SUBDIRS.install_cluster): $(SUBDIRS)
164 $(MAKE) -C $(@:.install_cluster=) install_cluster
166 $(SUBDIRS.install_device-mapper): $(SUBDIRS)
167 $(MAKE) -C $(@:.install_device-mapper=) install_device-mapper
170 -$(MAKE) -C $(@:.clean=) clean
172 $(SUBDIRS.distclean):
173 -$(MAKE) -C $(@:.distclean=) distclean
175 ifeq ("@INTL@", "yes")
176 pofile: $(SUBDIRS.pofile) $(POTFILES)
179 $(MAKE) -C $(@:.pofile=) pofile
182 ifneq ("@CFLOW_CMD@", "")
183 cflow: $(SUBDIRS.cflow)
186 $(MAKE) -C $(@:.cflow=) cflow
189 $(TARGETS): $(OBJECTS)
192 $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
195 $(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
196 $(DEFS) $(CFLAGS) $< > $@
199 $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
201 ifeq ("@LIB_SUFFIX@","so")
202 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
203 $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
204 $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
207 ifeq ("@LIB_SUFFIX@","dylib")
208 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
209 $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
210 $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
214 $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
215 $(CFLAGS) $(CLDFLAGS) $(LIBS) -o $@ \
216 @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@
218 $(LIB_STATIC): $(OBJECTS)
220 $(AR) rs $@ $(OBJECTS)
224 FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
225 DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
226 $(CC) -MM $(INCLUDES) $(DEFS) $(CFLAGS) $< | \
227 sed "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" > $@; \
228 [ -s $@ ] || $(RM) $@
233 clean: $(SUBDIRS.clean)
234 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
235 $(SOURCES:%.c=%.pot) $(SOURCES:%.c=%.gcno) \
236 $(SOURCES:%.c=%.gcda) $(LDDEPS)
238 distclean: $(SUBDIRS.distclean)
239 $(RM) -rf $(DISTCLEAN_DIRS)
240 $(RM) $(DISTCLEAN_TARGETS) \
241 $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
242 $(SOURCES:%.c=%.pot) $(SOURCES:%.c=%.gcno) \
243 $(SOURCES:%.c=%.gcda) $(LDDEPS) \
244 config.cache config.log config.status \
245 Makefile make.tmpl core \
248 .export.sym: .exported_symbols
249 set -e; (echo "Base {"; echo " global:"; \
250 sed "s/^/ /;s/$$/;/" < $<; \
251 echo " local:"; echo " *;"; echo "};") > $@
253 ifneq ($(MAKECMDGOALS),clean)
254 ifneq ($(MAKECMDGOALS),distclean)
256 -include $(SOURCES:.c=.d)