-AFLAGS_vmlinux.lds.o := -traditional
-
-prepare: target_links
-
-.PHONY: target_links FORCE
-target_links:
- @echo ' Making asm-sh/cpu -> asm-sh/$(cpuincdir-y) link'
- @rm -f include/asm-sh/cpu
- @ln -sf $(cpuincdir-y) include/asm-sh/cpu
-
- @echo ' Making asm-sh/mach -> asm-sh/$(incdir-y) link'
- @rm -f include/asm-sh/mach
- @ln -sf $(incdir-y) include/asm-sh/mach
-
+CPPFLAGS_vmlinux.lds := -traditional
+
+incdir-prefix := $(srctree)/include/asm-sh/
+
+# Update machine arch and proc symlinks if something which affects
+# them changed. We use .arch and .mach to indicate when they were
+# updated last, otherwise make uses the target directory mtime.
+
+include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) \
+ include/config/auto.conf FORCE
+ @echo ' SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)'
+ $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
+ $(Q)ln -fsn $(incdir-prefix)$(cpuincdir-y) include/asm-sh/cpu
+ @touch $@
+
+# Most boards have their own mach directories. For the ones that
+# don't, just reference the parent directory so the semantics are
+# kept roughly the same.
+
+include/asm-sh/.mach: $(wildcard include/config/sh/*.h) \
+ include/config/auto.conf FORCE
+ @echo -n ' SYMLINK include/asm-sh/mach -> '
+ $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
+ $(Q)if [ -d $(incdir-prefix)$(incdir-y) ]; then \
+ echo -e 'include/asm-sh/$(incdir-y)'; \
+ ln -fsn $(incdir-prefix)$(incdir-y) \
+ include/asm-sh/mach; \
+ else \
+ echo -e 'include/asm-sh'; \
+ ln -fsn $(incdir-prefix) include/asm-sh/mach; \
+ fi
+ @touch $@
+
+archprepare: include/asm-sh/.cpu include/asm-sh/.mach maketools
+
+PHONY += maketools FORCE
+maketools: include/linux/version.h FORCE