Skip to contentSkip to conversation

2.2.21pre CONFIG_MODVERSIONS make rules update

PATCH New Mikael Pettersson 1 participant 1 message Jan 3, 2002 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.2.21pre CONFIG_MODVERSIONS make rules update

Alan,

Here's a backport of the 2.4 CONFIG_MODVERSIONS make rules for 2.2.21pre. This is needed on fast boxes since 'make dep' can update modversions.h at sub-second intervals, and this breaks make's 'st_mtime'-based dependency checking. (Without this patch, it's basically impossible to build 2.2.20 with modversions on my P4, due to incomplete expansion of symbol versions.)

/Mikael

Makefile +3 -0
diff -ruN linux-2.2.21pre2/Makefile linux-2.2.21pre2.modver-2.4-backport/Makefile
@@ -445,6 +445,9 @@
 #	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep ;done
 # let this be made through the fastdep rule in Rules.make
 	$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)"
+ifdef CONFIG_MODVERSIONS
+	$(MAKE) update-modverfile
+endif
 
 MODVERFILE :=
 
Rules.make +18 -7
diff -ruN linux-2.2.21pre2/Rules.make linux-2.2.21pre2.modver-2.4-backport/Rules.make
@@ -230,8 +230,16 @@
 	
 $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h
 
-$(TOPDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
-	@echo updating $(TOPDIR)/include/linux/modversions.h
+# updates .ver files but not modversions.h
+fastdep: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
+
+# updates .ver files and modversions.h like before (is this needed?)
+dep: fastdep update-modverfile
+
+endif # SYMTAB_OBJS 
+
+# update modversions.h, but only if it would change
+update-modverfile:
 	@(echo "#ifndef _LINUX_MODVERSIONS_H";\
 	  echo "#define _LINUX_MODVERSIONS_H"; \
 	  echo "#include <linux/modsetver.h>"; \
@@ -240,11 +248,14 @@
 	    if [ -f $$f ]; then echo "#include <linux/modules/$${f}>"; fi; \
 	  done; \
 	  echo "#endif"; \
-	) > $@
-
-dep fastdep: $(TOPDIR)/include/linux/modversions.h
-
-endif # SYMTAB_OBJS 
+	) > $(TOPDIR)/include/linux/modversions.h.tmp
+	@if [ -r $(TOPDIR)/include/linux/modversions.h ] && cmp -s $(TOPDIR)/include/linux/modversions.h $(TOPDIR)/include/linux/modversions.h.tmp; then \
+		echo $(TOPDIR)/include/linux/modversions.h was not updated; \
+		rm -f $(TOPDIR)/include/linux/modversions.h.tmp; \
+	else \
+		echo $(TOPDIR)/include/linux/modversions.h was updated; \
+		mv -f $(TOPDIR)/include/linux/modversions.h.tmp $(TOPDIR)/include/linux/modversions.h; \
+	fi
 
 $(M_OBJS): $(TOPDIR)/include/linux/modversions.h
 ifdef MAKING_MODULES