patch-1.3.39 linux/Rules.make

Next file: linux/arch/alpha/Makefile
Previous file: linux/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.38/linux/Rules.make linux/Rules.make
@@ -22,6 +22,13 @@
 unexport O_OBJS
 unexport L_OBJS
 unexport M_OBJS
+unexport ALL_MOBJS
+# objects that export symbol tables
+unexport OX_OBJS
+unexport LX_OBJS
+unexport MX_OBJS
+unexport SYMTAB_OBJS
+
 unexport MOD_LIST_NAME
 
 #
@@ -46,10 +53,11 @@
 # Rule to compile a set of .o files into one .o file
 #
 ifdef O_TARGET
-$(O_TARGET): $(O_OBJS) $(TOPDIR)/include/linux/config.h
+ALL_O = $(OX_OBJS) $(O_OBJS)
+$(O_TARGET): $(ALL_O) $(TOPDIR)/include/linux/config.h
 	rm -f $@
-ifdef O_OBJS
-	$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(O_OBJS)
+ifneq "$(strip $(ALL_O))" ""
+	$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(ALL_O)
 else
 	$(AR) rcs $@
 endif
@@ -59,9 +67,9 @@
 # Rule to compile a set of .o files into one .a file
 #
 ifdef L_TARGET
-$(L_TARGET): $(L_OBJS) $(TOPDIR)/include/linux/config.h
+$(L_TARGET): $(LX_OBJS) $(L_OBJS) $(TOPDIR)/include/linux/config.h
 	rm -f $@
-	$(AR) $(EXTRA_ARFLAGS) rcs $@ $(L_OBJS)
+	$(AR) $(EXTRA_ARFLAGS) rcs $@ $(LX_OBJS) $(L_OBJS)
 endif
 
 #
@@ -85,10 +93,11 @@
 #
 # A rule to make modules
 #
-ifdef M_OBJS
+ALL_MOBJS = $(MX_OBJS) $(M_OBJS)
+ifneq "$(strip $(ALL_MOBJS))" ""
 PDWN=$(shell /bin/sh $(TOPDIR)/scripts/pathdown.sh)
 endif
-modules: $(M_OBJS) dummy
+modules: $(ALL_MOBJS) dummy
 ifdef MOD_SUB_DIRS
 	set -e; for i in $(MOD_SUB_DIRS); do $(MAKE) -C $$i modules; done
 endif
@@ -98,13 +107,13 @@
 	for i in $(MOD_SUB_DIRS); do \
 	    echo `basename $$i`.o >> $$TOPDIR/modules/$(MOD_LIST_NAME); done
 endif
-ifdef M_OBJS
-	echo $(M_OBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
+ifneq "$(strip $(ALL_MOBJS))" ""
+	echo $(ALL_MOBJS) >> $$TOPDIR/modules/$(MOD_LIST_NAME)
 endif
 endif
-ifdef M_OBJS
+ifneq "$(strip $(ALL_MOBJS))" ""
 	echo $(PDWN)
-	cd $$TOPDIR/modules; for i in $(M_OBJS); do \
+	cd $$TOPDIR/modules; for i in $(ALL_MOBJS); do \
 	    ln -sf ../$(PDWN)/$$i .; done
 endif
 
@@ -118,6 +127,41 @@
 #
 script:
 	$(SCRIPT)
+
+#
+# This sets version suffixes on exported symbols
+# Uses SYMTAB_OBJS
+# Separate the object into "normal" objects and "exporting" objects
+# Exporting objects are: all objects that define symbol tables
+#
+ifdef CONFIG_MODVERSIONS
+SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS)
+ifneq "$(strip $(SYMTAB_OBJS))" ""
+
+%.ver: %.c
+	@if [ ! -x /sbin/genksyms ]; then echo "Please read: README.modules"; fi
+	$(CC) $(CFLAGS) -E -D__GENKSYMS__ $< | /sbin/genksyms -w $(TOPDIR)/include/linux/modules
+	@ln -sf $(TOPDIR)/include/linux/modules/$@ .
+
+$(SYMTAB_OBJS:.o=.ver): $(TOPDIR)/include/linux/autoconf.h
+
+$(TOPDIR)/include/linux/modversions.h: $(SYMTAB_OBJS:.o=.ver)
+	@echo updating $(TOPDIR)/include/linux/modversions.h
+	@(cd $(TOPDIR)/include/linux/modules; for f in *.ver;\
+	do echo "#include <linux/modules/$${f}>"; done) \
+	> $(TOPDIR)/include/linux/modversions.h
+
+$(MX_OBJS): $(TOPDIR)/include/linux/modversions.h
+	$(CC) $(CFLAGS) -DEXPORT_SYMTAB -c $(@:.o=.c)
+
+$(LX_OBJS) $(OX_OBJS): $(TOPDIR)/include/linux/modversions.h
+	$(CC) $(CFLAGS) -DMODVERSIONS -DEXPORT_SYMTAB -c $(@:.o=.c)
+
+dep fastdep: $(TOPDIR)/include/linux/modversions.h
+
+endif
+endif
+
 #
 # include dependency files they exist
 #

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this