[PATCH] add posix timer compat functions
[linux-2.6/history.git] / Makefile
blob285bc96fa97df302619c01c0b669baad19cc7e2a
1 VERSION = 2
2 PATCHLEVEL = 6
3 SUBLEVEL = 0
4 EXTRAVERSION = -test3
6 # *DOCUMENTATION*
7 # To see a list of typical targets execute "make help"
8 # More info can be located in ./README
9 # Comments in this file are targeted only to the developer, do not
10 # expect to learn how to build the kernel reading this file.
12 # We are using a recursive build, so we need to do a little thinking
13 # to get the ordering right.
15 # Most importantly: sub-Makefiles should only ever modify files in
16 # their own directory. If in some directory we have a dependency on
17 # a file in another dir (which doesn't happen often, but it's of
18 # unavoidable when linking the built-in.o targets which finally
19 # turn into vmlinux), we will call a sub make in that other dir, and
20 # after that we are sure that everything which is in that other dir
21 # is now up to date.
23 # The only cases where we need to modify files which have global
24 # effects are thus separated out and done before the recursive
25 # descending is started. They are now explicitly listed as the
26 # prepare rule.
28 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
30 # SUBARCH tells the usermode build what the underlying arch is. That is set
31 # first, and if a usermode build is happening, the "ARCH=um" on the command
32 # line overrides the setting of ARCH below. If a native build is happening,
33 # then ARCH is assigned, getting whatever value it gets normally, and
34 # SUBARCH is subsequently ignored.
36 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
37 -e s/arm.*/arm/ -e s/sa110/arm/ \
38 -e s/s390x/s390/ -e s/parisc64/parisc/ )
40 # Remove hyphens since they have special meaning in RPM filenames
41 KERNELPATH=kernel-$(subst -,,$(KERNELRELEASE))
43 # Cross compiling and selecting different set of gcc/bin-utils
44 # ---------------------------------------------------------------------------
46 # When performing cross compilation for other architectures ARCH shall be set
47 # to the target architecture. (See arch/* for the possibilities).
48 # ARCH can be set during invocation of make:
49 # make ARCH=ia64
50 # Another way is to have ARCH set in the environment.
51 # The default ARCH is the host where make is executed.
53 # CROSS_COMPILE specify the prefix used for all executables used
54 # during compilation. Only gcc and related bin-utils executables
55 # are prefixed with $(CROSS_COMPILE).
56 # CROSS_COMPILE can be set on the command line
57 # make CROSS_COMPILE=ia64-linux-
58 # Alternatively CROSS_COMPILE can be set in the environment.
59 # Default value for CROSS_COMPILE is not to prefix executables
60 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
62 ARCH ?= $(SUBARCH)
63 CROSS_COMPILE ?=
65 # Architecture as present in compile.h
66 UTS_MACHINE := $(ARCH)
68 # SHELL used by kbuild
69 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
70 else if [ -x /bin/bash ]; then echo /bin/bash; \
71 else echo sh; fi ; fi)
72 TOPDIR := $(CURDIR)
74 HOSTCC = gcc
75 HOSTCXX = g++
76 HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
77 HOSTCXXFLAGS = -O2
80 # That's our default target when none is given on the command line
81 # Note that 'modules' will be added as a prerequisite as well,
82 # in the CONFIG_MODULES part below
84 all: vmlinux
86 # Decide whether to build built-in, modular, or both.
87 # Normally, just do built-in.
89 KBUILD_MODULES :=
90 KBUILD_BUILTIN := 1
92 # If we have only "make modules", don't compile built-in objects.
93 # When we're building modules with modversions, we need to consider
94 # the built-in objects during the descend as well, in order to
95 # make sure the checksums are uptodate before we record them.
97 ifeq ($(MAKECMDGOALS),modules)
98 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
99 endif
101 # If we have "make <whatever> modules", compile modules
102 # in addition to whatever we do anyway.
103 # Just "make" or "make all" shall build modules as well
105 ifneq ($(filter all modules,$(MAKECMDGOALS)),)
106 KBUILD_MODULES := 1
107 endif
109 ifeq ($(MAKECMDGOALS),)
110 KBUILD_MODULES := 1
111 endif
113 export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE KBUILD_CHECKSRC
115 # To put more focus on warnings, less verbose as default
116 # Use 'make V=1' to see the full commands
118 ifdef V
119 ifeq ("$(origin V)", "command line")
120 KBUILD_VERBOSE = $(V)
121 endif
122 endif
123 ifndef KBUILD_VERBOSE
124 KBUILD_VERBOSE = 0
125 endif
127 # Call sparse as part of compilation of C files
128 # Use 'make C=1' to enable sparse checking
130 ifdef C
131 ifeq ("$(origin C)", "command line")
132 KBUILD_CHECKSRC = $(C)
133 endif
134 endif
135 ifndef KBUILD_CHECKSRC
136 KBUILD_CHECKSRC = 0
137 endif
139 # Do not print 'Entering directory ...'
141 MAKEFLAGS += --no-print-directory
143 # For maximum performance (+ possibly random breakage, uncomment
144 # the following)
146 #MAKEFLAGS += -rR
148 # Beautify output
149 # ---------------------------------------------------------------------------
151 # Normally, we echo the whole command before executing it. By making
152 # that echo $($(quiet)$(cmd)), we now have the possibility to set
153 # $(quiet) to choose other forms of output instead, e.g.
155 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
156 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
158 # If $(quiet) is empty, the whole command will be printed.
159 # If it is set to "quiet_", only the short version will be printed.
160 # If it is set to "silent_", nothing wil be printed at all, since
161 # the variable $(silent_cmd_cc_o_c) doesn't exist.
163 # A simple variant is to prefix commands with $(Q) - that's usefull
164 # for commands that shall be hidden in non-verbose mode.
166 # $(Q)ln $@ :<
168 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
169 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
171 ifeq ($(KBUILD_VERBOSE),1)
172 quiet =
174 else
175 quiet=quiet_
176 Q = @
177 endif
179 # If the user is running make -s (silent mode), suppress echoing of
180 # commands
182 ifneq ($(findstring s,$(MAKEFLAGS)),)
183 quiet=silent_
184 endif
186 export quiet Q KBUILD_VERBOSE
188 # Paths to obj / src tree
190 src := .
191 obj := .
192 srctree := .
193 objtree := .
195 export srctree objtree
197 # Make variables (CC, etc...)
199 AS = $(CROSS_COMPILE)as
200 LD = $(CROSS_COMPILE)ld
201 CC = $(CROSS_COMPILE)gcc
202 CPP = $(CC) -E
203 AR = $(CROSS_COMPILE)ar
204 NM = $(CROSS_COMPILE)nm
205 STRIP = $(CROSS_COMPILE)strip
206 OBJCOPY = $(CROSS_COMPILE)objcopy
207 OBJDUMP = $(CROSS_COMPILE)objdump
208 AWK = awk
209 RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
210 else echo rpm; fi)
211 GENKSYMS = scripts/genksyms/genksyms
212 DEPMOD = /sbin/depmod
213 KALLSYMS = scripts/kallsyms
214 PERL = perl
215 CHECK = sparse
216 MODFLAGS = -DMODULE
217 CFLAGS_MODULE = $(MODFLAGS)
218 AFLAGS_MODULE = $(MODFLAGS)
219 LDFLAGS_MODULE = -r
220 CFLAGS_KERNEL =
221 AFLAGS_KERNEL =
223 NOSTDINC_FLAGS = -nostdinc -iwithprefix include
225 CPPFLAGS := -D__KERNEL__ -Iinclude
226 CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
227 -fno-strict-aliasing -fno-common
228 AFLAGS := -D__ASSEMBLY__
230 export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
231 CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
232 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
233 HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK
235 export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
236 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
237 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
239 export MODVERDIR := .tmp_versions
241 # The temporary file to save gcc -MD generated dependencies must not
242 # contain a comma
243 comma := ,
244 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
246 noconfig_targets := xconfig gconfig menuconfig config oldconfig randconfig \
247 defconfig allyesconfig allnoconfig allmodconfig \
248 clean mrproper distclean rpm \
249 help tags TAGS cscope %docs \
250 checkconfig checkhelp checkincludes
252 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
253 RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
255 # Helpers built in scripts/
256 # ---------------------------------------------------------------------------
258 scripts/docproc scripts/fixdep scripts/split-include : scripts ;
260 .PHONY: scripts
261 scripts:
262 $(Q)$(MAKE) $(build)=scripts
264 # Objects we will link into vmlinux / subdirs we need to visit
265 # ---------------------------------------------------------------------------
267 init-y := init/
268 drivers-y := drivers/ sound/
269 net-y := net/
270 libs-y := lib/
271 core-y := usr/
272 SUBDIRS :=
274 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
276 export include_config := 1
278 -include .config
280 endif
282 include arch/$(ARCH)/Makefile
284 # Let architecture Makefiles change CPPFLAGS if needed
285 CFLAGS += $(CPPFLAGS) $(CFLAGS)
286 AFLAGS += $(CPPFLAGS) $(AFLAGS)
288 core-y += kernel/ mm/ fs/ ipc/ security/ crypto/
290 SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
291 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
292 $(net-y) $(net-m) $(libs-y) $(libs-m)))
294 ALL_SUBDIRS := $(sort $(SUBDIRS) $(patsubst %/,%,$(filter %/, \
295 $(init-n) $(init-) \
296 $(core-n) $(core-) $(drivers-n) $(drivers-) \
297 $(net-n) $(net-) $(libs-n) $(libs-))))
299 init-y := $(patsubst %/, %/built-in.o, $(init-y))
300 core-y := $(patsubst %/, %/built-in.o, $(core-y))
301 drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
302 net-y := $(patsubst %/, %/built-in.o, $(net-y))
303 libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
304 libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
305 libs-y := $(libs-y1) $(libs-y2)
307 ifdef include_config
309 # Here goes the main Makefile
310 # ===========================================================================
312 # If the user gave a *config target, it'll be handled in another
313 # section below, since in this case we cannot include .config
314 # Same goes for other targets like clean/mrproper etc, which
315 # don't need .config, either
317 # In this section, we need .config
319 -include .config.cmd
321 ifndef CONFIG_FRAME_POINTER
322 CFLAGS += -fomit-frame-pointer
323 endif
325 ifdef CONFIG_DEBUG_INFO
326 CFLAGS += -g
327 endif
330 # INSTALL_PATH specifies where to place the updated kernel and system map
331 # images. Uncomment if you want to place them anywhere other than root.
334 #export INSTALL_PATH=/boot
337 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
338 # relocations required by build roots. This is not defined in the
339 # makefile but the arguement can be passed to make if needed.
342 MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
343 export MODLIB
345 # Build vmlinux
346 # ---------------------------------------------------------------------------
348 # This is a bit tricky: If we need to relink vmlinux, we want
349 # the version number incremented, which means recompile init/version.o
350 # and relink init/init.o. However, we cannot do this during the
351 # normal descending-into-subdirs phase, since at that time
352 # we cannot yet know if we will need to relink vmlinux.
353 # So we descend into init/ inside the rule for vmlinux again.
354 head-y += $(HEAD)
355 vmlinux-objs := $(head-y) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
357 quiet_cmd_vmlinux__ = LD $@
358 define cmd_vmlinux__
359 $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(head-y) $(init-y) \
360 --start-group \
361 $(core-y) \
362 $(libs-y) \
363 $(drivers-y) \
364 $(net-y) \
365 --end-group \
366 $(filter .tmp_kallsyms%,$^) \
367 -o $@
368 endef
370 # set -e makes the rule exit immediately on error
372 define rule_vmlinux__
373 +set -e; \
374 $(if $(filter .tmp_kallsyms%,$^),, \
375 echo ' GEN .version'; \
376 . $(srctree)/scripts/mkversion > .tmp_version; \
377 mv -f .tmp_version .version; \
378 $(MAKE) $(build)=init; \
380 $(if $($(quiet)cmd_vmlinux__), \
381 echo ' $($(quiet)cmd_vmlinux__)' &&) \
382 $(cmd_vmlinux__); \
383 echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
384 endef
386 define rule_vmlinux
387 $(rule_vmlinux__); \
388 $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
389 endef
391 LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
393 # Generate section listing all symbols and add it into vmlinux
394 # It's a three stage process:
395 # o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
396 # empty
397 # Running kallsyms on that gives us .tmp_kallsyms1.o with
398 # the right size
399 # o .tmp_vmlinux2 now has a __kallsyms section of the right size,
400 # but due to the added section, some addresses have shifted
401 # From here, we generate a correct .tmp_kallsyms2.o
402 # o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
404 ifdef CONFIG_KALLSYMS
406 kallsyms.o := .tmp_kallsyms2.o
408 quiet_cmd_kallsyms = KSYM $@
409 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) > $@
411 .tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
412 $(call if_changed_dep,as_o_S)
414 .tmp_kallsyms%.S: .tmp_vmlinux%
415 $(call cmd,kallsyms)
417 .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE
418 +$(call if_changed_rule,vmlinux__)
420 .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE
421 $(call if_changed_rule,vmlinux__)
423 endif
425 # Finally the vmlinux rule
427 vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/vmlinux.lds.s FORCE
428 $(call if_changed_rule,vmlinux)
430 # The actual objects are generated when descending,
431 # make sure no implicit rule kicks in
433 $(sort $(vmlinux-objs)): $(SUBDIRS) ;
435 # Handle descending into subdirectories listed in $(SUBDIRS)
437 .PHONY: $(SUBDIRS)
438 $(SUBDIRS): prepare
439 $(Q)$(MAKE) $(build)=$@
441 # Things we need done before we descend to build or make
442 # module versions are listed in "prepare"
444 .PHONY: prepare
445 prepare: include/linux/version.h include/asm include/config/MARKER
446 ifdef KBUILD_MODULES
447 ifeq ($(origin SUBDIRS),file)
448 $(Q)rm -rf $(MODVERDIR)
449 else
450 @echo '*** Warning: Overriding SUBDIRS on the command line can cause'
451 @echo '*** inconsistencies'
452 endif
453 endif
454 $(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR))
456 # This can be used by arch/$ARCH/Makefile to preprocess
457 # their vmlinux.lds.S file
459 AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
461 arch/$(ARCH)/vmlinux.lds.s: %.s: %.S scripts FORCE
462 $(call if_changed_dep,as_s_S)
464 targets += arch/$(ARCH)/vmlinux.lds.s
466 # Single targets
467 # ---------------------------------------------------------------------------
469 %.s: %.c scripts FORCE
470 $(Q)$(MAKE) $(build)=$(@D) $@
471 %.i: %.c scripts FORCE
472 $(Q)$(MAKE) $(build)=$(@D) $@
473 %.o: %.c scripts FORCE
474 $(Q)$(MAKE) $(build)=$(@D) $@
475 %/: scripts prepare FORCE
476 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
477 %.lst: %.c scripts FORCE
478 $(Q)$(MAKE) $(build)=$(@D) $@
479 %.s: %.S scripts FORCE
480 $(Q)$(MAKE) $(build)=$(@D) $@
481 %.o: %.S scripts FORCE
482 $(Q)$(MAKE) $(build)=$(@D) $@
484 # FIXME: The asm symlink changes when $(ARCH) changes. That's
485 # hard to detect, but I suppose "make mrproper" is a good idea
486 # before switching between archs anyway.
488 include/asm:
489 @echo ' Making asm->asm-$(ARCH) symlink'
490 @ln -s asm-$(ARCH) $@
492 # Split autoconf.h into include/linux/config/*
494 include/config/MARKER: scripts/split-include include/linux/autoconf.h
495 @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
496 @scripts/split-include include/linux/autoconf.h include/config
497 @touch $@
499 # if .config is newer than include/linux/autoconf.h, someone tinkered
500 # with it and forgot to run make oldconfig
502 include/linux/autoconf.h: .config scripts/fixdep
503 $(Q)$(MAKE) $(build)=scripts/kconfig scripts/kconfig/conf
504 ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
506 # Generate some files
507 # ---------------------------------------------------------------------------
509 # version.h changes when $(KERNELRELEASE) etc change, as defined in
510 # this Makefile
512 uts_len := 64
514 define filechk_version.h
515 if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
516 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
517 exit 1; \
518 fi; \
519 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
520 echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
521 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
523 endef
525 include/linux/version.h: Makefile
526 $(call filechk,version.h)
528 # ---------------------------------------------------------------------------
530 .PHONY: depend dep
531 depend dep:
532 @echo '*** Warning: make $@ is unnecessary now.'
534 # ---------------------------------------------------------------------------
535 # Modules
537 ifdef CONFIG_MODULES
539 # By default, build modules as well
541 all: modules
543 # Build modules
545 .PHONY: modules
546 modules: $(SUBDIRS) $(if $(KBUILD_BUILTIN),vmlinux)
547 @echo ' Building modules, stage 2.';
548 $(Q)$(MAKE) -rR -f scripts/Makefile.modpost
550 # Install modules
552 .PHONY: modules_install
553 modules_install: _modinst_ _modinst_post
555 .PHONY: _modinst_
556 _modinst_:
557 @rm -rf $(MODLIB)/kernel
558 @rm -f $(MODLIB)/build
559 @mkdir -p $(MODLIB)/kernel
560 @ln -s $(TOPDIR) $(MODLIB)/build
561 $(Q)$(MAKE) -rR -f scripts/Makefile.modinst
563 # If System.map exists, run depmod. This deliberately does not have a
564 # dependency on System.map since that would run the dependency tree on
565 # vmlinux. This depmod is only for convenience to give the initial
566 # boot a modules.dep even before / is mounted read-write. However the
567 # boot script depmod is the master version.
568 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
569 depmod_opts :=
570 else
571 depmod_opts := -b $(INSTALL_MOD_PATH) -r
572 endif
573 .PHONY: _modinst_post
574 _modinst_post: _modinst_
575 if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
577 else # CONFIG_MODULES
579 # Modules not configured
580 # ---------------------------------------------------------------------------
582 modules modules_install: FORCE
583 @echo
584 @echo "The present kernel configuration has modules disabled."
585 @echo "Type 'make config' and enable loadable module support."
586 @echo "Then build a kernel with module support enabled."
587 @echo
588 @exit 1
590 endif # CONFIG_MODULES
592 # Generate asm-offsets.h
593 # ---------------------------------------------------------------------------
595 define filechk_gen-asm-offsets
596 (set -e; \
597 echo "#ifndef __ASM_OFFSETS_H__"; \
598 echo "#define __ASM_OFFSETS_H__"; \
599 echo "/*"; \
600 echo " * DO NOT MODIFY."; \
601 echo " *"; \
602 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
603 echo " *"; \
604 echo " */"; \
605 echo ""; \
606 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
607 echo ""; \
608 echo "#endif" )
609 endef
611 else # ifdef include_config
613 ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
615 # Targets which don't need .config
616 # ===========================================================================
618 # These targets basically have their own Makefile - not quite, but at
619 # least its own exclusive section in the same Makefile. The reason for
620 # this is the following:
621 # To know the configuration, the main Makefile has to include
622 # .config. That's a obviously a problem when .config doesn't exist
623 # yet, but that could be kludged around with only including it if it
624 # exists.
625 # However, the larger problem is: If you run make *config, make will
626 # include the old .config, then execute your *config. It will then
627 # notice that a piece it included (.config) did change and restart from
628 # scratch. Which will cause execution of *config again. You get the
629 # picture.
630 # If we don't explicitly let the Makefile know that .config is changed
631 # by *config (the old way), it won't reread .config after *config,
632 # thus working with possibly stale values - we don't that either.
634 # So we divide things: This part here is for making *config targets,
635 # and other targets which should work when no .config exists yet.
636 # The main part above takes care of the rest after a .config exists.
638 # Kernel configuration
639 # ---------------------------------------------------------------------------
641 .PHONY: oldconfig xconfig gconfig menuconfig config \
642 make_with_config rpm
644 scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf scripts/kconfig/gconf: scripts/fixdep FORCE
645 $(Q)$(MAKE) $(build)=scripts/kconfig $@
647 xconfig: scripts/kconfig/qconf
648 ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
650 gconfig: scripts/kconfig/gconf
651 ./scripts/kconfig/gconf arch/$(ARCH)/Kconfig
653 menuconfig: scripts/kconfig/mconf
654 $(Q)$(MAKE) $(build)=scripts/lxdialog
655 ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
657 config: scripts/kconfig/conf
658 ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
660 oldconfig: scripts/kconfig/conf
661 ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
663 randconfig: scripts/kconfig/conf
664 ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
666 allyesconfig: scripts/kconfig/conf
667 ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
669 allnoconfig: scripts/kconfig/conf
670 ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
672 allmodconfig: scripts/kconfig/conf
673 ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
675 defconfig: scripts/kconfig/conf
676 ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
679 # Cleaning is done on three levels.
680 # make clean Delete all automatically generated files, including
681 # tools and firmware.
682 # make mrproper Delete the current configuration, and related files
683 # Any core files spread around are deleted as well
684 # make distclean Remove editor backup files, patch leftover files and the like
686 # Files removed with 'make clean'
687 CLEAN_FILES += vmlinux System.map MC*
689 # Files removed with 'make mrproper'
690 MRPROPER_FILES += \
691 include/linux/autoconf.h include/linux/version.h \
692 .version .config .config.old config.in config.old \
693 .menuconfig.log \
694 include/asm \
695 .hdepend include/linux/modversions.h \
696 tags TAGS cscope kernel.spec \
697 .tmp*
699 # Directories removed with 'make mrproper'
700 MRPROPER_DIRS += \
701 $(MODVERDIR) \
702 .tmp_export-objs \
703 include/config \
704 include/linux/modules
706 # clean - Delete all intermediate files
708 clean-dirs += $(addprefix _clean_,$(ALL_SUBDIRS) Documentation/DocBook scripts)
709 .PHONY: $(clean-dirs) clean archclean mrproper archmrproper distclean
710 $(clean-dirs):
711 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
713 quiet_cmd_rmclean = RM $$(CLEAN_FILES)
714 cmd_rmclean = rm -f $(CLEAN_FILES)
715 clean: archclean $(clean-dirs)
716 $(call cmd,rmclean)
717 @find . $(RCS_FIND_IGNORE) \
718 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
719 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
720 -type f -print | xargs rm -f
722 # mrproper - delete configuration + modules + core files
724 quiet_cmd_mrproper = RM $$(MRPROPER_DIRS) + $$(MRPROPER_FILES)
725 cmd_mrproper = rm -rf $(MRPROPER_DIRS) && rm -f $(MRPROPER_FILES)
726 mrproper distclean: clean archmrproper
727 @echo ' Making $@ in the srctree'
728 @find . $(RCS_FIND_IGNORE) \
729 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
730 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
731 -o -name '.*.rej' -o -size 0 \
732 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
733 -type f -print | xargs rm -f
734 $(call cmd,mrproper)
736 # Generate tags for editors
737 # ---------------------------------------------------------------------------
739 define all-sources
740 ( find . $(RCS_FIND_IGNORE) \
741 \( -name include -o -name arch \) -prune -o \
742 -name '*.[chS]' -print; \
743 find arch/$(ARCH) $(RCS_FIND_IGNORE) \
744 -name '*.[chS]' -print; \
745 find include $(RCS_FIND_IGNORE) \
746 \( -name config -o -name 'asm-*' \) -prune \
747 -o -name '*.[chS]' -print; \
748 find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \
749 -name '*.[chS]' -print; \
750 find include/asm-generic $(RCS_FIND_IGNORE) \
751 -name '*.[chS]' -print )
752 endef
754 quiet_cmd_cscope = MAKE $@
755 cmd_cscope = $(all-sources) | cscope -k -b -i -
757 quiet_cmd_TAGS = MAKE $@
758 cmd_TAGS = $(all-sources) | etags -
760 # Exuberant ctags works better with -I
762 quiet_cmd_tags = MAKE $@
763 define cmd_tags
764 rm -f $@; \
765 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
766 $(all-sources) | xargs ctags $$CTAGSF -a
767 endef
769 cscope: FORCE
770 $(call cmd,cscope)
772 TAGS: FORCE
773 $(call cmd,TAGS)
775 tags: FORCE
776 $(call cmd,tags)
778 # RPM target
779 # ---------------------------------------------------------------------------
781 # If you do a make spec before packing the tarball you can rpm -ta it
783 spec:
784 . $(srctree)/scripts/mkspec >kernel.spec
786 # Build a tar ball, generate an rpm from it and pack the result
787 # There are two bits of magic here
788 # 1) The use of /. to avoid tar packing just the symlink
789 # 2) Removing the .dep files as they have source paths in them that
790 # will become invalid
792 rpm: clean spec
793 find . $(RCS_FIND_IGNORE) \
794 \( -size 0 -o -name .depend -o -name .hdepend \) \
795 -type f -print | xargs rm -f
796 set -e; \
797 cd $(TOPDIR)/.. ; \
798 ln -sf $(TOPDIR) $(KERNELPATH) ; \
799 tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
800 rm $(KERNELPATH) ; \
801 cd $(TOPDIR) ; \
802 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > .tmp_version ; \
803 mv -f .tmp_version .version; \
804 $(RPM) -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \
805 rm $(TOPDIR)/../$(KERNELPATH).tar.gz
807 # Brief documentation of the typical targets used
808 # ---------------------------------------------------------------------------
810 help:
811 @echo 'Cleaning targets:'
812 @echo ' clean - remove most generated files but keep the config'
813 @echo ' mrproper - remove all generated files + config + various backup files'
814 @echo ''
815 @echo 'Configuration targets:'
816 @echo ' oldconfig - Update current config utilising a line-oriented program'
817 @echo ' menuconfig - Update current config utilising a menu based program'
818 @echo ' xconfig - Update current config utilising a QT based front-end'
819 @echo ' gconfig - Update current config utilising a GTK based front-end'
820 @echo ' defconfig - New config with default answer to all options'
821 @echo ' allmodconfig - New config selecting modules when possible'
822 @echo ' allyesconfig - New config where all options are accepted with yes'
823 @echo ' allnoconfig - New minimal config'
824 @echo ''
825 @echo 'Other generic targets:'
826 @echo ' all - Build all targets marked with [*]'
827 @echo '* vmlinux - Build the bare kernel'
828 @echo '* modules - Build all modules'
829 @echo ' modules_install - Install all modules'
830 @echo ' dir/ - Build all files in dir and below'
831 @echo ' dir/file.[ois] - Build specified target only'
832 @echo ' rpm - Build a kernel as an RPM package'
833 @echo ' tags/TAGS - Generate tags file for editors'
834 @echo ''
835 @echo 'Documentation targets:'
836 @$(MAKE) --no-print-directory -f Documentation/DocBook/Makefile dochelp
837 @echo ''
838 @echo 'Architecture specific targets ($(ARCH)):'
839 @$(if $(archhelp),$(archhelp),\
840 echo ' No architecture specific help defined for $(ARCH)')
841 @echo ''
842 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
843 @echo ' make C=1 [targets] Check all c source with checker tool'
844 @echo ''
845 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
846 @echo 'For further info see the ./README file'
849 # Documentation targets
850 # ---------------------------------------------------------------------------
851 %docs: scripts/docproc FORCE
852 $(Q)$(MAKE) $(build)=Documentation/DocBook $@
854 # Scripts to check various things for consistency
855 # ---------------------------------------------------------------------------
857 checkconfig:
858 find * $(RCS_FIND_IGNORE) \
859 -name '*.[hcS]' -type f -print | sort \
860 | xargs $(PERL) -w scripts/checkconfig.pl
862 checkincludes:
863 find * $(RCS_FIND_IGNORE) \
864 -name '*.[hcS]' -type f -print | sort \
865 | xargs $(PERL) -w scripts/checkincludes.pl
867 else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
869 # We're called with both targets which do and do not need
870 # .config included. Handle them one after the other.
871 # ===========================================================================
873 %:: FORCE
874 $(Q)$(MAKE) $@
876 endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
877 endif # ifdef include_config
879 # FIXME Should go into a make.lib or something
880 # ===========================================================================
882 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) $(NOSTDINC_FLAGS) \
883 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
885 quiet_cmd_as_s_S = CPP $@
886 cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
888 quiet_cmd_as_o_S = AS $@
889 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
891 # read all saved command lines
893 targets := $(wildcard $(sort $(targets)))
894 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
896 ifneq ($(cmd_files),)
897 include $(cmd_files)
898 endif
900 # execute the command and also postprocess generated .d dependencies
901 # file
903 if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
904 $(filter-out $(cmd_$(1)),$(cmd_$@))\
905 $(filter-out $(cmd_$@),$(cmd_$(1)))),\
906 @set -e; \
907 $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \
908 $(cmd_$(1)); \
909 scripts/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
910 rm -f $(depfile); \
911 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
913 # Usage: $(call if_changed_rule,foo)
914 # will check if $(cmd_foo) changed, or any of the prequisites changed,
915 # and if so will execute $(rule_foo)
917 if_changed_rule = $(if $(strip $? \
918 $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
919 $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
920 @$(rule_$(1)))
922 # If quiet is set, only print short version of command
924 cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
926 # filechk is used to check if the content of a generated file is updated.
927 # Sample usage:
928 # define filechk_sample
929 # echo $KERNELRELEASE
930 # endef
931 # version.h : Makefile
932 # $(call filechk,sample)
933 # The rule defined shall write to stdout the content of the new file.
934 # The existing file will be compared with the new one.
935 # - If no file exist it is created
936 # - If the content differ the new file is used
937 # - If they are equal no change, and no timestamp update
939 define filechk
940 @set -e; \
941 echo ' CHK $@'; \
942 $(filechk_$(1)) < $< > $@.tmp; \
943 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
944 rm -f $@.tmp; \
945 else \
946 echo ' UPD $@'; \
947 mv -f $@.tmp $@; \
949 endef
951 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir
952 # Usage:
953 # $(Q)$(MAKE) $(build)=dir
954 build := -f scripts/Makefile.build obj
956 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
957 # Usage:
958 # $(Q)$(MAKE) $(clean)=dir
959 clean := -f scripts/Makefile.clean obj
961 # $(call descend,<dir>,<target>)
962 # Recursively call a sub-make in <dir> with target <target>
963 # Usage is deprecated, because make does not see this as an invocation of make.
964 descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)
966 FORCE: