Merge branch 'master' in devel-3.0
[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
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
56 SYSCONFDIR = /etc
57 CONFFILE = $(SYSCONFDIR)/mdadm.conf
58 CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
59 MAILCMD =/usr/sbin/sendmail -t
60 CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
61 CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS)
62
63 # If you want a static binary, you might uncomment these
64 # LDFLAGS = -static
65 # STRIP = -s
66
67 INSTALL = /usr/bin/install
68 DESTDIR =
69 BINDIR = /sbin
70 MANDIR = /usr/share/man
71 MAN4DIR = $(MANDIR)/man4
72 MAN5DIR = $(MANDIR)/man5
73 MAN8DIR = $(MANDIR)/man8
74
75 OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
76 Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
77 Incremental.o \
78 mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
79 restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o \
80 platform-intel.o probe_roms.o
81
82 SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
83 Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
84 Incremental.c \
85 mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
86 restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c \
87 platform-intel.c probe_roms.c
88
89 MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
90 Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
91 super-ddf.o sha1.o crc32.o msg.o Monitor.o bitmap.o \
92 platform-intel.o probe_roms.o
93
94
95 STATICSRC = pwgr.c
96 STATICOBJS = pwgr.o
97
98 ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c \
99 super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \
100 platform-intel.c probe_roms.c sysfs.c
101 ASSEMBLE_AUTO_SRCS := mdopen.c
102 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
103 ifdef MDASSEMBLE_AUTO
104 ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
105 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
106 endif
107
108 all : mdadm mdmon mdadm.man md.man mdadm.conf.man
109
110 everything: all mdadm.static swap_super test_stripe \
111 mdassemble mdassemble.auto mdassemble.static mdassemble.man \
112 mdadm.Os mdadm.O2
113 everything-test: all mdadm.static swap_super test_stripe \
114 mdassemble.auto mdassemble.static mdassemble.man \
115 mdadm.Os mdadm.O2
116 # mdadm.uclibc and mdassemble.uclibc don't work on x86-64
117 # mdadm.tcc doesn't work..
118
119 mdadm : $(OBJS)
120 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
121
122 mdadm.static : $(OBJS) $(STATICOBJS)
123 $(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
124
125 mdadm.tcc : $(SRCS) mdadm.h
126 $(TCC) -o mdadm.tcc $(SRCS)
127
128 mdadm.klibc : $(SRCS) mdadm.h
129 rm -f $(OBJS)
130 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)
131
132 mdadm.Os : $(SRCS) mdadm.h
133 gcc -o mdadm.Os $(CFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
134
135 mdadm.O2 : $(SRCS) mdadm.h
136 gcc -o mdadm.O2 $(CFLAGS) -DHAVE_STDINT_H -O2 $(SRCS)
137
138 mdmon : $(MON_OBJS)
139 $(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
140 msg.o: msg.c msg.h
141
142 test_stripe : restripe.c mdadm.h
143 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
144
145 mdassemble : $(ASSEMBLE_SRCS) mdadm.h
146 rm -f $(OBJS)
147 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
148
149 mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
150 rm -f $(OBJS)
151 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
152
153 mdassemble.auto : $(ASSEMBLE_SRCS) mdadm.h $(ASSEMBLE_AUTO_SRCS)
154 rm -f mdassemble.static
155 $(MAKE) MDASSEMBLE_AUTO=1 mdassemble.static
156 mv mdassemble.static mdassemble.auto
157
158 mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
159 rm -f $(OJS)
160 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
161
162 # This doesn't work
163 mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
164 rm -f $(OBJS)
165 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
166
167 mdadm.man : mdadm.8
168 nroff -man mdadm.8 > mdadm.man
169
170 md.man : md.4
171 nroff -man md.4 > md.man
172
173 mdadm.conf.man : mdadm.conf.5
174 nroff -man mdadm.conf.5 > mdadm.conf.man
175
176 mdassemble.man : mdassemble.8
177 nroff -man mdassemble.8 > mdassemble.man
178
179 $(OBJS) : mdadm.h mdmon.h bitmap.h
180 $(MON_OBJS) : mdadm.h mdmon.h bitmap.h
181
182 sha1.o : sha1.c sha1.h md5.h
183 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
184
185 install : mdadm mdmon install-man install-udev
186 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
187 $(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
188
189 install-static : mdadm.static install-man
190 $(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
191
192 install-tcc : mdadm.tcc install-man
193 $(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
194
195 install-uclibc : mdadm.uclibc install-man
196 $(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
197
198 install-klibc : mdadm.klibc install-man
199 $(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
200
201 install-man: mdadm.8 md.4 mdadm.conf.5
202 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
203 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
204 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
205
206 install-udev: udev-md-raid.rules
207 $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
208
209 uninstall:
210 rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 md.4 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
211
212 test: mdadm test_stripe swap_super
213 @echo "Please run 'sh ./test' as root"
214
215 clean :
216 rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
217 mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
218 mdadm.Os mdadm.O2 \
219 mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
220 mdassemble.klibc swap_super \
221 init.cpio.gz mdadm.uclibc.static test_stripe mdmon
222
223 dist : clean
224 ./makedist
225
226 testdist : everything-test clean
227 ./makedist test
228
229 TAGS :
230 etags *.h *.c
231
232 DISTRO_MAKEFILE := $(wildcard distropkg/Makefile)
233 ifdef DISTRO_MAKEFILE
234 include $(DISTRO_MAKEFILE)
235 endif
236