Commit 2e57d051160dd61776461637f767df19036b1186
1 parent
a53ce098a7
Exists in
master
and in
39 other branches
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>
Showing 2 changed files with 29 additions and 16 deletions Side-by-side Diff
Kbuild
... | ... | @@ -43,7 +43,7 @@ |
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,7 +81,6 @@ |
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 | ##### |
Makefile
... | ... | @@ -925,7 +925,9 @@ |
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 |
932 | 934 | |
933 | 935 | |
... | ... | @@ -951,22 +953,34 @@ |
951 | 953 | |
952 | 954 | # The asm symlink changes when $(ARCH) changes. |
953 | 955 | # Detect this and ask user to run make mrproper |
954 | - | |
955 | -include/asm: FORCE | |
956 | - $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ | |
957 | - if [ -L include/asm ]; then \ | |
958 | - if [ "$$asmlink" != "$(SRCARCH)" ]; then \ | |
956 | +define check-symlink | |
957 | + set -e; \ | |
958 | + if [ -L include/asm ]; then \ | |
959 | + asmlink=`readlink include/asm | cut -d '-' -f 2`; \ | |
960 | + if [ "$$asmlink" != "$(SRCARCH)" ]; then \ | |
959 | 961 | echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ |
960 | 962 | echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ |
961 | - exit 1; \ | |
962 | - fi; \ | |
963 | - else \ | |
964 | - echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ | |
965 | - if [ ! -d include ]; then \ | |
966 | - mkdir -p include; \ | |
967 | - fi; \ | |
968 | - ln -fsn asm-$(SRCARCH) $@; \ | |
963 | + exit 1; \ | |
964 | + fi; \ | |
969 | 965 | fi |
966 | +endef | |
967 | + | |
968 | +# We create the target directory of the symlink if it does | |
969 | +# not exist so the test in chack-symlink works and we have a | |
970 | +# directory for generated filesas used by some architectures. | |
971 | +define create-symlink | |
972 | + if [ ! -L include/asm ]; then \ | |
973 | + echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ | |
974 | + if [ ! -d include/asm-$(SRCARCH) ]; then \ | |
975 | + mkdir -p include/asm-$(SRCARCH); \ | |
976 | + fi; \ | |
977 | + ln -fsn asm-$(SRCARCH) $@; \ | |
978 | + fi | |
979 | +endef | |
980 | + | |
981 | +include/asm: FORCE | |
982 | + $(Q)$(check-symlink) | |
983 | + $(Q)$(create-symlink) | |
970 | 984 | |
971 | 985 | # Generate some files |
972 | 986 | # --------------------------------------------------------------------------- |