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@
32 LD_FLAGS += @LD_FLAGS@
35 # Setup directory variables
37 exec_prefix = @exec_prefix@
38 bindir = $(DESTDIR)@bindir@
39 includedir = $(DESTDIR)@includedir@
40 libdir = $(DESTDIR)@libdir@
41 sbindir = $(DESTDIR)@sbindir@
42 infodir = $(DESTDIR)@infodir@
43 mandir = $(DESTDIR)@mandir@
44 localedir = $(DESTDIR)@LOCALEDIR@
46 # setup misc variables
47 # define the ownership variables for the binaries and man pages
51 # The number of jobs to run, if blank, defaults to the make standard
56 SUFFIXES = .c .d .o .so .a .po .pot .mo
58 CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline
60 #CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual -Wmissing-noreturn
62 ifeq ("@DEBUG@", "yes")
63 CFLAGS += -g -fno-omit-frame-pointer -DDEBUG
69 ifeq ("@INTL@", "yes")
70 CFLAGS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
73 LD_FLAGS += -L$(top_srcdir)/lib -L$(libdir)
75 ifeq ("@STATIC_LINK@", "yes")
79 #CFLAGS += -DDEBUG_POOL
80 #CFLAGS += -DBOUNDS_CHECK
88 LIB_VERSION := $(shell cat $(top_srcdir)/VERSION | \
89 awk -F '.' '{printf "%s.%s",$$1,$$2}')
91 INCLUDES += -I. -I$(top_srcdir)/include
94 INCLUDES += -I$(DESTDIR)/usr/include
97 INC_LNS = $(top_srcdir)/include/.symlinks_created
99 DEPS = $(top_srcdir)/make.tmpl $(top_srcdir)/VERSION Makefile $(INC_LNS)
101 OBJECTS = $(SOURCES:%.c=%.o)
102 POTFILES = $(SOURCES:%.c=%.pot)
104 SUBDIRS.install := $(SUBDIRS:=.install)
105 SUBDIRS.pofile := $(SUBDIRS:=.pofile)
106 SUBDIRS.clean := $(SUBDIRS:=.clean)
107 SUBDIRS.distclean := $(SUBDIRS:=.distclean)
109 .PHONY: all install pofile distclean clean
110 .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
111 .PHONY: $(SUBDIRS.pofile)
113 TARGETS += $(LIB_SHARED) $(LIB_STATIC)
115 all: $(SUBDIRS) $(TARGETS)
117 install: all $(SUBDIRS.install)
122 $(SUBDIRS.install): $(SUBDIRS)
123 $(MAKE) -C $(@:.install=) install
126 -$(MAKE) -C $(@:.clean=) clean
128 $(SUBDIRS.distclean):
129 -$(MAKE) -C $(@:.distclean=) distclean
131 ifeq ("@INTL@", "yes")
132 pofile: $(SUBDIRS.pofile) $(POTFILES)
135 $(MAKE) -C $(@:.pofile=) pofile
138 $(TARGETS): $(OBJECTS)
141 $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
144 $(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
150 $(CC) -c $(INCLUDES) $(CFLAGS) %< -o $@
152 %.so: $(OBJECTS) $(LD_DEPS)
153 $(CC) $(SOFLAG) -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
154 $(CLDFLAGS) $(OBJECTS) -o $@
156 $(LIB_STATIC): $(OBJECTS)
158 $(AR) rs $@ $(OBJECTS)
162 FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
163 DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
164 $(CC) -MM $(INCLUDES) $(CFLAGS) $< | \
165 sed "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" > $@; \
166 [ -s $@ ] || $(RM) $@
171 clean: $(SUBDIRS.clean)
172 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
173 $(SOURCES:%.c=%.pot) $(LD_DEPS)
175 distclean: $(SUBDIRS.distclean)
176 $(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(SOURCES:%.c=%.d) \
177 $(SOURCES:%.c=%.pot) $(LD_DEPS) \
178 config.cache config.log config.status \
179 Makefile make.tmpl core \
182 .export.sym: .exported_symbols
183 set -e; (echo "Base {"; echo " global:"; \
184 sed "s/^/ /;s/$$/;/" < $<; \
185 echo " local:"; echo " *;"; echo "};") > $@
187 ifneq ($(MAKECMDGOALS),clean)
188 ifneq ($(MAKECMDGOALS),distclean)
190 -include $(SOURCES:.c=.d)