kbuild: asm symlink support for arch/$ARCH/include

Adjust the asm symlink support so we do not create the
symlink unless really needed.
We check the precense of include/asm-$ARCH by checking
for the system.h file. We may end up with a stale directory
so it is not enough to check if the directory is present.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

+29 -16
+1 -2
Kbuild
··· 43 43 # 2) Generate asm-offsets.h 44 44 # 45 45 46 - offsets-file := include/asm-$(SRCARCH)/asm-offsets.h 46 + offsets-file := include/asm/asm-offsets.h 47 47 48 48 always += $(offsets-file) 49 49 targets += $(offsets-file) ··· 81 81 $(call if_changed_dep,cc_s_c) 82 82 83 83 $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild 84 - $(Q)mkdir -p $(dir $@) 85 84 $(call cmd,offsets) 86 85 87 86 #####
+28 -14
Makefile
··· 925 925 /bin/false; \ 926 926 fi; 927 927 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; 928 - $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm 928 + $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/system.h ]; then \ 929 + ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \ 930 + fi 929 931 endif 930 932 931 933 # prepare2 creates a makefile if using a separate output directory ··· 953 951 954 952 # The asm symlink changes when $(ARCH) changes. 955 953 # Detect this and ask user to run make mrproper 956 - 957 - include/asm: FORCE 958 - $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ 959 - if [ -L include/asm ]; then \ 960 - if [ "$$asmlink" != "$(SRCARCH)" ]; then \ 954 + define check-symlink 955 + set -e; \ 956 + if [ -L include/asm ]; then \ 957 + asmlink=`readlink include/asm | cut -d '-' -f 2`; \ 958 + if [ "$$asmlink" != "$(SRCARCH)" ]; then \ 961 959 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ 962 960 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ 963 - exit 1; \ 964 - fi; \ 965 - else \ 966 - echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ 967 - if [ ! -d include ]; then \ 968 - mkdir -p include; \ 969 - fi; \ 970 - ln -fsn asm-$(SRCARCH) $@; \ 961 + exit 1; \ 962 + fi; \ 971 963 fi 964 + endef 965 + 966 + # We create the target directory of the symlink if it does 967 + # not exist so the test in chack-symlink works and we have a 968 + # directory for generated filesas used by some architectures. 969 + define create-symlink 970 + if [ ! -L include/asm ]; then \ 971 + echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ 972 + if [ ! -d include/asm-$(SRCARCH) ]; then \ 973 + mkdir -p include/asm-$(SRCARCH); \ 974 + fi; \ 975 + ln -fsn asm-$(SRCARCH) $@; \ 976 + fi 977 + endef 978 + 979 + include/asm: FORCE 980 + $(Q)$(check-symlink) 981 + $(Q)$(create-symlink) 972 982 973 983 # Generate some files 974 984 # ---------------------------------------------------------------------------