A kernel patch needed to add a spare to an active external-metadata array
[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
36 KLIBC=/home/src/klibc/klibc-0.77
37
38 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
39
40 CC = $(CROSS_COMPILE)gcc
41 CXFLAGS = -ggdb
42 CWFLAGS = -Wall -Werror -Wstrict-prototypes
43
44 ifdef DEBIAN
45 CPPFLAGS= -DDEBIAN
46 else
47 CPPFLAGS=
48 endif
49
50 SYSCONFDIR = /etc
51 CONFFILE = $(SYSCONFDIR)/mdadm.conf
52 CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
53 MAILCMD =/usr/sbin/sendmail -t
54 CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
55 CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS)
56
57 # If you want a static binary, you might uncomment these
58 # LDFLAGS = -static
59 # STRIP = -s
60
61 INSTALL = /usr/bin/install
62 DESTDIR =
63 BINDIR = /sbin
64 MANDIR = /usr/share/man
65 MAN4DIR = $(MANDIR)/man4
66 MAN5DIR = $(MANDIR)/man5
67 MAN8DIR = $(MANDIR)/man8
68
69 OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
70 Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
71 Incremental.o \
72 mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
73 restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o
74 SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
75 Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
76 Incremental.c \
77 mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
78 restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c
79
80 MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
81 Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
82 super-ddf.o sha1.o crc32.o msg.o
83
84
85 STATICSRC = pwgr.c
86 STATICOBJS = pwgr.o
87
88 ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c \
89 super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c
90 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
91 ifdef MDASSEMBLE_AUTO
92 ASSEMBLE_SRCS += mdopen.c mdstat.c
93 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
94 endif
95
96 all : mdadm mdmon mdadm.man md.man mdadm.conf.man
97
98 everything: all mdadm.static swap_super test_stripe \
99 mdassemble mdassemble.static mdassemble.man \
100 mdadm.Os mdadm.O2
101 # mdadm.uclibc and mdassemble.uclibc don't work on x86-64
102 # mdadm.tcc doesn't work..
103
104 mdadm : $(OBJS)
105 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
106
107 mdadm.static : $(OBJS) $(STATICOBJS)
108 $(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
109
110 mdadm.tcc : $(SRCS) mdadm.h
111 $(TCC) -o mdadm.tcc $(SRCS)
112
113 dadm.uclibc : $(SRCS) mdadm.h
114 $(UCLIBC_GCC) -DUCLIBC -DHAVE_STDINT_H -o mdadm.uclibc $(SRCS) $(STATICSRC)
115
116 mdadm.klibc : $(SRCS) mdadm.h
117 rm -f $(OBJS)
118 gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32 $(CFLAGS) $(SRCS)
119
120 mdadm.Os : $(SRCS) mdadm.h
121 gcc -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
122
123 mdadm.O2 : $(SRCS) mdadm.h
124 gcc -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
125
126 mdmon : $(MON_OBJS)
127 $(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
128 msg.o: msg.c msg.h
129
130 test_stripe : restripe.c mdadm.h
131 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
132
133 mdassemble : $(ASSEMBLE_SRCS) mdadm.h
134 rm -f $(OBJS)
135 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
136
137 mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
138 rm -f $(OBJS)
139 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
140
141 mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
142 rm -f $(OJS)
143 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
144
145 # This doesn't work
146 mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
147 rm -f $(OBJS)
148 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
149
150 mdadm.man : mdadm.8
151 nroff -man mdadm.8 > mdadm.man
152
153 md.man : md.4
154 nroff -man md.4 > md.man
155
156 mdadm.conf.man : mdadm.conf.5
157 nroff -man mdadm.conf.5 > mdadm.conf.man
158
159 mdassemble.man : mdassemble.8
160 nroff -man mdassemble.8 > mdassemble.man
161
162 $(OBJS) : mdadm.h bitmap.h
163
164 sha1.o : sha1.c sha1.h md5.h
165 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
166
167 install : mdadm install-man
168 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
169
170 install-static : mdadm.static install-man
171 $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
172
173 install-tcc : mdadm.tcc install-man
174 $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
175
176 install-uclibc : mdadm.uclibc install-man
177 $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
178
179 install-klibc : mdadm.klibc install-man
180 $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
181
182 install-man: mdadm.8 md.4 mdadm.conf.5
183 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
184 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
185 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
186
187 uninstall:
188 rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 md.4 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
189
190 test: mdadm test_stripe swap_super
191 @echo "Please run 'sh ./test' as root"
192
193 clean :
194 rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
195 mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
196 mdadm.Os mdadm.O2 \
197 mdassemble mdassemble.static mdassemble.uclibc mdassemble.klibc swap_super \
198 init.cpio.gz mdadm.uclibc.static test_stripe
199
200 dist : clean
201 ./makedist
202
203 testdist : everything clean
204 ./makedist test
205
206 TAGS :
207 etags *.h *.c