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
28 CLDFLAGS += @CLDFLAGS@
29 CLDWHOLEARCHIVE += @CLDWHOLEARCHIVE@
30 CLDNOWHOLEARCHIVE += @CLDNOWHOLEARCHIVE@
35 # Setup directory variables
37 exec_prefix = @exec_prefix@
38 bindir = $(DESTDIR)@bindir@
39 confdir = $(DESTDIR)@CONFDIR@/lvm
40 includedir = $(DESTDIR)@includedir@
41 libdir = $(DESTDIR)@libdir@
42 sbindir = $(DESTDIR)@sbindir@
43 infodir = $(DESTDIR)@infodir@
44 mandir = $(DESTDIR)@mandir@
45 localedir = $(DESTDIR)@LOCALEDIR@
46 staticdir = $(DESTDIR)@STATICDIR@
48 # setup misc variables
49 # define the ownership variables for the binaries and man pages
53 # The number of jobs to run, if blank, defaults to the make standard
58 SUFFIXES = .c .d .o .so .a .po .pot .mo
60 CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline
62 #CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual -Wmissing-noreturn
64 CFLAGS += @COPTIMISE_FLAG@
66 ifeq ("@DEBUG@", "yes")
67 CFLAGS += -g -fno-omit-frame-pointer -DDEBUG
71 ifeq ("@INTL@", "yes")
72 CFLAGS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
75 LDFLAGS += -L$(top_srcdir)/lib -L$(libdir)
77 #CFLAGS += -DDEBUG_POOL
78 #CFLAGS += -DBOUNDS_CHECK
86 LIB_VERSION := $(shell cat $(top_srcdir)/VERSION | \
87 awk -F '.' '{printf "%s.%s",$$1,$$2}')
89 INCLUDES += -I. -I$(top_srcdir)/include
92 INCLUDES += -I$(DESTDIR)/usr/include
95 INC_LNS = $(top_srcdir)/include/.symlinks_created
97 DEPS = $(top_srcdir)/make.tmpl $(top_srcdir)/VERSION Makefile $(INC_LNS)
99 OBJECTS = $(SOURCES:%.c=%.o)
100 POTFILES = $(SOURCES:%.c=%.pot)
102 SUBDIRS.install := $(SUBDIRS:=.install)
103 SUBDIRS.pofile := $(SUBDIRS:=.pofile)
104 SUBDIRS.clean := $(SUBDIRS:=.clean)
105 SUBDIRS.distclean := $(SUBDIRS:=.distclean)
107 .PHONY: all install pofile distclean clean
108 .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
109 .PHONY: $(SUBDIRS.pofile)
111 TARGETS += $(LIB_SHARED) $(LIB_STATIC)
113 all: $(SUBDIRS) $(TARGETS)
115 install: all $(SUBDIRS.install)
120 $(SUBDIRS.install): $(SUBDIRS)
121 $(MAKE) -C $(@:.install=) install
124 -$(MAKE) -C $(@:.clean=) clean
126 $(SUBDIRS.distclean):
127 -$(MAKE) -C $(@:.distclean=) distclean
129 ifeq ("@INTL@", "yes")
130 pofile: $(SUBDIRS.pofile) $(POTFILES)
133 $(MAKE) -C $(@:.pofile=) pofile
136 $(TARGETS): $(OBJECTS)
139 $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
142 $(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
146 $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
148 $(LIB_SHARED): $(OBJECTS) $(LDDEPS)
149 $(CC) $(SOFLAG) -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
150 $(CLDFLAGS) $(OBJECTS) -o $@
152 $(LIB_STATIC): $(OBJECTS)
154 $(AR) rs $@ $(OBJECTS)
158 FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
159 DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
160 $(CC) -MM $(INCLUDES) $(CFLAGS) $< | \
161 sed "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" > $@; \
162 [ -s $@ ] || $(RM) $@
167 clean: $(SUBDIRS.clean)
168 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
169 $(SOURCES:%.c=%.pot) $(LDDEPS)
171 distclean: $(SUBDIRS.distclean)
172 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
173 $(SOURCES:%.c=%.pot) $(LDDEPS) \
174 config.cache config.log config.status \
175 Makefile make.tmpl core \
178 .export.sym: .exported_symbols
179 set -e; (echo "Base {"; echo " global:"; \
180 sed "s/^/ /;s/$$/;/" < $<; \
181 echo " local:"; echo " *;"; echo "};") > $@
183 ifneq ($(MAKECMDGOALS),clean)
184 ifneq ($(MAKECMDGOALS),distclean)
186 -include $(SOURCES:.c=.d)