]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Makefile
Detail: clean up handing of the 'info' we load from superblock.
[thirdparty/mdadm.git] / Makefile
index 56363926031af63254271289b3883fab604aafa4..818e2d1b73f1271631db70bc2b6b4d30b31399fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -48,9 +48,15 @@ CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O
 endif
 
 ifdef DEBIAN
-CPPFLAGS= -DDEBIAN
+CPPFLAGS := -DDEBIAN
 else
-CPPFLAGS=
+CPPFLAGS :=
+endif
+ifdef DEFAULT_OLD_METADATA
+ CPPFLAG += -DDEFAULT_OLD_METADATA
+ DEFAULT_METADATA=0.90
+else
+ DEFAULT_METADATA=1.2
 endif
 
 SYSCONFDIR = /etc
@@ -58,7 +64,24 @@ CONFFILE = $(SYSCONFDIR)/mdadm.conf
 CONFFILE2 = $(SYSCONFDIR)/mdadm/mdadm.conf
 MAILCMD =/usr/sbin/sendmail -t
 CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
-CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS)
+# 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
+MAP_FILE = map
+MDMON_DIR = /dev/.mdadm
+DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\"
+DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
+CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
+
+# 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
 
 # If you want a static binary, you might uncomment these
 # LDFLAGS = -static
@@ -91,6 +114,10 @@ MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
        super-ddf.o sha1.o crc32.o msg.o bitmap.o \
        platform-intel.o probe_roms.o
 
+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
 
 STATICSRC = pwgr.c
 STATICOBJS = pwgr.o
@@ -130,13 +157,17 @@ mdadm.klibc : $(SRCS) mdadm.h
        $(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)
 
 mdadm.Os : $(SRCS) mdadm.h
-       $(CC) -o mdadm.Os $(CFLAGS)  -DHAVE_STDINT_H -Os $(SRCS)
+       $(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)
 
-mdadm.O2 : $(SRCS) mdadm.h
-       $(CC) -o mdadm.O2 $(CFLAGS)  -DHAVE_STDINT_H -O2 $(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
 mdmon : $(MON_OBJS)
-       $(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
+       $(CC) $(LDFLAGS) -z now -o mdmon $(MON_OBJS) $(LDLIBS)
 msg.o: msg.c msg.h
 
 test_stripe : restripe.c mdadm.h
@@ -164,6 +195,9 @@ mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
        rm -f $(OBJS)
        $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
 
+mdadm.8 : mdadm.8.in
+       sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' mdadm.8.in > mdadm.8
+
 mdadm.man : mdadm.8
        nroff -man mdadm.8 > mdadm.man
 
@@ -218,8 +252,8 @@ test: mdadm mdmon test_stripe swap_super
 
 clean : 
        rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
-       mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
-       mdadm.Os mdadm.O2 \
+       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 \
        init.cpio.gz mdadm.uclibc.static test_stripe mdmon