Add gpt pseudo-metadata
[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 )
1cccd683
N
34#DIET_GCC = diet gcc
35# sorry, but diet-libc doesn't know about posix_memalign,
36# so we cannot use it any more.
37DIET_GCC = gcc -DHAVE_STDINT_H
b5e64645
NB
38
39KLIBC=/home/src/klibc/klibc-0.77
40
41KLIBC_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 42
c9fae710 43CC = $(CROSS_COMPILE)gcc
2d465520 44CXFLAGS = -ggdb
f21e18ca 45CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter
3d2c4fc7
DW
46ifdef WARN_UNUSED
47CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O
48endif
5bbb4842
NB
49
50ifdef DEBIAN
26f467a9 51CPPFLAGS := -DDEBIAN
5bbb4842 52else
26f467a9 53CPPFLAGS :=
54endif
55ifdef DEFAULT_OLD_METADATA
56 CPPFLAG += -DDEFAULT_OLD_METADATA
57 DEFAULT_METADATA=0.90
58else
59 DEFAULT_METADATA=1.2
5bbb4842
NB
60endif
61
11a3e71d
NB
62SYSCONFDIR = /etc
63CONFFILE = $(SYSCONFDIR)/mdadm.conf
4e9b5839 64CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
aa88f531 65MAILCMD =/usr/sbin/sendmail -t
4e9b5839 66CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
753cf905
DL
67# Both MAP_DIR and MDMON_DIR should be somewhere that persists across the
68# pivotroot from early boot to late boot.
7f5de63d
N
69# /dev is an odd place to put this, but it is the only directory that
70# meets the requirements.
71MAP_DIR=/dev/.mdadm
753cf905 72MAP_FILE = map
7f5de63d 73MDMON_DIR = /dev/.mdadm
753cf905
DL
74DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\"
75DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
76CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
11a3e71d 77
f4190c2f
DW
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
80USE_PTHREADS = 1
81ifdef USE_PTHREADS
82CFLAGS += -DUSE_PTHREADS
5d40884d 83MON_LDFLAGS += -pthread
f4190c2f
DW
84endif
85
11a3e71d
NB
86# If you want a static binary, you might uncomment these
87# LDFLAGS = -static
88# STRIP = -s
64c4757e 89
cd29a5c8 90INSTALL = /usr/bin/install
c913b90e 91DESTDIR =
9a9dab36 92BINDIR = /sbin
c913b90e
NB
93MANDIR = /usr/share/man
94MAN4DIR = $(MANDIR)/man4
95MAN5DIR = $(MANDIR)/man5
96MAN8DIR = $(MANDIR)/man8
cd29a5c8 97
5527fc74 98OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
c82f047c 99 Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
8382f19b 100 Incremental.o \
cdddbdbc 101 mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
0592faeb 102 super-mbr.o super-gpt.o \
88c32bb1
DW
103 restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o \
104 platform-intel.o probe_roms.o
105
5527fc74 106SRCS = mdadm.c config.c policy.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
c82f047c 107 Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
8382f19b 108 Incremental.c \
cdddbdbc 109 mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
0592faeb 110 super-mbr.c super-gpt.c \
88c32bb1
DW
111 restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c \
112 platform-intel.c probe_roms.c
4b1ac34b 113
0f22b998
N
114INCL = mdadm.h part.h bitmap.h
115
5527fc74 116MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o policy.o \
549e9569 117 Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
0592faeb 118 super-mbr.o super-gpt.o \
38a07ed6 119 super-ddf.o sha1.o crc32.o msg.o bitmap.o \
88c32bb1 120 platform-intel.o probe_roms.o
549e9569 121
5527fc74 122MON_SRCS = mdmon.c monitor.c managemon.c util.c mdstat.c sysfs.c config.c policy.c \
fcf57625 123 Kill.c sg_io.c dlink.c ReadMe.c super0.c super1.c super-intel.c \
0592faeb 124 super-mbr.c super-gpt.c \
fcf57625
N
125 super-ddf.c sha1.c crc32.c msg.c bitmap.c \
126 platform-intel.c probe_roms.c
549e9569 127
8268ed74
NB
128STATICSRC = pwgr.c
129STATICOBJS = pwgr.o
1377730f 130
5527fc74 131ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c policy.c dlink.c util.c \
88c32bb1 132 super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \
0592faeb 133 platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c
8844e291 134ASSEMBLE_AUTO_SRCS := mdopen.c
b56c3630 135ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
b5e64645 136ifdef MDASSEMBLE_AUTO
7702a58b 137ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
c7654afc 138ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
b5e64645 139endif
cd29a5c8 140
e0fe762a 141all : mdadm mdmon mdadm.man md.man mdadm.conf.man mdmon.man
64c4757e 142
5624768a 143everything: all mdadm.static swap_super test_stripe \
7815fbfe 144 mdassemble mdassemble.auto mdassemble.static mdassemble.man \
5624768a 145 mdadm.Os mdadm.O2
388953d2
N
146everything-test: all mdadm.static swap_super test_stripe \
147 mdassemble.auto mdassemble.static mdassemble.man \
148 mdadm.Os mdadm.O2
f783ca4f 149# mdadm.uclibc and mdassemble.uclibc don't work on x86-64
8431b2b2 150# mdadm.tcc doesn't work..
5787fa49 151
c97be4db 152mdadm : $(OBJS)
05697ec1 153 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
64c4757e 154
c97be4db
NB
155mdadm.static : $(OBJS) $(STATICOBJS)
156 $(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
5787fa49 157
0f22b998 158mdadm.tcc : $(SRCS) $(INCL)
5787fa49
NB
159 $(TCC) -o mdadm.tcc $(SRCS)
160
0f22b998 161mdadm.klibc : $(SRCS) $(INCL)
d013a55e 162 rm -f $(OBJS)
667e66d3 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)
d013a55e 164
0f22b998 165mdadm.Os : $(SRCS) $(INCL)
f4190c2f 166 $(CC) -o mdadm.Os $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
5624768a 167
0f22b998 168mdadm.O2 : $(SRCS) $(INCL) mdmon.O2
f4190c2f 169 $(CC) -o mdadm.O2 $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(SRCS)
fcf57625 170
0f22b998 171mdmon.O2 : $(MON_SRCS) $(INCL) mdmon.h
5d40884d 172 $(CC) -o mdmon.O2 $(CFLAGS) $(LDFLAGS) $(MON_LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(MON_SRCS)
5624768a 173
23eb475a 174# use '-z now' to guarantee no dynamic linker interactions with the monitor thread
549e9569 175mdmon : $(MON_OBJS)
8efb9d16 176 $(CC) $(LDFLAGS) $(MON_LDFLAGS) -Wl,-z,now -o mdmon $(MON_OBJS) $(LDLIBS)
b109d928 177msg.o: msg.c msg.h
549e9569 178
e86c9dd6
NB
179test_stripe : restripe.c mdadm.h
180 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
181
0f22b998 182mdassemble : $(ASSEMBLE_SRCS) $(INCL)
98c6faba 183 rm -f $(OBJS)
c97be4db 184 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
98c6faba 185
0f22b998 186mdassemble.static : $(ASSEMBLE_SRCS) $(INCL)
b5e64645 187 rm -f $(OBJS)
c97be4db 188 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
b5e64645 189
0f22b998 190mdassemble.auto : $(ASSEMBLE_SRCS) $(INCL) $(ASSEMBLE_AUTO_SRCS)
7815fbfe
NB
191 rm -f mdassemble.static
192 $(MAKE) MDASSEMBLE_AUTO=1 mdassemble.static
193 mv mdassemble.static mdassemble.auto
194
0f22b998 195mdassemble.uclibc : $(ASSEMBLE_SRCS) $(INCL)
d1f1011b 196 rm -f $(OJS)
c97be4db 197 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
98c6faba 198
b5e64645 199# This doesn't work
0f22b998 200mdassemble.klibc : $(ASSEMBLE_SRCS) $(INCL)
b5e64645 201 rm -f $(OBJS)
b56c3630 202 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
98c6faba 203
26f467a9 204mdadm.8 : mdadm.8.in
205 sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' mdadm.8.in > mdadm.8
206
9a9dab36
NB
207mdadm.man : mdadm.8
208 nroff -man mdadm.8 > mdadm.man
cd29a5c8 209
e0fe762a
N
210mdmon.man : mdmon.8
211 nroff -man mdmon.8 > mdmon.man
212
56eb10c0
NB
213md.man : md.4
214 nroff -man md.4 > md.man
215
216mdadm.conf.man : mdadm.conf.5
217 nroff -man mdadm.conf.5 > mdadm.conf.man
218
ccf44f32
NB
219mdassemble.man : mdassemble.8
220 nroff -man mdassemble.8 > mdassemble.man
221
0f22b998
N
222$(OBJS) : $(INCL) mdmon.h
223$(MON_OBJS) : $(INCL) mdmon.h
64c4757e 224
05697ec1
NB
225sha1.o : sha1.c sha1.h md5.h
226 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
05697ec1 227
757a5d74 228install : mdadm mdmon install-man install-udev
c913b90e 229 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
4ad866b1 230 $(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
ff7754ed
NB
231
232install-static : mdadm.static install-man
233 $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
234
235install-tcc : mdadm.tcc install-man
236 $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
237
238install-uclibc : mdadm.uclibc install-man
239 $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
240
241install-klibc : mdadm.klibc install-man
242 $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
243
e0fe762a 244install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
c913b90e 245 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
e0fe762a 246 $(INSTALL) -D -m 644 mdmon.8 $(DESTDIR)$(MAN8DIR)/mdmon.8
c913b90e
NB
247 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
248 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
cd29a5c8 249
757a5d74 250install-udev: udev-md-raid.rules
25956fef 251 $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
757a5d74 252
3bb59d40 253uninstall:
e0fe762a 254 rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
3bb59d40 255
55e54759 256test: mdadm mdmon test_stripe swap_super
5624768a
NB
257 @echo "Please run 'sh ./test' as root"
258
64c4757e 259clean :
549e9569 260 rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
a31c140f
N
261 mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt .merge_file_* \
262 mdadm.Os mdadm.O2 mdmon.O2 \
7815fbfe
NB
263 mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
264 mdassemble.klibc swap_super \
850a3178
N
265 init.cpio.gz mdadm.uclibc.static test_stripe mdmon \
266 mdadm.8
64c4757e
NB
267
268dist : clean
269 ./makedist
682c7051 270
388953d2 271testdist : everything-test clean
1e0d770c
NB
272 ./makedist test
273
682c7051
NB
274TAGS :
275 etags *.h *.c
0bc38b50
DL
276
277DISTRO_MAKEFILE := $(wildcard distropkg/Makefile)
278ifdef DISTRO_MAKEFILE
279include $(DISTRO_MAKEFILE)
280endif
281