handle Manage_subdevs() for 'external' arrays
[thirdparty/mdadm.git] / Makefile
CommitLineData
64c4757e 1#
9a9dab36 2# mdadm - manage Linux "md" devices aka RAID arrays.
64c4757e 3#
cd29a5c8 4# Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
64c4757e
NB
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
2d465520
NB
30# define "CXFLAGS" to give extra flags to CC.
31# e.g. make CXFLAGS=-O to optimise
5787fa49 32TCC = tcc
e5329c37 33UCLIBC_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 )
b5e64645
NB
34DIET_GCC = diet gcc
35
36KLIBC=/home/src/klibc/klibc-0.77
37
38KLIBC_GCC = gcc -nostdinc -iwithprefix include -I$(KLIBC)/klibc/include -I$(KLIBC)/linux/include -I$(KLIBC)/klibc/arch/i386/include -I$(KLIBC)/klibc/include/bits32
5787fa49 39
c9fae710 40CC = $(CROSS_COMPILE)gcc
2d465520 41CXFLAGS = -ggdb
aa88f531 42CWFLAGS = -Wall -Werror -Wstrict-prototypes
5bbb4842
NB
43
44ifdef DEBIAN
45CPPFLAGS= -DDEBIAN
46else
47CPPFLAGS=
48endif
49
11a3e71d
NB
50SYSCONFDIR = /etc
51CONFFILE = $(SYSCONFDIR)/mdadm.conf
4e9b5839 52CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
aa88f531 53MAILCMD =/usr/sbin/sendmail -t
4e9b5839 54CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
55CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS)
11a3e71d
NB
56
57# If you want a static binary, you might uncomment these
58# LDFLAGS = -static
59# STRIP = -s
64c4757e 60
cd29a5c8 61INSTALL = /usr/bin/install
c913b90e 62DESTDIR =
9a9dab36 63BINDIR = /sbin
c913b90e
NB
64MANDIR = /usr/share/man
65MAN4DIR = $(MANDIR)/man4
66MAN5DIR = $(MANDIR)/man5
67MAN8DIR = $(MANDIR)/man8
cd29a5c8 68
b5e64645 69OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
c82f047c 70 Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
8382f19b 71 Incremental.o \
cdddbdbc 72 mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
f7dd881f 73 restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o
b5e64645 74SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
c82f047c 75 Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
8382f19b 76 Incremental.c \
cdddbdbc 77 mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
f7dd881f 78 restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c
4b1ac34b 79
8268ed74
NB
80STATICSRC = pwgr.c
81STATICOBJS = pwgr.o
1377730f 82
a322f70c 83ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c \
cdddbdbc 84 super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c
b56c3630 85ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
b5e64645
NB
86ifdef MDASSEMBLE_AUTO
87ASSEMBLE_SRCS += mdopen.c mdstat.c
c7654afc 88ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
b5e64645 89endif
cd29a5c8 90
56eb10c0 91all : mdadm mdadm.man md.man mdadm.conf.man
64c4757e 92
5624768a
NB
93everything: all mdadm.static swap_super test_stripe \
94 mdassemble mdassemble.static mdassemble.man \
95 mdadm.Os mdadm.O2
f783ca4f 96# mdadm.uclibc and mdassemble.uclibc don't work on x86-64
8431b2b2 97# mdadm.tcc doesn't work..
5787fa49 98
c97be4db 99mdadm : $(OBJS)
05697ec1 100 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
64c4757e 101
c97be4db
NB
102mdadm.static : $(OBJS) $(STATICOBJS)
103 $(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
5787fa49
NB
104
105mdadm.tcc : $(SRCS) mdadm.h
106 $(TCC) -o mdadm.tcc $(SRCS)
107
5624768a 108dadm.uclibc : $(SRCS) mdadm.h
c97be4db 109 $(UCLIBC_GCC) -DUCLIBC -DHAVE_STDINT_H -o mdadm.uclibc $(SRCS) $(STATICSRC)
5787fa49 110
d013a55e
NB
111mdadm.klibc : $(SRCS) mdadm.h
112 rm -f $(OBJS)
113 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)
114
5624768a
NB
115mdadm.Os : $(SRCS) mdadm.h
116 gcc -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
117
118mdadm.O2 : $(SRCS) mdadm.h
119 gcc -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
120
e86c9dd6
NB
121test_stripe : restripe.c mdadm.h
122 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
123
b5e64645 124mdassemble : $(ASSEMBLE_SRCS) mdadm.h
98c6faba 125 rm -f $(OBJS)
c97be4db 126 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
98c6faba 127
b5e64645
NB
128mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
129 rm -f $(OBJS)
c97be4db 130 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
b5e64645
NB
131
132mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
d1f1011b 133 rm -f $(OJS)
c97be4db 134 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
98c6faba 135
b5e64645
NB
136# This doesn't work
137mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
138 rm -f $(OBJS)
b56c3630 139 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
98c6faba 140
9a9dab36
NB
141mdadm.man : mdadm.8
142 nroff -man mdadm.8 > mdadm.man
cd29a5c8 143
56eb10c0
NB
144md.man : md.4
145 nroff -man md.4 > md.man
146
147mdadm.conf.man : mdadm.conf.5
148 nroff -man mdadm.conf.5 > mdadm.conf.man
149
ccf44f32
NB
150mdassemble.man : mdassemble.8
151 nroff -man mdassemble.8 > mdassemble.man
152
c82f047c 153$(OBJS) : mdadm.h bitmap.h
64c4757e 154
05697ec1
NB
155sha1.o : sha1.c sha1.h md5.h
156 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
05697ec1 157
ff7754ed 158install : mdadm install-man
c913b90e 159 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
ff7754ed
NB
160
161install-static : mdadm.static install-man
162 $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
163
164install-tcc : mdadm.tcc install-man
165 $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
166
167install-uclibc : mdadm.uclibc install-man
168 $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
169
170install-klibc : mdadm.klibc install-man
171 $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
172
173install-man: mdadm.8 md.4 mdadm.conf.5
c913b90e
NB
174 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
175 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
176 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
cd29a5c8 177
3bb59d40
NB
178uninstall:
179 rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 md.4 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
180
5624768a
NB
181test: mdadm test_stripe swap_super
182 @echo "Please run 'sh ./test' as root"
183
64c4757e 184clean :
1377730f 185 rm -f mdadm $(OBJS) $(STATICOBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
5624768a 186 mdadm.Os mdadm.O2 \
0ff1a185 187 mdassemble mdassemble.static mdassemble.uclibc mdassemble.klibc swap_super \
39c5a909 188 init.cpio.gz mdadm.uclibc.static test_stripe
64c4757e
NB
189
190dist : clean
191 ./makedist
682c7051 192
1e0d770c
NB
193testdist : everything clean
194 ./makedist test
195
682c7051
NB
196TAGS :
197 etags *.h *.c