diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 57 |
1 files changed, 38 insertions, 19 deletions
@@ -115,13 +115,20 @@ saved-output := $(KBUILD_OUTPUT) | |||
115 | KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) | 115 | KBUILD_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 | ||
119 | PHONY += $(MAKECMDGOALS) | 122 | PHONY += $(MAKECMDGOALS) sub-make |
120 | 123 | ||
121 | $(filter-out _all,$(MAKECMDGOALS)) _all: | 124 | $(filter-out _all sub-make,$(MAKECMDGOALS)) _all: sub-make |
125 | $(Q)@: | ||
126 | |||
127 | sub-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 |
127 | skip-makefile := 1 | 134 | skip-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 | ||
314 | CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) | 321 | KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) |
315 | 322 | ||
316 | CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | 323 | KBUILD_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 |
319 | AFLAGS := -D__ASSEMBLY__ | 326 | KBUILD_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) |
322 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) | 329 | KERNELRELEASE = $(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 | |||
327 | export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE | 334 | export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE |
328 | export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS | 335 | export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS |
329 | 336 | ||
330 | export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS | 337 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS |
331 | export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE | 338 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE |
332 | export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE | 339 | export 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) | |||
485 | all: vmlinux | 492 | all: vmlinux |
486 | 493 | ||
487 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE | 494 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE |
488 | CFLAGS += -Os | 495 | KBUILD_CFLAGS += -Os |
489 | else | 496 | else |
490 | CFLAGS += -O2 | 497 | KBUILD_CFLAGS += -O2 |
491 | endif | 498 | endif |
492 | 499 | ||
493 | include $(srctree)/arch/$(ARCH)/Makefile | 500 | include $(srctree)/arch/$(ARCH)/Makefile |
494 | 501 | ||
495 | ifdef CONFIG_FRAME_POINTER | 502 | ifdef CONFIG_FRAME_POINTER |
496 | CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | 503 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
497 | else | 504 | else |
498 | CFLAGS += -fomit-frame-pointer | 505 | KBUILD_CFLAGS += -fomit-frame-pointer |
499 | endif | 506 | endif |
500 | 507 | ||
501 | ifdef CONFIG_DEBUG_INFO | 508 | ifdef CONFIG_DEBUG_INFO |
502 | CFLAGS += -g | 509 | KBUILD_CFLAGS += -g |
510 | KBUILD_AFLAGS += -gdwarf-2 | ||
503 | endif | 511 | endif |
504 | 512 | ||
505 | # Force gcc to behave correct even for buggy distributions | 513 | # Force gcc to behave correct even for buggy distributions |
506 | CFLAGS += $(call cc-option, -fno-stack-protector) | 514 | KBUILD_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 |
509 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) | 517 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
510 | CHECKFLAGS += $(NOSTDINC_FLAGS) | 518 | CHECKFLAGS += $(NOSTDINC_FLAGS) |
511 | 519 | ||
512 | # warn about C99 declaration after statement | 520 | # warn about C99 declaration after statement |
513 | CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) | 521 | KBUILD_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 |
516 | CFLAGS += $(call cc-option,-Wno-pointer-sign,) | 524 | KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,) |
525 | |||
526 | # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments | ||
527 | KBUILD_CPPFLAGS += $(CPPFLAGS) | ||
528 | KBUILD_AFLAGS += $(AFLAGS) | ||
529 | KBUILD_CFLAGS += $(CFLAGS) | ||
517 | 530 | ||
518 | # Use --build-id when available. | 531 | # Use --build-id when available. |
519 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ | 532 | LDFLAGS_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 | ||
1257 | clean: rm-dirs := $(MODVERDIR) | 1271 | clean: rm-dirs := $(MODVERDIR) |
1272 | clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers | ||
1258 | clean: $(clean-dirs) | 1273 | clean: $(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: | |||
1411 | namespacecheck: | 1427 | namespacecheck: |
1412 | $(PERL) $(srctree)/scripts/namespace.pl | 1428 | $(PERL) $(srctree)/scripts/namespace.pl |
1413 | 1429 | ||
1430 | export_report: | ||
1431 | $(PERL) $(srctree)/scripts/export_report.pl | ||
1432 | |||
1414 | endif #ifeq ($(config-targets),1) | 1433 | endif #ifeq ($(config-targets),1) |
1415 | endif #ifeq ($(mixed-targets),1) | 1434 | endif #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 | ||
1491 | a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ | 1510 | a_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 | ||
1495 | quiet_cmd_as_o_S = AS $@ | 1514 | quiet_cmd_as_o_S = AS $@ |