From fc333b2df388d6e8791b3ee59c0679e4a131555a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 17 Oct 2007 23:30:14 +0200 Subject: kbuild: check asm symlink when building a kernel We often hit the situation where the asm symlink in include/ points to the wrong architecture. In 9 out of 10 cases thats because we forgot to set ARCH but sometimes we just reused the same tree for another ARCH. For the merged x86 tree we need to create a new symlink but this is not obvious. So with the following patch we check if the symlink points to the correct architecture and error out if this is not the case. Signed-off-by: Sam Ravnborg --- Makefile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 529b9048d97e..feca34c26145 100644 --- a/Makefile +++ b/Makefile @@ -903,14 +903,24 @@ prepare: prepare0 export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) -# FIXME: The asm symlink changes when $(ARCH) changes. That's -# hard to detect, but I suppose "make mrproper" is a good idea -# before switching between archs anyway. - -include/asm: - @echo ' SYMLINK $@ -> include/asm-$(SRCARCH)' - $(Q)if [ ! -d include ]; then mkdir -p include; fi; - @ln -fsn asm-$(SRCARCH) $@ +# The asm symlink changes when $(ARCH) changes. +# Detect this and ask user to run make mrproper + +include/asm: FORCE + $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ + if [ -L include/asm ]; then \ + if [ "$$asmlink" != "$(SRCARCH)" ]; then \ + echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ + echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ + exit 1; \ + fi; \ + else \ + echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ + if [ ! -d include ]; then \ + mkdir -p include; \ + fi; \ + ln -fsn asm-$(SRCARCH) $@; \ + fi # Generate some files # --------------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2 From 347d12d727d214f517921d579e1eded2dc082a10 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 18 Oct 2007 13:23:33 +0200 Subject: kbuild: mailing list has moved The old list at sourceforge had a few issues: - it was subscriber-only - it were relying on moderation And I could see several mails did not get to the list lately so I decided this was a good time for a new list. I already requested marc.info to archieve the new list - and I dunno where else the old list was archieved but we ought to update. I have no access to the list of subscribers on the old list so people will have to subscribe manually. How to subscribe: send a mail to: majordomo@vger.kernel.org containing following text: subscribe linux-kbuild See also http://vger.kernel.org/vger-lists.html Signed-off-by: Sam Ravnborg --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 10deabeb3929..f978c60f0d05 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2178,7 +2178,7 @@ S: Maintained KCONFIG P: Roman Zippel M: zippel@linux-m68k.org -L: kbuild-devel@lists.sourceforge.net +L: linux-kbuild@vger.kernel.org S: Maintained KDUMP @@ -2207,6 +2207,7 @@ KERNEL BUILD (kbuild: Makefile, scripts/Makefile.*) P: Sam Ravnborg M: sam@ravnborg.org T: git kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git +L: linux-kbuild@vger.kernel.org S: Maintained KERNEL JANITORS -- cgit v1.2.3-70-g09d2 From 37ab7a269637086d56940c31968f3fb3389b6d68 Mon Sep 17 00:00:00 2001 From: Yinghai Lu Date: Wed, 17 Oct 2007 16:43:39 -0700 Subject: kbuild: cscope - filter out .tmp_* in find_sources remove .tmp_kallsyms*.S in cscope.files Signed-off-by: Yinghai Lu Signed-off-by: Sam Ravnborg --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index feca34c26145..e8ace82e334f 100644 --- a/Makefile +++ b/Makefile @@ -1351,7 +1351,7 @@ define find-sources find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ -name $1 -print; \ find $(__srctree) $(RCS_FIND_IGNORE) \ - \( -name include -o -name arch \) -prune -o \ + \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ -name $1 -print; \ ) endef -- cgit v1.2.3-70-g09d2 From 4b21960f90d4d011e49e386d0525b1e89f320658 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Thu, 11 Oct 2007 16:40:10 -0700 Subject: kbuild: modpost problem when symbols move from one module to another When part of build an external module tree, modpost first reads in the kernel's and then the external tree's Module.symvers files. From these files it establishes a symbol => module mapping. When it later reads in each module built and processes the symbols it finds, it discovers the symbol=>module mapping from Module.symvers and leaves it as it is. The problem comes with a module has been re-named or a symbol has moved from one module to another, since the Module.symvers file was generated. modpost does not update the symbol=>module mapping when it finds the new location of the symbol when scanning the newly built modules. This results in the module containing incorrect dependency information and the new Module.symvers file written by modpost will also contain the incorrect mappings, perpetuating the problem to the next build, and so on. When building the out of kernel development tree for kernel subsystem, like v4l-dvb or ALSA, deleting the external Module.symvers file before building (which the kernel build system doesn't do and shouldn't be necessary anyway), won't fix the problem. modpost still reads the kernel's Module.symvers, and since we a building a kernel subsystem, it will define the same symbols as the external modules. Signed-off-by: Trent Piepho Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2ef9a193fcae..93ac52adb498 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -268,6 +268,9 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, "was in %s%s\n", mod->name, name, s->module->name, is_vmlinux(s->module->name) ?"":".ko"); + } else { + /* In case Modules.symvers was out of date */ + s->module = mod; } } s->preloaded = 0; -- cgit v1.2.3-70-g09d2 From bb13be5145e18cfb3a2f9cc6091aa048d032a3cd Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 9 Oct 2007 01:25:18 -0500 Subject: kbuild: stop docproc segfaulting when SRCTREE isn't set. Prevent docproc from segfaulting when SRCTREE isn't set. Signed-off-by: Rob Landley Acked-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/basic/docproc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index e5c6ac7bde9b..0e4bd5459df4 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c @@ -66,12 +66,15 @@ FILELINE * entity_system; #define FUNCTION "-function" #define NOFUNCTION "-nofunction" +char *srctree; + void usage (void) { fprintf(stderr, "Usage: docproc {doc|depend} file\n"); fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); fprintf(stderr, "doc: frontend when generating kernel documentation\n"); fprintf(stderr, "depend: generate list of files referenced within file\n"); + fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n"); } /* @@ -90,7 +93,7 @@ void exec_kernel_doc(char **svec) exit(1); case 0: memset(real_filename, 0, sizeof(real_filename)); - strncat(real_filename, getenv("SRCTREE"), PATH_MAX); + strncat(real_filename, srctree, PATH_MAX); strncat(real_filename, KERNELDOCPATH KERNELDOC, PATH_MAX - strlen(real_filename)); execvp(real_filename, svec); @@ -171,7 +174,7 @@ void find_export_symbols(char * filename) if (filename_exist(filename) == NULL) { char real_filename[PATH_MAX + 1]; memset(real_filename, 0, sizeof(real_filename)); - strncat(real_filename, getenv("SRCTREE"), PATH_MAX); + strncat(real_filename, srctree, PATH_MAX); strncat(real_filename, filename, PATH_MAX - strlen(real_filename)); sym = add_new_file(filename); @@ -338,6 +341,10 @@ void parse_file(FILE *infile) int main(int argc, char *argv[]) { FILE * infile; + + srctree = getenv("SRCTREE"); + if (!srctree) + srctree = getcwd(NULL, 0); if (argc != 3) { usage(); exit(1); -- cgit v1.2.3-70-g09d2 From e9e40e143cf3eecc76b98f3e89db9d234e14b2be Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 15 Oct 2007 19:23:12 -0500 Subject: kconfig: comment typo in scripts/kconfig/Makefile. Typo in comment in scripts/kconfig/Makefile. Signed-off-by: Rob Landley Signed-off-by: Sam Ravnborg --- scripts/kconfig/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index bb08069b04af..83c5e76414ce 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -84,7 +84,7 @@ help: # lxdialog stuff check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh -# Use reursively expanded variables so we do not call gcc unless +# Use recursively expanded variables so we do not call gcc unless # we really need to do so. (Do not call gcc as part of make mrproper) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) -- cgit v1.2.3-70-g09d2 From 6f67a00498abf8f0b29c2cecfce188c70be309d0 Mon Sep 17 00:00:00 2001 From: "bugme-daemon@bugzilla.kernel.org" Date: Wed, 29 Aug 2007 07:57:41 -0700 Subject: kbuild: make deb-pkg - add 'Provides:' line http://bugzilla.kernel.org/show_bug.cgi?id=8941 Current Debian's kernel-modules depend on matching linux-image-$version, though Linux's make deb-pkg build a .deb that 'Provides: kernel-image-$version' only. The following patch adds the Debian-compliant 'Provides', leaving the default one; hopely this will make way all happy. Signed-off-by: paolo Signed-off-by: Sam Ravnborg --- scripts/package/builddeb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 6edb29f2b4a6..0f657b5f3bc8 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -83,6 +83,7 @@ Maintainer: $name Standards-Version: 3.6.1 Package: $packagename +Provides: kernel-image-$version, linux-image-$version Architecture: any Description: User Mode Linux kernel, version $version User-mode Linux is a port of the Linux kernel to its own system call @@ -104,6 +105,7 @@ Maintainer: $name Standards-Version: 3.6.1 Package: $packagename +Provides: kernel-image-$version, linux-image-$version Architecture: any Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other -- cgit v1.2.3-70-g09d2 From 50a8ec31c3a00594ceb7c5f1dcf2ecdaf6a5b847 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 18 Oct 2007 21:24:21 +0200 Subject: kbuild: disable depmod in cross-compile kernel build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building embedded systems in a cross-compile environment and populating a target's file system image, we don't want to run the depmod on the host as we may be building for a completely different architecture. Since there's no such thing as a cross-depmod, we just disable running depmod in the cross-compile case and we just run depmod on the target at bootup. Inspired by patches from Christian, Armin and Deepak. This solves: http://bugzilla.kernel.org/show_bug.cgi?id=3881 Signed-off-by: Sam Ravnborg Cc: Christian Bjølevik Cc: Deepak Saxena and Cc: Armin Kuster , --- Makefile | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index e8ace82e334f..784903a63e0f 100644 --- a/Makefile +++ b/Makefile @@ -1030,19 +1030,12 @@ _modinst_: fi $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst -# If System.map exists, run depmod. This deliberately does not have a -# dependency on System.map since that would run the dependency tree on -# vmlinux. This depmod is only for convenience to give the initial +# This depmod is only for convenience to give the initial # boot a modules.dep even before / is mounted read-write. However the # boot script depmod is the master version. -ifeq "$(strip $(INSTALL_MOD_PATH))" "" -depmod_opts := -else -depmod_opts := -b $(INSTALL_MOD_PATH) -r -endif PHONY += _modinst_post _modinst_post: _modinst_ - if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi + $(call cmd,depmod) else # CONFIG_MODULES @@ -1259,15 +1252,6 @@ _emodinst_: $(Q)mkdir -p $(MODLIB)/$(install-dir) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst -# Run depmod only is we have System.map and depmod is executable -quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) - cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \ - $(DEPMOD) -ae -F System.map \ - $(if $(strip $(INSTALL_MOD_PATH)), \ - -b $(INSTALL_MOD_PATH) -r) \ - $(KERNELRELEASE); \ - fi - PHONY += _emodinst_post _emodinst_post: _emodinst_ $(call cmd,depmod) @@ -1516,6 +1500,16 @@ quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) cmd_rmfiles = rm -f $(rm-files) +# Run depmod only is we have System.map and depmod is executable +# and we build for the host arch +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = \ + if [ -r System.map -a -x $(DEPMOD) -a "$(SUBARCH)" == "$(ARCH)" ]; then \ + $(DEPMOD) -ae -F System.map \ + $(if $(strip $(INSTALL_MOD_PATH)), -b $(INSTALL_MOD_PATH) -r) \ + $(KERNELRELEASE); \ + fi + a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ -- cgit v1.2.3-70-g09d2 From 910b40468a9ce3f2f5d48c5d260329c27d45adb5 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 19 Oct 2007 21:46:01 +0200 Subject: kbuild: introduce cc-cross-prefix cc-cross-prefix is useful for the architecture that like to provide a default CROSS_COMPILE value, but may have several to select between. Sample usage: ifneq ($(SUBARCH),$(ARCH)) ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) endif endif Actual usage by the different archs will taken care of later. Signed-off-by: Sam Ravnborg --- Documentation/kbuild/makefiles.txt | 22 ++++++++++++++++++++++ scripts/Kbuild.include | 11 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index f099b814d383..6166e2d7da76 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -518,6 +518,28 @@ more details, with real examples. In this example for a specific GCC version the build will error out explaining to the user why it stops. + cc-cross-prefix + cc-cross-prefix is used to check if there exist a $(CC) in path with + one of the listed prefixes. The first prefix where there exist a + prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found + then nothing is returned. + Additional prefixes are separated by a single space in the + call of cc-cross-prefix. + This functionality is usefull for architecture Makefile that try + to set CROSS_COMPILE to well know values but may have several + values to select between. + It is recommended only to try to set CROSS_COMPILE is it is a cross + build (host arch is different from target arch). And is CROSS_COMPILE + is already set then leave it with the old value. + + Example: + #arch/m68k/Makefile + ifneq ($(SUBARCH),$(ARCH)) + ifeq ($(CROSS_COMPILE),) + CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-) + endif + endif + === 4 Host Program support Kbuild supports building executables on the host for use during the diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index de7bb284c611..b96ea8d6a5ed 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -56,6 +56,17 @@ endef # gcc support functions # See documentation in Documentation/kbuild/makefiles.txt +# cc-cross-prefix +# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) +# Return first prefix where a prefix$(CC) is found in PATH. +# If no $(CC) found in PATH with listed prefixes return nothing +cc-cross-prefix = \ + $(word 1, $(foreach c,$(1), \ + $(shell set -e; \ + if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ + echo $(c); \ + fi))) + # output directory for tests below TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) -- cgit v1.2.3-70-g09d2 From 6e66b9005dfc9e0bc6785d734745a4bf8f85f16b Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 19 Oct 2007 10:53:48 -0700 Subject: kconfig: update kconfig-language text Add kconfig-language docs for mainmenu, def_bool, and def_tristate. Remove "requires" as a synonym of "depends on" since it was removed from the parser in commit 247537b9a270b52cc0375adcb0fb2605a160cba5. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- Documentation/kbuild/kconfig-language.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index fe8b0c4892cf..616043a6da99 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -77,7 +77,12 @@ applicable everywhere (see syntax). Optionally, dependencies only for this default value can be added with "if". -- dependencies: "depends on"/"requires" +- type definition + default value: + "def_bool"/"def_tristate" ["if" ] + This is a shorthand notation for a type definition plus a value. + Optionally dependencies for this default value can be added with "if". + +- dependencies: "depends on" This defines a dependency for this menu entry. If multiple dependencies are defined, they are connected with '&&'. Dependencies are applied to all other options within this menu entry (which also @@ -289,3 +294,10 @@ source: "source" This reads the specified configuration file. This file is always parsed. + +mainmenu: + + "mainmenu" + +This sets the config program's title bar if the config program chooses +to use it. -- cgit v1.2.3-70-g09d2 From 7bb9d092de0b21f8f3f0a20dc2ec84395549fb62 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 19 Oct 2007 22:20:02 +0200 Subject: kbuild: fix first module build When building a specific module before doing a total kernel build it failed because $(MORVERDIR) were missing. Creating the MODVERDIR explicit (independent of KBUILD_MODULES) fixed this. As a side-effect the MODVERDIR will be created also for a non-module build - but no harm done by that. Signed-off-by: Sam Ravnborg --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 784903a63e0f..6d7527cee9fa 100644 --- a/Makefile +++ b/Makefile @@ -884,10 +884,7 @@ prepare2: prepare3 outputmakefile prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \ include/asm include/config/auto.conf -ifneq ($(KBUILD_MODULES),) - $(Q)mkdir -p $(MODVERDIR) - $(Q)rm -f $(MODVERDIR)/* -endif + $(cmd_crmodverdir) archprepare: prepare1 scripts_basic @@ -1223,8 +1220,7 @@ else # KBUILD_EXTMOD KBUILD_MODULES := 1 PHONY += crmodverdir crmodverdir: - $(Q)mkdir -p $(MODVERDIR) - $(Q)rm -f $(MODVERDIR)/* + $(cmd_crmodverdir) PHONY += $(objtree)/Module.symvers $(objtree)/Module.symvers: @@ -1484,9 +1480,11 @@ endif # Modules / %/: prepare scripts FORCE + $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir) %.ko: prepare scripts FORCE + $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir) $(@:.ko=.o) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost @@ -1510,6 +1508,9 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) $(KERNELRELEASE); \ fi +# Create temporary dir for module support files +cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR); rm -f $(MODVERDIR)/* + a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ -- cgit v1.2.3-70-g09d2