mdadm/Makefile

275 lines
9.1 KiB
Makefile
Raw Normal View History

2001-06-08 04:36:23 +02:00
#
2002-03-08 01:03:52 +01:00
# mdadm - manage Linux "md" devices aka RAID arrays.
2001-06-08 04:36:23 +02:00
#
2002-03-07 00:17:40 +01:00
# Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
2001-06-08 04:36:23 +02:00
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Author: Neil Brown
# Email: <neilb@cse.unsw.edu.au>
# Paper: Neil Brown
# School of Computer Science and Engineering
# The University of New South Wales
# Sydney, 2052
# Australia
#
2002-05-10 06:06:19 +02:00
# define "CXFLAGS" to give extra flags to CC.
# e.g. make CXFLAGS=-O to optimise
2003-02-12 01:17:26 +01:00
TCC = tcc
2004-08-11 04:16:01 +02:00
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 )
#DIET_GCC = diet gcc
# sorry, but diet-libc doesn't know about posix_memalign,
# so we cannot use it any more.
DIET_GCC = gcc -DHAVE_STDINT_H
2004-11-01 05:49:34 +01:00
KLIBC=/home/src/klibc/klibc-0.77
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
2003-02-12 01:17:26 +01:00
CC = $(CROSS_COMPILE)gcc
2002-05-10 06:06:19 +02:00
CXFLAGS = -ggdb
2003-07-29 01:59:00 +02:00
CWFLAGS = -Wall -Werror -Wstrict-prototypes
trivial warn_unused_result squashing Made the mistake of recompiling the F9 mdadm rpm which has a patch to remove -Werror and add "-Wp,-D_FORTIFY_SOURCE -O2" which turns on lots of errors: config.c:568: warning: ignoring return value of asprintf Assemble.c:411: warning: ignoring return value of asprintf Assemble.c:413: warning: ignoring return value of asprintf super0.c:549: warning: ignoring return value of posix_memalign super0.c:742: warning: ignoring return value of posix_memalign super0.c:812: warning: ignoring return value of posix_memalign super1.c:692: warning: ignoring return value of posix_memalign super1.c:1039: warning: ignoring return value of posix_memalign super1.c:1155: warning: ignoring return value of posix_memalign super-ddf.c:508: warning: ignoring return value of posix_memalign super-ddf.c:645: warning: ignoring return value of posix_memalign super-ddf.c:696: warning: ignoring return value of posix_memalign super-ddf.c:715: warning: ignoring return value of posix_memalign super-ddf.c:1476: warning: ignoring return value of posix_memalign super-ddf.c:1603: warning: ignoring return value of posix_memalign super-ddf.c:1614: warning: ignoring return value of posix_memalign super-ddf.c:1842: warning: ignoring return value of posix_memalign super-ddf.c:2013: warning: ignoring return value of posix_memalign super-ddf.c:2140: warning: ignoring return value of write super-ddf.c:2143: warning: ignoring return value of write super-ddf.c:2147: warning: ignoring return value of write super-ddf.c:2150: warning: ignoring return value of write super-ddf.c:2162: warning: ignoring return value of write super-ddf.c:2169: warning: ignoring return value of write super-ddf.c:2172: warning: ignoring return value of write super-ddf.c:2176: warning: ignoring return value of write super-ddf.c:2181: warning: ignoring return value of write super-ddf.c:2686: warning: ignoring return value of posix_memalign super-ddf.c:2690: warning: ignoring return value of write super-ddf.c:3070: warning: ignoring return value of posix_memalign super-ddf.c:3254: warning: ignoring return value of posix_memalign bitmap.c:128: warning: ignoring return value of posix_memalign mdmon.c:94: warning: ignoring return value of write mdmon.c:221: warning: ignoring return value of pipe mdmon.c:327: warning: ignoring return value of write mdmon.c:330: warning: ignoring return value of chdir mdmon.c:335: warning: ignoring return value of dup monitor.c:415: warning: rv may be used uninitialized in this function ...some of these like the write() ones are not so trivial so save those fixes for the next patch. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-28 21:12:07 +02:00
ifdef WARN_UNUSED
CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O
endif
ifdef DEBIAN
CPPFLAGS := -DDEBIAN
else
CPPFLAGS :=
endif
ifdef DEFAULT_OLD_METADATA
CPPFLAG += -DDEFAULT_OLD_METADATA
DEFAULT_METADATA=0.90
else
DEFAULT_METADATA=1.2
endif
2002-03-20 23:39:50 +01:00
SYSCONFDIR = /etc
CONFFILE = $(SYSCONFDIR)/mdadm.conf
CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
2003-07-29 01:59:00 +02:00
MAILCMD =/usr/sbin/sendmail -t
CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
Fix all the confusion over directories once and for all. We now have 3 directory definitions: mdmon directory for its pid and sock files (compile time define, not changable at run time), mdmonitor directory which is for the mdadm monitor mode pid file (can only be passed in via command line at the time mdadm is invoked in monitor mode), and the directory for the mdadm incremental assembly map file (compile time define, not changable at run time). Only the mdadm map file still hunts multiple locations, and the number of locations has been reduced to /var/run and the compile time specified location. Re-use of similar sounding defines that actually didn't denote their actual usage at compile time made it more difficult for a person to know what affect changing the compile time defines would have on the resulting programs. This patch renames the various defines to clearly identify which item the define affects. It also reduces the number of various directories which will be searched for these files as this has lead to confusion in mdadm and mdmon in terms of which files should take precedence when files exist in multiple locations, etc. It's best if the person compiling the program intentionally and with planning selects the right directories to be used for the various purposes. Which directory is right depends on which items you are talking about and what boot loader your system uses and what initramfs generation program your system uses. Because of the inter-dependency of all these items it would typically be up to the distribution that mdadm is being integrated into to select the correct values for these defines. Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-20 18:15:37 +02:00
# Both MAP_DIR and MDMON_DIR should be somewhere that persists across the
# pivotroot from early boot to late boot.
# /dev is an odd place to put this, but it is the only directory that
# meets the requirements.
MAP_DIR=/dev/.mdadm
Fix all the confusion over directories once and for all. We now have 3 directory definitions: mdmon directory for its pid and sock files (compile time define, not changable at run time), mdmonitor directory which is for the mdadm monitor mode pid file (can only be passed in via command line at the time mdadm is invoked in monitor mode), and the directory for the mdadm incremental assembly map file (compile time define, not changable at run time). Only the mdadm map file still hunts multiple locations, and the number of locations has been reduced to /var/run and the compile time specified location. Re-use of similar sounding defines that actually didn't denote their actual usage at compile time made it more difficult for a person to know what affect changing the compile time defines would have on the resulting programs. This patch renames the various defines to clearly identify which item the define affects. It also reduces the number of various directories which will be searched for these files as this has lead to confusion in mdadm and mdmon in terms of which files should take precedence when files exist in multiple locations, etc. It's best if the person compiling the program intentionally and with planning selects the right directories to be used for the various purposes. Which directory is right depends on which items you are talking about and what boot loader your system uses and what initramfs generation program your system uses. Because of the inter-dependency of all these items it would typically be up to the distribution that mdadm is being integrated into to select the correct values for these defines. Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-20 18:15:37 +02:00
MAP_FILE = map
MDMON_DIR = /dev/.mdadm
Fix all the confusion over directories once and for all. We now have 3 directory definitions: mdmon directory for its pid and sock files (compile time define, not changable at run time), mdmonitor directory which is for the mdadm monitor mode pid file (can only be passed in via command line at the time mdadm is invoked in monitor mode), and the directory for the mdadm incremental assembly map file (compile time define, not changable at run time). Only the mdadm map file still hunts multiple locations, and the number of locations has been reduced to /var/run and the compile time specified location. Re-use of similar sounding defines that actually didn't denote their actual usage at compile time made it more difficult for a person to know what affect changing the compile time defines would have on the resulting programs. This patch renames the various defines to clearly identify which item the define affects. It also reduces the number of various directories which will be searched for these files as this has lead to confusion in mdadm and mdmon in terms of which files should take precedence when files exist in multiple locations, etc. It's best if the person compiling the program intentionally and with planning selects the right directories to be used for the various purposes. Which directory is right depends on which items you are talking about and what boot loader your system uses and what initramfs generation program your system uses. Because of the inter-dependency of all these items it would typically be up to the distribution that mdadm is being integrated into to select the correct values for these defines. Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-20 18:15:37 +02:00
DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\"
DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
2002-03-20 23:39:50 +01:00
# The glibc TLS ABI requires applications that call clone(2) to set up
# TLS data structures, use pthreads until mdmon implements this support
USE_PTHREADS = 1
ifdef USE_PTHREADS
CFLAGS += -DUSE_PTHREADS
LDFLAGS += -pthread
endif
2002-03-20 23:39:50 +01:00
# If you want a static binary, you might uncomment these
# LDFLAGS = -static
# STRIP = -s
2001-06-08 04:36:23 +02:00
2002-03-07 00:17:40 +01:00
INSTALL = /usr/bin/install
2002-04-06 00:00:28 +02:00
DESTDIR =
2002-03-08 01:03:52 +01:00
BINDIR = /sbin
2002-04-06 00:00:28 +02:00
MANDIR = /usr/share/man
MAN4DIR = $(MANDIR)/man4
MAN5DIR = $(MANDIR)/man5
MAN8DIR = $(MANDIR)/man8
2002-03-07 00:17:40 +01:00
2004-11-01 05:49:34 +01:00
OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
Incremental.o \
mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o \
platform-intel.o probe_roms.o
2004-11-01 05:49:34 +01:00
SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
Incremental.c \
mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c \
platform-intel.c probe_roms.c
2008-05-15 08:48:37 +02:00
MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
super-ddf.o sha1.o crc32.o msg.o bitmap.o \
platform-intel.o probe_roms.o
2008-05-15 08:48:37 +02:00
MON_SRCS = mdmon.c monitor.c managemon.c util.c mdstat.c sysfs.c config.c \
Kill.c sg_io.c dlink.c ReadMe.c super0.c super1.c super-intel.c \
super-ddf.c sha1.c crc32.c msg.c bitmap.c \
platform-intel.c probe_roms.c
2008-05-15 08:48:37 +02:00
STATICSRC = pwgr.c
STATICOBJS = pwgr.o
ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c \
super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \
2009-03-10 06:47:02 +01:00
platform-intel.c probe_roms.c sysfs.c
ASSEMBLE_AUTO_SRCS := mdopen.c
ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
2004-11-01 05:49:34 +01:00
ifdef MDASSEMBLE_AUTO
ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
2004-11-01 05:49:34 +01:00
endif
2002-03-07 00:17:40 +01:00
all : mdadm mdmon mdadm.man md.man mdadm.conf.man mdmon.man
2001-06-08 04:36:23 +02:00
everything: all mdadm.static swap_super test_stripe \
mdassemble mdassemble.auto mdassemble.static mdassemble.man \
mdadm.Os mdadm.O2
2009-03-10 06:38:37 +01:00
everything-test: all mdadm.static swap_super test_stripe \
mdassemble.auto mdassemble.static mdassemble.man \
mdadm.Os mdadm.O2
# mdadm.uclibc and mdassemble.uclibc don't work on x86-64
# mdadm.tcc doesn't work..
2003-02-12 01:17:26 +01:00
mdadm : $(OBJS)
$(CC) $(LDFLAGS) -o mdadm $(OBJS) $(LDLIBS)
2001-06-08 04:36:23 +02:00
mdadm.static : $(OBJS) $(STATICOBJS)
$(CC) $(LDFLAGS) -static -o mdadm.static $(OBJS) $(STATICOBJS)
2003-02-12 01:17:26 +01:00
mdadm.tcc : $(SRCS) mdadm.h
$(TCC) -o mdadm.tcc $(SRCS)
2003-03-03 00:11:38 +01:00
mdadm.klibc : $(SRCS) mdadm.h
rm -f $(OBJS)
$(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)
2003-03-03 00:11:38 +01:00
mdadm.Os : $(SRCS) mdadm.h
$(CC) -o mdadm.Os $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -Os $(SRCS)
mdadm.O2 : $(SRCS) mdadm.h mdmon.O2
$(CC) -o mdadm.O2 $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(SRCS)
mdmon.O2 : $(MON_SRCS) mdadm.h mdmon.h
$(CC) -o mdmon.O2 $(CFLAGS) $(LDFLAGS) -DHAVE_STDINT_H -O2 -D_FORTIFY_SOURCE=2 $(MON_SRCS)
# use '-z now' to guarantee no dynamic linker interactions with the monitor thread
2008-05-15 08:48:37 +02:00
mdmon : $(MON_OBJS)
$(CC) $(LDFLAGS) -z now -o mdmon $(MON_OBJS) $(LDLIBS)
msg.o: msg.c msg.h
2008-05-15 08:48:37 +02:00
test_stripe : restripe.c mdadm.h
$(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
2004-11-01 05:49:34 +01:00
mdassemble : $(ASSEMBLE_SRCS) mdadm.h
2004-01-22 03:10:29 +01:00
rm -f $(OBJS)
$(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
2004-01-22 03:10:29 +01:00
2004-11-01 05:49:34 +01:00
mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
$(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -DHAVE_STDINT_H -o mdassemble.static $(ASSEMBLE_SRCS) $(STATICSRC)
2004-11-01 05:49:34 +01:00
mdassemble.auto : $(ASSEMBLE_SRCS) mdadm.h $(ASSEMBLE_AUTO_SRCS)
rm -f mdassemble.static
$(MAKE) MDASSEMBLE_AUTO=1 mdassemble.static
mv mdassemble.static mdassemble.auto
2004-11-01 05:49:34 +01:00
mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OJS)
$(UCLIBC_GCC) $(ASSEMBLE_FLAGS) -DUCLIBC -DHAVE_STDINT_H -static -o mdassemble.uclibc $(ASSEMBLE_SRCS) $(STATICSRC)
2004-01-22 03:10:29 +01:00
2004-11-01 05:49:34 +01:00
# This doesn't work
mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
rm -f $(OBJS)
$(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
2004-01-22 03:10:29 +01:00
mdadm.8 : mdadm.8.in
sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' mdadm.8.in > mdadm.8
2002-03-08 01:03:52 +01:00
mdadm.man : mdadm.8
nroff -man mdadm.8 > mdadm.man
2002-03-07 00:17:40 +01:00
mdmon.man : mdmon.8
nroff -man mdmon.8 > mdmon.man
2002-03-15 06:21:36 +01:00
md.man : md.4
nroff -man md.4 > md.man
mdadm.conf.man : mdadm.conf.5
nroff -man mdadm.conf.5 > mdadm.conf.man
mdassemble.man : mdassemble.8
nroff -man mdassemble.8 > mdassemble.man
$(OBJS) : mdadm.h mdmon.h bitmap.h
$(MON_OBJS) : mdadm.h mdmon.h bitmap.h
2001-06-08 04:36:23 +02:00
sha1.o : sha1.c sha1.h md5.h
$(CC) $(CFLAGS) -DHAVE_STDINT_H -o sha1.o -c sha1.c
install : mdadm mdmon install-man install-udev
2002-04-06 00:00:28 +02:00
$(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
$(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
install-static : mdadm.static install-man
$(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
install-tcc : mdadm.tcc install-man
$(INSTALL) -D $(STRIP) -m 755 mdadm.tcc $(DESTDIR)$(BINDIR)/mdadm
install-uclibc : mdadm.uclibc install-man
$(INSTALL) -D $(STRIP) -m 755 mdadm.uclibc $(DESTDIR)$(BINDIR)/mdadm
install-klibc : mdadm.klibc install-man
$(INSTALL) -D $(STRIP) -m 755 mdadm.klibc $(DESTDIR)$(BINDIR)/mdadm
install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
2002-04-06 00:00:28 +02:00
$(INSTALL) -D -m 644 mdadm.8 $(DESTDIR)$(MAN8DIR)/mdadm.8
$(INSTALL) -D -m 644 mdmon.8 $(DESTDIR)$(MAN8DIR)/mdmon.8
2002-04-06 00:00:28 +02:00
$(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
$(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
2002-03-07 00:17:40 +01:00
install-udev: udev-md-raid.rules
$(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
uninstall:
rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
test: mdadm mdmon test_stripe swap_super
@echo "Please run 'sh ./test' as root"
2001-06-08 04:36:23 +02:00
clean :
2008-05-15 08:48:37 +02:00
rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
2010-03-10 05:58:46 +01:00
mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt .merge_file_* \
mdadm.Os mdadm.O2 mdmon.O2 \
mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
mdassemble.klibc swap_super \
2009-03-10 06:38:37 +01:00
init.cpio.gz mdadm.uclibc.static test_stripe mdmon
2001-06-08 04:36:23 +02:00
dist : clean
./makedist
2001-06-14 07:33:53 +02:00
2009-03-10 06:38:37 +01:00
testdist : everything-test clean
./makedist test
2001-06-14 07:33:53 +02:00
TAGS :
etags *.h *.c
DISTRO_MAKEFILE := $(wildcard distropkg/Makefile)
ifdef DISTRO_MAKEFILE
include $(DISTRO_MAKEFILE)
endif