xref: /dragonfly/contrib/lvm2/dist/make.tmpl.in (revision d4ef6694)
1# @configure_input@
2#
3# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
4# Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
5#
6# This file is part of LVM2.
7#
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.
11#
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
15
16SHELL = /bin/sh
17
18@SET_MAKE@
19
20CC = @CC@
21RANLIB = @RANLIB@
22SHELL = /bin/sh
23INSTALL = @INSTALL@
24MKDIR_P = @MKDIR_P@
25MSGFMT = @MSGFMT@
26LCOV = @LCOV@
27GENHTML = @GENHTML@
28LN_S = @LN_S@
29SED = @SED@
30
31LIBS = @LIBS@
32DEFS += @DEFS@
33CFLAGS += @CFLAGS@
34CLDFLAGS += @CLDFLAGS@
35LDDEPS += @LDDEPS@
36LDFLAGS += @LDFLAGS@
37LIB_SUFFIX = @LIB_SUFFIX@
38
39# Setup directory variables
40prefix = @prefix@
41exec_prefix = @exec_prefix@
42udev_prefix = @udev_prefix@
43bindir = $(DESTDIR)@bindir@
44confdir = $(DESTDIR)@CONFDIR@/lvm
45includedir = $(DESTDIR)@includedir@
46libdir = $(DESTDIR)@libdir@
47usrlibdir = $(DESTDIR)@usrlibdir@
48sbindir = $(DESTDIR)@sbindir@
49usrsbindir = $(DESTDIR)@usrsbindir@
50infodir = $(DESTDIR)@infodir@
51mandir = $(DESTDIR)@mandir@
52localedir = $(DESTDIR)@LOCALEDIR@
53staticdir = $(DESTDIR)@STATICDIR@
54udevdir = $(DESTDIR)@udevdir@
55
56interface = @interface@
57interfacedir = $(top_srcdir)/libdm/$(interface)
58
59# setup misc variables
60# define the ownership variables for the binaries and man pages
61OWNER = @OWNER@
62GROUP = @GROUP@
63
64# The number of jobs to run, if blank, defaults to the make standard
65ifndef MAKEFLAGS
66MAKEFLAGS = @JOBS@
67endif
68
69.SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
70
71CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security
72
73#CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual
74#CFLAGS += -pedantic -std=gnu99
75
76CFLAGS += @COPTIMISE_FLAG@
77
78ifeq ("@DEBUG@", "yes")
79  CFLAGS += -g -fno-omit-frame-pointer
80  DEFS += -DDEBUG
81  DEFS += -DDEBUG_MEM
82endif
83
84ifeq ("@INTL@", "yes")
85  DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
86endif
87
88LDFLAGS += -L$(top_builddir)/libdm -L$(top_builddir)/lib
89CLDFLAGS += -L$(top_builddir)/libdm -L$(top_builddir)/lib
90
91ifeq ("@DMEVENTD@", "yes")
92  LDFLAGS += -L$(top_builddir)/daemons/dmeventd
93  CLDFLAGS += -L$(top_builddir)/daemons/dmeventd
94endif
95
96ifeq ("@DM_COMPAT@", "yes")
97  DEFS += -DDM_COMPAT
98endif
99
100ifeq ("@DM_IOCTLS@", "yes")
101  DEFS += -DDM_IOCTLS
102endif
103
104#DEFS += -DDEBUG_POOL
105#DEFS += -DBOUNDS_CHECK
106
107#CFLAGS += -pg
108#LDFLAGS += -pg
109
110STRIP=
111#STRIP = -s
112
113LVM_VERSION := $(shell cat $(top_srcdir)/VERSION)
114
115LIB_VERSION_LVM := $(shell cat $(top_srcdir)/VERSION | \
116		     awk -F '.' '{printf "%s.%s",$$1,$$2}')
117
118LIB_VERSION_DM := $(shell cat $(top_srcdir)/VERSION_DM | \
119		    awk -F '.' '{printf "%s.%s",$$1,$$2}')
120
121LIB_VERSION_APP := $(shell cat $(top_srcdir)/VERSION | \
122		     awk -F '[(). ]' '{printf "%s.%s",$$1,$$4}')
123
124INCLUDES += -I. -I$(top_builddir)/include
125
126INC_LNS = $(top_builddir)/include/.symlinks_created
127
128DEPS = $(top_builddir)/make.tmpl $(top_srcdir)/VERSION \
129       $(top_builddir)/Makefile $(INC_LNS)
130
131OBJECTS = $(SOURCES:%.c=%.o)
132POTFILES = $(SOURCES:%.c=%.pot)
133
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)
139
140SUBDIRS.device-mapper := $(SUBDIRS:=.device-mapper)
141SUBDIRS.install := $(SUBDIRS:=.install)
142SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster)
143SUBDIRS.install_device-mapper := $(SUBDIRS:=.install_device-mapper)
144SUBDIRS.install_lvm2 := $(SUBDIRS:=.install_lvm2)
145SUBDIRS.pofile := $(SUBDIRS:=.pofile)
146SUBDIRS.cflow := $(SUBDIRS:=.cflow)
147SUBDIRS.clean := $(SUBDIRS:=.clean)
148SUBDIRS.distclean := $(SUBDIRS:=.distclean)
149
150TARGETS += $(LIB_SHARED) $(LIB_STATIC) $(VERSIONED_SHLIB)
151
152all: $(SUBDIRS) $(TARGETS)
153
154install: all $(SUBDIRS.install)
155install_cluster: all $(SUBDIRS.install_cluster)
156install_device-mapper: $(SUBDIRS.install_device-mapper)
157install_lvm2: $(SUBDIRS.install_lvm2)
158
159$(SUBDIRS): $(SUBDIRS.device-mapper)
160	$(MAKE) -C $@
161
162$(SUBDIRS.device-mapper):
163	$(MAKE) -C $(@:.device-mapper=) device-mapper
164
165$(SUBDIRS.install): $(SUBDIRS)
166	$(MAKE) -C $(@:.install=) install
167
168$(SUBDIRS.install_cluster): $(SUBDIRS)
169	$(MAKE) -C $(@:.install_cluster=) install_cluster
170
171$(SUBDIRS.install_device-mapper): device-mapper
172	$(MAKE) -C $(@:.install_device-mapper=) install_device-mapper
173
174$(SUBDIRS.install_lvm2): $(SUBDIRS)
175	$(MAKE) -C $(@:.install_lvm2=) install_lvm2
176
177$(SUBDIRS.clean):
178	-$(MAKE) -C $(@:.clean=) clean
179
180$(SUBDIRS.distclean):
181	-$(MAKE) -C $(@:.distclean=) distclean
182
183ifeq ("@INTL@", "yes")
184pofile: $(SUBDIRS.pofile) $(POTFILES)
185
186$(SUBDIRS.pofile):
187	$(MAKE) -C $(@:.pofile=) pofile
188endif
189
190ifneq ("@CFLOW_CMD@", "")
191cflow: $(SUBDIRS.cflow)
192
193$(SUBDIRS.cflow):
194	$(MAKE) -C $(@:.cflow=) cflow
195endif
196
197$(TARGETS): $(OBJECTS)
198
199%.o: %.c
200	$(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
201
202%.pot: %.c Makefile
203	$(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
204		$(DEFS) $(CFLAGS) $< > $@
205
206%.so: %.o
207	$(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $(CLDFLAGS) $< $(LIBS) -o $@
208
209ifeq ("@LIB_SUFFIX@","so")
210$(LIB_SHARED): $(OBJECTS) $(LDDEPS)
211	$(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
212	$(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
213endif
214
215ifeq ("@LIB_SUFFIX@","dylib")
216$(LIB_SHARED): $(OBJECTS) $(LDDEPS)
217	$(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
218	$(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
219endif
220
221%.so: %.a
222	$(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
223	$(CFLAGS) $(CLDFLAGS) $(LIBS) -o $@ \
224	@CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@
225
226$(LIB_STATIC): $(OBJECTS)
227	$(RM) $@
228	$(AR) rs $@ $(OBJECTS)
229
230%.d: %.c
231	$(MKDIR_P) $(dir $@); \
232	set -e; \
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) $@
238
239%.mo: %.po
240	$(MSGFMT) -o $@ $<
241
242clean: $(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)
246
247distclean: $(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 \
255	      lvm-version.h
256
257.export.sym: .exported_symbols
258	set -e; (echo "Base {"; echo "	global:"; \
259		 sed "s/^/		/;s/$$/;/" < $<; \
260		 echo "	local:"; echo "		*;"; echo "};") > $@
261
262ifneq ($(MAKECMDGOALS),clean)
263  ifneq ($(MAKECMDGOALS),distclean)
264    ifdef SOURCES
265       -include $(SOURCES:.c=.d)
266    endif
267    ifdef SOURCES2
268       -include $(SOURCES2:.c=.d)
269    endif
270  endif
271endif
272
273