]> git.ipfire.org Git - thirdparty/mdadm.git/blob - Makefile
Makefile improvements for static linking.
[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 LDLIBS=-lssl
36
37 KLIBC=/home/src/klibc/klibc-0.77
38
39 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
40
41 CC = $(CROSS_COMPILE)gcc
42 CXFLAGS = -ggdb
43 CWFLAGS = -Wall -Werror -Wstrict-prototypes
44
45 ifdef DEBIAN
46 CPPFLAGS= -DDEBIAN
47 else
48 CPPFLAGS=
49 endif
50
51 SYSCONFDIR = /etc
52 CONFFILE = $(SYSCONFDIR)/mdadm.conf
53 MAILCMD =/usr/sbin/sendmail -t
54 CFLAGS = $(CWFLAGS) $(STATIC) $(CPPFLAGS) -DCONFFILE=\"$(CONFFILE)\" $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\"
55
56 # If you want a static binary, you might uncomment these
57 # LDFLAGS = -static
58 # STRIP = -s
59
60 INSTALL = /usr/bin/install
61 DESTDIR =
62 BINDIR = /sbin
63 MANDIR = /usr/share/man
64 MAN4DIR = $(MANDIR)/man4
65 MAN5DIR = $(MANDIR)/man5
66 MAN8DIR = $(MANDIR)/man8
67
68 OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
69 Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
70 mdopen.o super0.o super1.o bitmap.o restripe.o sysfs.o
71 SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
72 Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
73 mdopen.c super0.c super1.c bitmap.c restripe.c sysfs.c
74
75 STATICOBJS = SHA1.o sha1.o
76
77 ASSEMBLE_SRCS := mdassemble.c Assemble.c config.c dlink.c util.c super0.c super1.c
78 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
79 ifdef MDASSEMBLE_AUTO
80 ASSEMBLE_SRCS += mdopen.c mdstat.c
81 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
82 endif
83
84 all : mdadm mdadm.man md.man mdadm.conf.man
85
86 everything: all mdadm.static mdadm.uclibc swap_super test_stripe mdassemble mdassemble.uclibc mdassemble.static mdassemble.man
87 # mdadm.tcc doesn't work..
88
89 mdadm : rmconf $(OBJS)
90 $(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
91
92 mdadm.static : STATIC=-DSTATIC
93 mdadm.static : rmconf $(OBJS) $(STATICOBJS)
94 $(CC) $(LDFLAGS) -DSTATIC -static -o mdadm.static $(OBJS) $(STATICOBJS)
95
96 rmconf:
97 rm -f config.o
98
99 mdadm.tcc : $(SRCS) mdadm.h
100 $(TCC) -o mdadm.tcc $(SRCS)
101
102 mdadm.uclibc : $(SRCS) mdadm.h
103 $(UCLIBC_GCC) -DUCLIBC -DHAVE_STDINT_H -o mdadm.uclibc $(SRCS) SHA1.c sha1.c
104
105 mdadm.klibc : $(SRCS) mdadm.h
106 rm -f $(OBJS)
107 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)
108
109 test_stripe : restripe.c mdadm.h
110 $(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
111
112 mdassemble : $(ASSEMBLE_SRCS) mdadm.h
113 rm -f $(OBJS)
114 $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) SHA1.c sha1.c
115
116 mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
117 rm -f $(OBJS)
118 $(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DSTATIC -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) SHA1.c sha1.c
119
120 mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
121 rm -f $(OJS)
122 $(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DSTATIC -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) SHA1.c sha1.c
123
124 # This doesn't work
125 mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
126 rm -f $(OBJS)
127 $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
128
129 mdadm.man : mdadm.8
130 nroff -man mdadm.8 > mdadm.man
131
132 md.man : md.4
133 nroff -man md.4 > md.man
134
135 mdadm.conf.man : mdadm.conf.5
136 nroff -man mdadm.conf.5 > mdadm.conf.man
137
138 mdassemble.man : mdassemble.8
139 nroff -man mdassemble.8 > mdassemble.man
140
141 $(OBJS) : mdadm.h bitmap.h
142
143 sha1.o : sha1.c sha1.h md5.h
144 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
145 SHA1.o : SHA1.c
146 $(CC) $(CFLAGS) -DHAVE_STDINT_H -o SHA1.o -c SHA1.c
147
148 install : mdadm mdadm.8 md.4 mdadm.conf.5
149 $(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
150 $(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
151 $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
152 $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
153
154 clean :
155 rm -f mdadm $(OBJS) $(STATICOBJS) core *.man mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
156 mdassemble mdassemble.static mdassemble.uclibc mdassemble.klibc swap_super \
157 init.cpio.gz mdadm.uclibc.static test_stripe
158
159 dist : clean
160 ./makedist
161
162 testdist : everything clean
163 ./makedist test
164
165 TAGS :
166 etags *.h *.c