Commit 67b95633 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: modversions improvements

If an object was changed to not export symbols anymore, the
corresponding stale .ver file would have been left lying around
and been picked up when generating modversions.h. 

The obvious solution to remove include/linux/modules/* at the
beginning of "make dep" is not really good, since that means
that .ver files would be regenerated unconditionally, thus causing
a lot of possibly unnecessary rebuilds.

So, instead, we build a temporary shadow tree of all export-objs
(as empty files) during the recursive "make fastdep" phase, and use 
that to generate modversions.h.

Ensure that we touch include/linux/modversions.h if any of the
.ver files changes, that's our marker to rebuild all modversions
affected files.
parent 9d0ac54b
......@@ -245,15 +245,14 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ;
# Handle descending into subdirectories listed in $(SUBDIRS)
.PHONY: $(SUBDIRS)
$(SUBDIRS): prepare
$(SUBDIRS): .hdepend prepare include/config/MARKER
@$(MAKE) -C $@
# Things we need done before we even start the actual build.
# The dependency on .hdepend will in turn take care of
# include/asm, include/linux/version etc.
# Things we need done before we descend to build or make
# module versions are listed in "prepare"
.PHONY: prepare
prepare: .hdepend include/config/MARKER
prepare: include/linux/version.h include/asm
# Single targets
# ---------------------------------------------------------------------------
......@@ -326,39 +325,29 @@ scripts:
depend dep: .hdepend
ifdef CONFIG_MODVERSIONS
# Before descending for the actual build, we need module
# versions done. - Still using the old, illogical name
# .hdepend
# .hdepend only indicates if we have generated module
# version checksums before now. For now, if they've
# been generated once, no rechecking will be done unless
# explicitly asked for using "make dep".
# .hdepend is our (misnomed) marker for whether we've run
# generated module versions and made archdep
.hdepend: scripts/fixdep include/linux/version.h include/asm \
$(if $(filter dep depend,$(MAKECMDGOALS)),FORCE)
touch $@
@$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS))
@$(MAKE) include/linux/modversions.h
@$(MAKE) archdep
.hdepend: $(if $(filter dep depend,$(MAKECMDGOALS)),FORCE)
@$(MAKE) archdep include/linux/modversions.h
@touch $@
$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE
@$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
ifdef CONFIG_MODVERSIONS
# Update modversions.h, but only if it would change.
include/linux/modversions.h: FORCE
@(echo "#ifndef _LINUX_MODVERSIONS_H";\
include/linux/modversions.h: scripts/fixdep prepare FORCE
@rm -rf .tmp_export-objs
@$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS))
@( echo "#ifndef _LINUX_MODVERSIONS_H";\
echo "#define _LINUX_MODVERSIONS_H"; \
echo "#include <linux/modsetver.h>"; \
cd $(TOPDIR)/include/linux; \
for f in `find modules -name \*.ver`; do \
for f in `cd .tmp_export-objs; find modules -name \*.ver -print`; do \
echo "#include <linux/$${f}>"; \
done; \
echo "#endif"; \
) > $@.tmp
@rm -rf .tmp_export-objs
@if [ -r $@ ] && cmp -s $@ $@.tmp; then \
echo $@ was not updated; \
rm -f $@.tmp; \
......@@ -367,12 +356,14 @@ include/linux/modversions.h: FORCE
mv -f $@.tmp $@; \
fi
$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE
@$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
else # !CONFIG_MODVERSIONS
.hdepend: include/linux/version.h include/asm \
$(if $(filter dep depend,$(MAKECMDGOALS)),FORCE)
touch $@
@$(MAKE) archdep
.PHONY: include/linux/modversions.h
include/linux/modversions.h:
endif # CONFIG_MODVERSIONS
......
......@@ -315,11 +315,17 @@ $(MODVERDIR)/%.ver: %.c FORCE
@if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \
else \
touch $(TOPDIR)/include/linux/modversions.h; \
mv -f $@.tmp $@; \
fi
# updates .ver files but not modversions.h
fastdep: $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
ifneq ($(export-objs),)
@mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))
endif
endif # export-objs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment