Fix bug in forced assemble.
[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 bitmap.o restripe.o sysfs.o sha1.o \
73 mapfile.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 bitmap.c restripe.c sysfs.c sha1.c \
78 mapfile.c
79
80 STATICSRC = pwgr.c
81 STATICOBJS = pwgr.o
82
83 ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c \
84 super0.c super1.c sha1.c
85 ASSEMBLE_AUTO_SRCS := mdopen.c mdstat.c sysfs.c
86 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
87 ifdef MDASSEMBLE_AUTO
88 ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
89 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
90 endif
91
92 all : mdadm mdadm.man md.man mdadm.conf.man
93
94 everything: all mdadm.static swap_super test_stripe \
95 mdassemble mdassemble.auto mdassemble.static mdassemble.man \
96 mdadm.Os mdadm.O2
97 # mdadm.uclibc and mdassemble.uclibc don't work on x86-64
98 # mdadm.tcc doesn't work..
99
100 mdadm : $(OBJS)
101 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
102
103 mdadm.static : $(OBJS) $(STATICOBJS)
104 $(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
105
106 mdadm.tcc : $(SRCS) mdadm.h
107 $(TCC) -o mdadm.tcc $(SRCS)
108
109 dadm.uclibc : $(SRCS) mdadm.h
110 $(UCLIBC_GCC) -DUCLIBC -DHAVE_STDINT_H -o mdadm.uclibc $(SRCS) $(STATICSRC)
111
112 mdadm.klibc : $(SRCS) mdadm.h
113 rm -f $(OBJS)
114 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)
115
116 mdadm.Os : $(SRCS) mdadm.h
117 gcc -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
118
119 mdadm.O2 : $(SRCS) mdadm.h
120 gcc -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
121
122 test_stripe : restripe.c mdadm.h
123 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
124
125 mdassemble : $(ASSEMBLE_SRCS) mdadm.h
126 rm -f $(OBJS)
127 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
128
129 mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
130 rm -f $(OBJS)
131 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
132
133 mdassemble.auto : $(ASSEMBLE_SRCS) mdadm.h $(ASSEMBLE_AUTO_SRCS)
134 rm -f mdassemble.static
135 $(MAKE) MDASSEMBLE_AUTO=1 mdassemble.static
136 mv mdassemble.static mdassemble.auto
137
138 mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
139 rm -f $(OJS)
140 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
141
142 # This doesn't work
143 mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
144 rm -f $(OBJS)
145 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
146
147 mdadm.man : mdadm.8
148 nroff -man mdadm.8 > mdadm.man
149
150 md.man : md.4
151 nroff -man md.4 > md.man
152
153 mdadm.conf.man : mdadm.conf.5
154 nroff -man mdadm.conf.5 > mdadm.conf.man
155
156 mdassemble.man : mdassemble.8
157 nroff -man mdassemble.8 > mdassemble.man
158
159 $(OBJS) : mdadm.h bitmap.h
160
161 sha1.o : sha1.c sha1.h md5.h
162 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
163
164 install : mdadm install-man
165 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
166
167 install-static : mdadm.static install-man
168 $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
169
170 install-tcc : mdadm.tcc install-man
171 $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
172
173 install-uclibc : mdadm.uclibc install-man
174 $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
175
176 install-klibc : mdadm.klibc install-man
177 $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
178
179 install-man: mdadm.8 md.4 mdadm.conf.5
180 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
181 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
182 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
183
184 uninstall:
185 rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 md.4 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
186
187 test: mdadm test_stripe swap_super
188 @echo "Please run 'sh ./test' as root"
189
190 clean :
191 rm -f mdadm $(OBJS) $(STATICOBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
192 mdadm.Os mdadm.O2 \
193 mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
194 mdassemble.klibc swap_super \
195 init.cpio.gz mdadm.uclibc.static test_stripe
196
197 dist : clean
198 ./makedist
199
200 testdist : everything clean
201 ./makedist test
202
203 TAGS :
204 etags *.h *.c