VERSION = 2 PATCHLEVEL = 5 SUBLEVEL = 44 EXTRAVERSION =
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) ARCH := $(SUBARCH)
KERNELPATH=kernel-$(shell echo $(KERNELRELEASE) | sed -e "s/-//g")
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi ; fi) TOPDIR := $(CURDIR)
HOSTCC = gcc HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
CROSS_COMPILE =
all: vmlinux
KBUILD_MODULES := KBUILD_BUILTIN := 1
ifeq ($(MAKECMDGOALS),modules)
KBUILD_BUILTIN :=
endif
ifneq ($(filter modules,$(MAKECMDGOALS)),)
KBUILD_MODULES := 1
endif
ifeq ($(MAKECMDGOALS),)
KBUILD_MODULES := 1
endif
ifneq ($(filter all,$(MAKECMDGOALS)),)
KBUILD_MODULES := 1
endif
export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 1
endif
MAKEFLAGS += --no-print-directory
ifneq ($(KBUILD_VERBOSE),1)
quiet=quiet_
endif
ifneq ($(findstring s,$(MAKEFLAGS)),)
quiet=silent_
endif
export quiet KBUILD_VERBOSE
src := . obj := . srctree := . objtree := .
export srctree objtree
AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld CC = $(CROSS_COMPILE)gcc CPP = $(CC) -E AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump MAKEFILES = .config GENKSYMS = /sbin/genksyms DEPMOD = /sbin/depmod KALLSYMS = /sbin/kallsyms PERL = perl MODFLAGS = -DMODULE CFLAGS_MODULE = $(MODFLAGS) AFLAGS_MODULE = $(MODFLAGS) CFLAGS_KERNEL = AFLAGS_KERNEL = NOSTDINC_FLAGS = -nostdinc -iwithprefix include
CPPFLAGS := -D__KERNEL__ -Iinclude CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \ -fomit-frame-pointer -fno-strict-aliasing -fno-common AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL
export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
noconfig_targets := xconfig menuconfig config oldconfig randconfig \ defconfig allyesconfig allnoconfig allmodconfig \ clean mrproper distclean \ help tags TAGS sgmldocs psdocs pdfdocs htmldocs \ checkconfig checkhelp checkincludes
RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
scripts/docproc scripts/fixdep scripts/split-include : scripts ;
.PHONY: scripts scripts: +@$(call descend,scripts,)
init-y := init/ drivers-y := drivers/ sound/ net-y := net/ libs-y := lib/ core-y := SUBDIRS :=
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
include-config := 1
-include .config
endif
include arch/$(ARCH)/Makefile
core-y += kernel/ mm/ fs/ ipc/ security/
SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ $(net-y) $(net-m) $(libs-y) $(libs-m)))
ALL_SUBDIRS := $(SUBDIRS) $(patsubst %/,%,$(filter %/, $(init-n) $(init-) \ $(core-n) $(core-) $(drivers-n) $(drivers-) \ $(net-n) $(net-) $(libs-n) $(libs-)))
init-y := $(patsubst %/, %/built-in.o, $(init-y)) core-y := $(patsubst %/, %/built-in.o, $(core-y)) drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) net-y := $(patsubst %/, %/built-in.o, $(net-y)) libs-y := $(patsubst %/, %/lib.a, $(libs-y))
ifdef include-config
.config: arch/$(ARCH)/config.in # FIXME $(shell find . -name Config.in) @echo '***' @if [ -f $@ ]; then \ echo '*** The tree was updated, so your .config may be'; \ echo '*** out of date!'; \ else \ echo '*** You have not yet configured your kernel!'; \ fi @echo '***' @echo '*** Please run some configurator (e.g. "make oldconfig" or' @echo '*** "make menuconfig" or "make xconfig").' @echo '***' @exit 1
ifdef CONFIG_MODULES export EXPORT_FLAGS := -DEXPORT_SYMTAB endif
MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) export MODLIB
vmlinux-objs := $(HEAD) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
quiet_cmd_vmlinux__ = LD $@ define cmd_vmlinux__ $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(init-y) \ --start-group \ $(core-y) \ $(libs-y) \ $(drivers-y) \ $(net-y) \ --end-group \ $(filter .tmp_kallsyms%,$^) \ -o $@ endef
define rule_vmlinux__ set -e $(if $(filter .tmp_kallsyms%,$^),, echo ' Generating build number' . scripts/mkversion > .tmp_version mv -f .tmp_version .version +$(call descend,init,) ) $(call cmd,vmlinux__) echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd endef
define rule_vmlinux $(rule_vmlinux__) $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map endef
LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
ifdef CONFIG_KALLSYMS
kallsyms.o := .tmp_kallsyms2.o
quiet_cmd_kallsyms = KSYM $@ cmd_kallsyms = $(KALLSYMS) $< > $@
.tmp_kallsyms1.o: .tmp_vmlinux1 $(call cmd,kallsyms)
.tmp_kallsyms2.o: .tmp_vmlinux2 $(call cmd,kallsyms)
.tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE $(call if_changed_rule,vmlinux__)
.tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE $(call if_changed_rule,vmlinux__)
endif
vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/vmlinux.lds.s FORCE $(call if_changed_rule,vmlinux)
$(sort $(vmlinux-objs)): $(SUBDIRS) ;
.PHONY: $(SUBDIRS) $(SUBDIRS): .hdepend prepare +@$(call descend,$@,)
.PHONY: prepare prepare: include/linux/version.h include/asm include/config/MARKER @echo ' Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)'
AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
arch/$(ARCH)/vmlinux.lds.s: %.s: %.S scripts FORCE $(call if_changed_dep,as_s_S)
targets += arch/$(ARCH)/vmlinux.lds.s
%.s: %.c scripts FORCE +@$(call descend,$(@D),$@) %.i: %.c scripts FORCE +@$(call descend,$(@D),$@) %.o: %.c scripts FORCE +@$(call descend,$(@D),$@) %.lst: %.c scripts FORCE +@$(call descend,$(@D),$@) %.s: %.S scripts FORCE +@$(call descend,$(@D),$@) %.o: %.S scripts FORCE +@$(call descend,$(@D),$@)
include/asm: @echo ' Making asm->asm-$(ARCH) symlink' @ln -s asm-$(ARCH) $@
include/config/MARKER: scripts/split-include include/linux/autoconf.h @echo ' SPLIT include/linux/autoconf.h -> include/config/*' @scripts/split-include include/linux/autoconf.h include/config @touch $@
include/linux/autoconf.h: .config @echo '***' @echo '*** You changed .config w/o running make *config?' @echo '*** Please run "make oldconfig"' @echo '***' @exit 1
uts_len := 64
include/linux/version.h: Makefile @if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \ echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ exit 1; \ fi; @echo -n ' Generating $@' @(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \ echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ ) > [email protected] @$(update-if-changed)
.PHONY: depend dep $(patsubst %,_sfdep_%,$(SUBDIRS))
depend dep: .hdepend
make-versions := $(strip $(if $(filter dep depend,$(MAKECMDGOALS)),1) \ $(if $(wildcard .hdepend),,1))
.hdepend: prepare FORCE ifneq ($(make-versions),) @$(MAKE) include/linux/modversions.h @touch $@ endif
ifdef CONFIG_MODVERSIONS
include/linux/modversions.h: FORCE @rm -rf .tmp_export-objs @$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) @echo -n ' Generating $@' @( echo "#ifndef _LINUX_MODVERSIONS_H";\ echo "#define _LINUX_MODVERSIONS_H"; \ echo "#include <linux/modsetver.h>"; \ cd .tmp_export-objs >/dev/null; \ for f in `find modules -name \*.ver -print | sort`; do \ echo "#include <linux/$${f}>"; \ done; \ echo "#endif"; \ ) > [email protected]; \ $(update-if-changed)
$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE +@$(call descend,$(patsubst _sfdep_%,%,$@),fastdep)
else # !CONFIG_MODVERSIONS
.PHONY: include/linux/modversions.h
include/linux/modversions.h:
endif # CONFIG_MODVERSIONS
ifdef CONFIG_MODULES
ifdef CONFIG_MODVERSIONS MODFLAGS += -include include/linux/modversions.h endif
.PHONY: modules modules: $(SUBDIRS)
.PHONY: modules_install modules_install: _modinst_ $(patsubst %, _modinst_%, $(SUBDIRS)) _modinst_post
.PHONY: _modinst_ _modinst_: @rm -rf $(MODLIB)/kernel @rm -f $(MODLIB)/build @mkdir -p $(MODLIB)/kernel @ln -s $(TOPDIR) $(MODLIB)/build
ifeq "$(strip $(INSTALL_MOD_PATH))" "" depmod_opts := else depmod_opts := -b $(INSTALL_MOD_PATH) -r endif .PHONY: _modinst_post _modinst_post: if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
.PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) $(patsubst %, _modinst_%, $(SUBDIRS)) : +@$(call descend,$(patsubst _modinst_%,%,$@),modules_install)
else # CONFIG_MODULES
modules modules_install: FORCE @echo @echo "The present kernel configuration has modules disabled." @echo "Type 'make config' and enable loadable module support." @echo "Then build a kernel with module support enabled." @echo @exit 1
endif # CONFIG_MODULES
define generate-asm-offsets.h (set -e; \ echo "#ifndef __ASM_OFFSETS_H__"; \ echo "#define __ASM_OFFSETS_H__"; \ echo "/*"; \ echo " * DO NOT MODIFY."; \ echo " *"; \ echo " * This file was generated by arch/$(ARCH)/Makefile"; \ echo " *"; \ echo " */"; \ echo ""; \ sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ echo ""; \ echo "#endif" ) endef
spec: . scripts/mkspec >kernel.spec
rpm: clean spec find . $(RCS_FIND_IGNORE) \ \( -size 0 -o -name .depend -o -name .hdepend \) \ -type f -print | xargs rm -f set -e; \ cd $(TOPDIR)/.. ; \ ln -sf $(TOPDIR) $(KERNELPATH) ; \ tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \ rm $(KERNELPATH) ; \ cd $(TOPDIR) ; \ . scripts/mkversion > .version ; \ rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \ rm $(TOPDIR)/../$(KERNELPATH).tar.gz
else # ifdef include-config
ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
.PHONY: oldconfig xconfig menuconfig config \ make_with_config
xconfig: +@$(call descend,scripts,scripts/kconfig.tk) wish -f scripts/kconfig.tk
menuconfig: +@$(call descend,scripts,lxdialog) $(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in
config: $(CONFIG_SHELL) $(src)/scripts/Configure arch/$(ARCH)/config.in
oldconfig: $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in
randconfig: $(CONFIG_SHELL) $(src)/scripts/Configure -r arch/$(ARCH)/config.in
allyesconfig: $(CONFIG_SHELL) $(src)/scripts/Configure -y arch/$(ARCH)/config.in
allnoconfig: $(CONFIG_SHELL) $(src)/scripts/Configure -n arch/$(ARCH)/config.in
allmodconfig: $(CONFIG_SHELL) $(src)/scripts/Configure -m arch/$(ARCH)/config.in
defconfig: yes | $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in
CLEAN_FILES += vmlinux System.map MC*
MRPROPER_FILES += \ include/linux/autoconf.h include/linux/version.h \ .version .config .config.old config.in config.old \ .menuconfig.log \ include/asm \ .hdepend include/linux/modversions.h \ tags TAGS kernel.spec \ .tmp*
MRPROPER_DIRS += \ .tmp_export-objs \ include/config \ include/linux/modules
clean-dirs += $(ALL_SUBDIRS) Documentation/DocBook scripts
$(addprefix _clean_,$(clean-dirs)): $(MAKE) MAKEFILES= -rR -f scripts/Makefile.clean obj=$(patsubst _clean_%,%,$@)
quiet_cmd_rmclean = RM $$(CLEAN_FILES) cmd_rmclean = rm -f $(CLEAN_FILES) clean: archclean $(addprefix _clean_,$(clean-dirs)) $(call cmd,rmclean) @find . $(RCS_FIND_IGNORE) \ \( -name '*.[oas]' -o -name '.*.cmd' -o -name '.*.d' \ -o -name '.*.tmp' \) -type f -print | xargs rm -f
quiet_cmd_mrproper = RM $$(MRPROPER_DIRS) + $$(MRPROPER_FILES) cmd_mrproper = rm -rf $(MRPROPER_DIRS) && rm -f $(MRPROPER_FILES) mrproper distclean: clean archmrproper @echo ' Making $@ in the srctree' @find . $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' -o -size 0 \ -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ -type f -print | xargs rm -f $(call cmd,mrproper)
define all-sources ( find . $(RCS_FIND_IGNORE) \ \( -name include -o -name arch \) -prune -o \ -name '*.[chS]' -print; \ find arch/$(ARCH) $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find include $(RCS_FIND_IGNORE) \ \( -name config -o -name 'asm-*' \) -prune \ -o -name '*.[chS]' -print; \ find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find include/asm-generic $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print ) endef
quiet_cmd_TAGS = MAKE $@ cmd_TAGS = $(all-sources) | etags -
quiet_cmd_tags = MAKE $@ define cmd_tags rm -f $@; \ CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \ $(all-sources) | xargs ctags $$CTAGSF -a endef
TAGS: FORCE $(call cmd,TAGS)
tags: FORCE $(call cmd,tags)
help: @echo 'Cleaning targets:' @echo ' clean - remove most generated files but keep the config' @echo ' mrproper - remove all generated files including the config' @echo ' distclean - mrproper + remove files generated by editors and patch' @echo @echo 'Configuration targets:' @echo ' oldconfig - Update current config utilising a line-oriented program' @echo ' menuconfig - Update current config utilising a menu based program' @echo ' xconfig - Update current config utilising a X-based program' @echo ' defconfig - New config with default answer to all options' @echo ' allmodconfig - New config selecting modules when possible' @echo ' allyesconfig - New config where all options are accepted with yes' @echo ' allnoconfig - New minimal config' @echo @echo 'Other generic targets:' @echo ' all - Build all targets marked with [*]' @echo ' dep - Create module version information' @echo '* vmlinux - Build the bare kernel' @echo '* modules - Build all modules' @echo ' dir/file.[ois]- Build specified target only' @echo ' rpm - Build a kernel as an RPM package' @echo ' tags/TAGS - Generate tags file for editors' @echo @echo 'Documentation targets:' @$(MAKE) --no-print-directory -f Documentation/DocBook/Makefile dochelp @echo @echo 'Architecture specific targets ($(ARCH)):' @$(MAKE) --no-print-directory -f arch/$(ARCH)/boot/Makefile archhelp @echo @echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'For further info browse Documentation/kbuild/*'
sgmldocs psdocs pdfdocs htmldocs: scripts +@$(call descend,Documentation/DocBook,$@)
checkconfig: find * $(RCS_FIND_IGNORE) \ -name '*.[hcS]' -type f -print | sort \ | xargs $(PERL) -w scripts/checkconfig.pl
checkhelp: find * $(RCS_FIND_IGNORE) \ -name [cC]onfig.in -print | sort \ | xargs $(PERL) -w scripts/checkhelp.pl
checkincludes: find * $(RCS_FIND_IGNORE) \ -name '*.[hcS]' -type f -print | sort \ | xargs $(PERL) -w scripts/checkincludes.pl
else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
%:: FORCE $(MAKE) $@
endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) endif # ifdef include-config
echo_target = $@
a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \ $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
quiet_cmd_as_s_S = CPP $(echo_target) cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ifneq ($(cmd_files),)
include $(cmd_files)
endif
if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ $(filter-out $(cmd_$(1)),$(cmd_$@))\ $(filter-out $(cmd_$@),$(cmd_$(1)))),\ @set -e; \ $(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))';) \ $(cmd_$(1)); \ scripts/fixdep $(depfile) $@ '$(cmd_$(1))' > $(@D)/.$(@F).tmp; \ rm -f $(depfile); \ mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
if_changed_rule = $(if $(strip $? \ $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\ $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\ @$(rule_$(1)))
cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
define update-if-changed if [ -r $@ ] && cmp -s $@ [email protected]; then \ echo ' (unchanged)'; \ rm -f [email protected]; \ else \ echo ' (updated)'; \ mv -f [email protected] $@; \ fi endef
ifeq ($(KBUILD_VERBOSE),1) descend = echo '$(MAKE) -f $(1)/Makefile $(2)'; endif descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2)
FORCE: