7d2ff24bb6c719f40b0ce12a4a32f2245b916658
[linux-flexiantxendom0-3.2.10.git] / Makefile
1 VERSION = 2
2 PATCHLEVEL = 5
3 SUBLEVEL = 45
4 EXTRAVERSION =
5
6 # *DOCUMENTATION*
7 # To see a list of typical targets execute "make help"
8 # More info can be located in ./Documentation/kbuild
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.
11
12 # We are using a recursive build, so we need to do a little thinking
13 # to get the ordering right.
14 #
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.
22 #
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.
27
28 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
29
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.
35
36 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
37 ARCH := $(SUBARCH)
38
39 KERNELPATH=kernel-$(shell echo $(KERNELRELEASE) | sed -e "s/-//g")
40
41 UTS_MACHINE := $(ARCH)
42
43 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
44           else if [ -x /bin/bash ]; then echo /bin/bash; \
45           else echo sh; fi ; fi)
46 TOPDIR  := $(CURDIR)
47
48 HOSTCC          = gcc
49 HOSTCXX         = g++
50 HOSTCFLAGS      = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
51 HOSTCXXFLAGS    = -O2
52
53 CROSS_COMPILE   =
54
55 #       That's our default target when none is given on the command line
56
57 all:    vmlinux
58
59 #       Decide whether to build built-in, modular, or both.
60 #       Normally, just do built-in.
61
62 KBUILD_MODULES :=
63 KBUILD_BUILTIN := 1
64
65 #       If we have only "make modules", don't compile built-in objects.
66
67 ifeq ($(MAKECMDGOALS),modules)
68   KBUILD_BUILTIN :=
69 endif
70
71 #       If we have "make <whatever> modules", compile modules
72 #       in addition to whatever we do anyway.
73
74 ifneq ($(filter modules,$(MAKECMDGOALS)),)
75   KBUILD_MODULES := 1
76 endif
77
78 #       Just "make" or "make all" shall build modules as well
79
80 ifeq ($(MAKECMDGOALS),)
81   KBUILD_MODULES := 1
82 endif
83
84 ifneq ($(filter all,$(MAKECMDGOALS)),)
85   KBUILD_MODULES := 1
86 endif
87
88 export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
89
90 # Beautify output
91 # ---------------------------------------------------------------------------
92 #
93 # Normally, we echo the whole command before executing it. By making
94 # that echo $($(quiet)$(cmd)), we now have the possibility to set
95 # $(quiet) to choose other forms of output instead, e.g.
96 #
97 #         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
98 #         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
99 #
100 # If $(quiet) is empty, the whole command will be printed.
101 # If it is set to "quiet_", only the short version will be printed. 
102 # If it is set to "silent_", nothing wil be printed at all, since
103 # the variable $(silent_cmd_cc_o_c) doesn't exist.
104
105 #       For now, leave verbose as default
106
107 ifndef KBUILD_VERBOSE
108   KBUILD_VERBOSE = 1
109 endif
110
111 MAKEFLAGS += --no-print-directory
112
113 # For maximum performance (+ possibly random breakage, uncomment
114 # the following)
115
116 #MAKEFLAGS += -rR
117
118 #       If the user wants quiet mode, echo short versions of the commands 
119 #       only
120
121 ifeq ($(KBUILD_VERBOSE),1)
122   quiet =
123   Q =
124 else
125   quiet=quiet_
126   Q = @
127 endif
128
129 #       If the user is running make -s (silent mode), suppress echoing of
130 #       commands
131
132 ifneq ($(findstring s,$(MAKEFLAGS)),)
133   quiet=silent_
134 endif
135
136 export quiet Q KBUILD_VERBOSE
137
138 #       Paths to obj / src tree
139
140 src     := .
141 obj     := .
142 srctree := .
143 objtree := .
144
145 export srctree objtree
146
147 #       Make variables (CC, etc...)
148
149 AS              = $(CROSS_COMPILE)as
150 LD              = $(CROSS_COMPILE)ld
151 CC              = $(CROSS_COMPILE)gcc
152 CPP             = $(CC) -E
153 AR              = $(CROSS_COMPILE)ar
154 NM              = $(CROSS_COMPILE)nm
155 STRIP           = $(CROSS_COMPILE)strip
156 OBJCOPY         = $(CROSS_COMPILE)objcopy
157 OBJDUMP         = $(CROSS_COMPILE)objdump
158 AWK             = awk
159 GENKSYMS        = /sbin/genksyms
160 DEPMOD          = /sbin/depmod
161 KALLSYMS        = /sbin/kallsyms
162 PERL            = perl
163 MODFLAGS        = -DMODULE
164 CFLAGS_MODULE   = $(MODFLAGS)
165 AFLAGS_MODULE   = $(MODFLAGS)
166 CFLAGS_KERNEL   =
167 AFLAGS_KERNEL   =
168 NOSTDINC_FLAGS  = -nostdinc -iwithprefix include
169
170 CPPFLAGS        := -D__KERNEL__ -Iinclude
171 CFLAGS          := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
172                    -fomit-frame-pointer -fno-strict-aliasing -fno-common
173 AFLAGS          := -D__ASSEMBLY__ $(CPPFLAGS)
174
175 export  VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
176         CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
177         CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
178         HOSTCXX HOSTCXXFLAGS
179
180 export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
181 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 
182 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
183
184 # The temporary file to save gcc -MD generated dependencies must not
185 # contain a comma
186 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
187
188 noconfig_targets := xconfig menuconfig config oldconfig randconfig \
189                     defconfig allyesconfig allnoconfig allmodconfig \
190                     clean mrproper distclean \
191                     help tags TAGS sgmldocs psdocs pdfdocs htmldocs \
192                     checkconfig checkhelp checkincludes
193
194 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
195 RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
196
197 # Helpers built in scripts/
198 # ---------------------------------------------------------------------------
199
200 scripts/docproc scripts/fixdep scripts/split-include : scripts ;
201
202 .PHONY: scripts
203 scripts:
204         +@$(Q)$(MAKE) -f scripts/Makefile.build obj=scripts
205
206 # Objects we will link into vmlinux / subdirs we need to visit
207 # ---------------------------------------------------------------------------
208
209 init-y          := init/
210 drivers-y       := drivers/ sound/
211 net-y           := net/
212 libs-y          := lib/
213 core-y          := usr/
214 SUBDIRS         :=
215
216 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
217
218 export include_config := 1
219
220 -include .config
221
222 endif
223
224 include arch/$(ARCH)/Makefile
225
226 core-y          += kernel/ mm/ fs/ ipc/ security/ crypto/
227
228 SUBDIRS         += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
229                      $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
230                      $(net-y) $(net-m) $(libs-y) $(libs-m)))
231
232 ALL_SUBDIRS     := $(sort $(SUBDIRS) $(patsubst %/,%,$(filter %/, \
233                      $(init-n) $(init-) \
234                      $(core-n) $(core-) $(drivers-n) $(drivers-) \
235                      $(net-n)  $(net-)  $(libs-n)    $(libs-))))
236
237 init-y          := $(patsubst %/, %/built-in.o, $(init-y))
238 core-y          := $(patsubst %/, %/built-in.o, $(core-y))
239 drivers-y       := $(patsubst %/, %/built-in.o, $(drivers-y))
240 net-y           := $(patsubst %/, %/built-in.o, $(net-y))
241 libs-y          := $(patsubst %/, %/lib.a, $(libs-y))
242
243 ifdef include_config
244
245 # Here goes the main Makefile
246 # ===========================================================================
247 #
248 # If the user gave a *config target, it'll be handled in another
249 # section below, since in this case we cannot include .config
250 # Same goes for other targets like clean/mrproper etc, which
251 # don't need .config, either
252
253 #       In this section, we need .config
254
255 -include ..config.cmd
256
257 ifdef CONFIG_MODULES
258 export EXPORT_FLAGS := -DEXPORT_SYMTAB
259 endif
260
261 #
262 # INSTALL_PATH specifies where to place the updated kernel and system map
263 # images.  Uncomment if you want to place them anywhere other than root.
264 #
265
266 #export INSTALL_PATH=/boot
267
268 #
269 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
270 # relocations required by build roots.  This is not defined in the
271 # makefile but the arguement can be passed to make if needed.
272 #
273
274 MODLIB  := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
275 export MODLIB
276
277 # Build vmlinux
278 # ---------------------------------------------------------------------------
279
280 #       This is a bit tricky: If we need to relink vmlinux, we want
281 #       the version number incremented, which means recompile init/version.o
282 #       and relink init/init.o. However, we cannot do this during the
283 #       normal descending-into-subdirs phase, since at that time
284 #       we cannot yet know if we will need to relink vmlinux.
285 #       So we descend into init/ inside the rule for vmlinux again.
286
287 vmlinux-objs := $(HEAD) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
288
289 quiet_cmd_vmlinux__ = LD      $@
290 define cmd_vmlinux__
291         $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(init-y) \
292         --start-group \
293         $(core-y) \
294         $(libs-y) \
295         $(drivers-y) \
296         $(net-y) \
297         --end-group \
298         $(filter .tmp_kallsyms%,$^) \
299         -o $@
300 endef
301
302 #       set -e makes the rule exit immediately on error
303
304 define rule_vmlinux__
305         set -e
306         $(if $(filter .tmp_kallsyms%,$^),,
307           echo '  Generating build number'
308           . scripts/mkversion > .tmp_version
309           mv -f .tmp_version .version
310           $(Q)$(MAKE) -f scripts/Makefile.build obj=init
311         )
312         $(call cmd,vmlinux__)
313         echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
314 endef
315
316 define rule_vmlinux
317         $(rule_vmlinux__)
318         $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
319 endef
320
321 LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
322
323 #       Generate section listing all symbols and add it into vmlinux
324 #       It's a three stage process:
325 #       o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
326 #         empty
327 #         Running kallsyms on that gives as .tmp_kallsyms1.o with
328 #         the right size
329 #       o .tmp_vmlinux2 now has a __kallsyms section of the right size,
330 #         but due to the added section, some addresses have shifted
331 #         From here, we generate a correct .tmp_kallsyms2.o
332 #       o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
333
334 ifdef CONFIG_KALLSYMS
335
336 kallsyms.o := .tmp_kallsyms2.o
337
338 quiet_cmd_kallsyms = KSYM    $@
339 cmd_kallsyms = $(KALLSYMS) $< > $@
340
341 .tmp_kallsyms1.o: .tmp_vmlinux1
342         $(call cmd,kallsyms)
343
344 .tmp_kallsyms2.o: .tmp_vmlinux2
345         $(call cmd,kallsyms)
346
347 .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE
348         $(call if_changed_rule,vmlinux__)
349
350 .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE
351         $(call if_changed_rule,vmlinux__)
352
353 endif
354
355 #       Finally the vmlinux rule
356
357 vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/vmlinux.lds.s FORCE
358         $(call if_changed_rule,vmlinux)
359
360 #       The actual objects are generated when descending, 
361 #       make sure no implicit rule kicks in
362
363 $(sort $(vmlinux-objs)): $(SUBDIRS) ;
364
365 #       Handle descending into subdirectories listed in $(SUBDIRS)
366
367 .PHONY: $(SUBDIRS)
368 $(SUBDIRS): .hdepend prepare
369         $(Q)$(MAKE) -f scripts/Makefile.build obj=$@
370
371 #       Things we need done before we descend to build or make
372 #       module versions are listed in "prepare"
373
374 .PHONY: prepare
375 prepare: include/linux/version.h include/asm include/config/MARKER
376         @echo '  Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)'
377
378 #       This can be used by arch/$ARCH/Makefile to preprocess
379 #       their vmlinux.lds.S file
380
381 AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
382
383 arch/$(ARCH)/vmlinux.lds.s: %.s: %.S scripts FORCE
384         $(call if_changed_dep,as_s_S)
385
386 targets += arch/$(ARCH)/vmlinux.lds.s
387
388 # Single targets
389 # ---------------------------------------------------------------------------
390
391 %.s: %.c scripts FORCE
392         $(Q)$(MAKE) -f scripts/Makefile.build obj=$(@D) $@
393 %.i: %.c scripts FORCE
394         $(Q)$(MAKE) -f scripts/Makefile.build obj=$(@D) $@
395 %.o: %.c scripts FORCE
396         $(Q)$(MAKE) -f scripts/Makefile.build obj=$(@D) $@
397 %.lst: %.c scripts FORCE
398         $(Q)$(MAKE) -f scripts/Makefile.build obj=$(@D) $@
399 %.s: %.S scripts FORCE
400         $(Q)$(MAKE) -f scripts/Makefile.build obj=$(@D) $@
401 %.o: %.S scripts FORCE
402         $(Q)$(MAKE) -f scripts/Makefile.build obj=$(@D) $@
403
404 #       FIXME: The asm symlink changes when $(ARCH) changes. That's
405 #       hard to detect, but I suppose "make mrproper" is a good idea
406 #       before switching between archs anyway.
407
408 include/asm:
409         @echo '  Making asm->asm-$(ARCH) symlink'
410         @ln -s asm-$(ARCH) $@
411
412 #       Split autoconf.h into include/linux/config/*
413
414 include/config/MARKER: scripts/split-include include/linux/autoconf.h
415         @echo '  SPLIT  include/linux/autoconf.h -> include/config/*'
416         @scripts/split-include include/linux/autoconf.h include/config
417         @touch $@
418
419 #       if .config is newer than include/linux/autoconf.h, someone tinkered
420 #       with it and forgot to run make oldconfig
421
422 include/linux/autoconf.h: .config
423         +@$(call descend,scripts/kconfig,scripts/kconfig/conf)
424         ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
425
426 # Generate some files
427 # ---------------------------------------------------------------------------
428
429 #       version.h changes when $(KERNELRELEASE) etc change, as defined in
430 #       this Makefile
431
432 uts_len := 64
433
434 include/linux/version.h: Makefile
435         @if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
436           echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
437           exit 1; \
438         fi;
439         @echo -n '  Generating $@'
440         @(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
441           echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
442          echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
443         ) > $@.tmp
444         @$(update-if-changed)
445
446 # Generate module versions
447 # ---------------------------------------------------------------------------
448
449 #       The targets are still named depend / dep for traditional
450 #       reasons, but the only thing we do here is generating
451 #       the module version checksums.
452
453 .PHONY: depend dep $(patsubst %,_sfdep_%,$(SUBDIRS))
454
455 depend dep: .hdepend
456
457 #       .hdepend is our (misnomed) marker for whether we've
458 #       generated module versions
459
460 make-versions := $(strip $(if $(filter dep depend,$(MAKECMDGOALS)),1) \
461                          $(if $(wildcard .hdepend),,1))
462
463 .hdepend: prepare FORCE
464 ifneq ($(make-versions),)
465         @$(MAKE) include/linux/modversions.h
466         @touch $@
467 endif
468
469 ifdef CONFIG_MODVERSIONS
470
471 #       Update modversions.h, but only if it would change.
472
473 .PHONY: __rm_tmp_export-objs
474 __rm_tmp_export-objs: 
475         @rm -rf .tmp_export-objs
476
477 include/linux/modversions.h: $(patsubst %,_modver_%,$(SUBDIRS))
478         @echo -n '  Generating $@'
479         @( echo "#ifndef _LINUX_MODVERSIONS_H";\
480            echo "#define _LINUX_MODVERSIONS_H"; \
481            echo "#include <linux/modsetver.h>"; \
482            cd .tmp_export-objs >/dev/null; \
483            for f in `find modules -name \*.ver -print | sort`; do \
484              echo "#include <linux/$${f}>"; \
485            done; \
486            echo "#endif"; \
487         ) > $@.tmp; \
488         $(update-if-changed)
489
490 .PHONY: $(patsubst %, _modver_%, $(SUBDIRS))
491 $(patsubst %, _modver_%, $(SUBDIRS)): __rm_tmp_export-objs
492         $(Q)$(MAKE) -f scripts/Makefile.modver obj=$(patsubst _modver_%,%,$@)
493
494 else # !CONFIG_MODVERSIONS
495
496 .PHONY: include/linux/modversions.h
497
498 include/linux/modversions.h:
499
500 endif # CONFIG_MODVERSIONS
501
502 # ---------------------------------------------------------------------------
503 # Modules
504
505 ifdef CONFIG_MODULES
506
507 #       Build modules
508
509 ifdef CONFIG_MODVERSIONS
510 MODFLAGS += -include include/linux/modversions.h
511 endif
512
513 .PHONY: modules
514 modules: $(SUBDIRS)
515
516 #       Install modules
517
518 .PHONY: modules_install
519 modules_install: _modinst_ $(patsubst %, _modinst_%, $(SUBDIRS)) _modinst_post
520
521 .PHONY: _modinst_
522 _modinst_:
523         @rm -rf $(MODLIB)/kernel
524         @rm -f $(MODLIB)/build
525         @mkdir -p $(MODLIB)/kernel
526         @ln -s $(TOPDIR) $(MODLIB)/build
527
528 # If System.map exists, run depmod.  This deliberately does not have a
529 # dependency on System.map since that would run the dependency tree on
530 # vmlinux.  This depmod is only for convenience to give the initial
531 # boot a modules.dep even before / is mounted read-write.  However the
532 # boot script depmod is the master version.
533 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
534 depmod_opts     :=
535 else
536 depmod_opts     := -b $(INSTALL_MOD_PATH) -r
537 endif
538 .PHONY: _modinst_post
539 _modinst_post:
540         if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
541
542 .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
543 $(patsubst %, _modinst_%, $(SUBDIRS)) :
544         $(Q)$(MAKE) -f scripts/Makefile.modinst obj=$(patsubst _modinst_%,%,$@)
545 else # CONFIG_MODULES
546
547 # Modules not configured
548 # ---------------------------------------------------------------------------
549
550 modules modules_install: FORCE
551         @echo
552         @echo "The present kernel configuration has modules disabled."
553         @echo "Type 'make config' and enable loadable module support."
554         @echo "Then build a kernel with module support enabled."
555         @echo
556         @exit 1
557
558 endif # CONFIG_MODULES
559
560 # Generate asm-offsets.h 
561 # ---------------------------------------------------------------------------
562
563 define generate-asm-offsets.h
564         (set -e; \
565          echo "#ifndef __ASM_OFFSETS_H__"; \
566          echo "#define __ASM_OFFSETS_H__"; \
567          echo "/*"; \
568          echo " * DO NOT MODIFY."; \
569          echo " *"; \
570          echo " * This file was generated by arch/$(ARCH)/Makefile"; \
571          echo " *"; \
572          echo " */"; \
573          echo ""; \
574          sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
575          echo ""; \
576          echo "#endif" )
577 endef
578
579 # RPM target
580 # ---------------------------------------------------------------------------
581
582 #       If you do a make spec before packing the tarball you can rpm -ta it
583
584 spec:
585         . scripts/mkspec >kernel.spec
586
587 #       Build a tar ball, generate an rpm from it and pack the result
588 #       There arw two bits of magic here
589 #       1) The use of /. to avoid tar packing just the symlink
590 #       2) Removing the .dep files as they have source paths in them that
591 #          will become invalid
592
593 rpm:    clean spec
594         find . $(RCS_FIND_IGNORE) \
595                 \( -size 0 -o -name .depend -o -name .hdepend \) \
596                 -type f -print | xargs rm -f
597         set -e; \
598         cd $(TOPDIR)/.. ; \
599         ln -sf $(TOPDIR) $(KERNELPATH) ; \
600         tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
601         rm $(KERNELPATH) ; \
602         cd $(TOPDIR) ; \
603         . scripts/mkversion > .version ; \
604         rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \
605         rm $(TOPDIR)/../$(KERNELPATH).tar.gz
606
607 else # ifdef include_config
608
609 ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
610
611 # Targets which don't need .config
612 # ===========================================================================
613 #
614 # These targets basically have their own Makefile - not quite, but at
615 # least its own exclusive section in the same Makefile. The reason for
616 # this is the following:
617 # To know the configuration, the main Makefile has to include
618 # .config. That's a obviously a problem when .config doesn't exist
619 # yet, but that could be kludged around with only including it if it
620 # exists.
621 # However, the larger problem is: If you run make *config, make will
622 # include the old .config, then execute your *config. It will then
623 # notice that a piece it included (.config) did change and restart from
624 # scratch. Which will cause execution of *config again. You get the
625 # picture.
626 # If we don't explicitly let the Makefile know that .config is changed
627 # by *config (the old way), it won't reread .config after *config,
628 # thus working with possibly stale values - we don't that either.
629 #
630 # So we divide things: This part here is for making *config targets,
631 # and other targets which should work when no .config exists yet.
632 # The main part above takes care of the rest after a .config exists.
633
634 # Kernel configuration
635 # ---------------------------------------------------------------------------
636
637 .PHONY: oldconfig xconfig menuconfig config \
638         make_with_config
639
640 scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf: scripts/fixdep FORCE
641         +@$(call descend,scripts/kconfig,$@)
642
643 xconfig: scripts/kconfig/qconf
644         ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
645
646 menuconfig: scripts/kconfig/mconf
647         $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts lxdialog
648         ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
649
650 config: scripts/kconfig/conf
651         ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
652
653 oldconfig: scripts/kconfig/conf
654         ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
655
656 randconfig: scripts/kconfig/conf
657         ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
658
659 allyesconfig: scripts/kconfig/conf
660         ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
661
662 allnoconfig: scripts/kconfig/conf
663         ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
664
665 allmodconfig: scripts/kconfig/conf
666         ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
667
668 defconfig: scripts/kconfig/conf
669         ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
670
671 ###
672 # Cleaning is done on three levels.
673 # make clean     Delete all automatically generated files, including
674 #                tools and firmware.
675 # make mrproper  Delete the current configuration, and related files
676 #                Any core files spread around is deleted as well
677 # make distclean Remove editor backup files, patch leftover files and the like
678
679 # Files removed with 'make clean'
680 CLEAN_FILES += vmlinux System.map MC*
681
682 # Files removed with 'make mrproper'
683 MRPROPER_FILES += \
684         include/linux/autoconf.h include/linux/version.h \
685         .version .config .config.old config.in config.old \
686         .menuconfig.log \
687         include/asm \
688         .hdepend include/linux/modversions.h \
689         tags TAGS kernel.spec \
690         .tmp*
691
692 # Directories removed with 'make mrproper'
693 MRPROPER_DIRS += \
694         .tmp_export-objs \
695         include/config \
696         include/linux/modules
697
698 # clean - Delete all intermediate files
699 #
700 clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts
701
702 $(addprefix _clean_,$(clean-dirs)):
703         $(Q)$(MAKE) -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@)
704
705 quiet_cmd_rmclean = RM  $$(CLEAN_FILES)
706 cmd_rmclean       = rm -f $(CLEAN_FILES)
707 clean: archclean $(addprefix _clean_,$(clean-dirs))
708         $(call cmd,rmclean)
709         @find . $(RCS_FIND_IGNORE) \
710                 \( -name '*.[oas]' -o -name '.*.cmd' -o -name '.*.d' \
711                 -o -name '.*.tmp' \) -type f -print | xargs rm -f
712
713 # mrproper - delete configuration + modules + core files
714 #
715 quiet_cmd_mrproper = RM  $$(MRPROPER_DIRS) + $$(MRPROPER_FILES)
716 cmd_mrproper = rm -rf $(MRPROPER_DIRS) && rm -f $(MRPROPER_FILES)
717 mrproper distclean: clean archmrproper
718         @echo '  Making $@ in the srctree'
719         @find . $(RCS_FIND_IGNORE) \
720                 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
721                 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
722                 -o -name '.*.rej' -o -size 0 \
723                 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
724                 -type f -print | xargs rm -f
725         $(call cmd,mrproper)
726
727 # Generate tags for editors
728 # ---------------------------------------------------------------------------
729
730 define all-sources
731         ( find . $(RCS_FIND_IGNORE) \
732                \( -name include -o -name arch \) -prune -o \
733                -name '*.[chS]' -print; \
734           find arch/$(ARCH) $(RCS_FIND_IGNORE) \
735                -name '*.[chS]' -print; \
736           find include $(RCS_FIND_IGNORE) \
737                \( -name config -o -name 'asm-*' \) -prune \
738                -o -name '*.[chS]' -print; \
739           find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \
740                -name '*.[chS]' -print; \
741           find include/asm-generic $(RCS_FIND_IGNORE) \
742                -name '*.[chS]' -print )
743 endef
744
745 quiet_cmd_TAGS = MAKE   $@
746 cmd_TAGS = $(all-sources) | etags -
747
748 #       Exuberant ctags works better with -I
749
750 quiet_cmd_tags = MAKE   $@
751 define cmd_tags
752         rm -f $@; \
753         CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
754         $(all-sources) | xargs ctags $$CTAGSF -a
755 endef
756
757 TAGS: FORCE
758         $(call cmd,TAGS)
759
760 tags: FORCE
761         $(call cmd,tags)
762
763 # Brief documentation of the typical targets used
764 # ---------------------------------------------------------------------------
765
766 help:
767         @echo  'Cleaning targets:'
768         @echo  '  clean         - remove most generated files but keep the config'
769         @echo  '  mrproper      - remove all generated files + config + various backup files'
770         @echo  ''
771         @echo  'Configuration targets:'
772         @echo  '  oldconfig     - Update current config utilising a line-oriented program'
773         @echo  '  menuconfig    - Update current config utilising a menu based program'
774         @echo  '  xconfig       - Update current config utilising a X-based program'
775         @echo  '  defconfig     - New config with default answer to all options'
776         @echo  '  allmodconfig  - New config selecting modules when possible'
777         @echo  '  allyesconfig  - New config where all options are accepted with yes'
778         @echo  '  allnoconfig   - New minimal config'
779         @echo  ''
780         @echo  'Other generic targets:'
781         @echo  '  all           - Build all targets marked with [*]'
782         @echo  '  dep           - Create module version information'
783         @echo  '* vmlinux       - Build the bare kernel'
784         @echo  '* modules       - Build all modules'
785         @echo  '  dir/file.[ois]- Build specified target only'
786         @echo  '  rpm           - Build a kernel as an RPM package'
787         @echo  '  tags/TAGS     - Generate tags file for editors'
788         @echo  ''
789         @echo  'Documentation targets:'
790         @$(MAKE) --no-print-directory -f Documentation/DocBook/Makefile dochelp
791         @echo  ''
792         @echo  'Architecture specific targets ($(ARCH)):'
793         @$(MAKE) --no-print-directory -f arch/$(ARCH)/boot/Makefile archhelp
794         @echo  ''
795         @echo  'Execute "make" or "make all" to build all targets marked with [*] '
796         @echo  'For further info browse Documentation/kbuild/*'
797  
798
799 # Documentation targets
800 # ---------------------------------------------------------------------------
801 sgmldocs psdocs pdfdocs htmldocs: scripts
802         $(Q)$(MAKE) -f scripts/Makefile.build obj=Documentation/DocBook $@
803
804 # Scripts to check various things for consistency
805 # ---------------------------------------------------------------------------
806
807 checkconfig:
808         find * $(RCS_FIND_IGNORE) \
809                 -name '*.[hcS]' -type f -print | sort \
810                 | xargs $(PERL) -w scripts/checkconfig.pl
811
812 checkhelp:
813         find * $(RCS_FIND_IGNORE) \
814                 -name [cC]onfig.in -print | sort \
815                 | xargs $(PERL) -w scripts/checkhelp.pl
816
817 checkincludes:
818         find * $(RCS_FIND_IGNORE) \
819                 -name '*.[hcS]' -type f -print | sort \
820                 | xargs $(PERL) -w scripts/checkincludes.pl
821
822 else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
823
824 # We're called with both targets which do and do not need
825 # .config included. Handle them one after the other.
826 # ===========================================================================
827
828 %:: FORCE
829         $(MAKE) $@
830
831 endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
832 endif # ifdef include_config
833
834 # FIXME Should go into a make.lib or something 
835 # ===========================================================================
836
837 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \
838           $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
839
840 quiet_cmd_as_s_S = CPP     $@
841 cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $< 
842
843 # read all saved command lines
844
845 targets := $(wildcard $(sort $(targets)))
846 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
847
848 ifneq ($(cmd_files),)
849   include $(cmd_files)
850 endif
851
852 # execute the command and also postprocess generated .d dependencies
853 # file
854
855 if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
856                           $(filter-out $(cmd_$(1)),$(cmd_$@))\
857                           $(filter-out $(cmd_$@),$(cmd_$(1)))),\
858         @set -e; \
859         $(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))';) \
860         $(cmd_$(1)); \
861         scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \
862         rm -f $(depfile); \
863         mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
864
865 # Usage: $(call if_changed_rule,foo)
866 # will check if $(cmd_foo) changed, or any of the prequisites changed,
867 # and if so will execute $(rule_foo)
868
869 if_changed_rule = $(if $(strip $? \
870                                $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
871                                $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
872                        @$(rule_$(1)))
873
874 # If quiet is set, only print short version of command
875
876 cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
877
878 define update-if-changed
879         if [ -r $@ ] && cmp -s $@ $@.tmp; then \
880                 echo ' (unchanged)'; \
881                 rm -f $@.tmp; \
882         else \
883                 echo ' (updated)'; \
884                 mv -f $@.tmp $@; \
885         fi
886 endef
887 #       $(call descend,<dir>,<target>)
888 #       Recursively call a sub-make in <dir> with target <target>
889
890 descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)
891
892 FORCE: