menu: simplify usage for clients
[barebox-mini2440.git] / Makefile
blob1f9a32de38b92ae33b4242a6e54dd0b95e8b3e10
1 VERSION = 2010
2 PATCHLEVEL = 08
3 SUBLEVEL = 0
4 EXTRAVERSION =
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 barebox), 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 -I$(srctree)/arch/$(ARCH)/include \
292 -I$(objtree)/arch/$(ARCH)/include \
293 -include include/generated/autoconf.h
295 CPPFLAGS := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
297 CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
298 -fno-strict-aliasing -fno-common -Os -pipe
299 AFLAGS := -D__ASSEMBLY__
301 LDFLAGS := -Map barebox.map
303 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
304 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
305 KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
307 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
308 export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
309 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
310 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
312 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
313 export CFLAGS CFLAGS_KERNEL
314 export AFLAGS AFLAGS_KERNEL
316 # Files to ignore in find ... statements
318 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
319 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
321 # ===========================================================================
322 # Rules shared between *config targets and build targets
324 # Basic helpers built in scripts/
325 PHONY += scripts_basic
326 scripts_basic:
327 $(Q)$(MAKE) $(build)=scripts/basic
329 # To avoid any implicit rule to kick in, define an empty command.
330 scripts/basic/%: scripts_basic ;
332 PHONY += outputmakefile
333 # outputmakefile generates a Makefile in the output directory, if using a
334 # separate output directory. This allows convenient use of make in the
335 # output directory.
336 outputmakefile:
337 ifneq ($(KBUILD_SRC),)
338 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
339 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
340 endif
342 # To make sure we do not include .config for any of the *config targets
343 # catch them early, and hand them over to scripts/kconfig/Makefile
344 # It is allowed to specify more targets when calling make, including
345 # mixing *config targets and build targets.
346 # For example 'make oldconfig all'.
347 # Detect when mixed targets is specified, and make a second invocation
348 # of make so .config is not included in this case either (for *config).
350 no-dot-config-targets := clean mrproper distclean \
351 cscope TAGS tags help %docs check% \
352 include/linux/version.h headers_% \
353 kernelrelease kernelversion
355 config-targets := 0
356 mixed-targets := 0
357 dot-config := 1
359 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
360 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
361 dot-config := 0
362 endif
363 endif
365 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
366 config-targets := 1
367 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
368 mixed-targets := 1
369 endif
370 endif
372 ifeq ($(mixed-targets),1)
373 # ===========================================================================
374 # We're called with mixed targets (*config and build targets).
375 # Handle them one by one.
377 %:: FORCE
378 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
380 else
381 ifeq ($(config-targets),1)
382 # ===========================================================================
383 # *config targets only - make sure prerequisites are updated, and descend
384 # in scripts/kconfig to make the *config target
386 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
387 # KBUILD_DEFCONFIG may point out an alternative default configuration
388 # used for 'make defconfig'
389 include $(srctree)/arch/$(ARCH)/Makefile
390 export KBUILD_DEFCONFIG
392 config %config: scripts_basic outputmakefile FORCE
393 $(Q)mkdir -p include/linux include/config
394 $(Q)$(MAKE) $(build)=scripts/kconfig $@
396 else
397 # ===========================================================================
398 # Build targets only - this includes barebox, arch specific targets, clean
399 # targets and others. In general all targets except *config targets.
401 # Additional helpers built in scripts/
402 # Carefully list dependencies so we do not try to build scripts twice
403 # in parallel
404 PHONY += scripts
405 scripts: scripts_basic include/config/auto.conf
406 $(Q)$(MAKE) $(build)=$(@)
408 # Objects we will link into barebox / subdirs we need to visit
409 common-y := common/ drivers/ commands/ lib/ net/ fs/
411 ifeq ($(dot-config),1)
412 # Read in config
413 -include include/config/auto.conf
415 # Read in dependencies to all Kconfig* files, make sure to run
416 # oldconfig if changes are detected.
417 -include include/config/auto.conf.cmd
419 # To avoid any implicit rule to kick in, define an empty command
420 $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
422 # If .config is newer than include/config/auto.conf, someone tinkered
423 # with it and forgot to run make oldconfig.
424 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
425 # we execute the config step to be sure to catch updated Kconfig files
426 include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
427 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
429 else
430 # Dummy target needed, because used as prerequisite
431 include/config/auto.conf: ;
432 endif # $(dot-config)
434 # The all: target is the default when no target is given on the
435 # command line.
436 # This allow a user to issue only 'make' to build a kernel
437 # Defaults barebox but it is usually overridden in the arch makefile
438 all: barebox.bin
440 include $(srctree)/arch/$(ARCH)/Makefile
442 ifdef CONFIG_DEBUG_INFO
443 CFLAGS += -g
444 endif
446 # Force gcc to behave correct even for buggy distributions
447 CFLAGS += $(call cc-option, -fno-stack-protector)
449 # arch Makefile may override CC so keep this after arch Makefile is included
450 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
451 CHECKFLAGS += $(NOSTDINC_FLAGS)
453 # warn about C99 declaration after statement
454 CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
456 # disable pointer signed / unsigned warnings in gcc 4.0
457 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
459 # Default kernel image to build when no specific target is given.
460 # KBUILD_IMAGE may be overruled on the command line or
461 # set in the environment
462 # Also any assignments in arch/$(ARCH)/Makefile take precedence over
463 # this default value
464 export KBUILD_IMAGE ?= barebox
466 barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y)))
468 barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \
469 $(common-n) $(common-) \
470 $(core-n) $(core-) $(drivers-n) $(drivers-) \
471 $(net-n) $(net-) $(libs-n) $(libs-))))
473 common-y := $(patsubst %/, %/built-in.o, $(common-y))
475 # Build barebox
476 # ---------------------------------------------------------------------------
477 # barebox is built from the objects selected by $(barebox-init) and
478 # $(barebox-main). Most are built-in.o files from top-level directories
479 # in the kernel tree, others are specified in arch/$(ARCH)Makefile.
480 # Ordering when linking is important, and $(barebox-init) must be first.
482 # FIXME: This picture is wrong for barebox. We have no init, driver, mm
484 # barebox
487 # +-< $(barebox-init)
488 # | +--< init/version.o + more
490 # +--< $(barebox-main)
491 # | +--< driver/built-in.o mm/built-in.o + more
493 # +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
495 # barebox version cannot be updated during normal
496 # descending-into-subdirs phase since we do not yet know if we need to
497 # update barebox.
499 # System.map is generated to document addresses of all kernel symbols
501 barebox-common := $(common-y)
502 barebox-all := $(barebox-common)
503 barebox-lds := $(lds-y)
505 # Rule to link barebox
506 # May be overridden by arch/$(ARCH)/Makefile
507 quiet_cmd_barebox__ ?= LD $@
508 cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
509 -T $(barebox-lds) $(barebox-head) \
510 --start-group $(barebox-common) --end-group \
511 $(filter-out $(barebox-lds) $(barebox-common) FORCE ,$^)
513 # Generate new barebox version
514 quiet_cmd_barebox_version = GEN .version
515 cmd_barebox_version = set -e; \
516 if [ ! -r .version ]; then \
517 rm -f .version; \
518 echo 1 >.version; \
519 else \
520 mv .version .old_version; \
521 expr 0$$(cat .old_version) + 1 >.version; \
522 fi; \
525 # Generate System.map
526 quiet_cmd_sysmap = SYSMAP
527 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
529 # Link of barebox
530 # Generate System.map and verify that the content is consistent
531 # Use + in front of the barebox_version rule to silent warning with make -j2
532 # First command is ':' to allow us to use + in front of the rule
533 define rule_barebox__
536 $(call cmd,barebox__)
538 $(Q)echo 'cmd_$@ := $(cmd_barebox__)' > $(@D)/.$(@F).cmd
540 $(Q)$(if $($(quiet)cmd_sysmap), \
541 echo ' $($(quiet)cmd_sysmap) System.map' &&) \
542 $(cmd_sysmap) $@ System.map; \
543 if [ $$? -ne 0 ]; then \
544 rm -f $@; \
545 /bin/false; \
547 endef
549 ifdef CONFIG_KALLSYMS
550 # Generate section listing all symbols and add it into barebox $(kallsyms.o)
551 # It's a three stage process:
552 # o .tmp_barebox1 has all symbols and sections, but __kallsyms is
553 # empty
554 # Running kallsyms on that gives us .tmp_kallsyms1.o with
555 # the right size - barebox version is updated during this step
556 # o .tmp_barebox2 now has a __kallsyms section of the right size,
557 # but due to the added section, some addresses have shifted.
558 # From here, we generate a correct .tmp_kallsyms2.o
559 # o The correct .tmp_kallsyms2.o is linked into the final barebox.
560 # o Verify that the System.map from barebox matches the map from
561 # .tmp_barebox2, just in case we did not generate kallsyms correctly.
562 # o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
563 # .tmp_barebox3 and .tmp_kallsyms3.o. This is only meant as a
564 # temporary bypass to allow the kernel to be built while the
565 # maintainers work out what went wrong with kallsyms.
567 ifdef CONFIG_KALLSYMS_EXTRA_PASS
568 last_kallsyms := 3
569 else
570 last_kallsyms := 2
571 endif
573 kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
575 define verify_kallsyms
576 $(Q)$(if $($(quiet)cmd_sysmap), \
577 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
578 $(cmd_sysmap) .tmp_barebox$(last_kallsyms) .tmp_System.map
579 $(Q)cmp -s System.map .tmp_System.map || \
580 (echo Inconsistent kallsyms data; \
581 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
582 rm .tmp_kallsyms* ; /bin/false )
583 endef
585 # Update barebox version before link
586 # Use + in front of this rule to silent warning about make -j1
587 # First command is ':' to allow us to use + in front of this rule
588 cmd_ksym_ld = $(cmd_barebox__)
589 define rule_ksym_ld
591 +$(call cmd,barebox_version)
592 $(call cmd,barebox__)
593 $(Q)echo 'cmd_$@ := $(cmd_barebox__)' > $(@D)/.$(@F).cmd
594 endef
596 # Generate .S file with all kernel symbols
597 quiet_cmd_kallsyms = KSYM $@
598 cmd_kallsyms = $(NM) -g -n $< | $(KALLSYMS) > $@
600 .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
601 $(call if_changed_dep,as_o_S)
603 .tmp_kallsyms%.S: .tmp_barebox% $(KALLSYMS)
604 $(call cmd,kallsyms)
606 # .tmp_barebox1 must be complete except kallsyms, so update barebox version
607 .tmp_barebox1: $(barebox-lds) $(barebox-all) FORCE
608 $(call if_changed_rule,ksym_ld)
610 .tmp_barebox2: $(barebox-lds) $(barebox-all) .tmp_kallsyms1.o FORCE
611 $(call if_changed,barebox__)
613 .tmp_barebox3: $(barebox-lds) $(barebox-all) .tmp_kallsyms2.o FORCE
614 $(call if_changed,barebox__)
616 # Needs to visit scripts/ before $(KALLSYMS) can be used.
617 $(KALLSYMS): scripts ;
619 # Generate some data for debugging strange kallsyms problems
620 debug_kallsyms: .tmp_map$(last_kallsyms)
622 .tmp_map%: .tmp_barebox% FORCE
623 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
625 .tmp_map3: .tmp_map2
627 .tmp_map2: .tmp_map1
629 endif # ifdef CONFIG_KALLSYMS
631 # Do modpost on a prelinked vmlinux. The finally linked vmlinux has
632 # relevant sections renamed as per the linker script.
633 quiet_cmd_barebox-modpost = LD $@
634 cmd_barebox-modpost = $(LD) $(LDFLAGS) -r -o $@ \
635 $(vmlinux-init) --start-group $(barebox-main) --end-group \
636 $(filter-out $(barebox-init) $(barebox-main) $(barebox-lds) FORCE ,$^)
637 define rule_barebox-modpost
639 +$(call cmd,barebox-modpost)
640 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
641 $(Q)echo 'cmd_$@ := $(cmd_barebox-modpost)' > $(dot-target).cmd
642 endef
644 quiet_cmd_objcopy = OBJCOPY $@
645 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
647 OBJCOPYFLAGS_barebox.bin = -O binary
649 barebox.bin: barebox FORCE
650 $(call if_changed,objcopy)
652 ifdef CONFIG_X86
653 barebox.S: barebox
654 ifdef CONFIG_X86_HDBOOT
655 @echo "-------------------------------------------------" > barebox.S
656 @echo " * MBR content" >> barebox.S
657 $(Q)$(OBJDUMP) -j .bootsector -mi8086 -d barebox >> barebox.S
658 @echo "-------------------------------------------------" >> barebox.S
659 @echo " * Boot loader content" >> barebox.S
660 $(Q)$(OBJDUMP) -j .bootstrapping -mi8086 -d barebox >> barebox.S
661 endif
662 @echo "-------------------------------------------------" >> barebox.S
663 @echo " * Regular Text content" >> barebox.S
664 $(Q)$(OBJDUMP) -j .text -d barebox >> barebox.S
665 @echo "-------------------------------------------------" >> barebox.S
666 @echo " * Regular Data content" >> barebox.S
667 $(Q)$(OBJDUMP) -j .data -d barebox >> barebox.S
668 @echo "-------------------------------------------------" >> barebox.S
669 @echo " * Commands content" >> barebox.S
670 $(Q)$(OBJDUMP) -j .barebox_cmd -d barebox >> barebox.S
671 @echo "-------------------------------------------------" >> barebox.S
672 @echo " * Init Calls content" >> barebox.S
673 $(Q)$(OBJDUMP) -j .barebox_initcalls -d barebox >> barebox.S
674 else
675 quiet_cmd_disasm = DISASM $@
676 cmd_disasm = $(OBJDUMP) -d $< > $@
678 barebox.S: barebox FORCE
679 $(call if_changed,disasm)
680 endif
682 # barebox image
683 barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
684 $(call barebox-modpost)
685 $(call if_changed_rule,barebox__)
686 $(Q)rm -f .old_version
688 # The actual objects are generated when descending,
689 # make sure no implicit rule kicks in
690 $(sort $(barebox-head) $(barebox-common) ) $(barebox-lds): $(barebox-dirs) ;
692 # Handle descending into subdirectories listed in $(barebox-dirs)
693 # Preset locale variables to speed up the build process. Limit locale
694 # tweaks to this spot to avoid wrong language settings when running
695 # make menuconfig etc.
696 # Error messages still appears in the original language
698 PHONY += $(barebox-dirs)
699 $(barebox-dirs): prepare scripts
700 $(Q)$(MAKE) $(build)=$@
702 # Build the kernel release string
704 # The KERNELRELEASE value built here is stored in the file
705 # include/config/kernel.release, and is used when executing several
706 # make targets, such as "make install" or "make modules_install."
708 # The eventual kernel release string consists of the following fields,
709 # shown in a hierarchical format to show how smaller parts are concatenated
710 # to form the larger and final value, with values coming from places like
711 # the Makefile, kernel config options, make command line options and/or
712 # SCM tag information.
714 # $(KERNELVERSION)
715 # $(VERSION) eg, 2
716 # $(PATCHLEVEL) eg, 6
717 # $(SUBLEVEL) eg, 18
718 # $(EXTRAVERSION) eg, -rc6
719 # $(localver-full)
720 # $(localver)
721 # localversion* (all localversion* files)
722 # $(CONFIG_LOCALVERSION) (from kernel config setting)
723 # $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set)
724 # ./scripts/setlocalversion (SCM tag, if one exists)
725 # $(LOCALVERSION) (from make command line if provided)
727 # Note how the final $(localver-auto) string is included *only* if the
728 # kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the
729 # moment, only git is supported but other SCMs can edit the script
730 # scripts/setlocalversion and add the appropriate checks as needed.
732 nullstring :=
733 space := $(nullstring) # end of line
735 ___localver = $(objtree)/localversion* $(srctree)/localversion*
736 __localver = $(sort $(wildcard $(___localver)))
737 # skip backup files (containing '~')
738 _localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
740 localver = $(subst $(space),, \
741 $(shell cat /dev/null $(_localver)) \
742 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
744 # If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
745 # and if the SCM is know a tag from the SCM is appended.
746 # The appended tag is determined by the SCM used.
748 # Currently, only git is supported.
749 # Other SCMs can edit scripts/setlocalversion and add the appropriate
750 # checks as needed.
751 ifdef CONFIG_LOCALVERSION_AUTO
752 _localver-auto = $(shell $(CONFIG_SHELL) \
753 $(srctree)/scripts/setlocalversion $(srctree))
754 localver-auto = $(LOCALVERSION)$(_localver-auto)
755 endif
757 localver-full = $(localver)$(localver-auto)
759 # Store (new) KERNELRELASE string in include/config/kernel.release
760 kernelrelease = $(KERNELVERSION)$(localver-full)
761 include/config/kernel.release: include/config/auto.conf FORCE
762 $(Q)rm -f $@
763 $(Q)echo $(kernelrelease) > $@
766 # Things we need to do before we recursively start building the kernel
767 # or the modules are listed in "prepare".
768 # A multi level approach is used. prepareN is processed before prepareN-1.
769 # archprepare is used in arch Makefiles and when processed asm symlink,
770 # version.h and scripts_basic is processed / created.
772 # Listed in dependency order
773 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
775 # prepare-all is deprecated, use prepare as valid replacement
776 PHONY += prepare-all
778 # prepare3 is used to check if we are building in a separate output directory,
779 # and if so do:
780 # 1) Check that make has not been executed in the kernel src $(srctree)
781 # 2) Create the include2 directory, used for the second asm symlink
782 prepare3: include/config/kernel.release
783 ifneq ($(KBUILD_SRC),)
784 @echo ' Using $(srctree) as source for kernel'
785 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
786 echo " $(srctree) is not clean, please run 'make mrproper'";\
787 echo " in the '$(srctree)' directory.";\
788 /bin/false; \
790 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
791 $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/barebox.h ]; then \
792 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
794 endif
796 # prepare2 creates a makefile if using a separate output directory
797 prepare2: prepare3 outputmakefile
799 prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \
800 include/asm include/config.h include/config/auto.conf
802 ifneq ($(KBUILD_MODULES),)
803 $(Q)mkdir -p $(MODVERDIR)
804 $(Q)rm -f $(MODVERDIR)/*
805 endif
807 archprepare: prepare1 scripts_basic
809 prepare0: archprepare FORCE
810 $(Q)$(MAKE) $(build)=.
812 # All the preparing..
813 prepare prepare-all: prepare0
815 # Leave this as default for preprocessing barebox.lds.S, which is now
816 # done in arch/$(ARCH)/kernel/Makefile
818 export CPPFLAGS_barebox.lds += -P -C -U$(ARCH)
820 # FIXME: The asm symlink changes when $(ARCH) changes. That's
821 # hard to detect, but I suppose "make mrproper" is a good idea
822 # before switching between archs anyway.
824 define check-symlink
825 set -e; \
826 if [ -L include/asm ]; then \
827 asmlink=`readlink include/asm | cut -d '-' -f 2`; \
828 if [ "$$asmlink" != "$(SRCARCH)" ]; then \
829 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
830 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \
831 exit 1; \
832 fi; \
834 endef
836 # We create the target directory of the symlink if it does
837 # not exist so the test in chack-symlink works and we have a
838 # directory for generated filesas used by some architectures.
839 define create-symlink
840 if [ ! -L include/asm ]; then \
841 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
842 if [ ! -d include/asm-$(SRCARCH) ]; then \
843 mkdir -p include/asm-$(SRCARCH); \
844 fi; \
845 ln -fsn asm-$(SRCARCH) $@; \
847 endef
849 include/asm:
850 $(Q)$(check-symlink)
851 $(Q)$(create-symlink)
853 include/config.h: include/config/auto.conf
854 @echo ' SYMLINK $@ -> $(BOARD)/config.h'
855 ifneq ($(KBUILD_SRC),)
856 $(Q)ln -fsn $(srctree)/$(BOARD)/config.h $@
857 else
858 @ln -fsn ../$(BOARD)/config.h $@
859 endif
861 # Generate some files
862 # ---------------------------------------------------------------------------
864 # KERNELRELEASE can change from a few different places, meaning version.h
865 # needs to be updated, so this check is forced on all builds
867 uts_len := 64
868 define filechk_utsrelease.h
869 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
870 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
871 exit 1; \
872 fi; \
873 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
874 endef
876 define filechk_version.h
877 (echo \#define LINUX_VERSION_CODE $(shell \
878 expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
879 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
880 endef
882 include/linux/version.h: $(srctree)/Makefile FORCE
883 $(call filechk,version.h)
885 include/linux/utsrelease.h: include/config/kernel.release FORCE
886 $(call filechk,utsrelease.h)
888 # ---------------------------------------------------------------------------
890 PHONY += depend dep
891 depend dep:
892 @echo '*** Warning: make $@ is unnecessary now.'
894 # ---------------------------------------------------------------------------
895 # Modules
897 ifdef CONFIG_MODULES
899 # By default, build modules as well
901 all: modules
903 # Build modules
905 PHONY += modules
906 modules: $(barebox-dirs) $(if $(KBUILD_BUILTIN),barebox)
907 @echo ' Building modules, stage 2.';
908 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
911 # Target to prepare building external modules
912 PHONY += modules_prepare
913 modules_prepare: prepare scripts
915 # Target to install modules
916 PHONY += modules_install
917 modules_install: _modinst_ _modinst_post
919 PHONY += _modinst_
920 _modinst_:
921 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
922 echo "Warning: you may need to install module-init-tools"; \
923 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
924 sleep 1; \
926 @rm -rf $(MODLIB)/kernel
927 @rm -f $(MODLIB)/source
928 @mkdir -p $(MODLIB)/kernel
929 @ln -s $(srctree) $(MODLIB)/source
930 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
931 rm -f $(MODLIB)/build ; \
932 ln -s $(objtree) $(MODLIB)/build ; \
934 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
936 # If System.map exists, run depmod. This deliberately does not have a
937 # dependency on System.map since that would run the dependency tree on
938 # vmlinux. This depmod is only for convenience to give the initial
939 # boot a modules.dep even before / is mounted read-write. However the
940 # boot script depmod is the master version.
941 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
942 depmod_opts :=
943 else
944 depmod_opts := -b $(INSTALL_MOD_PATH) -r
945 endif
946 PHONY += _modinst_post
947 _modinst_post: _modinst_
948 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
950 else # CONFIG_MODULES
952 # Modules not configured
953 # ---------------------------------------------------------------------------
955 modules modules_install: FORCE
956 @echo
957 @echo "The present kernel configuration has modules disabled."
958 @echo "Type 'make config' and enable loadable module support."
959 @echo "Then build a kernel with module support enabled."
960 @echo
961 @exit 1
963 endif # CONFIG_MODULES
966 # Cleaning is done on three levels.
967 # make clean Delete most generated files
968 # Leave enough to build external modules
969 # make mrproper Delete the current configuration, and all generated files
970 # make distclean Remove editor backup files, patch leftover files and the like
972 # Directories & files removed with 'make clean'
973 CLEAN_DIRS += $(MODVERDIR)
974 CLEAN_FILES += barebox System.map include/barebox_default_env.h \
975 .tmp_version .tmp_barebox* barebox.bin barebox.S \
976 .tmp_kallsyms* barebox_default_env barebox.ldr
978 # Directories & files removed with 'make mrproper'
979 MRPROPER_DIRS += include/config include2 usr/include
980 MRPROPER_FILES += .config .config.old include/asm .version .old_version \
981 include/generated/autoconf.h include/linux/version.h \
982 include/linux/utsrelease.h include/config.h \
983 Module.symvers tags TAGS cscope*
985 # clean - Delete most, but leave enough to build external modules
987 clean: rm-dirs := $(CLEAN_DIRS)
988 clean: rm-files := $(CLEAN_FILES)
989 clean-dirs := $(addprefix _clean_,$(srctree) $(barebox-alldirs))
991 PHONY += $(clean-dirs) clean archclean
992 $(clean-dirs):
993 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
995 clean: archclean $(clean-dirs)
996 $(call cmd,rmdirs)
997 $(call cmd,rmfiles)
998 @find . $(RCS_FIND_IGNORE) \
999 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1000 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1001 -o -name '*.symtypes' \) \
1002 -type f -print | xargs rm -f
1004 # mrproper - Delete all generated files, including .config
1006 mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
1007 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1008 mrproper-dirs := $(addprefix _mrproper_,scripts)
1010 PHONY += $(mrproper-dirs) mrproper archmrproper
1011 $(mrproper-dirs):
1012 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1014 mrproper: clean archmrproper $(mrproper-dirs)
1015 $(call cmd,rmdirs)
1016 $(call cmd,rmfiles)
1018 # distclean
1020 PHONY += distclean
1022 distclean: mrproper
1023 @find $(srctree) $(RCS_FIND_IGNORE) \
1024 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1025 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
1026 -o -name '.*.rej' -o -size 0 \
1027 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
1028 -type f -print | xargs rm -f
1031 # Packaging of the kernel to various formats
1032 # ---------------------------------------------------------------------------
1033 # rpm target kept for backward compatibility
1034 package-dir := $(srctree)/scripts/package
1036 %pkg: include/config/kernel.release FORCE
1037 $(Q)$(MAKE) $(build)=$(package-dir) $@
1038 rpm: include/config/kernel.release FORCE
1039 $(Q)$(MAKE) $(build)=$(package-dir) $@
1042 # Brief documentation of the typical targets used
1043 # ---------------------------------------------------------------------------
1045 boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
1046 boards := $(notdir $(boards))
1048 help:
1049 @echo 'Cleaning targets:'
1050 @echo ' clean - Remove most generated files but keep the config and'
1051 @echo ' enough build support to build external modules'
1052 @echo ' mrproper - Remove all generated files + config + various backup files'
1053 @echo ' distclean - mrproper + remove editor backup and patch files'
1054 @echo ' docs - start doxygen for all output types (only HTML - FIXME)'
1055 @echo ' htmldocs - create documentation in HTML format'
1056 @echo ''
1057 @echo 'Configuration targets:'
1058 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1059 @echo ''
1060 @echo 'Other generic targets:'
1061 @echo ' all - Build all targets marked with [*]'
1062 @echo '* barebox - Build the bare kernel'
1063 @echo ' dir/ - Build all files in dir and below'
1064 @echo ' dir/file.[ois] - Build specified target only'
1065 @echo ' dir/file.ko - Build module including final link'
1066 @echo ' tags/TAGS - Generate tags file for editors'
1067 @echo ' cscope - Generate cscope index'
1068 @echo ' (default: $(INSTALL_HDR_PATH))'
1069 @echo ''
1070 @echo 'Static analysers'
1071 @echo ' checkstack - Generate a list of stack hogs'
1072 @echo ' namespacecheck - Name space analysis on compiled kernel'
1073 @if [ -r include/asm-$(ARCH)/Kbuild ]; then \
1074 echo ' headers_check - Sanity check on exported headers'; \
1076 @echo ''
1077 @echo 'Architecture specific targets ($(ARCH)):'
1078 @$(if $(archhelp),$(archhelp),\
1079 echo ' No architecture specific help defined for $(ARCH)')
1080 @echo ''
1081 @$(if $(boards), \
1082 $(foreach b, $(boards), \
1083 printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1084 echo '')
1086 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1087 @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
1088 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
1089 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
1090 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1091 @echo ''
1092 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
1093 @echo 'For further info see the ./README file'
1095 # Generate doxygen docs
1096 # ---------------------------------------------------------------------------
1097 .PHONY += docs htmldocs
1099 docs : htmldocs
1101 htmldocs:
1102 @echo 'Running doxygen with local Doxyfile'
1103 $(Q)doxygen Doxyfile
1105 # Generate tags for editors
1106 # ---------------------------------------------------------------------------
1108 #We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
1109 #(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1110 #Adding $(srctree) adds about 20M on i386 to the size of the output file!
1112 ifeq ($(src),$(obj))
1113 __srctree =
1114 else
1115 __srctree = $(srctree)/
1116 endif
1118 ifeq ($(ALLSOURCE_ARCHS),)
1119 ifeq ($(ARCH),um)
1120 ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
1121 else
1122 ALLINCLUDE_ARCHS := $(ARCH)
1123 endif
1124 else
1125 #Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour.
1126 ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1127 endif
1129 ALLSOURCE_ARCHS := $(ARCH)
1131 define find-sources
1132 ( find $(__srctree) $(RCS_FIND_IGNORE) \
1133 \( -name include -o -name arch \) -prune -o \
1134 -name $1 -print; \
1135 for ARCH in $(ALLSOURCE_ARCHS) ; do \
1136 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
1137 -name $1 -print; \
1138 done ; \
1139 find $(__srctree)include $(RCS_FIND_IGNORE) \
1140 \( -name config -o -name 'asm-*' \) -prune \
1141 -o -name $1 -print; \
1142 for ARCH in $(ALLINCLUDE_ARCHS) ; do \
1143 test -e $(__srctree)include/asm-$${arch} && \
1144 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1145 -name $1 -print; \
1146 test -e $(__srctree)arch/$${arch}/include/asm && \
1147 find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
1148 -name $1 -print; \
1149 done ; \
1150 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
1151 -name $1 -print )
1152 endef
1154 define all-sources
1155 $(call find-sources,'*.[chS]')
1156 endef
1157 define all-kconfigs
1158 $(call find-sources,'Kconfig*')
1159 endef
1160 define all-defconfigs
1161 $(call find-sources,'defconfig')
1162 endef
1164 define xtags
1165 if $1 --version 2>&1 | grep -iq exuberant; then \
1166 $(all-sources) | xargs $1 -a \
1167 -I __initdata,__exitdata,__acquires,__releases \
1168 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1169 --extra=+f --c-kinds=+px \
1170 --regex-asm='/ENTRY\(([^)]*)\).*/\1/'; \
1171 $(all-kconfigs) | xargs $1 -a \
1172 --langdef=kconfig \
1173 --language-force=kconfig \
1174 --regex-kconfig='/^[[:blank:]]*config[[:blank:]]+([[:alnum:]_]+)/\1/'; \
1175 $(all-defconfigs) | xargs -r $1 -a \
1176 --langdef=dotconfig \
1177 --language-force=dotconfig \
1178 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
1179 elif $1 --version 2>&1 | grep -iq emacs; then \
1180 $(all-sources) | xargs $1 -a; \
1181 $(all-kconfigs) | xargs $1 -a \
1182 --regex='/^[ \t]*config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \
1183 $(all-defconfigs) | xargs -r $1 -a \
1184 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
1185 else \
1186 $(all-sources) | xargs $1 -a; \
1188 endef
1190 quiet_cmd_cscope-file = FILELST cscope.files
1191 cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
1193 quiet_cmd_cscope = MAKE cscope.out
1194 cmd_cscope = cscope -b
1196 cscope: FORCE
1197 $(call cmd,cscope-file)
1198 $(call cmd,cscope)
1200 quiet_cmd_TAGS = MAKE $@
1201 define cmd_TAGS
1202 rm -f $@; \
1203 $(call xtags,etags)
1204 endef
1206 TAGS: FORCE
1207 $(call cmd,TAGS)
1209 quiet_cmd_tags = MAKE $@
1210 define cmd_tags
1211 rm -f $@; \
1212 $(call xtags,ctags)
1213 endef
1215 tags: FORCE
1216 $(call cmd,tags)
1219 endif #ifeq ($(config-targets),1)
1220 endif #ifeq ($(mixed-targets),1)
1222 # Single targets
1223 # ---------------------------------------------------------------------------
1224 # Single targets are compatible with:
1225 # - build whith mixed source and output
1226 # - build with separate output dir 'make O=...'
1227 # - external modules
1229 # target-dir => where to store outputfile
1230 # build-dir => directory in kernel source tree to use
1232 build-dir = $(patsubst %/,%,$(dir $@))
1233 target-dir = $(dir $@)
1235 %.s: %.c prepare scripts FORCE
1236 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1237 %.i: %.c prepare scripts FORCE
1238 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1239 %.o: %.c prepare scripts FORCE
1240 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1241 %.lst: %.c prepare scripts FORCE
1242 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1243 %.s: %.S prepare scripts FORCE
1244 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1245 %.o: %.S prepare scripts FORCE
1246 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1247 %.symtypes: %.c prepare scripts FORCE
1248 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1250 # Modules
1251 / %/: prepare scripts FORCE
1252 $(Q)$(MAKE) $(build)=$(build-dir)
1253 %.ko: prepare scripts FORCE
1254 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1255 $(build)=$(build-dir) $(@:.ko=.o)
1256 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1258 # FIXME Should go into a make.lib or something
1259 # ===========================================================================
1261 quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
1262 cmd_rmdirs = rm -rf $(rm-dirs)
1264 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1265 cmd_rmfiles = rm -f $(rm-files)
1268 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
1269 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
1270 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1272 quiet_cmd_as_o_S = AS $@
1273 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
1275 # read all saved command lines
1277 targets := $(wildcard $(sort $(targets)))
1278 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1280 ifneq ($(cmd_files),)
1281 $(cmd_files): ; # Do not try to update included dependency files
1282 include $(cmd_files)
1283 endif
1285 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1286 # Usage:
1287 # $(Q)$(MAKE) $(clean)=dir
1288 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1290 endif # skip-makefile
1292 PHONY += FORCE
1293 FORCE:
1295 # Cancel implicit rules on top Makefile, `-rR' will apply to sub-makes.
1296 Makefile: ;
1298 # Declare the contents of the .PHONY variable as phony. We keep that
1299 # information in a variable se we can use it in if_changed and friends.
1300 .PHONY: $(PHONY)