3 # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
4 # Copyright (C) 2004 Red Hat, Inc. All rights reserved.
6 # This file is part of the 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
29 CLDFLAGS += @CLDFLAGS@
32 LIB_SUFFIX = @LIB_SUFFIX@
34 # Setup directory variables
36 exec_prefix = @exec_prefix@
37 bindir = $(DESTDIR)@bindir@
38 confdir = $(DESTDIR)@CONFDIR@/lvm
39 includedir = $(DESTDIR)@includedir@
40 libdir = $(DESTDIR)@libdir@
41 sbindir = $(DESTDIR)@sbindir@
42 infodir = $(DESTDIR)@infodir@
43 mandir = $(DESTDIR)@mandir@
44 localedir = $(DESTDIR)@LOCALEDIR@
45 staticdir = $(DESTDIR)@STATICDIR@
47 # setup misc variables
48 # define the ownership variables for the binaries and man pages
52 # The number of jobs to run, if blank, defaults to the make standard
57 .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
59 CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security
61 #CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual
62 #CFLAGS += -pedantic -std=gnu99
64 CFLAGS += @COPTIMISE_FLAG@
66 ifeq ("@DEBUG@", "yes")
67 CFLAGS += -g -fno-omit-frame-pointer
72 ifeq ("@INTL@", "yes")
73 DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
77 LDFLAGS += -L@DMDIR@/lib/ioctl
78 ifeq ("@DMEVENTD@", "yes")
79 LDFLAGS += -L@DMDIR@/dmeventd
83 LDFLAGS += -L$(top_srcdir)/lib -L$(libdir)
86 #DEFS += -DBOUNDS_CHECK
94 LIB_VERSION := $(shell cat $(top_srcdir)/VERSION | \
95 awk -F '.' '{printf "%s.%s",$$1,$$2}')
97 INCLUDES += -I$(top_srcdir)/include
100 INCLUDES += -I@DMDIR@/include
104 INCLUDES += -I$(DESTDIR)/usr/include
107 INC_LNS = $(top_srcdir)/include/.symlinks_created
109 DEPS = $(top_srcdir)/make.tmpl $(top_srcdir)/VERSION Makefile $(INC_LNS)
111 OBJECTS = $(SOURCES:%.c=%.o)
112 POTFILES = $(SOURCES:%.c=%.pot)
114 .PHONY: all install install_cluster pofile distclean clean cflow
115 .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
116 .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
118 SUBDIRS.install := $(SUBDIRS:=.install)
119 SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster)
120 SUBDIRS.pofile := $(SUBDIRS:=.pofile)
121 SUBDIRS.cflow := $(SUBDIRS:=.cflow)
122 SUBDIRS.clean := $(SUBDIRS:=.clean)
123 SUBDIRS.distclean := $(SUBDIRS:=.distclean)
125 TARGETS += $(LIB_SHARED) $(LIB_STATIC)
127 all: $(SUBDIRS) $(TARGETS)
129 install: all $(SUBDIRS.install)
130 install_cluster: all $(SUBDIRS.install_cluster)
135 $(SUBDIRS.install): $(SUBDIRS)
136 $(MAKE) -C $(@:.install=) install
138 $(SUBDIRS.install_cluster): $(SUBDIRS)
139 $(MAKE) -C $(@:.install_cluster=) install_cluster
142 -$(MAKE) -C $(@:.clean=) clean
144 $(SUBDIRS.distclean):
145 -$(MAKE) -C $(@:.distclean=) distclean
147 ifeq ("@INTL@", "yes")
148 pofile: $(SUBDIRS.pofile) $(POTFILES)
151 $(MAKE) -C $(@:.pofile=) pofile
154 ifneq ("@CFLOW_CMD@", "")
155 cflow: $(SUBDIRS.cflow)
158 $(MAKE) -C $(@:.cflow=) cflow
161 $(TARGETS): $(OBJECTS)
164 $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
167 $(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
168 $(DEFS) $(CFLAGS) $< > $@
171 $(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
173 ifeq ("@LIB_SUFFIX@","so")
174 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
175 $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
176 $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
179 ifeq ("@LIB_SUFFIX@","dylib")
180 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
181 $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
182 $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
186 $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
187 $(CFLAGS) $(CLDFLAGS) $(LIBS) -o $@ \
188 @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@
190 $(LIB_STATIC): $(OBJECTS)
192 $(AR) rs $@ $(OBJECTS)
196 FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
197 DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
198 $(CC) -MM $(INCLUDES) $(DEFS) $(CFLAGS) $< | \
199 sed "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" > $@; \
200 [ -s $@ ] || $(RM) $@
205 clean: $(SUBDIRS.clean)
206 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
207 $(SOURCES:%.c=%.pot) $(LDDEPS)
209 distclean: $(SUBDIRS.distclean)
210 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(DISTCLEAN_TARGETS) \
211 $(SOURCES:%.c=%.d) $(SOURCES:%.c=%.pot) $(LDDEPS) \
212 config.cache config.log config.status \
213 Makefile make.tmpl core \
216 .export.sym: .exported_symbols
217 set -e; (echo "Base {"; echo " global:"; \
218 sed "s/^/ /;s/$$/;/" < $<; \
219 echo " local:"; echo " *;"; echo "};") > $@
221 ifneq ($(MAKECMDGOALS),clean)
222 ifneq ($(MAKECMDGOALS),distclean)
224 -include $(SOURCES:.c=.d)