aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile103
1 files changed, 66 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 4635a64da36c..68ef80b30340 100644
--- a/Makefile
+++ b/Makefile
@@ -115,13 +115,20 @@ saved-output := $(KBUILD_OUTPUT)
115KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) 115KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
116$(if $(KBUILD_OUTPUT),, \ 116$(if $(KBUILD_OUTPUT),, \
117 $(error output directory "$(saved-output)" does not exist)) 117 $(error output directory "$(saved-output)" does not exist))
118# Check that OUTPUT directory is not the same as where we have kernel src
119$(if $(filter-out $(KBUILD_OUTPUT),$(shell /bin/pwd)),, \
120 $(error Output directory (O=...) specifies kernel src dir))
118 121
119PHONY += $(MAKECMDGOALS) 122PHONY += $(MAKECMDGOALS) sub-make
120 123
121$(filter-out _all,$(MAKECMDGOALS)) _all: 124$(filter-out _all sub-make,$(MAKECMDGOALS)) _all: sub-make
125 $(Q)@:
126
127sub-make: FORCE
122 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ 128 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
123 KBUILD_SRC=$(CURDIR) \ 129 KBUILD_SRC=$(CURDIR) \
124 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@ 130 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
131 $(filter-out _all sub-make,$(MAKECMDGOALS))
125 132
126# Leave processing to above invocation of make 133# Leave processing to above invocation of make
127skip-makefile := 1 134skip-makefile := 1
@@ -186,7 +193,8 @@ ARCH ?= $(SUBARCH)
186CROSS_COMPILE ?= 193CROSS_COMPILE ?=
187 194
188# Architecture as present in compile.h 195# Architecture as present in compile.h
189UTS_MACHINE := $(ARCH) 196UTS_MACHINE := $(ARCH)
197SRCARCH := $(ARCH)
190 198
191KCONFIG_CONFIG ?= .config 199KCONFIG_CONFIG ?= .config
192 200
@@ -310,25 +318,25 @@ LINUXINCLUDE := -Iinclude \
310 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ 318 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
311 -include include/linux/autoconf.h 319 -include include/linux/autoconf.h
312 320
313CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 321KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
314 322
315CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 323KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
316 -fno-strict-aliasing -fno-common \ 324 -fno-strict-aliasing -fno-common \
317 -Werror-implicit-function-declaration 325 -Werror-implicit-function-declaration
318AFLAGS := -D__ASSEMBLY__ 326KBUILD_AFLAGS := -D__ASSEMBLY__
319 327
320# Read KERNELRELEASE from include/config/kernel.release (if it exists) 328# Read KERNELRELEASE from include/config/kernel.release (if it exists)
321KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 329KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
322KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) 330KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
323 331
324export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 332export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
325export ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC 333export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
326export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE 334export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
327export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 335export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
328 336
329export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 337export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
330export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 338export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
331export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 339export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
332 340
333# When compiling out-of-tree modules, put MODVERDIR in the module 341# When compiling out-of-tree modules, put MODVERDIR in the module
334# tree rather than in the kernel tree. The kernel tree might 342# tree rather than in the kernel tree. The kernel tree might
@@ -484,35 +492,41 @@ endif # $(dot-config)
484all: vmlinux 492all: vmlinux
485 493
486ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 494ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
487CFLAGS += -Os 495KBUILD_CFLAGS += -Os
488else 496else
489CFLAGS += -O2 497KBUILD_CFLAGS += -O2
490endif 498endif
491 499
492include $(srctree)/arch/$(ARCH)/Makefile 500include $(srctree)/arch/$(ARCH)/Makefile
493 501
494ifdef CONFIG_FRAME_POINTER 502ifdef CONFIG_FRAME_POINTER
495CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 503KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
496else 504else
497CFLAGS += -fomit-frame-pointer 505KBUILD_CFLAGS += -fomit-frame-pointer
498endif 506endif
499 507
500ifdef CONFIG_DEBUG_INFO 508ifdef CONFIG_DEBUG_INFO
501CFLAGS += -g 509KBUILD_CFLAGS += -g
510KBUILD_AFLAGS += -gdwarf-2
502endif 511endif
503 512
504# Force gcc to behave correct even for buggy distributions 513# Force gcc to behave correct even for buggy distributions
505CFLAGS += $(call cc-option, -fno-stack-protector) 514KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
506 515
507# arch Makefile may override CC so keep this after arch Makefile is included 516# arch Makefile may override CC so keep this after arch Makefile is included
508NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 517NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
509CHECKFLAGS += $(NOSTDINC_FLAGS) 518CHECKFLAGS += $(NOSTDINC_FLAGS)
510 519
511# warn about C99 declaration after statement 520# warn about C99 declaration after statement
512CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) 521KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
513 522
514# disable pointer signed / unsigned warnings in gcc 4.0 523# disable pointer signed / unsigned warnings in gcc 4.0
515CFLAGS += $(call cc-option,-Wno-pointer-sign,) 524KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
525
526# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
527KBUILD_CPPFLAGS += $(CPPFLAGS)
528KBUILD_AFLAGS += $(AFLAGS)
529KBUILD_CFLAGS += $(CFLAGS)
516 530
517# Use --build-id when available. 531# Use --build-id when available.
518LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ 532LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
@@ -609,7 +623,7 @@ libs-y := $(libs-y1) $(libs-y2)
609vmlinux-init := $(head-y) $(init-y) 623vmlinux-init := $(head-y) $(init-y)
610vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) 624vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)
611vmlinux-all := $(vmlinux-init) $(vmlinux-main) 625vmlinux-all := $(vmlinux-init) $(vmlinux-main)
612vmlinux-lds := arch/$(ARCH)/kernel/vmlinux.lds 626vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.lds
613export KBUILD_VMLINUX_OBJS := $(vmlinux-all) 627export KBUILD_VMLINUX_OBJS := $(vmlinux-all)
614 628
615# Rule to link vmlinux - also used during CONFIG_KALLSYMS 629# Rule to link vmlinux - also used during CONFIG_KALLSYMS
@@ -760,6 +774,9 @@ vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) vmlinux.o
760ifdef CONFIG_HEADERS_CHECK 774ifdef CONFIG_HEADERS_CHECK
761 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 775 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
762endif 776endif
777ifdef CONFIG_SAMPLES
778 $(Q)$(MAKE) $(build)=samples
779endif
763 $(call vmlinux-modpost) 780 $(call vmlinux-modpost)
764 $(call if_changed_rule,vmlinux__) 781 $(call if_changed_rule,vmlinux__)
765 $(Q)rm -f .old_version 782 $(Q)rm -f .old_version
@@ -862,7 +879,7 @@ ifneq ($(KBUILD_SRC),)
862 /bin/false; \ 879 /bin/false; \
863 fi; 880 fi;
864 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; 881 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
865 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm 882 $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm
866endif 883endif
867 884
868# prepare2 creates a makefile if using a separate output directory 885# prepare2 creates a makefile if using a separate output directory
@@ -894,9 +911,9 @@ export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
894# before switching between archs anyway. 911# before switching between archs anyway.
895 912
896include/asm: 913include/asm:
897 @echo ' SYMLINK $@ -> include/asm-$(ARCH)' 914 @echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'
898 $(Q)if [ ! -d include ]; then mkdir -p include; fi; 915 $(Q)if [ ! -d include ]; then mkdir -p include; fi;
899 @ln -fsn asm-$(ARCH) $@ 916 @ln -fsn asm-$(SRCARCH) $@
900 917
901# Generate some files 918# Generate some files
902# --------------------------------------------------------------------------- 919# ---------------------------------------------------------------------------
@@ -936,7 +953,8 @@ depend dep:
936INSTALL_HDR_PATH=$(objtree)/usr 953INSTALL_HDR_PATH=$(objtree)/usr
937export INSTALL_HDR_PATH 954export INSTALL_HDR_PATH
938 955
939HDRARCHES=$(filter-out generic,$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) 956HDRFILTER=generic i386 x86_64
957HDRARCHES=$(filter-out $(HDRFILTER),$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild)))
940 958
941PHONY += headers_install_all 959PHONY += headers_install_all
942headers_install_all: include/linux/version.h scripts_basic FORCE 960headers_install_all: include/linux/version.h scripts_basic FORCE
@@ -947,11 +965,11 @@ headers_install_all: include/linux/version.h scripts_basic FORCE
947 965
948PHONY += headers_install 966PHONY += headers_install
949headers_install: include/linux/version.h scripts_basic FORCE 967headers_install: include/linux/version.h scripts_basic FORCE
950 @if [ ! -r $(srctree)/include/asm-$(ARCH)/Kbuild ]; then \ 968 @if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \
951 echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ 969 echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \
952 exit 1 ; fi 970 exit 1 ; fi
953 $(Q)$(MAKE) $(build)=scripts scripts/unifdef 971 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
954 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst obj=include 972 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include
955 973
956PHONY += headers_check_all 974PHONY += headers_check_all
957headers_check_all: headers_install_all 975headers_check_all: headers_install_all
@@ -961,7 +979,7 @@ headers_check_all: headers_install_all
961 979
962PHONY += headers_check 980PHONY += headers_check
963headers_check: headers_install 981headers_check: headers_install
964 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst obj=include HDRCHECK=1 982 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include HDRCHECK=1
965 983
966# --------------------------------------------------------------------------- 984# ---------------------------------------------------------------------------
967# Modules 985# Modules
@@ -1139,7 +1157,7 @@ help:
1139 @echo ' cscope - Generate cscope index' 1157 @echo ' cscope - Generate cscope index'
1140 @echo ' kernelrelease - Output the release version string' 1158 @echo ' kernelrelease - Output the release version string'
1141 @echo ' kernelversion - Output the version stored in Makefile' 1159 @echo ' kernelversion - Output the version stored in Makefile'
1142 @if [ -r $(srctree)/include/asm-$(ARCH)/Kbuild ]; then \ 1160 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \
1143 echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ 1161 echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1144 echo ' (default: $(INSTALL_HDR_PATH))'; \ 1162 echo ' (default: $(INSTALL_HDR_PATH))'; \
1145 fi 1163 fi
@@ -1147,7 +1165,8 @@ help:
1147 @echo 'Static analysers' 1165 @echo 'Static analysers'
1148 @echo ' checkstack - Generate a list of stack hogs' 1166 @echo ' checkstack - Generate a list of stack hogs'
1149 @echo ' namespacecheck - Name space analysis on compiled kernel' 1167 @echo ' namespacecheck - Name space analysis on compiled kernel'
1150 @if [ -r $(srctree)/include/asm-$(ARCH)/Kbuild ]; then \ 1168 @echo ' export_report - List the usages of all exported symbols'
1169 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \
1151 echo ' headers_check - Sanity check on exported headers'; \ 1170 echo ' headers_check - Sanity check on exported headers'; \
1152 fi 1171 fi
1153 @echo '' 1172 @echo ''
@@ -1253,8 +1272,10 @@ $(clean-dirs):
1253 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1272 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1254 1273
1255clean: rm-dirs := $(MODVERDIR) 1274clean: rm-dirs := $(MODVERDIR)
1275clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
1256clean: $(clean-dirs) 1276clean: $(clean-dirs)
1257 $(call cmd,rmdirs) 1277 $(call cmd,rmdirs)
1278 $(call cmd,rmfiles)
1258 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ 1279 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
1259 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1280 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1260 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ 1281 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
@@ -1292,18 +1313,23 @@ ifeq ($(ALLSOURCE_ARCHS),)
1292ifeq ($(ARCH),um) 1313ifeq ($(ARCH),um)
1293ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH) 1314ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
1294else 1315else
1295ALLINCLUDE_ARCHS := $(ARCH) 1316ALLINCLUDE_ARCHS := $(SRCARCH)
1296endif 1317endif
1297else 1318else
1298#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour. 1319#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour.
1299ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) 1320ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1300endif 1321endif
1301 1322
1323# Take care of arch/x86
1324ifeq ($(ARCH), $(SRCARCH))
1302ALLSOURCE_ARCHS := $(ARCH) 1325ALLSOURCE_ARCHS := $(ARCH)
1326else
1327ALLSOURCE_ARCHS := $(ARCH) $(SRCARCH)
1328endif
1303 1329
1304define find-sources 1330define find-sources
1305 ( for ARCH in $(ALLSOURCE_ARCHS) ; do \ 1331 ( for arch in $(ALLSOURCE_ARCHS) ; do \
1306 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ 1332 find $(__srctree)arch/$${arch} $(RCS_FIND_IGNORE) \
1307 -name $1 -print; \ 1333 -name $1 -print; \
1308 done ; \ 1334 done ; \
1309 find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \ 1335 find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
@@ -1311,8 +1337,8 @@ define find-sources
1311 find $(__srctree)include $(RCS_FIND_IGNORE) \ 1337 find $(__srctree)include $(RCS_FIND_IGNORE) \
1312 \( -name config -o -name 'asm-*' \) -prune \ 1338 \( -name config -o -name 'asm-*' \) -prune \
1313 -o -name $1 -print; \ 1339 -o -name $1 -print; \
1314 for ARCH in $(ALLINCLUDE_ARCHS) ; do \ 1340 for arch in $(ALLINCLUDE_ARCHS) ; do \
1315 find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \ 1341 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1316 -name $1 -print; \ 1342 -name $1 -print; \
1317 done ; \ 1343 done ; \
1318 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ 1344 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
@@ -1404,6 +1430,9 @@ versioncheck:
1404namespacecheck: 1430namespacecheck:
1405 $(PERL) $(srctree)/scripts/namespace.pl 1431 $(PERL) $(srctree)/scripts/namespace.pl
1406 1432
1433export_report:
1434 $(PERL) $(srctree)/scripts/export_report.pl
1435
1407endif #ifeq ($(config-targets),1) 1436endif #ifeq ($(config-targets),1)
1408endif #ifeq ($(mixed-targets),1) 1437endif #ifeq ($(mixed-targets),1)
1409 1438
@@ -1481,8 +1510,8 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
1481 cmd_rmfiles = rm -f $(rm-files) 1510 cmd_rmfiles = rm -f $(rm-files)
1482 1511
1483 1512
1484a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ 1513a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
1485 $(NOSTDINC_FLAGS) $(CPPFLAGS) \ 1514 $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
1486 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) 1515 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1487 1516
1488quiet_cmd_as_o_S = AS $@ 1517quiet_cmd_as_o_S = AS $@