]> git.hungrycats.org Git - linux/commitdiff
kbuild: Use the real instead of a phony target if we have one
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sat, 1 Jun 2002 19:54:18 +0000 (14:54 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sat, 1 Jun 2002 19:54:18 +0000 (14:54 -0500)
o A rule which makes the include/asm symlink should have the target
  "include/asm", not "symlinks". Likewise for ".hdepend".
  (include/linux/modversions.h yet to follow)

  Apart from being cleaner, this additionally gives us protection
  when a command fails or the user interrupts execution:

  E.g. for the case of "make dep", if the user interrupts at
  some point, make will delete the target (now ".hdepend") for us,
  so that at the next run, make knows that it needs to make the
  dependencies again, while otherwise it would just use the
  half-finished file.

o We don't need the include/asm symlink for the configuration targets,
  we only need it before generating dependencies.

  (The setup of having /usr/include/{linux,asm} symlinked to your
  current kernel source is already broken in 2.5, so this change
  doesn't break anything which wasn't broken before.)

o Add .hdepend to "prepare", i.e. what needs to be done before
  we can start the recursive build. That means we can get rid of
  the gross (and not always working) hack which made "make"
  run "make dep" when .hdepend didn't exist yet.

o Mark the *config targets phony and improve some comments.

Makefile

index 0de6a1e4c7c0bd217db696403f77adbf71eba318..3f4c769222b5961bc6452f0048884a269b61617a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -78,13 +78,8 @@ all: do-it-all
 
 ifeq (.config,$(wildcard .config))
 include .config
-ifeq (.hdepend,$(wildcard .hdepend))
 do-it-all:     vmlinux
 else
-CONFIGURATION = depend
-do-it-all:     depend
-endif
-else
 CONFIGURATION = config
 do-it-all:     config
 endif
@@ -191,10 +186,12 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ;
 $(SUBDIRS): prepare
        @$(MAKE) -C $@
 
-#      Things we need done before we even start the actual build
+#      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.
 
 .PHONY: prepare
-prepare: symlinks include/linux/version.h include/config/MARKER .hdepend
+prepare: .hdepend include/config/MARKER
 
 # Single targets
 # ---------------------------------------------------------------------------
@@ -213,61 +210,77 @@ prepare: symlinks include/linux/version.h include/config/MARKER .hdepend
 # Configuration
 # ---------------------------------------------------------------------------
 
-oldconfig: symlinks
+PHONY: oldconfig xconfig menuconfig config
+
+oldconfig:
        $(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in
 
-xconfig: symlinks
+xconfig:
        @$(MAKE) -C scripts kconfig.tk
        wish -f scripts/kconfig.tk
 
-menuconfig: include/linux/version.h symlinks
+menuconfig:
        @$(MAKE) -C scripts/lxdialog all
        $(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in
 
-config: symlinks
+config:
        $(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in
 
-# make asm->asm-$(ARCH) symlink
+#      FIXME: The asm symlink changes when $(ARCH) changes. That's
+#      hard to detect, but I suppose "make mrproper" is a good idea
+#      before switching between archs anyway.
 
-symlinks:
-       rm -f include/asm
-       ( cd include ; ln -sf asm-$(ARCH) asm)
-       @if [ ! -d include/linux/modules ]; then \
-               mkdir include/linux/modules; \
-       fi
+include/asm:
+       @echo 'Making asm->asm-$(ARCH) symlink'
+       @ln -s asm-$(ARCH) $@
+       @echo 'Making directory include/linux/modules'
+       @mkdir include/linux/modules
 
-# split autoconf.h into include/linux/config/*
+#      Split autoconf.h into include/linux/config/*
 
 include/config/MARKER: scripts/split-include include/linux/autoconf.h
        scripts/split-include include/linux/autoconf.h include/config
        @ touch include/config/MARKER
 
 # Generate some files
+# ---------------------------------------------------------------------------
 
-$(TOPDIR)/include/linux/version.h: include/linux/version.h
+#      version.h changes when $(KERNELRELEASE) etc change, as defined in
+#      this Makefile
 
-include/linux/version.h: ./Makefile
+include/linux/version.h: Makefile
        @echo Generating $@
        @. scripts/mkversion_h $@ $(KERNELRELEASE) $(VERSION) $(PATCHLEVEL) $(SUBLEVEL)
 
-# helpers built in scripts/
+# Helpers built in scripts/
+# ---------------------------------------------------------------------------
 
 scripts/mkdep scripts/split-include : FORCE
        @$(MAKE) -C scripts
 
-# ---------------------------------------------------------------------------
 # Generate dependencies
+# ---------------------------------------------------------------------------
+
+.PHONY: depend dep $(patsubst %,_sfdep_%,$(SUBDIRS))
+
+depend dep: .hdepend
 
-depend dep: dep-files
+#      .hdepend is missing prerequisites - in fact dependencies need
+#      to be redone basically each time anything changed - since
+#      that's too expensive, we traditionally rely on the user to
+#      run "make dep" manually whenever necessary. In this case,
+#      we make "FORCE" a prequisite, to force redoing the
+#      dependencies. Yeah, that's ugly, and it'll go away soon.
 
-dep-files: scripts/mkdep archdep include/linux/version.h
-       scripts/mkdep -- `find $(FINDHPATH) -name SCCS -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend
+.hdepend: scripts/mkdep include/linux/version.h include/asm \
+         $(if $(filter dep depend,$(MAKECMDGOALS)),FORCE)
+       scripts/mkdep -- `find $(FINDHPATH) -name SCCS -prune -o -follow -name \*.h ! -name modversions.h -print` > $@
        @$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS))
 ifdef CONFIG_MODVERSIONS
-       $(MAKE) update-modverfile
+       @$(MAKE) update-modverfile
 endif
+       @$(MAKE) archdep
 
-.PHONY: $(patsubst %,_sfdep_%,$(SUBDIRS))
 $(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE
        @$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep