[Ocfs2-commits] jlbec commits r1795 - in trunk: . cluster usysfs

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Jan 20 02:34:27 CST 2005


Author: jlbec
Date: 2005-01-20 02:34:25 -0600 (Thu, 20 Jan 2005)
New Revision: 1795

Added:
   trunk/Kbuild-24.make
Modified:
   trunk/Postamble.make
   trunk/Preamble.make
   trunk/cluster/Makefile
   trunk/usysfs/Makefile
Log:

o Update to modern Makebo files.
o Add Kbuild-24.make, a 2.4 external module build system.
o Make usysfs use Kbuild-24.make
o Completely rewrite cluster/Makefile to use Kbuild-24.make



Added: trunk/Kbuild-24.make
===================================================================
--- trunk/Kbuild-24.make	2005-01-19 12:17:58 UTC (rev 1794)
+++ trunk/Kbuild-24.make	2005-01-20 08:34:25 UTC (rev 1795)
@@ -0,0 +1,107 @@
+
+#
+# This is a Makefile for 2.4 external module builds.  Red Hat
+# Enterprise Linux does not support the usual:
+#
+#     make -C /lib/modules/`uname -r`/build SUBDIRS=`pwd` modules
+#
+# So we must hand-roll our compile lines.  This is in a seperate
+# file to keep the regular Makefile readable.
+#
+# This uses the Makebo schema.  So, the compile parts are filled in.
+# All Makefiles using this code should set MODULE_CFLAGS and
+# MODULE_DEFINES for any extra cflags/defines needed.
+#
+
+WARNINGS = -Wall -Wstrict-prototypes
+OPTIMIZE = -O2
+
+KERNEL_DEFINES = -D__KERNEL__ -DMODULE -DLINUX -DEXPORT_SYMTAB
+KERNEL_CFLAGS = -pipe -nostdinc -fno-strict-aliasing -fno-common \
+	-fomit-frame-pointer
+KERNEL_LDADD = -nostdlib
+
+#
+# These arch-specific flags would normally be provided by the
+# kbuild system.  Hope we got them right.
+#
+
+ifneq ($(OCFS_PROCESSOR),x86_64)
+WARNINGS += -Wmissing-prototypes -Wmissing-declarations
+endif 
+
+ifeq ($(OCFS_PROCESSOR),ppc64)
+  MACH_CFLAGS += -m64 -fsigned-char -fno-builtin -msoft-float \
+	-mminimal-toc
+  MACH_LDADD += -m elf64ppc
+endif
+ifeq ($(OCFS_PROCESSOR),x86_64)
+  MACH_CFLAGS += -m64 -mcmodel=kernel
+endif
+ifeq ($(OCFS_PROCESSOR),s390x)
+  MACH_CFLAGS += -fno-strength-reduce -fpic
+  MACH_LDADD += -m elf64_s390
+endif
+
+
+#
+# RHEL tree hacks.  RHEL 2.4 kernel source trees have a tricked-out
+# autoconf.h that contains all the possible configurations
+# mapped by ifdefs.  So, these magic defines switch among the
+# configurations.  The KVER make variable decides which configuration
+# to use.
+# 
+
+ifeq ($(KVER),hugemem)
+  KVER_DEFINES += -D__BOOT_KERNEL_HUGEMEM=1
+  KVER_DEFINES += -D__BOOT_KERNEL_SMP=0
+  KVER_DEFINES += -D__BOOT_KERNEL_UP=0
+endif
+ifeq ($(KVER),smp)
+  KVER_DEFINES += -D__BOOT_KERNEL_HUGEMEM=0
+  KVER_DEFINES += -D__BOOT_KERNEL_SMP=1
+  KVER_DEFINES += -D__BOOT_KERNEL_UP=0
+endif
+ifeq ($(KVER),up)
+  KVER_DEFINES += -D__BOOT_KERNEL_HUGEMEM=0
+  KVER_DEFINES += -D__BOOT_KERNEL_SMP=0
+  KVER_DEFINES += -D__BOOT_KERNEL_UP=1
+endif
+
+INCLUDES = -I. -I$(TOPDIR) -I$(KERNELINC) -I$(GCCINC)
+DEFINES = $(MODULE_DEFINES) $(KERNEL_DEFINES) $(KVER_DEFINES)
+CFLAGS = $(OPTIMIZE) $(MODULE_CFLAGS) $(KERNEL_CFLAGS) $(MACH_CFLAGS) \
+	$(MODVERSIONS) $(WARNINGS)
+LDADD = $(KERNEL_LDADD) $(MACH_LDADD)
+
+#
+# Ripping off some kbuild 2.6 tricks
+#
+
+# Modules that have multiple parts.
+multi-used-m := $(sort $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs))), $(m))))
+multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)))
+single-used-m := $(sort $(filter-out $(multi-used-m), $(obj-m)))
+link_multi_deps = $($(@:.o=-objs))
+
+#
+# It's impossible, AFAICT, to generate the dependancies for each
+# individual object:parts set.  In fact, kbuild 2.6 doesn't try either.
+# They use a simpler trick...they force the rebuild like this, but
+# call if_changed on each target to avoid the useless rebuilds.
+# This is a 2.4 hack, so I don't care that much :-)
+#
+$(multi-used-m): $(multi-objs-m)
+	$(CC) -Wl,-r -o $@ $(LDADD) $(link_multi_deps)
+
+build-modules: $(single-used-m) $(multi-used-m)
+
+install-modules: $(obj-m)
+	$(TOPDIR)/mkinstalldirs $(DESTDIR)$(MODULEDIR)/$(INSTALL_DIR)
+	for file in $(obj-m); do \
+	  $(INSTALL_DATA) $$file $(DESTDIR)/$(MODULEDIR)/$(INSTALL_DIR)/$$file; \
+	done
+
+clean-modules:
+	rm -f *.o *.p *.s
+

Modified: trunk/Postamble.make
===================================================================
--- trunk/Postamble.make	2005-01-19 12:17:58 UTC (rev 1794)
+++ trunk/Postamble.make	2005-01-20 08:34:25 UTC (rev 1795)
@@ -1,14 +1,43 @@
-include $(TOPDIR)/Versioning.make
+ifdef VERSION_SRC
 
-ifdef VERSION_OBJ
+ifndef VERSION_FILES
+$(error Need VERSION_FILES defined for version objects)
+endif
+
+ifndef VERSION_PREFIX
+$(error Need VERSION_PREFIX defined for version objects)
+endif
+
+VERSION_OBJ = $(subst .c,.o,$(VERSION_SRC))
+
+VERSION_NUM = $(VERSION_PREFIX)_BUILD_VERSION
+VERSION_DATE = $(VERSION_PREFIX)_BUILD_DATE
+VERSION_MD5 = $(VERSION_PREFIX)_BUILD_MD5
+
+VERDEFS = -D$(VERSION_NUM)=\""$(VERSION)"\" \
+	  -D$(VERSION_DATE)=\""$(shell LANG=C date)"\" \
+	  -D$(VERSION_MD5)=\""$(shell cat stamp-md5)"\"
+
+VERMAGIC = $(if $(filter $(VERSION_OBJ),$@),$(VERDEFS))
+
+ifneq ($(MAKECMDGOALS),install)
+VERSTAMP = stamp
+endif
+
+stamp: ;
+
+stamp-md5: $(VERSION_FILES)
+	@cat $(VERSION_FILES) Makefile | md5sum | sed -e 's/ .*//' > stamp-md5
+
 $(VERSION_OBJ): stamp-md5 $(VERSTAMP)
 endif
 
+
 LOCAL_CFLAGS = $($(subst /,_,$(basename $@))_CFLAGS)
 LOCAL_CPPFLAGS = $($(subst /,_,$(basename $@))_CPPFLAGS)
 
 %.o: %.c
-	$(CC) $(CFLAGS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(INCLUDES) $(DEFINES) $(VERMAGIC) -o $@ -c $<
+	$(CC) $(CFLAGS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(INCLUDES) $(DEFINES) $(VERMAGIC) $(CDEPFLAGS) -o $@ -c $<
 
 %.p: %.c
 	$(CC) $(CFLAGS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(INCLUDES) $(DEFINES) $(VERMAGIC) -E -o $@ -c $<
@@ -25,7 +54,7 @@
 	$(MAKE) -C $@
 
 .PHONY: all-rules
-all-rules: subdirs $(ALL_RULES) $(LIBRARIES) $(BIN_PROGRAMS) $(SBIN_PROGRAMS) $(MODULES) $(MANS)
+all-rules: subdirs $(LIBRARIES) $(BIN_PROGRAMS) $(SBIN_PROGRAMS) $(UNINST_PROGRAMS) $(MODULES) $(MANS) $(ALL_RULES)
 
 
 INSTALL_SUBDIRS = $(addsuffix -install,$(SUBDIRS))
@@ -92,12 +121,12 @@
 	$(MAKE) -C $(subst -clean,,$@) clean
 
 clean: clean-subdirs $(CLEAN_RULES)
-	rm -f *.o *.p core $(BIN_PROGRAMS) $(SBIN_PROGRAMS) $(LIBRARIES) stamp-md5
+	rm -f *.o *.p .*.d core $(BIN_PROGRAMS) $(SBIN_PROGRAMS) $(LIBRARIES) $(CLEAN_FILE) stamp-md5
 
 
 DIST_SUBDIRS = $(addsuffix -dist,$(SUBDIRS))
 
-.PHONY: dist-all dist-mkdir dist-copy dist-subdirs $(DIST_RULES) $(DIST_SUBDIRS)
+.PHONY: dist-all dist-mkdir dist-copy dist-subdirs dist dist-bye dist-fresh distclean $(DIST_RULES) $(DIST_SUBDIRS)
 
 dist-subdirs: $(DIST_SUBDIRS)
 
@@ -117,8 +146,26 @@
         done
 
 dist-all: dist-copy dist-subdirs
-	 
 
+dist-bye:
+	-rm -rf $(DIST_TOPDIR)
+
+dist-fresh: dist-bye
+	$(TOPDIR)/mkinstalldirs $(DIST_TOPDIR)
+
+dist: dist-fresh dist-all
+	GZIP=$(GZIP_OPTS) tar chozf $(DIST_TOPDIR).tar.gz $(DIST_TOPDIR)
+	$(MAKE) dist-bye
+
+distclean: clean
+	rm -f Config.make config.status config.cache config.log
+
+LOCAL_DFILES := $(wildcard .*.d)
+ifneq ($(LOCAL_DFILES),)
+.PHONY: $(LOCAL_DFILES)
+-include $(LOCAL_DFILES)
+endif
+
 ifeq (Cscope.make,$(wildcard Cscope.make))
 include Cscope.make
 endif

Modified: trunk/Preamble.make
===================================================================
--- trunk/Preamble.make	2005-01-19 12:17:58 UTC (rev 1794)
+++ trunk/Preamble.make	2005-01-20 08:34:25 UTC (rev 1795)
@@ -25,6 +25,8 @@
 
 CFLAGS += $($(subst /,_,$(basename $@))_CFLAGS)
 CFLAGS += -pipe
+# protect with configure?
+CDEPFLAGS = -MD -MP -MF $(@D)/.$(basename $(@F)).d
 
 LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 

Modified: trunk/cluster/Makefile
===================================================================
--- trunk/cluster/Makefile	2005-01-19 12:17:58 UTC (rev 1794)
+++ trunk/cluster/Makefile	2005-01-20 08:34:25 UTC (rev 1795)
@@ -1,49 +1,59 @@
-# See if we are being included by the 2.6 kernel build system.
+
 ifeq ($(KERNELRELEASE),)
-# Normal build that is being called locally
 TOPDIR = ..
 
 include $(TOPDIR)/Preamble.make
+else
+# We are included by kbuild.
 
-else # ifeq ($(KERNELRELEASE),)
-# We are being included by the 2.6.x kernel build system
+OUR_SRC_DIR	:= $(M)
 
-# Global parameter so we know where our stuff is
-CLUSTER_SRC_DIR	:= $(M)
+include $(OUR_SRC_DIR)/../Config.make
 
-include $(CLUSTER_SRC_DIR)/../Config.make
-endif
+STAMP_DIR = $(OUR_SRC_DIR)
 
-#-*******************************************************
-# Now do stuff which is global for 2.4.x and 2.6.x builds
-
-#ifdef OCFS_DEBUG
-OPTS += -g
-#endif
-
-#ifdef OCFS_DEBUG
-GLOBAL_DEFINES += -DDEBUG
-#endif
-
-ifdef OCFS_TRACE
-GLOBAL_DEFINES += -DTRACE
 endif
 
 ifdef HAVE_NPTL
-GLOBAL_DEFINES += -DHAVE_NPTL
+MODULE_DEFINES += -DHAVE_NPTL
 endif
 
 ifdef HAVE_SOCK_CREATE_LITE
-GLOBAL_DEFINES += -DHAVE_SOCK_CREATE_LITE
+MODULE_DEFINES += -DHAVE_SOCK_CREATE_LITE
 endif
 
-CFILES = \
+EXTRA_CFLAGS += $(MODULE_DEFINES)
+
+ifeq ($(KERNELRELEASE),)
+ifeq ($(KERNEL_26),)
+COMPAT_LIBFS := compat_libfs.o
+endif
+endif
+
+obj-m := ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o
+
+ocfs2_dlm-objs := dlmmod.o dlmthread.o dlmrecovery.o util.o \
+	dlmmaster.o dlmast.o dlmconvert.o dlmlock.o dlmunlock.o \
+	$(COMPAT_LIBFS)
+
+ocfs2_nodemanager-objs := nodemanager.o util.o $(COMPAT_LIBFS)
+
+ocfs2_heartbeat-objs := heartbeat.o util.o $(COMPAT_LIBFS)
+
+ocfs2_tcp-objs := tcp.o util.o $(COMPAT_LIBFS)
+
+
+ifeq ($(KERNELRELEASE),)
+#
+# Called from a regular "make".
+#
+
+SOURCES =		\
 	compat_libfs.c	\
 	dlmmaster.c	\
 	dlmmod.c	\
 	dlmast.c	\
 	dlmconvert.c	\
-	dlmlock.c	\
 	dlmunlock.c	\
 	dlmrecovery.c	\
 	dlmthread.c	\
@@ -51,9 +61,9 @@
 	nodemanager.c	\
 	tcp.c		\
 	util.c		\
-	test.c			
+	test.c
 
-HFILES = \
+HEADERS = 		\
 	compat_libfs.h	\
 	dlm_compat.h	\
 	dlmcommon.h	\
@@ -64,173 +74,40 @@
 	util.h		\
 	warning_hack.h
 
-CLEAN_RULES = clean-cluster
+DIST_FILES = $(SOURCES) $(HEADERS)
 
-OBJS = $(subst .c,.o,$(CFILES))
+ALL_RULES = build-modules
 
-# End of stuff which is global for 2.4.x and 2.6.x kernels
-#-********************************************************
+CLEAN_RULES = clean-modules
 
-# See if we are being included by the 2.6 kernel build system.
-ifeq ($(KERNELRELEASE),)
-# Normal build that is being called locally
-# Preliminary 2.6.x kernel support.  See if we are building for the 2.6.x
-# kernel
-ifndef KERNEL_26
-# Building for a 2.4.x kernel
+INSTALL_RULES = install-modules
 
-WARNINGS = -Wall -Wstrict-prototypes
 
-ifeq ($(KVER),vmware)
-  KERNELINC = /usr/src/linux-2.4/include
-endif
+ifneq ($(KERNEL_26),)
+#
+# This is a 2.6 kernel. Just forward to kbuild.
+#
 
-ifeq ($(KVER),suse)
-  GLOBAL_DEFINES += -DSUSE
-endif
-ifeq ($(KVER),hugemem)
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_HUGEMEM=1
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_ENTERPRISE=0
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_SMP=0
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_UP=0
-endif
-ifeq ($(KVER),smp)
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_HUGEMEM=0
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_ENTERPRISE=0 
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_SMP=1 
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_UP=0 
-endif
-ifeq ($(KVER),ent)
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_HUGEMEM=0
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_ENTERPRISE=1 
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_SMP=0 
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_UP=0 
-endif
-ifeq ($(KVER),up)
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_HUGEMEM=0
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_ENTERPRISE=0 
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_SMP=0 
-  GLOBAL_DEFINES += -D__BOOT_KERNEL_UP=1 
-endif
-
-ifeq ($(OCFS_PROCESSOR),ppc64)
-  MACH_CFLAGS += -m64 -fsigned-char -fno-builtin -msoft-float -mminimal-toc
-  LDADD += -m elf64ppc
-endif
-ifeq ($(OCFS_PROCESSOR),x86_64)
-  MACH_CFLAGS += -m64 -mcmodel=kernel
-endif
-
-BASE_DEFINES = -DEXPORT_SYMTAB -DMODULE -DLINUX -D__KERNEL__ 
-DEFINES += $(BASE_DEFINES) $(GLOBAL_DEFINES)
-
-INCLUDES = -I. -I$(KERNELINC) -I$(GCCINC)
-
-CFLAGS = $(OPTS) $(MACH_CFLAGS) -pipe -nostdinc -fno-strict-aliasing \
-	-fno-common -fomit-frame-pointer $(MODVERSIONS) $(WARNINGS)
-LDADD = -nostdlib
-
-OPTIMIZE = -O2
-
-CFLAGS += $(OPTIMIZE)
-
-MODULES = ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o
-TEST_MODULES = ocfs2_cluster_test.o
-
-INSTALL_MODULES = $(MODULES)
-
-# Make dependancies work
-$(CFILES): $(HFILES)
-$(OBJS): $(HFILES)
-
-build-cluster: $(MODULES)
-
-ocfs2_cluster_test.o: test.o util.o compat_libfs.o
-	$(CC) $(OPTS) -Wl,-r -o $@ $^ $(LDADD)
-
-ocfs2_dlm.o: dlmmod.o dlmthread.o dlmrecovery.o util.o compat_libfs.o dlmmaster.o \
-		dlmast.o dlmconvert.o dlmlock.o dlmunlock.o
-	$(CC) $(OPTS) -Wl,-r -o $@ $^ $(LDADD)
-
-ocfs2_nodemanager.o: nodemanager.o util.o compat_libfs.o
-	$(CC) $(OPTS) -Wl,-r -o $@ $^ $(LDADD)
-
-ocfs2_heartbeat.o: heartbeat.o util.o compat_libfs.o
-	$(CC) $(OPTS) -Wl,-r -o $@ $^ $(LDADD)
-
-ocfs2_tcp.o: tcp.o util.o compat_libfs.o
-	$(CC) $(OPTS) -Wl,-r -o $@ $^ $(LDADD)
-
-clean-cluster:
-	rm -f *.o *.p *.s
-
-else # ifndef KERNEL_26
-# The 2.6.x kernel makefile
-
-# This Makefile has two ways through it.  They are:
-#   1.	We are being included by the local Makefile to do a 2.6 kernel build.
-#	In this method we will call the kernel make system to build our module.
-#	This will cause the kernel make system to call back into our makefile
-#	(2nd way).
-
-INSTALL_MODULES = ocfs2_dlm.ko ocfs2_heartbeat.ko ocfs2_nodemanager.ko ocfs2_tcp.ko
-
-#ALL_RULES = stamp-md5 build-cluster
-ALL_RULES = build-cluster
-
-build-cluster:
+build-modules:
 	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules
 
-clean-cluster:
+install-modules:
+	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules_install
+
+clean-modules:
 	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) clean
+else
+#
+# This is a 2.4 kernel.  Because Red Hat's source tree is whack, do
+# everything by hand.
+#
 
-endif # OCFS_KERNEL_2_6
+INSTALL_DIR = ocfs2
 
-INSTALL_RULES = install-cluster
+include $(TOPDIR)/Kbuild-24.make
 
-install-cluster: $(INSTALL_MODULES)
-	$(TOPDIR)/mkinstalldirs $(DESTDIR)$(MODULEDIR)/ocfs2
-	for file in $(INSTALL_MODULES); do \
-	  $(INSTALL_DATA) $$file $(DESTDIR)$(MODULEDIR)/ocfs2/$$file; \
-        done
+endif
 
 include $(TOPDIR)/Postamble.make
 
-else # ifeq ($(KERNELRELEASE),)
-# We are being included by the 2.6 kernel build system.  So we will include the
-# 2.6.x Makefile and skip everything else.
-# The 2.6.x kernel makefile
-
-# This Makefile has two ways through it.  They are:
-#   1.	We are being included by the local Makefile to do a 2.6 kernel build.
-#	In this method we will call the kernel make system to build our module.
-#	This will cause the kernel make system to call back into our makefile
-#	(2nd way).
-#
-#   2.	We are being included by the kernel make system.  So in this method we
-#	just setup the variables that the make system wants and then the kernel
-#	make system will take care of the build.
-
-# 2nd method.  The kernel make system is including us.  We need to setup the
-# various parameters for the kernel make system and then it will take care of
-# building us.
-
-STAMP_DIR = $(CLUSTER_SRC_DIR)
-include $(CLUSTER_SRC_DIR)/../Versioning.make
-
-EXTRA_CFLAGS += $(GLOBAL_DEFINES)
-
-CFLAGS_$(VERSION_OBJ) += $(VERDEFS)
-
-# Kernel Module file to produce
-obj-m += ocfs2_dlm.o ocfs2_heartbeat.o ocfs2_nodemanager.o ocfs2_tcp.o
-
-# list of object files that are used to create our module
-ocfs2_cluster_test-objs := test.o util.o compat_libfs.o
-ocfs2_dlm-objs := dlmmod.o dlmthread.o dlmrecovery.o util.o compat_libfs.o dlmmaster.o \
-		  dlmast.o dlmconvert.o dlmlock.o dlmunlock.o
-ocfs2_nodemanager-objs := nodemanager.o util.o compat_libfs.o
-ocfs2_heartbeat-objs := heartbeat.o util.o compat_libfs.o
-ocfs2_tcp-objs := tcp.o util.o compat_libfs.o
-
-endif # ifneq ($(KERNELRELEASE),)
+endif

Modified: trunk/usysfs/Makefile
===================================================================
--- trunk/usysfs/Makefile	2005-01-19 12:17:58 UTC (rev 1794)
+++ trunk/usysfs/Makefile	2005-01-20 08:34:25 UTC (rev 1795)
@@ -11,48 +11,54 @@
 include $(USYSFS_SRC_DIR)/../Config.make
 endif
 
-HEADERS = usysfs.h usysfs_internal.h
-SOURCES = bin.c dir.c file.c inode.c mount.c symlink.c
-OBJECTS = $(subst .c,.o,$(SOURCES))
-
 ifeq ($(KERNELRELEASE),)
 #
-# Called from a regular "make".  We need to forward to kbuild.
+# Called from a regular "make".
 #
 
-# for now, no 2.4
-ifneq ($(KERNEL_26),)
-ALL_RULES = build-usysfs
+HEADERS = usysfs.h usysfs_internal.h
+USYSFS_SOURCES = bin.c dir.c file.c inode.c mount.c symlink.c
+BOBTEST_SOURCES = bobtest.c
+USYSFS_OBJECTS = $(subst .c,.o,$(USYSFS_SOURCES))
+BOBTEST_OBJECTS = $(subst .c,.o,$(BOBTEST_SOURCES))
 
-CLEAN_RULES = clean-usysfs
+DIST_FILES = $(USYSFS_SOURCES) $(BOBTEST_SOURCES) $(HEADERS)
 
-build-usysfs:
-	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules
+obj-m := usysfs.o bobtest.o
+usysfs-objs := $(USYSFS_OBJECTS)
 
-clean-usysfs:
-	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) clean
+ALL_RULES = build-modules
 
-INSTALL_MODULE = usysfs.ko
-INSTALL_RULES = install-usysfs
+CLEAN_RULES = clean-modules
 
-install-usysfs: $(INSTALL_MODULE)
-	$(TOPDIR)/mkinstaldirs $(DESTDIR)$(MODULEDIR)
-	$(INSTALL_DATA) $< $(DESTDIR)$(MODULEDIR)/$<
-endif
+INSTALL_RULES = install-modules
 
-DIST_FILES = $(SOURCES) $(HEADERS)
 
-include $(TOPDIR)/Postamble.make
+ifneq ($(KERNEL_26),)
+#
+# This is a 2.6 kernel. Just forward to kbuild.
+#
 
+build-modules:
+	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules
+
+install-modules:
+	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules_install
+
+clean-modules:
+	$(MAKE) -C $(KERNELDIR) M=$(CURDIR) clean
 else
-ifeq ($(VERSION).$(PATCHLEVEL),2.4)
+#
+# This is a 2.4 kernel.  Because Red Hat's source tree is whack, do
+# everything by hand.
+#
 
-O_TARGET := usysfs.o
+include $(TOPDIR)/Kbuild-24.make
 
-obj-y := $(OBJECTS)
-obj-m := $(O_TARGET)
+endif
 
-include $(TOPDIR)/Rules.make
+include $(TOPDIR)/Postamble.make
+
 else
 #
 # Called from kbuild in a kernel that predates Kbuild files.
@@ -60,4 +66,3 @@
 
 include $(USYSFS_SRC_DIR)/Kbuild
 endif
-endif



More information about the Ocfs2-commits mailing list