Commit efe775ab authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://linux-sam.bkbits.net/kbuild

into home.osdl.org:/home/torvalds/v2.5/linux
parents 1c20618e 9bb8df1d
...@@ -4,3 +4,5 @@ kconfig-language.txt ...@@ -4,3 +4,5 @@ kconfig-language.txt
- specification of Config Language, the language in Kconfig files - specification of Config Language, the language in Kconfig files
makefiles.txt makefiles.txt
- developer information for linux kernel makefiles - developer information for linux kernel makefiles
modules.txt
- how to build modules and to install them
For now this is a raw copy from the old Documentation/modules.txt,
which was removed in 2.6.0-test5.
The information herein is correct but not complete.
Installing modules in a non-standard location
---------------------------------------------
When the modules needs to be installed under another directory
the INSTALL_MOD_PATH can be used to prefix "/lib/modules" as seen
in the following example:
make INSTALL_MOD_PATH=/frodo modules_install
This will install the modules in the directory /frodo/lib/modules.
/frodo can be a NFS mounted filesystem on another machine, allowing
out-of-the-box support for installation on remote machines.
Compiling modules outside the official kernel
---------------------------------------------
Often modules are developed outside the official kernel.
To keep up with changes in the build system the most portable way
to compile a module outside the kernel is to use the following command-line:
make -C path/to/kernel/src SUBDIRS=$PWD modules
This requires that a makefile exits made in accordance to
Documentation/kbuild/makefiles.txt.
...@@ -9,6 +9,9 @@ EXTRAVERSION = -test5 ...@@ -9,6 +9,9 @@ EXTRAVERSION = -test5
# Comments in this file are targeted only to the developer, do not # Comments in this file are targeted only to the developer, do not
# expect to learn how to build the kernel reading this file. # expect to learn how to build the kernel reading this file.
# Do not print "Entering directory ..."
MAKEFLAGS += --no-print-directory
# We are using a recursive build, so we need to do a little thinking # We are using a recursive build, so we need to do a little thinking
# to get the ordering right. # to get the ordering right.
# #
...@@ -25,6 +28,87 @@ EXTRAVERSION = -test5 ...@@ -25,6 +28,87 @@ EXTRAVERSION = -test5
# descending is started. They are now explicitly listed as the # descending is started. They are now explicitly listed as the
# prepare rule. # prepare rule.
# To put more focus on warnings, be less verbose as default
# Use 'make V=1' to see the full commands
ifdef V
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
# Call sparse as part of compilation of C files
# Use 'make C=1' to enable sparse checking
ifdef C
ifeq ("$(origin C)", "command line")
KBUILD_CHECKSRC = $(C)
endif
endif
ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
endif
# kbuild supports saving output files in a separate directory.
# To locate output files in a separate directory two syntax'es are supported.
# In both cases the working directory must be the root of the kernel src.
# 1) O=
# Use "make O=dir/to/store/output/files/"
#
# 2) Set KBUILD_OUTPUT
# Set the environment variable KBUILD_OUTPUT to point to the directory
# where the output files shall be placed.
# export KBUILD_OUTPUT=dir/to/store/output/files/
# make
#
# The O= assigment takes precedence over the KBUILD_OUTPUT environment variable.
# KBUILD_SRC is set on invocation of make in OBJ directory
# KBUILD_SRC is not intended to be used by the regular user (for now)
ifeq ($(KBUILD_SRC),)
# OK, Make called in directory where kernel src resides
# Do we want to locate output files in a separate directory?
ifdef O
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif
endif
ifneq ($(KBUILD_OUTPUT),)
# Invoke a second make in the output directory, passing relevant variables
KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT); /bin/pwd)
.PHONY: $(MAKECMDGOALS) all
$(MAKECMDGOALS) all:
$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
KBUILD_SRC=$(CURDIR) KBUILD_VERBOSE=$(KBUILD_VERBOSE) \
KBUILD_CHECK=$(KBUILD_CHECK) -f $(CURDIR)/Makefile $(MAKECMDGOALS)
# Leave processing to above invocation of make
skip-makefile := 1
endif # ifneq ($(KBUILD_OUTPUT),)
endif # ifeq ($(KBUILD_SRC),)
# We process the rest of the Makefile if this is the final invocation of make
ifeq ($(skip-makefile),)
srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
TOPDIR := $(srctree)
# FIXME - TOPDIR is obsolete, use srctree/objtree
objtree := $(CURDIR)
src := $(srctree)
obj := $(objtree)
VPATH := $(srctree)
export srctree objtree VPATH TOPDIR
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
# SUBARCH tells the usermode build what the underlying arch is. That is set # SUBARCH tells the usermode build what the underlying arch is. That is set
...@@ -37,9 +121,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ ...@@ -37,9 +121,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ ) -e s/s390x/s390/ -e s/parisc64/parisc/ )
# Remove hyphens since they have special meaning in RPM filenames
KERNELPATH=kernel-$(subst -,,$(KERNELRELEASE))
# Cross compiling and selecting different set of gcc/bin-utils # Cross compiling and selecting different set of gcc/bin-utils
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
...@@ -69,7 +150,6 @@ UTS_MACHINE := $(ARCH) ...@@ -69,7 +150,6 @@ UTS_MACHINE := $(ARCH)
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \ else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi) else echo sh; fi ; fi)
TOPDIR := $(CURDIR)
HOSTCC = gcc HOSTCC = gcc
HOSTCXX = g++ HOSTCXX = g++
...@@ -110,40 +190,8 @@ ifeq ($(MAKECMDGOALS),) ...@@ -110,40 +190,8 @@ ifeq ($(MAKECMDGOALS),)
KBUILD_MODULES := 1 KBUILD_MODULES := 1
endif endif
export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE KBUILD_CHECKSRC export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
export KBUILD_CHECKSRC KBUILD_SRC
# To put more focus on warnings, less verbose as default
# Use 'make V=1' to see the full commands
ifdef V
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
# Call sparse as part of compilation of C files
# Use 'make C=1' to enable sparse checking
ifdef C
ifeq ("$(origin C)", "command line")
KBUILD_CHECKSRC = $(C)
endif
endif
ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
endif
# Do not print 'Entering directory ...'
MAKEFLAGS += --no-print-directory
# For maximum performance (+ possibly random breakage, uncomment
# the following)
#MAKEFLAGS += -rR
# Beautify output # Beautify output
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -185,14 +233,13 @@ endif ...@@ -185,14 +233,13 @@ endif
export quiet Q KBUILD_VERBOSE export quiet Q KBUILD_VERBOSE
# Paths to obj / src tree # Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree)
src := . # For maximum performance (+ possibly random breakage, uncomment
obj := . # the following)
srctree := .
objtree := .
export srctree objtree #MAKEFLAGS += -rR
# Make variables (CC, etc...) # Make variables (CC, etc...)
...@@ -222,13 +269,15 @@ AFLAGS_KERNEL = ...@@ -222,13 +269,15 @@ AFLAGS_KERNEL =
NOSTDINC_FLAGS = -nostdinc -iwithprefix include NOSTDINC_FLAGS = -nostdinc -iwithprefix include
CPPFLAGS := -D__KERNEL__ -Iinclude CPPFLAGS := -D__KERNEL__ -Iinclude \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include)
CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \ CFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
-fno-strict-aliasing -fno-common -fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__ AFLAGS := -D__ASSEMBLY__
export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK
...@@ -253,12 +302,15 @@ RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CV ...@@ -253,12 +302,15 @@ RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CV
# Helpers built in scripts/ # Helpers built in scripts/
scripts/docproc scripts/fixdep scripts/split-include : scripts ; scripts/docproc scripts/split-include : scripts ;
.PHONY: scripts .PHONY: scripts scripts/fixdep
scripts: scripts:
$(Q)$(MAKE) $(build)=scripts $(Q)$(MAKE) $(build)=scripts
scripts/fixdep:
$(Q)$(MAKE) $(build)=scripts $@
# To make sure we do not include .config for any of the *config targets # To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile # catch them early, and hand them over to scripts/kconfig/Makefile
...@@ -294,7 +346,7 @@ ifeq ($(mixed-targets),1) ...@@ -294,7 +346,7 @@ ifeq ($(mixed-targets),1)
# Handle them one by one. # Handle them one by one.
%:: FORCE %:: FORCE
$(Q)$(MAKE) $@ $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
else else
ifeq ($(config-targets),1) ifeq ($(config-targets),1)
...@@ -336,12 +388,12 @@ include .config ...@@ -336,12 +388,12 @@ include .config
# If .config is newer than include/linux/autoconf.h, someone tinkered # If .config is newer than include/linux/autoconf.h, someone tinkered
# with it and forgot to run make oldconfig # with it and forgot to run make oldconfig
include/linux/autoconf.h: scripts/fixdep .config include/linux/autoconf.h: .config
$(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
endif endif
include arch/$(ARCH)/Makefile include $(srctree)/arch/$(ARCH)/Makefile
# Let architecture Makefiles change CPPFLAGS if needed # Let architecture Makefiles change CPPFLAGS if needed
CFLAGS := $(CPPFLAGS) $(CFLAGS) CFLAGS := $(CPPFLAGS) $(CFLAGS)
...@@ -487,14 +539,34 @@ $(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds.s: $(SUBDIRS) ; ...@@ -487,14 +539,34 @@ $(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds.s: $(SUBDIRS) ;
# Handle descending into subdirectories listed in $(SUBDIRS) # Handle descending into subdirectories listed in $(SUBDIRS)
.PHONY: $(SUBDIRS) .PHONY: $(SUBDIRS)
$(SUBDIRS): prepare $(SUBDIRS): prepare-all
$(Q)$(MAKE) $(build)=$@ $(Q)$(MAKE) $(build)=$@
# Things we need done before we descend to build or make # Things we need to do before we recursively start building the kernel
# module versions are listed in "prepare" # or the modules are listed in "prepare-all".
# A multi level approach is used. prepare1 is updated first, then prepare0.
# prepare-all is the collection point for the prepare targets.
.PHONY: prepare-all prepare prepare0 prepare1
# prepare1 is used to check if we are building in a separate output directory,
# and if so do:
# 1) Check that make has not been executed in the kernel src $(srctree)
# 2) Create the include2 directory, used for the second asm symlink
prepare1:
ifneq ($(KBUILD_SRC),)
@echo ' Using $(srctree) as source for kernel'
$(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
echo " $(srctree) is not clean, please run 'make mrproper'";\
echo " in the '$(srctree)' directory.";\
/bin/false; \
fi;
$(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
$(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
endif
.PHONY: prepare prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
prepare: include/linux/version.h include/asm include/config/MARKER
ifdef KBUILD_MODULES ifdef KBUILD_MODULES
ifeq ($(origin SUBDIRS),file) ifeq ($(origin SUBDIRS),file)
$(Q)rm -rf $(MODVERDIR) $(Q)rm -rf $(MODVERDIR)
...@@ -505,6 +577,9 @@ endif ...@@ -505,6 +577,9 @@ endif
endif endif
$(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR)) $(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR))
# All the preparing..
prepare-all: prepare0 prepare
# Leave this as default for preprocessing vmlinux.lds.S, which is now # Leave this as default for preprocessing vmlinux.lds.S, which is now
# done in arch/$(ARCH)/kernel/Makefile # done in arch/$(ARCH)/kernel/Makefile
...@@ -533,8 +608,9 @@ export AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH) ...@@ -533,8 +608,9 @@ export AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
# before switching between archs anyway. # before switching between archs anyway.
include/asm: include/asm:
@echo ' Making asm->asm-$(ARCH) symlink' @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
@ln -s asm-$(ARCH) $@ $(Q)if [ ! -d include ]; then mkdir -p include; fi;
@ln -fsn asm-$(ARCH) $@
# Split autoconf.h into include/linux/config/* # Split autoconf.h into include/linux/config/*
...@@ -585,7 +661,7 @@ all: modules ...@@ -585,7 +661,7 @@ all: modules
.PHONY: modules .PHONY: modules
modules: $(SUBDIRS) $(if $(KBUILD_BUILTIN),vmlinux) modules: $(SUBDIRS) $(if $(KBUILD_BUILTIN),vmlinux)
@echo ' Building modules, stage 2.'; @echo ' Building modules, stage 2.';
$(Q)$(MAKE) -rR -f scripts/Makefile.modpost $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
# Install modules # Install modules
...@@ -603,7 +679,7 @@ _modinst_: ...@@ -603,7 +679,7 @@ _modinst_:
@rm -f $(MODLIB)/build @rm -f $(MODLIB)/build
@mkdir -p $(MODLIB)/kernel @mkdir -p $(MODLIB)/kernel
@ln -s $(TOPDIR) $(MODLIB)/build @ln -s $(TOPDIR) $(MODLIB)/build
$(Q)$(MAKE) -rR -f scripts/Makefile.modinst $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
# If System.map exists, run depmod. This deliberately does not have a # If System.map exists, run depmod. This deliberately does not have a
# dependency on System.map since that would run the dependency tree on # dependency on System.map since that would run the dependency tree on
...@@ -672,7 +748,7 @@ MRPROPER_FILES += \ ...@@ -672,7 +748,7 @@ MRPROPER_FILES += \
.menuconfig.log \ .menuconfig.log \
include/asm \ include/asm \
.hdepend include/linux/modversions.h \ .hdepend include/linux/modversions.h \
tags TAGS cscope kernel.spec \ tags TAGS cscope.out kernel.spec \
.tmp* .tmp*
# Directories removed with 'make mrproper' # Directories removed with 'make mrproper'
...@@ -680,7 +756,8 @@ MRPROPER_DIRS += \ ...@@ -680,7 +756,8 @@ MRPROPER_DIRS += \
$(MODVERDIR) \ $(MODVERDIR) \
.tmp_export-objs \ .tmp_export-objs \
include/config \ include/config \
include/linux/modules include/linux/modules \
include2
# clean - Delete all intermediate files # clean - Delete all intermediate files
# #
...@@ -759,31 +836,32 @@ tags: FORCE ...@@ -759,31 +836,32 @@ tags: FORCE
.PHONY: rpm .PHONY: rpm
# Remove hyphens since they have special meaning in RPM filenames
KERNELPATH=kernel-$(subst -,,$(KERNELRELEASE))
# If you do a make spec before packing the tarball you can rpm -ta it # If you do a make spec before packing the tarball you can rpm -ta it
spec: spec:
. $(srctree)/scripts/mkspec >kernel.spec $(CONFIG_SHELL) $(srctree)/scripts/mkspec > $(objtree)/kernel.spec
# Build a tar ball, generate an rpm from it and pack the result # a) Build a tar ball
# There are two bits of magic here # b) generate an rpm from it
# 1) The use of /. to avoid tar packing just the symlink # c) and pack the result
# 2) Removing the .dep files as they have source paths in them that # - Use /. to avoid tar packing just the symlink
# will become invalid
rpm: clean spec rpm: clean spec
find . $(RCS_FIND_IGNORE) \
\( -size 0 -o -name .depend -o -name .hdepend \) \
-type f -print | xargs rm -f
set -e; \ set -e; \
cd $(TOPDIR)/.. ; \ cd .. ; \
ln -sf $(TOPDIR) $(KERNELPATH) ; \ ln -sf $(srctree) $(KERNELPATH) ; \
tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \ tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
rm $(KERNELPATH) ; \ rm $(KERNELPATH)
cd $(TOPDIR) ; \
$(CONFIG_SHELL) $(srctree)/scripts/mkversion > .tmp_version ; \ set -e; \
mv -f .tmp_version .version; \ $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version;\
$(RPM) -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \ mv -f $(objtree)/.tmp_version $(objtree)/.version;
rm $(TOPDIR)/../$(KERNELPATH).tar.gz
$(RPM) -ta ../$(KERNELPATH).tar.gz
rm ../$(KERNELPATH).tar.gz
# Brief documentation of the typical targets used # Brief documentation of the typical targets used
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -814,6 +892,7 @@ help: ...@@ -814,6 +892,7 @@ help:
echo ' No architecture specific help defined for $(ARCH)') echo ' No architecture specific help defined for $(ARCH)')
@echo '' @echo ''
@echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
@echo ' make O=dir [targets] Locate all output files in "dir", including .config'
@echo ' make C=1 [targets] Check all c source with checker tool' @echo ' make C=1 [targets] Check all c source with checker tool'
@echo '' @echo ''
@echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'Execute "make" or "make all" to build all targets marked with [*] '
...@@ -849,7 +928,8 @@ endif #ifeq ($(mixed-targets),1) ...@@ -849,7 +928,8 @@ endif #ifeq ($(mixed-targets),1)
# FIXME Should go into a make.lib or something # FIXME Should go into a make.lib or something
# =========================================================================== # ===========================================================================
a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) $(NOSTDINC_FLAGS) \ a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
$(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
quiet_cmd_as_o_S = AS $@ quiet_cmd_as_o_S = AS $@
...@@ -907,6 +987,7 @@ cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) ...@@ -907,6 +987,7 @@ cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
define filechk define filechk
@set -e; \ @set -e; \
echo ' CHK $@'; \ echo ' CHK $@'; \
mkdir -p $(dir $@); \
$(filechk_$(1)) < $< > $@.tmp; \ $(filechk_$(1)) < $< > $@.tmp; \
if [ -r $@ ] && cmp -s $@ $@.tmp; then \ if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \ rm -f $@.tmp; \
...@@ -919,16 +1000,18 @@ endef ...@@ -919,16 +1000,18 @@ endef
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir
# Usage: # Usage:
# $(Q)$(MAKE) $(build)=dir # $(Q)$(MAKE) $(build)=dir
build := -f scripts/Makefile.build obj build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
# Usage: # Usage:
# $(Q)$(MAKE) $(clean)=dir # $(Q)$(MAKE) $(clean)=dir
clean := -f scripts/Makefile.clean obj clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
# $(call descend,<dir>,<target>) # $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target> # Recursively call a sub-make in <dir> with target <target>
# Usage is deprecated, because make does not see this as an invocation of make. # Usage is deprecated, because make does not see this as an invocation of make.
descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
endif # skip-makefile
FORCE: FORCE:
...@@ -108,11 +108,26 @@ SOFTWARE REQUIREMENTS ...@@ -108,11 +108,26 @@ SOFTWARE REQUIREMENTS
you can just update packages when obvious problems arise during you can just update packages when obvious problems arise during
build or operation. build or operation.
CONFIGURING the kernel: BUILD directory for the kernel:
When compiling the kernel all output files will per default be
stored together with the kernel source code.
Using the option "make O=output/dir" allow you to specify an alternate
place for the output files (including .config).
Example:
kernel source code: /usr/src/linux-2.6.N
build directory: /home/name/build/kernel
To configure and build the kernel use:
cd /usr/src/linux-2.6.N
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel install_modules install
- Do a "make config" to configure the basic kernel. "make config" needs Please note: If the 'O=output/dir' option is used then it must be
bash to work: it will search for bash in $BASH, /bin/bash and /bin/sh used for all invocations of make.
(in that order), so one of those must be correct for it to work.
CONFIGURING the kernel:
Do not skip this step even if you are only upgrading one minor Do not skip this step even if you are only upgrading one minor
version. New configuration options are added in each release, and version. New configuration options are added in each release, and
......
...@@ -99,4 +99,4 @@ zlilo: $(BOOTIMAGE) ...@@ -99,4 +99,4 @@ zlilo: $(BOOTIMAGE)
if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
install: $(BOOTIMAGE) install: $(BOOTIMAGE)
sh $(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
...@@ -58,10 +58,6 @@ bzImage: zImage ...@@ -58,10 +58,6 @@ bzImage: zImage
$(BOOT_TARGETS): vmlinux $(BOOT_TARGETS): vmlinux
$(Q)$(MAKE) $(build)=arch/ppc/boot $@ $(Q)$(MAKE) $(build)=arch/ppc/boot $@
%_config: arch/ppc/configs/%_defconfig
rm -f .config arch/ppc/defconfig
cp -f arch/ppc/configs/$(@:config=defconfig) .config
archclean: archclean:
$(Q)$(MAKE) $(clean)=arch/ppc/boot $(Q)$(MAKE) $(clean)=arch/ppc/boot
......
...@@ -41,10 +41,6 @@ boottarget-$(CONFIG_PPC_ISERIES) := vmlinux.sminitrd vmlinux.initrd vmlinux.sm ...@@ -41,10 +41,6 @@ boottarget-$(CONFIG_PPC_ISERIES) := vmlinux.sminitrd vmlinux.initrd vmlinux.sm
$(boottarget-y): vmlinux $(boottarget-y): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
%_config: arch/ppc64/configs/%_defconfig
rm -f .config arch/ppc64/defconfig
cp -f arch/ppc64/configs/$(@:config=defconfig) arch/ppc64/defconfig
bootimage-$(CONFIG_PPC_PSERIES) := zImage bootimage-$(CONFIG_PPC_PSERIES) := zImage
bootimage-$(CONFIG_PPC_ISERIES) := vmlinux.sm bootimage-$(CONFIG_PPC_ISERIES) := vmlinux.sm
BOOTIMAGE := $(bootimage-y) BOOTIMAGE := $(bootimage-y)
......
...@@ -14,6 +14,16 @@ include $(obj)/Makefile ...@@ -14,6 +14,16 @@ include $(obj)/Makefile
include scripts/Makefile.lib include scripts/Makefile.lib
ifneq ($(KBUILD_SRC),)
# Create output directory if not already present
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
# Create directories for object files if directory does not exist
# Needed when obj-y := dir/file.o syntax is used
_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
endif
ifdef EXTRA_TARGETS ifdef EXTRA_TARGETS
$(warning kbuild: $(obj)/Makefile - Usage of EXTRA_TARGETS is obsolete in 2.5. Please fix!) $(warning kbuild: $(obj)/Makefile - Usage of EXTRA_TARGETS is obsolete in 2.5. Please fix!)
endif endif
......
...@@ -63,4 +63,4 @@ cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) ...@@ -63,4 +63,4 @@ cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
# Usage: # Usage:
# $(Q)$(MAKE) $(clean)=dir # $(Q)$(MAKE) $(clean)=dir
clean := -f scripts/Makefile.clean obj clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
...@@ -58,6 +58,11 @@ multi-objs := $(multi-objs-y) $(multi-objs-m) ...@@ -58,6 +58,11 @@ multi-objs := $(multi-objs-y) $(multi-objs-m)
# in the local directory # in the local directory
subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
# $(obj-dirs) is a list of directories that contain object files
obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
obj-dirs += $(foreach f,$(host-progs), $(if $(dir $(f)),$(dir $(f))))
obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs))))
# Replace multi-part objects by their individual parts, look at local dir only # Replace multi-part objects by their individual parts, look at local dir only
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
...@@ -107,6 +112,7 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) ...@@ -107,6 +112,7 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
host-progs := $(addprefix $(obj)/,$(host-progs)) host-progs := $(addprefix $(obj)/,$(host-progs))
host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-csingle := $(addprefix $(obj)/,$(host-csingle))
host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
...@@ -129,15 +135,46 @@ depfile = $(subst $(comma),_,$(@D)/.$(@F).d) ...@@ -129,15 +135,46 @@ depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
# where foo and bar are the name of the modules. # where foo and bar are the name of the modules.
basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F)))
modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname)))) modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname))))
c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
$(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
$(basename_flags) $(modname_flags) _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS)\ _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
$(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) _hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o)
hostc_flags = -Wp,-MD,$(depfile) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS)\ _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o)
$(HOSTCFLAGS_$(*F).o)
hostcxx_flags = -Wp,-MD,$(depfile) $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS)\
$(HOSTCXXFLAGS_$(*F).o) # If building the kernel in a separate objtree expand all occurrences
# of -Idir to -Idir -I$(srctree)/dir.
# hereby allowing gcc to locate files in both trees. Local tree first.
ifeq ($(KBUILD_SRC),)
__c_flags = $(_c_flags)
__a_flags = $(_a_flags)
__hostc_flags = $(_hostc_flags)
__hostcxx_flags = $(_hostcxx_flags)
else
flags = $(foreach o,$($(1)),\
$(if $(filter -I%,$(o)),$(patsubst -I%,-I$(srctree)/%,$(o)),$(o)))
# -I$(obj) locate generated .h files
# -I$(srctree)/$(src) locate .h files in srctree, from generated .c files
# FIXME: Replace both with specific EXTRA_CFLAGS statements
__c_flags = -I$(obj) -I$(srctree)/$(src) $(call flags,_c_flags)
__a_flags = $(call flags,_a_flags)
__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
__hostcxx_flags = $(call flags,_hostcxx_flags)
endif
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(__c_flags) $(modkern_cflags) \
$(basename_flags) $(modname_flags)
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(__a_flags) $(modkern_aflags)
hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS) ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS)
# Finds the multi-part object the current object will be linked into # Finds the multi-part object the current object will be linked into
...@@ -225,14 +262,14 @@ if_changed_rule = $(if $(strip $? \ ...@@ -225,14 +262,14 @@ if_changed_rule = $(if $(strip $? \
# If quiet is set, only print short version of command # If quiet is set, only print short version of command
cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) cmd = @$(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
# $(call descend,<dir>,<target>) # $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target> # Recursively call a sub-make in <dir> with target <target>
# Usage is deprecated, because make do not see this as an invocation of make. # Usage is deprecated, because make do not see this as an invocation of make.
descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2) descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
# Usage: # Usage:
# $(Q)$(MAKE) $(build)=dir # $(Q)$(MAKE) $(build)=dir
build := -f scripts/Makefile.build obj build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
...@@ -35,7 +35,7 @@ targets += $(modules) ...@@ -35,7 +35,7 @@ targets += $(modules)
# Compile version info for unresolved symbols # Compile version info for unresolved symbols
quiet_cmd_cc_o_c = CC $@ quiet_cmd_cc_o_c = CC $@
cmd_cc_o_c = $(CC) -Wp,-MD,$(depfile) $(CFLAGS) $(CFLAGS_MODULE) \ cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
-c -o $@ $< -c -o $@ $<
$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
......
...@@ -40,6 +40,9 @@ allmodconfig: $(obj)/conf ...@@ -40,6 +40,9 @@ allmodconfig: $(obj)/conf
defconfig: $(obj)/conf defconfig: $(obj)/conf
$< -d arch/$(ARCH)/Kconfig $< -d arch/$(ARCH)/Kconfig
%_defconfig: $(obj)/conf
$(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig
# Help text used by make help # Help text used by make help
help: help:
@echo ' oldconfig - Update current config utilising a line-oriented program' @echo ' oldconfig - Update current config utilising a line-oriented program'
......
...@@ -26,6 +26,7 @@ enum { ...@@ -26,6 +26,7 @@ enum {
set_no, set_no,
set_random set_random
} input_mode = ask_all; } input_mode = ask_all;
char *defconfig_file;
static int indent = 1; static int indent = 1;
static int valid_stdin = 1; static int valid_stdin = 1;
...@@ -483,11 +484,12 @@ static void check_conf(struct menu *menu) ...@@ -483,11 +484,12 @@ static void check_conf(struct menu *menu)
int main(int ac, char **av) int main(int ac, char **av)
{ {
int i = 1;
const char *name; const char *name;
struct stat tmpstat; struct stat tmpstat;
if (ac > 1 && av[1][0] == '-') { if (ac > i && av[i][0] == '-') {
switch (av[1][1]) { switch (av[i++][1]) {
case 'o': case 'o':
input_mode = ask_new; input_mode = ask_new;
break; break;
...@@ -498,6 +500,15 @@ int main(int ac, char **av) ...@@ -498,6 +500,15 @@ int main(int ac, char **av)
case 'd': case 'd':
input_mode = set_default; input_mode = set_default;
break; break;
case 'D':
input_mode = set_default;
defconfig_file = av[i++];
if (!defconfig_file) {
printf("%s: No default config file specified\n",
av[0]);
exit(1);
}
break;
case 'n': case 'n':
input_mode = set_no; input_mode = set_no;
break; break;
...@@ -516,18 +527,21 @@ int main(int ac, char **av) ...@@ -516,18 +527,21 @@ int main(int ac, char **av)
printf("%s [-o|-s] config\n", av[0]); printf("%s [-o|-s] config\n", av[0]);
exit(0); exit(0);
} }
name = av[2]; }
} else name = av[i];
name = av[1]; if (!name) {
printf("%s: Kconfig file missing\n", av[0]);
}
conf_parse(name); conf_parse(name);
//zconfdump(stdout); //zconfdump(stdout);
switch (input_mode) { switch (input_mode) {
case set_default: case set_default:
name = conf_get_default_confname(); if (!defconfig_file)
if (conf_read(name)) { defconfig_file = conf_get_default_confname();
if (conf_read(defconfig_file)) {
printf("***\n" printf("***\n"
"*** Can't find default configuration \"%s\"!\n" "*** Can't find default configuration \"%s\"!\n"
"***\n", name); "***\n", defconfig_file);
exit(1); exit(1);
} }
break; break;
......
...@@ -27,7 +27,7 @@ echo "Summary: The Linux Kernel" ...@@ -27,7 +27,7 @@ echo "Summary: The Linux Kernel"
echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//g" echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//g"
# we need to determine the NEXT version number so that uname and # we need to determine the NEXT version number so that uname and
# rpm -q will agree # rpm -q will agree
echo "Release: `. scripts/mkversion`" echo "Release: `. $srctree/scripts/mkversion`"
echo "License: GPL" echo "License: GPL"
echo "Group: System Environment/Kernel" echo "Group: System Environment/Kernel"
echo "Vendor: The Linux Community" echo "Vendor: The Linux Community"
...@@ -45,7 +45,7 @@ echo "%prep" ...@@ -45,7 +45,7 @@ echo "%prep"
echo "%setup -q" echo "%setup -q"
echo "" echo ""
echo "%build" echo "%build"
echo "make clean oldconfig all" echo "make clean all"
echo "" echo ""
echo "%install" echo "%install"
echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules' echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment