aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile57
1 files changed, 38 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 1274084c9090..ed65de7078c7 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
@@ -311,12 +318,12 @@ LINUXINCLUDE := -Iinclude \
311 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ 318 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
312 -include include/linux/autoconf.h 319 -include include/linux/autoconf.h
313 320
314CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 321KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
315 322
316CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 323KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
317 -fno-strict-aliasing -fno-common \ 324 -fno-strict-aliasing -fno-common \
318 -Werror-implicit-function-declaration 325 -Werror-implicit-function-declaration
319AFLAGS := -D__ASSEMBLY__ 326KBUILD_AFLAGS := -D__ASSEMBLY__
320 327
321# Read KERNELRELEASE from include/config/kernel.release (if it exists) 328# Read KERNELRELEASE from include/config/kernel.release (if it exists)
322KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 329KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
@@ -327,9 +334,9 @@ export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
327export 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
328export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 335export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
329 336
330export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 337export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
331export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 338export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
332export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 339export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
333 340
334# When compiling out-of-tree modules, put MODVERDIR in the module 341# When compiling out-of-tree modules, put MODVERDIR in the module
335# tree rather than in the kernel tree. The kernel tree might 342# tree rather than in the kernel tree. The kernel tree might
@@ -485,35 +492,41 @@ endif # $(dot-config)
485all: vmlinux 492all: vmlinux
486 493
487ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 494ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
488CFLAGS += -Os 495KBUILD_CFLAGS += -Os
489else 496else
490CFLAGS += -O2 497KBUILD_CFLAGS += -O2
491endif 498endif
492 499
493include $(srctree)/arch/$(ARCH)/Makefile 500include $(srctree)/arch/$(ARCH)/Makefile
494 501
495ifdef CONFIG_FRAME_POINTER 502ifdef CONFIG_FRAME_POINTER
496CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 503KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
497else 504else
498CFLAGS += -fomit-frame-pointer 505KBUILD_CFLAGS += -fomit-frame-pointer
499endif 506endif
500 507
501ifdef CONFIG_DEBUG_INFO 508ifdef CONFIG_DEBUG_INFO
502CFLAGS += -g 509KBUILD_CFLAGS += -g
510KBUILD_AFLAGS += -gdwarf-2
503endif 511endif
504 512
505# Force gcc to behave correct even for buggy distributions 513# Force gcc to behave correct even for buggy distributions
506CFLAGS += $(call cc-option, -fno-stack-protector) 514KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
507 515
508# 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
509NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 517NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
510CHECKFLAGS += $(NOSTDINC_FLAGS) 518CHECKFLAGS += $(NOSTDINC_FLAGS)
511 519
512# warn about C99 declaration after statement 520# warn about C99 declaration after statement
513CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) 521KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
514 522
515# disable pointer signed / unsigned warnings in gcc 4.0 523# disable pointer signed / unsigned warnings in gcc 4.0
516CFLAGS += $(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)
517 530
518# Use --build-id when available. 531# Use --build-id when available.
519LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ 532LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
@@ -1149,6 +1162,7 @@ help:
1149 @echo 'Static analysers' 1162 @echo 'Static analysers'
1150 @echo ' checkstack - Generate a list of stack hogs' 1163 @echo ' checkstack - Generate a list of stack hogs'
1151 @echo ' namespacecheck - Name space analysis on compiled kernel' 1164 @echo ' namespacecheck - Name space analysis on compiled kernel'
1165 @echo ' export_report - List the usages of all exported symbols'
1152 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1166 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \
1153 echo ' headers_check - Sanity check on exported headers'; \ 1167 echo ' headers_check - Sanity check on exported headers'; \
1154 fi 1168 fi
@@ -1255,8 +1269,10 @@ $(clean-dirs):
1255 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1269 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1256 1270
1257clean: rm-dirs := $(MODVERDIR) 1271clean: rm-dirs := $(MODVERDIR)
1272clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
1258clean: $(clean-dirs) 1273clean: $(clean-dirs)
1259 $(call cmd,rmdirs) 1274 $(call cmd,rmdirs)
1275 $(call cmd,rmfiles)
1260 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ 1276 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
1261 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1277 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1262 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ 1278 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
@@ -1411,6 +1427,9 @@ versioncheck:
1411namespacecheck: 1427namespacecheck:
1412 $(PERL) $(srctree)/scripts/namespace.pl 1428 $(PERL) $(srctree)/scripts/namespace.pl
1413 1429
1430export_report:
1431 $(PERL) $(srctree)/scripts/export_report.pl
1432
1414endif #ifeq ($(config-targets),1) 1433endif #ifeq ($(config-targets),1)
1415endif #ifeq ($(mixed-targets),1) 1434endif #ifeq ($(mixed-targets),1)
1416 1435
@@ -1488,8 +1507,8 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
1488 cmd_rmfiles = rm -f $(rm-files) 1507 cmd_rmfiles = rm -f $(rm-files)
1489 1508
1490 1509
1491a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ 1510a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
1492 $(NOSTDINC_FLAGS) $(CPPFLAGS) \ 1511 $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
1493 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) 1512 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1494 1513
1495quiet_cmd_as_o_S = AS $@ 1514quiet_cmd_as_o_S = AS $@