1# 2# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 3# Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 4# 5# This file is part of LVM2. 6# 7# This copyrighted material is made available to anyone wishing to use, 8# modify, copy, or redistribute it subject to the terms and conditions 9# of the GNU General Public License v.2. 10# 11# You should have received a copy of the GNU General Public License 12# along with this program; if not, write to the Free Software Foundation, 13# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14 15srcdir = @srcdir@ 16top_srcdir = @top_srcdir@ 17top_builddir = @top_builddir@ 18VPATH = @srcdir@ 19 20LIB_PTHREAD = @LIB_PTHREAD@ 21 22SOURCES =\ 23 dumpconfig.c \ 24 formats.c \ 25 lvchange.c \ 26 lvconvert.c \ 27 lvcreate.c \ 28 lvdisplay.c \ 29 lvextend.c \ 30 lvmchange.c \ 31 lvmcmdline.c \ 32 lvmdiskscan.c \ 33 lvreduce.c \ 34 lvremove.c \ 35 lvrename.c \ 36 lvresize.c \ 37 lvscan.c \ 38 polldaemon.c \ 39 pvchange.c \ 40 pvck.c \ 41 pvcreate.c \ 42 pvdisplay.c \ 43 pvmove.c \ 44 pvremove.c \ 45 pvresize.c \ 46 pvscan.c \ 47 reporter.c \ 48 segtypes.c \ 49 toollib.c \ 50 vgcfgbackup.c \ 51 vgcfgrestore.c \ 52 vgchange.c \ 53 vgck.c \ 54 vgcreate.c \ 55 vgconvert.c \ 56 vgdisplay.c \ 57 vgexport.c \ 58 vgextend.c \ 59 vgimport.c \ 60 vgmerge.c \ 61 vgmknodes.c \ 62 vgreduce.c \ 63 vgremove.c \ 64 vgrename.c \ 65 vgscan.c \ 66 vgsplit.c 67 68SOURCES2 =\ 69 dmsetup.c 70 71TARGETS =\ 72 .commands \ 73 lvm 74 75TARGETS_DM = dmsetup 76 77INSTALL_LVM_TARGETS = install_tools_dynamic 78INSTALL_DMSETUP_TARGETS = install_dmsetup_dynamic 79INSTALL_CMDLIB_TARGETS = install_cmdlib_dynamic 80 81ifeq ("@STATIC_LINK@", "yes") 82 TARGETS += lvm.static 83 TARGETS_DM += dmsetup.static 84 INSTALL_LVM_TARGETS += install_tools_static 85 INSTALL_DMSETUP_TARGETS += install_dmsetup_static 86 INSTALL_CMDLIB_TARGETS += install_cmdlib_static 87endif 88 89LVMLIBS = -llvm-internal 90LIB_VERSION = $(LIB_VERSION_LVM) 91 92CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) liblvm2cmd.a liblvm2cmd-static.a lvm lvm.o \ 93 lvm2cmd.o lvm2cmd-static.o lvm2cmdlib.o lvm.static \ 94 lvm.cflow lvm.xref lvm.tree lvm.rxref lvm.rtree \ 95 lvmcmdlib.o lvm-static.o dmsetup.o $(TARGETS_DM) 96 97ifeq ("@CMDLIB@", "yes") 98 TARGETS += liblvm2cmd.$(LIB_SUFFIX) 99 INSTALL_LVM_TARGETS += $(INSTALL_CMDLIB_TARGETS) 100endif 101 102ifeq ("@DMEVENTD@", "yes") 103 LVMLIBS += -ldevmapper-event -lpthread 104endif 105 106LVMLIBS += -ldevmapper 107 108DEFS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\" 109 110include ../make.tmpl 111 112device-mapper: $(TARGETS_DM) 113 114dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX) 115 $(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/libdm \ 116 -o $@ dmsetup.o -ldevmapper $(LIBS) $(LIB_PTHREAD) 117 118dmsetup.static: dmsetup.o $(interfacedir)/libdevmapper.a 119 $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacedir) \ 120 -o $@ dmsetup.o -ldevmapper $(LIBS) $(LIB_PTHREAD) 121 122all: device-mapper 123 124lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a 125 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) lvm.o \ 126 $(LVMLIBS) $(LIBS) $(LIB_PTHREAD) -rdynamic 127 128lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a $(interfacedir)/libdevmapper.a 129 $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacedir) -o $@ \ 130 $(OBJECTS) lvm-static.o $(LVMLIBS) $(LIBS) $(LIB_PTHREAD) \ 131 -rdynamic 132 133liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o 134 cat $(top_builddir)/lib/liblvm-internal.a > $@ 135 $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd.o 136 137liblvm2cmd-static.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o 138 cat $(top_builddir)/lib/liblvm-internal.a > $@ 139 $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o 140 141liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS) 142 143.commands: commands.h cmdnames.h Makefile 144 $(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \ 145 egrep -v '^ *(|#.*|dumpconfig|formats|help|pvdata|segtypes|version) *$$' > .commands 146 147.PHONY: install_cmdlib_dynamic install_cmdlib_static \ 148 install_tools_dynamic install_tools_static 149 150ifneq ("@CFLOW_CMD@", "") 151CFLOW_FLAGS += --cpp="$(CC) -E" 152.PHONY: lvm.cflow 153-include $(top_srcdir)/lib/liblvm-internal.cflow 154lvm.cflow: $(SOURCES) 155 @CFLOW_CMD@ -o$@ $(CFLOW_FLAGS) $(INCLUDES) $(DEFS) $(SOURCES) 156lvm.rxref: $(SOURCES) 157 @CFLOW_CMD@ -o$@ --cpp="$(CC) -E" -r --omit-arguments -x $(INCLUDES) $(DEFS) $(SOURCES) 158lvm.xref: $(SOURCES) 159 @CFLOW_CMD@ -o$@ --cpp="$(CC) -E" --omit-arguments -x $(INCLUDES) $(DEFS) $(SOURCES) 160lvm.rtree: $(SOURCES) 161 @CFLOW_CMD@ -o$@ --cpp="$(CC) -E" -r --omit-arguments -T -b $(INCLUDES) $(DEFS) $(SOURCES) 162lvm.tree: $(SOURCES) 163 @CFLOW_CMD@ -o$@ --cpp="$(CC) -E" --omit-arguments -T -b $(INCLUDES) $(DEFS) $(SOURCES) 164cflow: lvm.cflow lvm.xref lvm.tree lvm.rtree lvm.rxref 165endif 166 167install_cmdlib_dynamic: liblvm2cmd.$(LIB_SUFFIX) 168 $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ 169 $(libdir)/liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) 170 $(LN_S) -f liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) $(libdir)/liblvm2cmd.$(LIB_SUFFIX) 171 $(INSTALL) -D $(OWNER) $(GROUP) -m 444 $(srcdir)/lvm2cmd.h \ 172 $(includedir)/lvm2cmd.h 173 174install_cmdlib_static: liblvm2cmd-static.a 175 $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ 176 $(libdir)/liblvm2cmd.a.$(LIB_VERSION) 177 $(LN_S) -f liblvm2cmd.a.$(LIB_VERSION) $(libdir)/liblvm2cmd.a 178 $(INSTALL) -D $(OWNER) $(GROUP) -m 444 $(srcdir)/lvm2cmd.h \ 179 $(includedir)/lvm2cmd.h 180 181install_tools_dynamic: lvm .commands 182 $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) lvm \ 183 $(sbindir)/lvm 184 @echo Creating symbolic links for individual commands in $(sbindir) 185 @( \ 186 for v in `cat $(srcdir)/.commands`; do \ 187 cd $(sbindir); \ 188 $(LN_S) -f lvm $$v; \ 189 done; \ 190 ) 191 192install_tools_static: lvm.static 193 $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ 194 $(staticdir)/lvm.static 195 196install_dmsetup_dynamic: dmsetup 197 $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< $(sbindir)/$< 198 199install_dmsetup_static: dmsetup.static 200 $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< $(sbindir)/$< 201 202install_device-mapper: $(INSTALL_DMSETUP_TARGETS) 203 204install_lvm2: $(INSTALL_LVM_TARGETS) 205 206install: install_lvm2 install_device-mapper 207