[DRBD-cvs] r1500 - in trunk: drbd scripts

svn at svn.drbd.org svn at svn.drbd.org
Tue Aug 24 15:48:59 CEST 2004


Author: lars
Date: 2004-08-24 15:48:56 +0200 (Tue, 24 Aug 2004)
New Revision: 1500

Added:
   trunk/scripts/adjust_drbd_config_h.sh
Modified:
   trunk/drbd/Makefile
Log:
added drbd_config.h auto adjustment magic

Modified: trunk/drbd/Makefile
===================================================================
--- trunk/drbd/Makefile	2004-08-23 22:36:57 UTC (rev 1499)
+++ trunk/drbd/Makefile	2004-08-24 13:48:56 UTC (rev 1500)
@@ -66,6 +66,8 @@
     KDIR := /lib/modules/$(shell uname -r)/build
   endif
 
+  # shell ls, because some of them may be missing
+  # inside a patched kernel source tree
   SRC_FILES := $(shell ls 2>/dev/null\
 	linux/drbd_config.h linux/drbd.h drbd_actlog.c drbd_bitmap.c drbd_fs.c \
 	drbd_main.c drbd_proc.c drbd_receiver.c drbd_req.c drbd_worker.c \
@@ -98,6 +100,8 @@
 
   kbuild: drbd_buildtag.c
 	@rm -f .kernelrelease*
+	test -x ../scripts/adjust_drbd_config_h.sh && \
+	 KDIR=$(KDIR) ../scripts/adjust_drbd_config_h.sh
 	$(MAKE) -C $(KDIR) SUBDIRS=$(DRBDSRC) $(ARCH_UM) modules
 	@mv .kernelrelease.new .kernelrelease
 	@echo -n "Memorizing module configuration ... "
@@ -161,5 +165,5 @@
 
   depmod:
 	[ -e $(KDIR)/System.map ] && [ -e ./$(MODOBJ) ] && \
-	   /sbin/depmod -F $(KDIR)/System.map -e ./$(MODOBJ) 2>&1 >/dev/null
+	   /sbin/depmod -F $(KDIR)/System.map -e ./$(MODOBJ) # 2>&1 >/dev/null
 endif

Added: trunk/scripts/adjust_drbd_config_h.sh
===================================================================
--- trunk/scripts/adjust_drbd_config_h.sh	2004-08-23 22:36:57 UTC (rev 1499)
+++ trunk/scripts/adjust_drbd_config_h.sh	2004-08-24 13:48:56 UTC (rev 1500)
@@ -0,0 +1,102 @@
+#!/bin/bash
+# drbd_config.h auto edit magic for 2.4 kernels ...
+
+# expects KDIR in the environment to be set correctly!
+
+set -e
+grep_q() { grep "$@" &>/dev/null ; }
+
+# PARANOIA:
+test -e ./linux/drbd_config.h || {
+       echo >&2 "oops, invoced in unexpected directory..."
+       exit 1
+}
+
+test -n "$KDIR"
+KDIR=${KDIR%/}
+
+ls >/dev/null \
+$KDIR/{.config,Makefile,include/{linux/{version,sched,list,fs},asm/bitops}.h}
+
+
+if grep_q "^PATCHLEVEL *= *4" $KDIR/Makefile ; then
+  # do we have the threadding stuff in the kernel,
+  # and need to use the sighand lock instead of the signal lock?
+  if grep_q "^struct sighand_struct {" $KDIR/include/linux/sched.h ; then
+    need_sighand_hack=1
+  else
+    need_sighand_hack=0
+  fi
+
+  # do we have hlist support already?
+  if grep_q "^struct hlist_head {" $KDIR/include/linux/list.h; then
+    hlist_backport=1
+  else
+    hlist_backport=0
+  fi
+
+  # is this a 2.4.18 kernel, which is supposed to have BH_launder,
+  # but already has BH_Launder?
+  if
+    grep_q '^SUBLEVEL *= *18$' $KDIR/Makefile &&
+    grep_q 'BH_Launder' $KDIR/include/linux/fs.h
+  then
+    need_RH_2_4_18_hack=1
+  else
+    need_RH_2_4_18_hack=0
+  fi
+
+  # do we have find_next_bit?
+  if
+    cat 2>/dev/null $KDIR/include/asm{,/arch}/bitops.h |
+    grep_q 'find_next_bit'
+  then
+    have_find_next_bit=1
+  else
+    have_find_next_bit=0
+  fi
+
+  # TODO autodetect whether we need this:
+  # USE_GENERIC_FIND_NEXT_BIT
+  # 
+
+  # do we have mm_inline, and need to include it explicitly?
+  if test -e $KDIR/include/linux/mm_inline.h ; then
+    have_mm_inline_h=1
+  else
+    have_mm_inline_h=0
+  fi
+else
+    # 2.6. kernel. just leave it alone...
+    need_sighand_hack=0
+    hlist_backport=0
+    need_RH_2_4_18_hack=0
+    have_find_next_bit=0
+    have_mm_inline_h=0
+fi
+
+test -e ./linux/drbd_config.h.orig || cp ./linux/drbd_config.h{,.orig}
+
+perl -i -pe "
+ s{.*(#define SIGHAND_HACK.*)}
+  { ( $need_sighand_hack ? '' : '//' ) . \$1}e;
+ s{.*(#define REDHAT_HLIST_BACKPORT.*)}
+  { ( $hlist_backport ? '' : '//' ) . \$1}e;
+ s{.*(#define REDHAT_2_4_18.*)}
+  { ( $need_RH_2_4_18_hack ? '' : '//' ) . \$1}e;
+ s{.*(#define HAVE_FIND_NEXT_BIT.*)}
+  { ( $have_find_next_bit ? '' : '//' ) . \$1}e;
+ s{.*(#define HAVE_MM_INLINE_H.*)}
+  { ( $have_mm_inline_h ? '' : '//' ) . \$1}e;" ./linux/drbd_config.h
+
+
+if ! DIFF=$(diff -s -U0 ./linux/drbd_config.h{.orig,}) ; then
+  sed -e 's/^/  /' <<___
+
+Adjusted drbd_config.h:
+$DIFF
+
+___
+else
+	echo -e "\n  Using unmodified drbd_config.h\n"
+fi


Property changes on: trunk/scripts/adjust_drbd_config_h.sh
___________________________________________________________________
Name: svn:executable
   + *



More information about the drbd-cvs mailing list