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