Add mbr pseudo metadata handler.
[thirdparty/mdadm.git] / Makefile
1 #
2 # mdadm - manage Linux "md" devices aka RAID arrays.
3 #
4 # Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
5 #
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #
21 # Author: Neil Brown
22 # Email: <neilb@cse.unsw.edu.au>
23 # Paper: Neil Brown
24 # School of Computer Science and Engineering
25 # The University of New South Wales
26 # Sydney, 2052
27 # Australia
28 #
29
30 # define "CXFLAGS" to give extra flags to CC.
31 # e.g. make CXFLAGS=-O to optimise
32 TCC = tcc
33 UCLIBC_GCC = $(shell for nm in i386-uclibc-linux-gcc i386-uclibc-gcc; do which $$nm > /dev/null && { echo $$nm ; exit; } ; done; echo false No uclibc found )
34 #DIET_GCC = diet gcc
35 # sorry, but diet-libc doesn't know about posix_memalign,
36 # so we cannot use it any more.
37 DIET_GCC = gcc -DHAVE_STDINT_H
38
39 KLIBC=/home/src/klibc/klibc-0.77
40
41 KLIBC_GCC = gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32
42
43 CC = $(CROSS_COMPILE)gcc
44 CXFLAGS = -ggdb
45 CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter
46 ifdef WARN_UNUSED
47 CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O
48 endif
49
50 ifdef DEBIAN
51 CPPFLAGS := -DDEBIAN
52 else
53 CPPFLAGS :=
54 endif
55 ifdef DEFAULT_OLD_METADATA
56 CPPFLAG += -DDEFAULT_OLD_METADATA
57 DEFAULT_METADATA=0.90
58 else
59 DEFAULT_METADATA=1.2
60 endif
61
62 SYSCONFDIR = /etc
63 CONFFILE = $(SYSCONFDIR)/mdadm.conf
64 CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
65 MAILCMD =/usr/sbin/sendmail -t
66 CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
67 # Both MAP_DIR and MDMON_DIR should be somewhere that persists across the
68 # pivotroot from early boot to late boot.
69 # /dev is an odd place to put this, but it is the only directory that
70 # meets the requirements.
71 MAP_DIR=/dev/.mdadm
72 MAP_FILE = map
73 MDMON_DIR = /dev/.mdadm
74 DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\"
75 DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
76 CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
77
78 # The glibc TLS ABI requires applications that call clone(2) to set up
79 # TLS data structures, use pthreads until mdmon implements this support
80 USE_PTHREADS = 1
81 ifdef USE_PTHREADS
82 CFLAGS += -DUSE_PTHREADS
83 MON_LDFLAGS += -pthread
84 endif
85
86 # If you want a static binary, you might uncomment these
87 # LDFLAGS = -static
88 # STRIP = -s
89
90 INSTALL = /usr/bin/install
91 DESTDIR =
92 BINDIR = /sbin
93 MANDIR = /usr/share/man
94 MAN4DIR = $(MANDIR)/man4
95 MAN5DIR = $(MANDIR)/man5
96 MAN8DIR = $(MANDIR)/man8
97
98 OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
99 Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
100 Incremental.o \
101 mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
102 super-mbr.o \
103 restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o \
104 platform-intel.o probe_roms.o
105
106 SRCS = mdadm.c config.c policy.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
107 Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
108 Incremental.c \
109 mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
110 super-mbr.c \
111 restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c \
112 platform-intel.c probe_roms.c
113
114 INCL = mdadm.h part.h bitmap.h
115
116 MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o policy.o \
117 Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
118 super-mbr.o \
119 super-ddf.o sha1.o crc32.o msg.o bitmap.o \
120 platform-intel.o probe_roms.o
121
122 MON_SRCS = mdmon.c monitor.c managemon.c util.c mdstat.c sysfs.c config.c policy.c \
123 Kill.c sg_io.c dlink.c ReadMe.c super0.c super1.c super-intel.c \
124 super-mbr.c \
125 super-ddf.c sha1.c crc32.c msg.c bitmap.c \
126 platform-intel.c probe_roms.c
127
128 STATICSRC = pwgr.c
129 STATICOBJS = pwgr.o
130
131 ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c policy.c dlink.c util.c \
132 super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \
133 platform-intel.c probe_roms.c sysfs.c super-mbr.c
134 ASSEMBLE_AUTO_SRCS := mdopen.c
135 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
136 ifdef MDASSEMBLE_AUTO
137 ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
138 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
139 endif
140
141 all : mdadm mdmon mdadm.man md.man mdadm.conf.man mdmon.man
142
143 everything: all mdadm.static swap_super test_stripe \
144 mdassemble mdassemble.auto mdassemble.static mdassemble.man \
145 mdadm.Os mdadm.O2
146 everything-test: all mdadm.static swap_super test_stripe \
147 mdassemble.auto mdassemble.static mdassemble.man \
148 mdadm.Os mdadm.O2
149 # mdadm.uclibc and mdassemble.uclibc don't work on x86-64
150 # mdadm.tcc doesn't work..
151
152 mdadm : $(OBJS)
153 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
154
155 mdadm.static : $(OBJS) $(STATICOBJS)
156 $(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
157
158 mdadm.tcc : $(SRCS) $(INCL)
159 $(TCC) -o mdadm.tcc $(SRCS)
160
161 mdadm.klibc : $(SRCS) $(INCL)
162 rm -f $(OBJS)
163 $(CC) -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
164
165 mdadm.Os : $(SRCS) $(INCL)
166 $(CC) -o mdadm.Os $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
167
168 mdadm.O2 : $(SRCS) $(INCL) mdmon.O2
169 $(CC) -o mdadm.O2 $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(SRCS)
170
171 mdmon.O2 : $(MON_SRCS) $(INCL) mdmon.h
172 $(CC) -o mdmon.O2 $(CFLAGS) $(LDFLAGS) $(MON_LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(MON_SRCS)
173
174 # use '-z now' to guarantee no dynamic linker interactions with the monitor thread
175 mdmon : $(MON_OBJS)
176 $(CC) $(LDFLAGS) $(MON_LDFLAGS) -Wl,-z,now -o mdmon $(MON_OBJS) $(LDLIBS)
177 msg.o: msg.c msg.h
178
179 test_stripe : restripe.c mdadm.h
180 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
181
182 mdassemble : $(ASSEMBLE_SRCS) $(INCL)
183 rm -f $(OBJS)
184 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
185
186 mdassemble.static : $(ASSEMBLE_SRCS) $(INCL)
187 rm -f $(OBJS)
188 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
189
190 mdassemble.auto : $(ASSEMBLE_SRCS) $(INCL) $(ASSEMBLE_AUTO_SRCS)
191 rm -f mdassemble.static
192 $(MAKE) MDASSEMBLE_AUTO=1 mdassemble.static
193 mv mdassemble.static mdassemble.auto
194
195 mdassemble.uclibc : $(ASSEMBLE_SRCS) $(INCL)
196 rm -f $(OJS)
197 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
198
199 # This doesn't work
200 mdassemble.klibc : $(ASSEMBLE_SRCS) $(INCL)
201 rm -f $(OBJS)
202 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
203
204 mdadm.8 : mdadm.8.in
205 sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' mdadm.8.in > mdadm.8
206
207 mdadm.man : mdadm.8
208 nroff -man mdadm.8 > mdadm.man
209
210 mdmon.man : mdmon.8
211 nroff -man mdmon.8 > mdmon.man
212
213 md.man : md.4
214 nroff -man md.4 > md.man
215
216 mdadm.conf.man : mdadm.conf.5
217 nroff -man mdadm.conf.5 > mdadm.conf.man
218
219 mdassemble.man : mdassemble.8
220 nroff -man mdassemble.8 > mdassemble.man
221
222 $(OBJS) : $(INCL) mdmon.h
223 $(MON_OBJS) : $(INCL) mdmon.h
224
225 sha1.o : sha1.c sha1.h md5.h
226 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
227
228 install : mdadm mdmon install-man install-udev
229 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
230 $(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
231
232 install-static : mdadm.static install-man
233 $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
234
235 install-tcc : mdadm.tcc install-man
236 $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
237
238 install-uclibc : mdadm.uclibc install-man
239 $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
240
241 install-klibc : mdadm.klibc install-man
242 $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
243
244 install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
245 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
246 $(INSTALL) -D -m 644 mdmon.8 $(DESTDIR)$(MAN8DIR)/mdmon.8
247 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
248 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
249
250 install-udev: udev-md-raid.rules
251 $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
252
253 uninstall:
254 rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
255
256 test: mdadm mdmon test_stripe swap_super
257 @echo "Please run 'sh ./test' as root"
258
259 clean :
260 rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
261 mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt .merge_file_* \
262 mdadm.Os mdadm.O2 mdmon.O2 \
263 mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
264 mdassemble.klibc swap_super \
265 init.cpio.gz mdadm.uclibc.static test_stripe mdmon \
266 mdadm.8
267
268 dist : clean
269 ./makedist
270
271 testdist : everything-test clean
272 ./makedist test
273
274 TAGS :
275 etags *.h *.c
276
277 DISTRO_MAKEFILE := $(wildcard distropkg/Makefile)
278 ifdef DISTRO_MAKEFILE
279 include $(DISTRO_MAKEFILE)
280 endif
281