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