kbuild: asm symlink support for arch/$ARCH/include
[barebox-mini2440.git] / Makefile
blob196d82193732f5de2f636a2bc70128ba09459f81
1 VERSION = 2
2 PATCHLEVEL = 0
3 SUBLEVEL = 0
4 EXTRAVERSION =-rc10
5 NAME = Amissive Actinocutious Kiwi
7 # *DOCUMENTATION*
8 # To see a list of typical targets execute "make help"
9 # More info can be located in ./README
10 # Comments in this file are targeted only to the developer, do not
11 # expect to learn how to build the kernel reading this file.
13 # Do not:
14 # o use make's built-in rules and variables
15 # (this increases performance and avoid hard-to-debug behavour);
16 # o print "Entering directory ...";
17 MAKEFLAGS += -rR --no-print-directory
19 # We are using a recursive build, so we need to do a little thinking
20 # to get the ordering right.
22 # Most importantly: sub-Makefiles should only ever modify files in
23 # their own directory. If in some directory we have a dependency on
24 # a file in another dir (which doesn't happen often, but it's often
25 # unavoidable when linking the built-in.o targets which finally
26 # turn into uboot), we will call a sub make in that other dir, and
27 # after that we are sure that everything which is in that other dir
28 # is now up to date.
30 # The only cases where we need to modify files which have global
31 # effects are thus separated out and done before the recursive
32 # descending is started. They are now explicitly listed as the
33 # prepare rule.
35 # To put more focus on warnings, be less verbose as default
36 # Use 'make V=1' to see the full commands
38 ifdef V
39 ifeq ("$(origin V)", "command line")
40 KBUILD_VERBOSE = $(V)
41 endif
42 endif
43 ifndef KBUILD_VERBOSE
44 KBUILD_VERBOSE = 0
45 endif
47 # Call a source code checker (by default, "sparse") as part of the
48 # C compilation.
50 # Use 'make C=1' to enable checking of only re-compiled files.
51 # Use 'make C=2' to enable checking of *all* source files, regardless
52 # of whether they are re-compiled or not.
54 # See the file "Documentation/sparse.txt" for more details, including
55 # where to get the "sparse" utility.
57 ifdef C
58 ifeq ("$(origin C)", "command line")
59 KBUILD_CHECKSRC = $(C)
60 endif
61 endif
62 ifndef KBUILD_CHECKSRC
63 KBUILD_CHECKSRC = 0
64 endif
66 # Use make M=dir to specify directory of external module to build
67 # Old syntax make ... SUBDIRS=$PWD is still supported
68 # Setting the environment variable KBUILD_EXTMOD take precedence
69 ifdef SUBDIRS
70 KBUILD_EXTMOD ?= $(SUBDIRS)
71 endif
72 ifdef M
73 ifeq ("$(origin M)", "command line")
74 KBUILD_EXTMOD := $(M)
75 endif
76 endif
79 # kbuild supports saving output files in a separate directory.
80 # To locate output files in a separate directory two syntaxes are supported.
81 # In both cases the working directory must be the root of the kernel src.
82 # 1) O=
83 # Use "make O=dir/to/store/output/files/"
85 # 2) Set KBUILD_OUTPUT
86 # Set the environment variable KBUILD_OUTPUT to point to the directory
87 # where the output files shall be placed.
88 # export KBUILD_OUTPUT=dir/to/store/output/files/
89 # make
91 # The O= assignment takes precedence over the KBUILD_OUTPUT environment
92 # variable.
95 # KBUILD_SRC is set on invocation of make in OBJ directory
96 # KBUILD_SRC is not intended to be used by the regular user (for now)
97 ifeq ($(KBUILD_SRC),)
99 # OK, Make called in directory where kernel src resides
100 # Do we want to locate output files in a separate directory?
101 ifdef O
102 ifeq ("$(origin O)", "command line")
103 KBUILD_OUTPUT := $(O)
104 endif
105 endif
107 # That's our default target when none is given on the command line
108 PHONY := _all
109 _all:
111 ifneq ($(KBUILD_OUTPUT),)
112 # Invoke a second make in the output directory, passing relevant variables
113 # check that the output directory actually exists
114 saved-output := $(KBUILD_OUTPUT)
115 KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
116 $(if $(KBUILD_OUTPUT),, \
117 $(error output directory "$(saved-output)" does not exist))
119 PHONY += $(MAKECMDGOALS)
121 $(filter-out _all,$(MAKECMDGOALS)) _all:
122 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
123 KBUILD_SRC=$(CURDIR) \
124 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
126 # Leave processing to above invocation of make
127 skip-makefile := 1
128 endif # ifneq ($(KBUILD_OUTPUT),)
129 endif # ifeq ($(KBUILD_SRC),)
131 # We process the rest of the Makefile if this is the final invocation of make
132 ifeq ($(skip-makefile),)
134 # If building an external module we do not care about the all: rule
135 # but instead _all depend on modules
136 PHONY += all
137 _all: all
139 srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
140 objtree := $(CURDIR)
141 src := $(srctree)
142 obj := $(objtree)
144 VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
146 export srctree objtree VPATH
148 # Cross compiling and selecting different set of gcc/bin-utils
149 # ---------------------------------------------------------------------------
151 # When performing cross compilation for other architectures ARCH shall be set
152 # to the target architecture. (See arch/* for the possibilities).
153 # ARCH can be set during invocation of make:
154 # make ARCH=ia64
155 # Another way is to have ARCH set in the environment.
156 # The default ARCH is the host where make is executed.
158 # CROSS_COMPILE specify the prefix used for all executables used
159 # during compilation. Only gcc and related bin-utils executables
160 # are prefixed with $(CROSS_COMPILE).
161 # CROSS_COMPILE can be set on the command line
162 # make CROSS_COMPILE=ia64-linux-
163 # Alternatively CROSS_COMPILE can be set in the environment.
164 # Default value for CROSS_COMPILE is not to prefix executables
166 ARCH ?= sandbox
167 CROSS_COMPILE ?=
169 # Architecture as present in compile.h
170 UTS_MACHINE := $(ARCH)
171 SRCARCH := $(ARCH)
173 KCONFIG_CONFIG ?= .config
175 # SHELL used by kbuild
176 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
177 else if [ -x /bin/bash ]; then echo /bin/bash; \
178 else echo sh; fi ; fi)
180 HOSTCC = gcc
181 HOSTCXX = g++
182 HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
183 HOSTCXXFLAGS = -O2
185 # Decide whether to build built-in, modular, or both.
186 # Normally, just do built-in.
188 KBUILD_MODULES :=
189 KBUILD_BUILTIN := 1
191 # If we have only "make modules", don't compile built-in objects.
192 # When we're building modules with modversions, we need to consider
193 # the built-in objects during the descend as well, in order to
194 # make sure the checksums are up to date before we record them.
196 ifeq ($(MAKECMDGOALS),modules)
197 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
198 endif
200 # If we have "make <whatever> modules", compile modules
201 # in addition to whatever we do anyway.
202 # Just "make" or "make all" shall build modules as well
204 ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
205 KBUILD_MODULES := 1
206 endif
208 export KBUILD_MODULES KBUILD_BUILTIN
209 export KBUILD_CHECKSRC KBUILD_SRC
211 # Beautify output
212 # ---------------------------------------------------------------------------
214 # Normally, we echo the whole command before executing it. By making
215 # that echo $($(quiet)$(cmd)), we now have the possibility to set
216 # $(quiet) to choose other forms of output instead, e.g.
218 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
219 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
221 # If $(quiet) is empty, the whole command will be printed.
222 # If it is set to "quiet_", only the short version will be printed.
223 # If it is set to "silent_", nothing will be printed at all, since
224 # the variable $(silent_cmd_cc_o_c) doesn't exist.
226 # A simple variant is to prefix commands with $(Q) - that's useful
227 # for commands that shall be hidden in non-verbose mode.
229 # $(Q)ln $@ :<
231 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
232 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
234 ifeq ($(KBUILD_VERBOSE),1)
235 quiet =
237 else
238 quiet=quiet_
239 Q = @
240 endif
242 # If the user is running make -s (silent mode), suppress echoing of
243 # commands
245 ifneq ($(findstring s,$(MAKEFLAGS)),)
246 quiet=silent_
247 endif
249 export quiet Q KBUILD_VERBOSE
252 # Look for make include files relative to root of kernel src
253 MAKEFLAGS += --include-dir=$(srctree)
255 # We need some generic definitions.
256 include $(srctree)/scripts/Kbuild.include
258 # Make variables (CC, etc...)
260 AS = $(CROSS_COMPILE)as
261 LD = $(CROSS_COMPILE)ld
262 CC = $(CROSS_COMPILE)gcc
263 CPP = $(CC) -E
264 AR = $(CROSS_COMPILE)ar
265 NM = $(CROSS_COMPILE)nm
266 STRIP = $(CROSS_COMPILE)strip
267 OBJCOPY = $(CROSS_COMPILE)objcopy
268 OBJDUMP = $(CROSS_COMPILE)objdump
269 AWK = awk
270 GENKSYMS = scripts/genksyms/genksyms
271 DEPMOD = /sbin/depmod
272 KALLSYMS = scripts/kallsyms
273 PERL = perl
274 CHECK = sparse
276 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
277 CFLAGS_KERNEL =
278 AFLAGS_KERNEL =
280 LDFLAGS_MODULE = -T common/module.lds
282 # When compiling out-of-tree modules, put MODVERDIR in the module
283 # tree rather than in the kernel tree. The kernel tree might
284 # even be read-only.
285 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
287 # Use LINUXINCLUDE when you must reference the include/ directory.
288 # Needed to be compatible with the O= option
289 LINUXINCLUDE := -Iinclude \
290 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
291 -include include/linux/autoconf.h
293 CPPFLAGS := -D__KERNEL__ -D__U_BOOT__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
295 CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
296 -fno-strict-aliasing -fno-common -Os -pipe
297 AFLAGS := -D__ASSEMBLY__
299 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
300 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
301 KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
303 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
304 export ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
305 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
306 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
308 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
309 export CFLAGS CFLAGS_KERNEL
310 export AFLAGS AFLAGS_KERNEL
312 # Files to ignore in find ... statements
314 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
315 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
317 # ===========================================================================
318 # Rules shared between *config targets and build targets
320 # Basic helpers built in scripts/
321 PHONY += scripts_basic
322 scripts_basic:
323 $(Q)$(MAKE) $(build)=scripts/basic
325 # To avoid any implicit rule to kick in, define an empty command.
326 scripts/basic/%: scripts_basic ;
328 PHONY += outputmakefile
329 # outputmakefile generates a Makefile in the output directory, if using a
330 # separate output directory. This allows convenient use of make in the
331 # output directory.
332 outputmakefile:
333 ifneq ($(KBUILD_SRC),)
334 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
335 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
336 endif
338 # To make sure we do not include .config for any of the *config targets
339 # catch them early, and hand them over to scripts/kconfig/Makefile
340 # It is allowed to specify more targets when calling make, including
341 # mixing *config targets and build targets.
342 # For example 'make oldconfig all'.
343 # Detect when mixed targets is specified, and make a second invocation
344 # of make so .config is not included in this case either (for *config).
346 no-dot-config-targets := clean mrproper distclean \
347 cscope TAGS tags help %docs check% \
348 include/linux/version.h headers_% \
349 kernelrelease kernelversion
351 config-targets := 0
352 mixed-targets := 0
353 dot-config := 1
355 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
356 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
357 dot-config := 0
358 endif
359 endif
361 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
362 config-targets := 1
363 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
364 mixed-targets := 1
365 endif
366 endif
368 ifeq ($(mixed-targets),1)
369 # ===========================================================================
370 # We're called with mixed targets (*config and build targets).
371 # Handle them one by one.
373 %:: FORCE
374 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
376 else
377 ifeq ($(config-targets),1)
378 # ===========================================================================
379 # *config targets only - make sure prerequisites are updated, and descend
380 # in scripts/kconfig to make the *config target
382 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
383 # KBUILD_DEFCONFIG may point out an alternative default configuration
384 # used for 'make defconfig'
385 include $(srctree)/arch/$(ARCH)/Makefile
386 export KBUILD_DEFCONFIG
388 config %config: scripts_basic outputmakefile FORCE
389 $(Q)mkdir -p include/linux include/config
390 $(Q)$(MAKE) $(build)=scripts/kconfig $@
392 else
393 # ===========================================================================
394 # Build targets only - this includes uboot, arch specific targets, clean
395 # targets and others. In general all targets except *config targets.
397 # Additional helpers built in scripts/
398 # Carefully list dependencies so we do not try to build scripts twice
399 # in parallel
400 PHONY += scripts
401 scripts: scripts_basic include/config/auto.conf
402 $(Q)$(MAKE) $(build)=$(@)
404 # Objects we will link into uboot / subdirs we need to visit
405 common-y := common/ drivers/ commands/ lib/ net/ fs/
407 ifeq ($(dot-config),1)
408 # Read in config
409 -include include/config/auto.conf
411 # Read in dependencies to all Kconfig* files, make sure to run
412 # oldconfig if changes are detected.
413 -include include/config/auto.conf.cmd
415 # To avoid any implicit rule to kick in, define an empty command
416 $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
418 # If .config is newer than include/config/auto.conf, someone tinkered
419 # with it and forgot to run make oldconfig.
420 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
421 # we execute the config step to be sure to catch updated Kconfig files
422 include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
423 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
425 else
426 # Dummy target needed, because used as prerequisite
427 include/config/auto.conf: ;
428 endif # $(dot-config)
430 # The all: target is the default when no target is given on the
431 # command line.
432 # This allow a user to issue only 'make' to build a kernel
433 # Defaults uboot but it is usually overridden in the arch makefile
434 all: uboot.bin
436 include $(srctree)/arch/$(ARCH)/Makefile
438 ifdef CONFIG_DEBUG_INFO
439 CFLAGS += -g
440 endif
442 # Force gcc to behave correct even for buggy distributions
443 CFLAGS += $(call cc-option, -fno-stack-protector)
445 # arch Makefile may override CC so keep this after arch Makefile is included
446 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
447 CHECKFLAGS += $(NOSTDINC_FLAGS)
449 # warn about C99 declaration after statement
450 CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
452 # disable pointer signed / unsigned warnings in gcc 4.0
453 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
455 # Default kernel image to build when no specific target is given.
456 # KBUILD_IMAGE may be overruled on the command line or
457 # set in the environment
458 # Also any assignments in arch/$(ARCH)/Makefile take precedence over
459 # this default value
460 export KBUILD_IMAGE ?= uboot
462 uboot-dirs := $(patsubst %/,%,$(filter %/, $(common-y)))
464 uboot-alldirs := $(sort $(uboot-dirs) $(patsubst %/,%,$(filter %/, \
465 $(common-n) $(common-) \
466 $(core-n) $(core-) $(drivers-n) $(drivers-) \
467 $(net-n) $(net-) $(libs-n) $(libs-))))
469 common-y := $(patsubst %/, %/built-in.o, $(common-y))
471 # Build uboot
472 # ---------------------------------------------------------------------------
473 # uboot is built from the objects selected by $(uboot-init) and
474 # $(uboot-main). Most are built-in.o files from top-level directories
475 # in the kernel tree, others are specified in arch/$(ARCH)Makefile.
476 # Ordering when linking is important, and $(uboot-init) must be first.
478 # FIXME: This picture is wrong for U-Boot. We have no init, driver, mm
480 # uboot
483 # +-< $(uboot-init)
484 # | +--< init/version.o + more
486 # +--< $(uboot-main)
487 # | +--< driver/built-in.o mm/built-in.o + more
489 # +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
491 # uboot version cannot be updated during normal
492 # descending-into-subdirs phase since we do not yet know if we need to
493 # update uboot.
495 # System.map is generated to document addresses of all kernel symbols
497 uboot-common := $(common-y)
498 uboot-all := $(uboot-common)
499 uboot-lds := $(lds-y)
501 # Rule to link uboot
502 # May be overridden by arch/$(ARCH)/Makefile
503 quiet_cmd_uboot__ ?= LD $@
504 cmd_uboot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_uboot) -o $@ \
505 -T $(uboot-lds) $(uboot-head) \
506 --start-group $(uboot-common) --end-group \
507 $(filter-out $(uboot-lds) $(uboot-common) FORCE ,$^)
509 # Generate new uboot version
510 quiet_cmd_uboot_version = GEN .version
511 cmd_uboot_version = set -e; \
512 if [ ! -r .version ]; then \
513 rm -f .version; \
514 echo 1 >.version; \
515 else \
516 mv .version .old_version; \
517 expr 0$$(cat .old_version) + 1 >.version; \
518 fi; \
521 # Generate System.map
522 quiet_cmd_sysmap = SYSMAP
523 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
525 # Link of uboot
526 # Generate System.map and verify that the content is consistent
527 # Use + in front of the uboot_version rule to silent warning with make -j2
528 # First command is ':' to allow us to use + in front of the rule
529 define rule_uboot__
532 $(call cmd,uboot__)
534 $(Q)echo 'cmd_$@ := $(cmd_uboot__)' > $(@D)/.$(@F).cmd
536 $(Q)$(if $($(quiet)cmd_sysmap), \
537 echo ' $($(quiet)cmd_sysmap) System.map' &&) \
538 $(cmd_sysmap) $@ System.map; \
539 if [ $$? -ne 0 ]; then \
540 rm -f $@; \
541 /bin/false; \
543 endef
545 ifdef CONFIG_KALLSYMS
546 # Generate section listing all symbols and add it into uboot $(kallsyms.o)
547 # It's a three stage process:
548 # o .tmp_uboot1 has all symbols and sections, but __kallsyms is
549 # empty
550 # Running kallsyms on that gives us .tmp_kallsyms1.o with
551 # the right size - uboot version is updated during this step
552 # o .tmp_uboot2 now has a __kallsyms section of the right size,
553 # but due to the added section, some addresses have shifted.
554 # From here, we generate a correct .tmp_kallsyms2.o
555 # o The correct .tmp_kallsyms2.o is linked into the final uboot.
556 # o Verify that the System.map from uboot matches the map from
557 # .tmp_uboot2, just in case we did not generate kallsyms correctly.
558 # o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
559 # .tmp_uboot3 and .tmp_kallsyms3.o. This is only meant as a
560 # temporary bypass to allow the kernel to be built while the
561 # maintainers work out what went wrong with kallsyms.
563 ifdef CONFIG_KALLSYMS_EXTRA_PASS
564 last_kallsyms := 3
565 else
566 last_kallsyms := 2
567 endif
569 kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
571 define verify_kallsyms
572 $(Q)$(if $($(quiet)cmd_sysmap), \
573 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
574 $(cmd_sysmap) .tmp_uboot$(last_kallsyms) .tmp_System.map
575 $(Q)cmp -s System.map .tmp_System.map || \
576 (echo Inconsistent kallsyms data; \
577 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
578 rm .tmp_kallsyms* ; /bin/false )
579 endef
581 # Update uboot version before link
582 # Use + in front of this rule to silent warning about make -j1
583 # First command is ':' to allow us to use + in front of this rule
584 cmd_ksym_ld = $(cmd_uboot__)
585 define rule_ksym_ld
587 +$(call cmd,uboot_version)
588 $(call cmd,uboot__)
589 $(Q)echo 'cmd_$@ := $(cmd_uboot__)' > $(@D)/.$(@F).cmd
590 endef
592 # Generate .S file with all kernel symbols
593 quiet_cmd_kallsyms = KSYM $@
594 cmd_kallsyms = $(NM) -g -n $< | $(KALLSYMS) > $@
596 .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
597 $(call if_changed_dep,as_o_S)
599 .tmp_kallsyms%.S: .tmp_uboot% $(KALLSYMS)
600 $(call cmd,kallsyms)
602 # .tmp_uboot1 must be complete except kallsyms, so update uboot version
603 .tmp_uboot1: $(uboot-lds) $(uboot-all) FORCE
604 $(call if_changed_rule,ksym_ld)
606 .tmp_uboot2: $(uboot-lds) $(uboot-all) .tmp_kallsyms1.o FORCE
607 $(call if_changed,uboot__)
609 .tmp_uboot3: $(uboot-lds) $(uboot-all) .tmp_kallsyms2.o FORCE
610 $(call if_changed,uboot__)
612 # Needs to visit scripts/ before $(KALLSYMS) can be used.
613 $(KALLSYMS): scripts ;
615 # Generate some data for debugging strange kallsyms problems
616 debug_kallsyms: .tmp_map$(last_kallsyms)
618 .tmp_map%: .tmp_uboot% FORCE
619 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
621 .tmp_map3: .tmp_map2
623 .tmp_map2: .tmp_map1
625 endif # ifdef CONFIG_KALLSYMS
627 # Do modpost on a prelinked vmlinux. The finally linked vmlinux has
628 # relevant sections renamed as per the linker script.
629 quiet_cmd_uboot-modpost = LD $@
630 cmd_uboot-modpost = $(LD) $(LDFLAGS) -r -o $@ \
631 $(vmlinux-init) --start-group $(uboot-main) --end-group \
632 $(filter-out $(uboot-init) $(uboot-main) $(uboot-lds) FORCE ,$^)
633 define rule_uboot-modpost
635 +$(call cmd,uboot-modpost)
636 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
637 $(Q)echo 'cmd_$@ := $(cmd_uboot-modpost)' > $(dot-target).cmd
638 endef
640 uboot.bin: uboot
641 $(Q)$(OBJCOPY) -O binary uboot uboot.bin
642 $(Q)$(OBJDUMP) -d uboot > uboot.S
644 # uboot image
645 uboot: $(uboot-lds) $(uboot-head) $(uboot-common) $(kallsyms.o) FORCE
646 $(call uboot-modpost)
647 $(call if_changed_rule,uboot__)
648 $(Q)rm -f .old_version
650 # The actual objects are generated when descending,
651 # make sure no implicit rule kicks in
652 $(sort $(uboot-head) $(uboot-common) ) $(uboot-lds): $(uboot-dirs) ;
654 # Handle descending into subdirectories listed in $(uboot-dirs)
655 # Preset locale variables to speed up the build process. Limit locale
656 # tweaks to this spot to avoid wrong language settings when running
657 # make menuconfig etc.
658 # Error messages still appears in the original language
660 PHONY += $(uboot-dirs)
661 $(uboot-dirs): prepare scripts
662 $(Q)$(MAKE) $(build)=$@
664 # Build the kernel release string
666 # The KERNELRELEASE value built here is stored in the file
667 # include/config/kernel.release, and is used when executing several
668 # make targets, such as "make install" or "make modules_install."
670 # The eventual kernel release string consists of the following fields,
671 # shown in a hierarchical format to show how smaller parts are concatenated
672 # to form the larger and final value, with values coming from places like
673 # the Makefile, kernel config options, make command line options and/or
674 # SCM tag information.
676 # $(KERNELVERSION)
677 # $(VERSION) eg, 2
678 # $(PATCHLEVEL) eg, 6
679 # $(SUBLEVEL) eg, 18
680 # $(EXTRAVERSION) eg, -rc6
681 # $(localver-full)
682 # $(localver)
683 # localversion* (all localversion* files)
684 # $(CONFIG_LOCALVERSION) (from kernel config setting)
685 # $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set)
686 # ./scripts/setlocalversion (SCM tag, if one exists)
687 # $(LOCALVERSION) (from make command line if provided)
689 # Note how the final $(localver-auto) string is included *only* if the
690 # kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the
691 # moment, only git is supported but other SCMs can edit the script
692 # scripts/setlocalversion and add the appropriate checks as needed.
694 nullstring :=
695 space := $(nullstring) # end of line
697 ___localver = $(objtree)/localversion* $(srctree)/localversion*
698 __localver = $(sort $(wildcard $(___localver)))
699 # skip backup files (containing '~')
700 _localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
702 localver = $(subst $(space),, \
703 $(shell cat /dev/null $(_localver)) \
704 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
706 # If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
707 # and if the SCM is know a tag from the SCM is appended.
708 # The appended tag is determined by the SCM used.
710 # Currently, only git is supported.
711 # Other SCMs can edit scripts/setlocalversion and add the appropriate
712 # checks as needed.
713 ifdef CONFIG_LOCALVERSION_AUTO
714 _localver-auto = $(shell $(CONFIG_SHELL) \
715 $(srctree)/scripts/setlocalversion $(srctree))
716 localver-auto = $(LOCALVERSION)$(_localver-auto)
717 endif
719 localver-full = $(localver)$(localver-auto)
721 # Store (new) KERNELRELASE string in include/config/kernel.release
722 kernelrelease = $(KERNELVERSION)$(localver-full)
723 include/config/kernel.release: include/config/auto.conf FORCE
724 $(Q)rm -f $@
725 $(Q)echo $(kernelrelease) > $@
728 # Things we need to do before we recursively start building the kernel
729 # or the modules are listed in "prepare".
730 # A multi level approach is used. prepareN is processed before prepareN-1.
731 # archprepare is used in arch Makefiles and when processed asm symlink,
732 # version.h and scripts_basic is processed / created.
734 # Listed in dependency order
735 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
737 # prepare-all is deprecated, use prepare as valid replacement
738 PHONY += prepare-all
740 # prepare3 is used to check if we are building in a separate output directory,
741 # and if so do:
742 # 1) Check that make has not been executed in the kernel src $(srctree)
743 # 2) Create the include2 directory, used for the second asm symlink
744 prepare3: include/config/kernel.release
745 ifneq ($(KBUILD_SRC),)
746 @echo ' Using $(srctree) as source for kernel'
747 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
748 echo " $(srctree) is not clean, please run 'make mrproper'";\
749 echo " in the '$(srctree)' directory.";\
750 /bin/false; \
752 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
753 $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/u-boot.h ]; then \
754 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
756 endif
758 # prepare2 creates a makefile if using a separate output directory
759 prepare2: prepare3 outputmakefile
761 prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \
762 include/asm include/config.h include/config/auto.conf
764 ifneq ($(KBUILD_MODULES),)
765 $(Q)mkdir -p $(MODVERDIR)
766 $(Q)rm -f $(MODVERDIR)/*
767 endif
769 archprepare: prepare1 scripts_basic
771 prepare0: archprepare FORCE
772 $(Q)$(MAKE) $(build)=.
774 # All the preparing..
775 prepare prepare-all: prepare0
777 # Leave this as default for preprocessing uboot.lds.S, which is now
778 # done in arch/$(ARCH)/kernel/Makefile
780 export CPPFLAGS_uboot.lds += -P -C -U$(ARCH)
782 # FIXME: The asm symlink changes when $(ARCH) changes. That's
783 # hard to detect, but I suppose "make mrproper" is a good idea
784 # before switching between archs anyway.
786 define check-symlink
787 set -e; \
788 if [ -L include/asm ]; then \
789 asmlink=`readlink include/asm | cut -d '-' -f 2`; \
790 if [ "$$asmlink" != "$(SRCARCH)" ]; then \
791 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
792 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \
793 exit 1; \
794 fi; \
796 endef
798 # We create the target directory of the symlink if it does
799 # not exist so the test in chack-symlink works and we have a
800 # directory for generated filesas used by some architectures.
801 define create-symlink
802 if [ ! -L include/asm ]; then \
803 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
804 if [ ! -d include/asm-$(SRCARCH) ]; then \
805 mkdir -p include/asm-$(SRCARCH); \
806 fi; \
807 ln -fsn asm-$(SRCARCH) $@; \
809 endef
811 include/asm:
812 $(Q)$(check-symlink)
813 $(Q)$(create-symlink)
815 include/config.h: include/config/auto.conf
816 @echo ' SYMLINK $@ -> board/$(board-y)/config.h'
817 ifneq ($(KBUILD_SRC),)
818 $(Q)ln -fsn $(srctree)/board/$(board-y)/config.h $@
819 else
820 @ln -fsn ../board/$(board-y)/config.h $@
821 endif
823 # Generate some files
824 # ---------------------------------------------------------------------------
826 # KERNELRELEASE can change from a few different places, meaning version.h
827 # needs to be updated, so this check is forced on all builds
829 uts_len := 64
830 define filechk_utsrelease.h
831 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
832 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
833 exit 1; \
834 fi; \
835 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
836 endef
838 define filechk_version.h
839 (echo \#define LINUX_VERSION_CODE $(shell \
840 expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
841 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
842 endef
844 include/linux/version.h: $(srctree)/Makefile FORCE
845 $(call filechk,version.h)
847 include/linux/utsrelease.h: include/config/kernel.release FORCE
848 $(call filechk,utsrelease.h)
850 # ---------------------------------------------------------------------------
852 PHONY += depend dep
853 depend dep:
854 @echo '*** Warning: make $@ is unnecessary now.'
856 # ---------------------------------------------------------------------------
857 # Modules
859 ifdef CONFIG_MODULES
861 # By default, build modules as well
863 all: modules
865 # Build modules
867 PHONY += modules
868 modules: $(uboot-dirs) $(if $(KBUILD_BUILTIN),uboot)
869 @echo ' Building modules, stage 2.';
870 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
873 # Target to prepare building external modules
874 PHONY += modules_prepare
875 modules_prepare: prepare scripts
877 # Target to install modules
878 PHONY += modules_install
879 modules_install: _modinst_ _modinst_post
881 PHONY += _modinst_
882 _modinst_:
883 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
884 echo "Warning: you may need to install module-init-tools"; \
885 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
886 sleep 1; \
888 @rm -rf $(MODLIB)/kernel
889 @rm -f $(MODLIB)/source
890 @mkdir -p $(MODLIB)/kernel
891 @ln -s $(srctree) $(MODLIB)/source
892 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
893 rm -f $(MODLIB)/build ; \
894 ln -s $(objtree) $(MODLIB)/build ; \
896 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
898 # If System.map exists, run depmod. This deliberately does not have a
899 # dependency on System.map since that would run the dependency tree on
900 # vmlinux. This depmod is only for convenience to give the initial
901 # boot a modules.dep even before / is mounted read-write. However the
902 # boot script depmod is the master version.
903 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
904 depmod_opts :=
905 else
906 depmod_opts := -b $(INSTALL_MOD_PATH) -r
907 endif
908 PHONY += _modinst_post
909 _modinst_post: _modinst_
910 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
912 else # CONFIG_MODULES
914 # Modules not configured
915 # ---------------------------------------------------------------------------
917 modules modules_install: FORCE
918 @echo
919 @echo "The present kernel configuration has modules disabled."
920 @echo "Type 'make config' and enable loadable module support."
921 @echo "Then build a kernel with module support enabled."
922 @echo
923 @exit 1
925 endif # CONFIG_MODULES
928 # Cleaning is done on three levels.
929 # make clean Delete most generated files
930 # Leave enough to build external modules
931 # make mrproper Delete the current configuration, and all generated files
932 # make distclean Remove editor backup files, patch leftover files and the like
934 # Directories & files removed with 'make clean'
935 CLEAN_DIRS += $(MODVERDIR)
936 CLEAN_FILES += uboot System.map include/uboot_default_env.h \
937 .tmp_version .tmp_uboot* uboot.bin uboot.S \
938 .tmp_kallsyms* uboot_default_env
940 # Directories & files removed with 'make mrproper'
941 MRPROPER_DIRS += include/config include2 usr/include
942 MRPROPER_FILES += .config .config.old include/asm .version .old_version \
943 include/linux/autoconf.h include/linux/version.h \
944 include/linux/utsrelease.h include/config.h \
945 Module.symvers tags TAGS cscope*
947 # clean - Delete most, but leave enough to build external modules
949 clean: rm-dirs := $(CLEAN_DIRS)
950 clean: rm-files := $(CLEAN_FILES)
951 clean-dirs := $(addprefix _clean_,$(srctree) $(uboot-alldirs))
953 PHONY += $(clean-dirs) clean archclean
954 $(clean-dirs):
955 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
957 clean: archclean $(clean-dirs)
958 $(call cmd,rmdirs)
959 $(call cmd,rmfiles)
960 @find . $(RCS_FIND_IGNORE) \
961 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
962 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
963 -o -name '*.symtypes' \) \
964 -type f -print | xargs rm -f
966 # mrproper - Delete all generated files, including .config
968 mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
969 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
970 mrproper-dirs := $(addprefix _mrproper_,scripts)
972 PHONY += $(mrproper-dirs) mrproper archmrproper
973 $(mrproper-dirs):
974 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
976 mrproper: clean archmrproper $(mrproper-dirs)
977 $(call cmd,rmdirs)
978 $(call cmd,rmfiles)
980 # distclean
982 PHONY += distclean
984 distclean: mrproper
985 @find $(srctree) $(RCS_FIND_IGNORE) \
986 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
987 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
988 -o -name '.*.rej' -o -size 0 \
989 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
990 -type f -print | xargs rm -f
993 # Packaging of the kernel to various formats
994 # ---------------------------------------------------------------------------
995 # rpm target kept for backward compatibility
996 package-dir := $(srctree)/scripts/package
998 %pkg: include/config/kernel.release FORCE
999 $(Q)$(MAKE) $(build)=$(package-dir) $@
1000 rpm: include/config/kernel.release FORCE
1001 $(Q)$(MAKE) $(build)=$(package-dir) $@
1004 # Brief documentation of the typical targets used
1005 # ---------------------------------------------------------------------------
1007 boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
1008 boards := $(notdir $(boards))
1010 help:
1011 @echo 'Cleaning targets:'
1012 @echo ' clean - Remove most generated files but keep the config and'
1013 @echo ' enough build support to build external modules'
1014 @echo ' mrproper - Remove all generated files + config + various backup files'
1015 @echo ' distclean - mrproper + remove editor backup and patch files'
1016 @echo ' docs - start doxygen for all output types (only HTML - FIXME)'
1017 @echo ' htmldocs - create documentation in HTML format'
1018 @echo ''
1019 @echo 'Configuration targets:'
1020 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1021 @echo ''
1022 @echo 'Other generic targets:'
1023 @echo ' all - Build all targets marked with [*]'
1024 @echo '* uboot - Build the bare kernel'
1025 @echo ' dir/ - Build all files in dir and below'
1026 @echo ' dir/file.[ois] - Build specified target only'
1027 @echo ' dir/file.ko - Build module including final link'
1028 @echo ' tags/TAGS - Generate tags file for editors'
1029 @echo ' cscope - Generate cscope index'
1030 @echo ' (default: $(INSTALL_HDR_PATH))'
1031 @echo ''
1032 @echo 'Static analysers'
1033 @echo ' checkstack - Generate a list of stack hogs'
1034 @echo ' namespacecheck - Name space analysis on compiled kernel'
1035 @if [ -r include/asm-$(ARCH)/Kbuild ]; then \
1036 echo ' headers_check - Sanity check on exported headers'; \
1038 @echo ''
1039 @echo 'Architecture specific targets ($(ARCH)):'
1040 @$(if $(archhelp),$(archhelp),\
1041 echo ' No architecture specific help defined for $(ARCH)')
1042 @echo ''
1043 @$(if $(boards), \
1044 $(foreach b, $(boards), \
1045 printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1046 echo '')
1048 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1049 @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
1050 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
1051 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
1052 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1053 @echo ''
1054 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
1055 @echo 'For further info see the ./README file'
1057 # Generate doxygen docs
1058 # ---------------------------------------------------------------------------
1059 .PHONY += docs htmldocs
1061 docs : htmldocs
1063 htmldocs:
1064 @echo 'Running doxygen with local Doxyfile'
1065 $(Q)doxygen Doxyfile
1067 # Generate tags for editors
1068 # ---------------------------------------------------------------------------
1070 #We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
1071 #(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1072 #Adding $(srctree) adds about 20M on i386 to the size of the output file!
1074 ifeq ($(src),$(obj))
1075 __srctree =
1076 else
1077 __srctree = $(srctree)/
1078 endif
1080 ifeq ($(ALLSOURCE_ARCHS),)
1081 ifeq ($(ARCH),um)
1082 ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
1083 else
1084 ALLINCLUDE_ARCHS := $(ARCH)
1085 endif
1086 else
1087 #Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour.
1088 ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1089 endif
1091 ALLSOURCE_ARCHS := $(ARCH)
1093 define find-sources
1094 ( find $(__srctree) $(RCS_FIND_IGNORE) \
1095 \( -name include -o -name arch \) -prune -o \
1096 -name $1 -print; \
1097 for ARCH in $(ALLSOURCE_ARCHS) ; do \
1098 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
1099 -name $1 -print; \
1100 done ; \
1101 find $(__srctree)include $(RCS_FIND_IGNORE) \
1102 \( -name config -o -name 'asm-*' \) -prune \
1103 -o -name $1 -print; \
1104 for ARCH in $(ALLINCLUDE_ARCHS) ; do \
1105 test -e $(__srctree)include/asm-$${arch} && \
1106 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1107 -name $1 -print; \
1108 test -e $(__srctree)arch/$${arch}/include/asm && \
1109 find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
1110 -name $1 -print; \
1111 done ; \
1112 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
1113 -name $1 -print )
1114 endef
1116 define all-sources
1117 $(call find-sources,'*.[chS]')
1118 endef
1119 define all-kconfigs
1120 $(call find-sources,'Kconfig*')
1121 endef
1122 define all-defconfigs
1123 $(call find-sources,'defconfig')
1124 endef
1126 define xtags
1127 if $1 --version 2>&1 | grep -iq exuberant; then \
1128 $(all-sources) | xargs $1 -a \
1129 -I __initdata,__exitdata,__acquires,__releases \
1130 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1131 --extra=+f --c-kinds=+px \
1132 --regex-asm='/ENTRY\(([^)]*)\).*/\1/'; \
1133 $(all-kconfigs) | xargs $1 -a \
1134 --langdef=kconfig \
1135 --language-force=kconfig \
1136 --regex-kconfig='/^[[:blank:]]*config[[:blank:]]+([[:alnum:]_]+)/\1/'; \
1137 $(all-defconfigs) | xargs -r $1 -a \
1138 --langdef=dotconfig \
1139 --language-force=dotconfig \
1140 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
1141 elif $1 --version 2>&1 | grep -iq emacs; then \
1142 $(all-sources) | xargs $1 -a; \
1143 $(all-kconfigs) | xargs $1 -a \
1144 --regex='/^[ \t]*config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \
1145 $(all-defconfigs) | xargs -r $1 -a \
1146 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
1147 else \
1148 $(all-sources) | xargs $1 -a; \
1150 endef
1152 quiet_cmd_cscope-file = FILELST cscope.files
1153 cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
1155 quiet_cmd_cscope = MAKE cscope.out
1156 cmd_cscope = cscope -b
1158 cscope: FORCE
1159 $(call cmd,cscope-file)
1160 $(call cmd,cscope)
1162 quiet_cmd_TAGS = MAKE $@
1163 define cmd_TAGS
1164 rm -f $@; \
1165 $(call xtags,etags)
1166 endef
1168 TAGS: FORCE
1169 $(call cmd,TAGS)
1171 quiet_cmd_tags = MAKE $@
1172 define cmd_tags
1173 rm -f $@; \
1174 $(call xtags,ctags)
1175 endef
1177 tags: FORCE
1178 $(call cmd,tags)
1181 endif #ifeq ($(config-targets),1)
1182 endif #ifeq ($(mixed-targets),1)
1184 # Single targets
1185 # ---------------------------------------------------------------------------
1186 # Single targets are compatible with:
1187 # - build whith mixed source and output
1188 # - build with separate output dir 'make O=...'
1189 # - external modules
1191 # target-dir => where to store outputfile
1192 # build-dir => directory in kernel source tree to use
1194 build-dir = $(patsubst %/,%,$(dir $@))
1195 target-dir = $(dir $@)
1197 %.s: %.c prepare scripts FORCE
1198 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1199 %.i: %.c prepare scripts FORCE
1200 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1201 %.o: %.c prepare scripts FORCE
1202 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1203 %.lst: %.c prepare scripts FORCE
1204 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1205 %.s: %.S prepare scripts FORCE
1206 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1207 %.o: %.S prepare scripts FORCE
1208 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1209 %.symtypes: %.c prepare scripts FORCE
1210 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1212 # Modules
1213 / %/: prepare scripts FORCE
1214 $(Q)$(MAKE) $(build)=$(build-dir)
1215 %.ko: prepare scripts FORCE
1216 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1217 $(build)=$(build-dir) $(@:.ko=.o)
1218 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1220 # FIXME Should go into a make.lib or something
1221 # ===========================================================================
1223 quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
1224 cmd_rmdirs = rm -rf $(rm-dirs)
1226 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1227 cmd_rmfiles = rm -f $(rm-files)
1230 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
1231 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
1232 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1234 quiet_cmd_as_o_S = AS $@
1235 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
1237 # read all saved command lines
1239 targets := $(wildcard $(sort $(targets)))
1240 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1242 ifneq ($(cmd_files),)
1243 $(cmd_files): ; # Do not try to update included dependency files
1244 include $(cmd_files)
1245 endif
1247 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1248 # Usage:
1249 # $(Q)$(MAKE) $(clean)=dir
1250 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1252 endif # skip-makefile
1254 PHONY += FORCE
1255 FORCE:
1257 # Cancel implicit rules on top Makefile, `-rR' will apply to sub-makes.
1258 Makefile: ;
1260 # Declare the contents of the .PHONY variable as phony. We keep that
1261 # information in a variable se we can use it in if_changed and friends.
1262 .PHONY: $(PHONY)
1265 # sanity checks for check default environemnt
1267 ifdef CONFIG_DEFAULT_ENVIRONMENT
1269 ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
1270 $(error default environment path empty))
1271 endif
1273 saved-env_path := $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
1274 CONFIG_DEFAULT_ENVIRONMENT_PATH := $(shell cd $(if $(filter /%,$(CONFIG_DEFAULT_ENVIRONMENT_PATH)),,$(srctree)/)$(CONFIG_DEFAULT_ENVIRONMENT_PATH) && /bin/pwd)
1275 $(if $(CONFIG_DEFAULT_ENVIRONMENT_PATH),, \
1276 $(error default environment path $(saved-env_path) does not exist))
1278 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT