aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile115
1 files changed, 70 insertions, 45 deletions
diff --git a/Makefile b/Makefile
index 3cad7db5eba7..40f24810116c 100644
--- a/Makefile
+++ b/Makefile
@@ -205,6 +205,9 @@ ifeq ($(ARCH),x86_64)
205 SRCARCH := x86 205 SRCARCH := x86
206endif 206endif
207 207
208# Where to locate arch specific headers
209hdr-arch := $(SRCARCH)
210
208KCONFIG_CONFIG ?= .config 211KCONFIG_CONFIG ?= .config
209 212
210# SHELL used by kbuild 213# SHELL used by kbuild
@@ -326,7 +329,8 @@ AFLAGS_KERNEL =
326# Needed to be compatible with the O= option 329# Needed to be compatible with the O= option
327LINUXINCLUDE := -Iinclude \ 330LINUXINCLUDE := -Iinclude \
328 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ 331 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
329 -include include/linux/autoconf.h 332 -I$(srctree)/arch/$(hdr-arch)/include \
333 -include include/linux/autoconf.h
330 334
331KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 335KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
332 336
@@ -922,7 +926,9 @@ ifneq ($(KBUILD_SRC),)
922 /bin/false; \ 926 /bin/false; \
923 fi; 927 fi;
924 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; 928 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
925 $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm 929 $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/system.h ]; then \
930 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
931 fi
926endif 932endif
927 933
928# prepare2 creates a makefile if using a separate output directory 934# prepare2 creates a makefile if using a separate output directory
@@ -948,22 +954,34 @@ export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
948 954
949# The asm symlink changes when $(ARCH) changes. 955# The asm symlink changes when $(ARCH) changes.
950# Detect this and ask user to run make mrproper 956# Detect this and ask user to run make mrproper
951 957define check-symlink
952include/asm: FORCE 958 set -e; \
953 $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ 959 if [ -L include/asm ]; then \
954 if [ -L include/asm ]; then \ 960 asmlink=`readlink include/asm | cut -d '-' -f 2`; \
955 if [ "$$asmlink" != "$(SRCARCH)" ]; then \ 961 if [ "$$asmlink" != "$(SRCARCH)" ]; then \
956 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ 962 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
957 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ 963 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \
958 exit 1; \ 964 exit 1; \
959 fi; \ 965 fi; \
960 else \
961 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
962 if [ ! -d include ]; then \
963 mkdir -p include; \
964 fi; \
965 ln -fsn asm-$(SRCARCH) $@; \
966 fi 966 fi
967endef
968
969# We create the target directory of the symlink if it does
970# not exist so the test in chack-symlink works and we have a
971# directory for generated filesas used by some architectures.
972define create-symlink
973 if [ ! -L include/asm ]; then \
974 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
975 if [ ! -d include/asm-$(SRCARCH) ]; then \
976 mkdir -p include/asm-$(SRCARCH); \
977 fi; \
978 ln -fsn asm-$(SRCARCH) $@; \
979 fi
980endef
981
982include/asm: FORCE
983 $(Q)$(check-symlink)
984 $(Q)$(create-symlink)
967 985
968# Generate some files 986# Generate some files
969# --------------------------------------------------------------------------- 987# ---------------------------------------------------------------------------
@@ -1010,36 +1028,43 @@ firmware_install: FORCE
1010 1028
1011# --------------------------------------------------------------------------- 1029# ---------------------------------------------------------------------------
1012# Kernel headers 1030# Kernel headers
1013INSTALL_HDR_PATH=$(objtree)/usr
1014export INSTALL_HDR_PATH
1015 1031
1016HDRFILTER=generic i386 x86_64 1032#Default location for installed headers
1017HDRARCHES=$(filter-out $(HDRFILTER),$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) 1033export INSTALL_HDR_PATH = $(objtree)/usr
1018 1034
1019PHONY += headers_install_all 1035hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
1020headers_install_all: include/linux/version.h scripts_basic FORCE 1036# Find out where the Kbuild file is located to support
1037# arch/$(ARCH)/include/asm
1038hdr-dir = $(strip \
1039 $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \
1040 arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch)))
1041
1042# If we do an all arch process set dst to asm-$(hdr-arch)
1043hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
1044
1045PHONY += __headers
1046__headers: include/linux/version.h scripts_basic FORCE
1021 $(Q)$(MAKE) $(build)=scripts scripts/unifdef 1047 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
1022 $(Q)for arch in $(HDRARCHES); do \ 1048
1023 $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ 1049PHONY += headers_install_all
1024 done 1050headers_install_all:
1051 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
1025 1052
1026PHONY += headers_install 1053PHONY += headers_install
1027headers_install: include/linux/version.h scripts_basic FORCE 1054headers_install: __headers
1028 @if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1055 $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
1029 echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \ 1056 $(error Headers not exportable for the $(SRCARCH) architecture))
1030 exit 1 ; fi 1057 $(Q)$(MAKE) $(hdr-inst)=include
1031 $(Q)$(MAKE) $(build)=scripts scripts/unifdef 1058 $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst)
1032 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include
1033 1059
1034PHONY += headers_check_all 1060PHONY += headers_check_all
1035headers_check_all: headers_install_all 1061headers_check_all: headers_install_all
1036 $(Q)for arch in $(HDRARCHES); do \ 1062 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
1037 $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\
1038 done
1039 1063
1040PHONY += headers_check 1064PHONY += headers_check
1041headers_check: headers_install 1065headers_check: headers_install
1042 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include HDRCHECK=1 1066 $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
1067 $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1
1043 1068
1044# --------------------------------------------------------------------------- 1069# ---------------------------------------------------------------------------
1045# Modules 1070# Modules
@@ -1131,7 +1156,7 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \
1131 include/linux/autoconf.h include/linux/version.h \ 1156 include/linux/autoconf.h include/linux/version.h \
1132 include/linux/utsrelease.h \ 1157 include/linux/utsrelease.h \
1133 include/linux/bounds.h include/asm*/asm-offsets.h \ 1158 include/linux/bounds.h include/asm*/asm-offsets.h \
1134 Module.symvers tags TAGS cscope* 1159 Module.symvers Module.markers tags TAGS cscope*
1135 1160
1136# clean - Delete most, but leave enough to build external modules 1161# clean - Delete most, but leave enough to build external modules
1137# 1162#
@@ -1150,7 +1175,7 @@ clean: archclean $(clean-dirs)
1150 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1175 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1151 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1176 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1152 -o -name '*.symtypes' -o -name 'modules.order' \ 1177 -o -name '*.symtypes' -o -name 'modules.order' \
1153 -o -name 'Module.markers' \) \ 1178 -o -name 'Module.markers' -o -name '.tmp_*.o.*' \) \
1154 -type f -print | xargs rm -f 1179 -type f -print | xargs rm -f
1155 1180
1156# mrproper - Delete all generated files, including .config 1181# mrproper - Delete all generated files, including .config
@@ -1224,21 +1249,17 @@ help:
1224 @echo ' cscope - Generate cscope index' 1249 @echo ' cscope - Generate cscope index'
1225 @echo ' kernelrelease - Output the release version string' 1250 @echo ' kernelrelease - Output the release version string'
1226 @echo ' kernelversion - Output the version stored in Makefile' 1251 @echo ' kernelversion - Output the version stored in Makefile'
1227 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1252 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1228 echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1229 echo ' (default: $(INSTALL_HDR_PATH))'; \ 1253 echo ' (default: $(INSTALL_HDR_PATH))'; \
1230 fi 1254 echo ''
1231 @echo ''
1232 @echo 'Static analysers' 1255 @echo 'Static analysers'
1233 @echo ' checkstack - Generate a list of stack hogs' 1256 @echo ' checkstack - Generate a list of stack hogs'
1234 @echo ' namespacecheck - Name space analysis on compiled kernel' 1257 @echo ' namespacecheck - Name space analysis on compiled kernel'
1235 @echo ' versioncheck - Sanity check on version.h usage' 1258 @echo ' versioncheck - Sanity check on version.h usage'
1236 @echo ' includecheck - Check for duplicate included header files' 1259 @echo ' includecheck - Check for duplicate included header files'
1237 @echo ' export_report - List the usages of all exported symbols' 1260 @echo ' export_report - List the usages of all exported symbols'
1238 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1261 @echo ' headers_check - Sanity check on exported headers'; \
1239 echo ' headers_check - Sanity check on exported headers'; \ 1262 echo ''
1240 fi
1241 @echo ''
1242 @echo 'Kernel packaging:' 1263 @echo 'Kernel packaging:'
1243 @$(MAKE) $(build)=$(package-dir) help 1264 @$(MAKE) $(build)=$(package-dir) help
1244 @echo '' 1265 @echo ''
@@ -1411,7 +1432,11 @@ define find-sources
1411 \( -name config -o -name 'asm-*' \) -prune \ 1432 \( -name config -o -name 'asm-*' \) -prune \
1412 -o -name $1 -print; \ 1433 -o -name $1 -print; \
1413 for arch in $(ALLINCLUDE_ARCHS) ; do \ 1434 for arch in $(ALLINCLUDE_ARCHS) ; do \
1414 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ 1435 test -e $(__srctree)include/asm-$${arch} && \
1436 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1437 -name $1 -print; \
1438 test -e $(__srctree)arch/$${arch}/include/asm && \
1439 find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
1415 -name $1 -print; \ 1440 -name $1 -print; \
1416 done ; \ 1441 done ; \
1417 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ 1442 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \