From 1d3fa84da087f3ca352a3f8a8c39b7c7ec14f68d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 8 Aug 2004 01:35:44 +0200 Subject: kbuild: Check for undefined symbols in vmlinux At least one bin-utils version for ARM is know to ignore undefined symbols when performing the final link of vmlinux. Add an explicit check for undefined symbols to catch this. The check is made in combination with generating the System.map file and the actual algorithm is moved to a small shell script - mksysmap. External symbols with three leading underscores are ignored - sparc uses them for the BTFIXUP logic. Signed-off-by: Sam Ravnborg --- scripts/mksysmap | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 scripts/mksysmap (limited to 'scripts') diff --git a/scripts/mksysmap b/scripts/mksysmap new file mode 100644 index 000000000000..0915b9ecc2bb --- /dev/null +++ b/scripts/mksysmap @@ -0,0 +1,54 @@ +#!/bin/sh -x +# Based on the vmlinux file create the System.map file +# System.map is used by module-init tools and some debugging +# tools to retreive the actual addresses of symbols in the kernel. +# +# Before creating the System.map file as a sideeffect check for +# undefined symbols. +# At least one version of the ARM bin-utils did not error out on +# undefined symbols, so catch them here instead. + +# Usage +# mksysmap vmlinux System.map + + +##### +# Check for undefined symbols. +# Undefined symbols with three leading underscores are ignored since +# they are used by the sparc BTFIXUP logic - and is assumed to be undefined. + + +if [ "`$NM -u $1 | grep -v ' ____'`" != "" ]; then + echo "$1: error: undefined symbol(s) found:" + $NM -u $1 | grep -v ' ___' + exit 1 +fi + +##### +# Generate System.map (actual filename passed as second argument) + +# $NM produces the following output: +# f0081e80 T alloc_vfsmnt + +# The second row specify the type of the symbol: +# A = Absolute +# B = Uninitialised data (.bss) +# C = Comon symbol +# D = Initialised data +# G = Initialised data for small objects +# I = Indirect reference to another symbol +# N = Debugging symbol +# R = Read only +# S = Uninitialised data for small objects +# T = Text code symbol +# U = Undefined symbol +# V = Weak symbol +# W = Weak symbol +# Corresponding small letters are local symbols + +# For System.map filter away: +# a - local absolute symbols +# U - undefined global symbols +# w - local weak symbols + +nm $1 | grep -v ' [aUw] ' > $2 -- cgit v1.2.3 From a66dcfe10a7a3cc5541f1906b6c3d72ae7a941d1 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 8 Aug 2004 13:34:43 +0200 Subject: kbuild/sparc: Use new generic mksysmap script to generate System.map o Introduced usage of the mksysmap script. o Improved the non-verbose output to look like this: BTFIX arch/sparc/boot/btfix.S AS arch/sparc/boot/btfix.o LD arch/sparc/boot/image SYSMAP arch/sparc/boot/System.map o No longer generate System.map for each build o Use normal AS rule to compile btfix.S Signed-off-by: Sam Ravnborg --- arch/sparc/boot/Makefile | 40 ++++++++++++++++++++++++++++++++-------- scripts/mksysmap | 2 +- 2 files changed, 33 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile index b19cc8689c37..d62e32d39675 100644 --- a/arch/sparc/boot/Makefile +++ b/arch/sparc/boot/Makefile @@ -8,27 +8,51 @@ ROOT_IMG := /usr/src/root.img ELFTOAOUT := elftoaout host-progs := piggyback btfixupprep -targets := tftpboot.img btfix.o btfix.s image +targets := tftpboot.img btfix.o btfix.S image quiet_cmd_elftoaout = ELFTOAOUT $@ cmd_elftoaout = $(ELFTOAOUT) $(obj)/image -o $@ -quiet_cmd_piggy = PIGGY $@ +quiet_cmd_piggy = PIGGY $@ cmd_piggy = $(obj)/piggyback $@ $(obj)/System.map $(ROOT_IMG) -quiet_cmd_btfix = BTFIX $@ +quiet_cmd_btfix = BTFIX $@ cmd_btfix = $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@ +quiet_cmd_sysmap = SYSMAP $(obj)/System.map + cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap +quiet_cmd_image = LD $@ + cmd_image = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) -o $@ + +define rule_image + $(if $($(quiet)cmd_image), \ + echo ' $($(quiet)cmd_image)' &&) \ + $(cmd_image); \ + $(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap)' &&) \ + $(cmd_sysmap) $@ $(obj)/System.map; \ + if [ $$? -ne 0 ]; then \ + rm -f $@; \ + /bin/false; \ + fi; \ + echo 'cmd_$@ := $(cmd_image)' > $(@D)/.$(@F).cmd +endef BTOBJS := $(HEAD_Y) $(INIT_Y) BTLIBS := $(CORE_Y) $(LIBS_Y) $(DRIVERS_Y) $(NET_Y) -LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group $(kallsyms.o) +LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds.s $(BTOBJS) \ + --start-group $(BTLIBS) --end-group \ + $(kallsyms.o) $(obj)/btfix.o -# Actual linking +# Link the final image including btfixup'ed symbols. +# This is a replacement for the link done in the top-level Makefile. +# Note: No dependency on the prerequisite files since that would require +# make to try check if they are updated - and due to changes +# in gcc options (path for example) this would result in +# these files being recompiled for each build. $(obj)/image: $(obj)/btfix.o FORCE - $(call if_changed,ld) - $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > $(obj)/System.map + $(call if_changed_rule,image) $(obj)/tftpboot.img: $(obj)/piggyback $(obj)/System.map $(obj)/image FORCE $(call if_changed,elftoaout) $(call if_changed,piggy) -$(obj)/btfix.s: $(obj)/btfixupprep vmlinux FORCE +$(obj)/btfix.S: $(obj)/btfixupprep vmlinux FORCE $(call if_changed,btfix) diff --git a/scripts/mksysmap b/scripts/mksysmap index 0915b9ecc2bb..bb0fbef3db2b 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -18,7 +18,7 @@ # they are used by the sparc BTFIXUP logic - and is assumed to be undefined. -if [ "`$NM -u $1 | grep -v ' ____'`" != "" ]; then +if [ "`$NM -u $1 | grep -v ' ___'`" != "" ]; then echo "$1: error: undefined symbol(s) found:" $NM -u $1 | grep -v ' ___' exit 1 -- cgit v1.2.3 From 048646ac6a6c1c6bba1a6355c958017e4b24c62c Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 8 Aug 2004 20:29:57 +0200 Subject: kconfig: save kernel version in .config file Save kernel version info and date when writing .config file. Tested with 'make {menuconfig|xconfig|gconfig}'. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/kconfig/confdata.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 90247d2e88ce..7b6285e7c8f9 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define LKC_DIRECT_LINK @@ -268,6 +269,7 @@ int conf_write(const char *name) char dirname[128], tmpname[128], newname[128]; int type, l; const char *str; + time_t now; dirname[0] = 0; if (name && name[0]) { @@ -301,14 +303,25 @@ int conf_write(const char *name) if (!out_h) return 1; } + sym = sym_lookup("KERNELRELEASE", 0); + sym_calc_value(sym); + time(&now); fprintf(out, "#\n" "# Automatically generated make config: don't edit\n" - "#\n"); + "# Linux kernel version: %s\n" + "# %s" + "#\n", + sym_get_string_value(sym), + ctime(&now)); if (out_h) fprintf(out_h, "/*\n" " * Automatically generated C config: don't edit\n" + " * Linux kernel version: %s\n" + " * %s" " */\n" - "#define AUTOCONF_INCLUDED\n"); + "#define AUTOCONF_INCLUDED\n", + sym_get_string_value(sym), + ctime(&now)); if (!sym_change_count) sym_clear_all_valid(); -- cgit v1.2.3 From 64fc2d35e0007be88f7ee1e3fb6fece74ec8bde1 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 9 Aug 2004 01:01:05 +0200 Subject: kbuild: Selective compile of targets in scripts/ Do not build executables unless needed. Same goes for scripts/mod/, descend only when CONFIG_MODULES are enabled. With inputs form: Russell King and Brian Gerst Signed-off-by: Sam Ravnborg --- Makefile | 2 +- scripts/Makefile | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 8006683febad..aef2e1e6f26c 100644 --- a/Makefile +++ b/Makefile @@ -584,7 +584,7 @@ cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) $(foreach x,$(CONFIG_KALLSYMS_ALL),--al .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE $(call if_changed_dep,as_o_S) -.tmp_kallsyms%.S: .tmp_vmlinux% +.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) $(call cmd,kallsyms) .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE diff --git a/scripts/Makefile b/scripts/Makefile index 81c913c1ee3f..ae375b1ff20c 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -2,14 +2,22 @@ # scripts contains sources for various helper programs used throughout # the kernel for the build process. # --------------------------------------------------------------------------- -# docproc: Preprocess .tmpl file in order to generate .sgml docs +# kallsyms: Find all symbols in vmlinux +# pnmttologo: Convert pnm files to logo files +# conmakehash: Create chartable # conmakehash: Create arrays for initializing the kernel console tables -host-progs := conmakehash kallsyms pnmtologo bin2c +hostprogs-$(CONFIG_KALLSYMS) += kallsyms +hostprogs-$(CONFIG_LOGO) += pnmtologo +hostprogs-$(CONFIG_VT) += conmakehash +hostprogs-$(CONFIG_PROM_CONSOLE) += conmakehash +hostprogs-$(CONFIG_IKCONFIG) += bin2c + +host-progs := $(sort $(hostprogs-y)) always := $(host-progs) -subdir-$(CONFIG_MODVERSIONS) += genksyms -subdir-y += mod +subdir-$(CONFIG_MODVERSIONS) += genksyms +subdir-$(CONFIG_MODULES) += mod # Let clean descend into subdirs subdir- += basic lxdialog kconfig package -- cgit v1.2.3 From 94869f86021d8d3e785e2222d151fb4b98d2ae2a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 10 Aug 2004 00:01:02 +0200 Subject: kbuild: Accept absolute paths in clean-files and introduce clean-dirs Teach kbuild to accept absolute paths in clean-files. This avoids using clean-rules in several places. Introduced clean-dirs to delete complete directories. Kept clean-rule - but do not print anything when used. Cleaned up a few places now the infrastructure are improved. Signed-off-by: Sam Ravnborg --- Documentation/DocBook/Makefile | 4 +--- Documentation/kbuild/makefiles.txt | 13 +++++++++++-- scripts/Makefile.clean | 30 ++++++++++++++++++++++-------- scripts/package/Makefile | 6 +++--- 4 files changed, 37 insertions(+), 16 deletions(-) (limited to 'scripts') diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index bf212c0211c9..9a23eab001d4 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -185,9 +185,7 @@ clean-files := $(DOCBOOKS) \ $(patsubst %.sgml, %.9, $(DOCBOOKS)) \ $(C-procfs-example) -ifneq ($(wildcard $(patsubst %.html,%,$(HTML))),) -clean-rule := rm -rf $(wildcard $(patsubst %.html,%,$(HTML))) -endif +clean-dirs := $(patsubst %.sgml,%,$(DOCBOOKS)) #man put files in man subdir - traverse down subdir- := man/ diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index ec817761629d..008228af6ec1 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -547,8 +547,17 @@ Additional files can be specified in kbuild makefiles by use of $(clean-files). clean-files := devlist.h classlist.h When executing "make clean", the two files "devlist.h classlist.h" will -be deleted. Kbuild knows that files specified by $(clean-files) are -located in the same directory as the makefile. +be deleted. Kbuild will assume files to be in same relative directory as the +Makefile except if an absolute path is specified (path starting with '/'). + +To delete a directory hirachy use: + Example: + #scripts/package/Makefile + clean-dirs := $(objtree)/debian/ + +This will delete the directory debian, including all subdirectories. +Kbuild will assume the directories to be in the same relative path as the +Makefile if no absolute path is specified (path does not start with '/'). Usually kbuild descends down in subdirectories due to "obj-* := dir/", but in the architecture makefiles where the kbuild infrastructure diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 7277dd208ead..1daba0623151 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -29,21 +29,35 @@ subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) # Add subdir path subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) -__clean-files := $(wildcard $(addprefix $(obj)/, \ - $(extra-y) $(EXTRA_TARGETS) $(always) $(host-progs) \ - $(targets) $(clean-files))) +__clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) $(host-progs) \ + $(targets) $(clean-files) +__clean-files := $(wildcard \ + $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \ + $(filter /%, $(__clean-files))) +__clean-dirs := $(wildcard \ + $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \ + $(filter /%, $(clean-dirs))) # ========================================================================== -quiet_cmd_clean = CLEAN $(obj) - cmd_clean = rm -f $(__clean-files); $(clean-rule) +quiet_cmd_clean = CLEAN $(obj) + cmd_clean = rm -f $(__clean-files) +quiet_cmd_cleandir = CLEAN $(__clean-dirs) + cmd_cleandir = rm -rf $(__clean-dirs) + __clean: $(subdir-ymn) -ifneq ($(strip $(__clean-files) $(clean-rule)),) +ifneq ($(strip $(__clean-files)),) +$(call cmd,clean) -else - @: endif +ifneq ($(strip $(__clean-dirs)),) + +$(call cmd,cleandir) +endif +ifneq ($(strip $(clean-rule)),) + +$(clean-rule) +endif + @: + # =========================================================================== # Generic stuff diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 48f89e17a3cf..3b1f2eff2584 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -51,7 +51,7 @@ rpm-pkg rpm: $(objtree)/kernel.spec $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz rm ../$(KERNELPATH).tar.gz -clean-rule += rm -f $(objtree)/kernel.spec +clean-files := $(objtree)/kernel.spec # binrpm-pkg .PHONY: binrpm-pkg @@ -67,7 +67,7 @@ binrpm-pkg: $(objtree)/binkernel.spec $(RPM) --define "_builddir $(srctree)" --target $(UTS_MACHINE) -bb $< -clean-rule += rm -f $(objtree)/binkernel.spec +clean-files += $(objtree)/binkernel.spec # Deb target # --------------------------------------------------------------------------- @@ -77,7 +77,7 @@ deb-pkg: $(MAKE) $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb -clean-rule += && rm -rf $(objtree)/debian/ +clean-dirs += $(objtree)/debian/ # Help text displayed when executing 'make help' -- cgit v1.2.3 From 9c1bfb5fc7a096f137476b2a6787d7e00b02d777 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 11 Aug 2004 00:09:55 +0200 Subject: kbuild: Separate out host-progs handling Concentrating all host-progs functionality in one file made a more readable Makefile.lib - and allow for potential reuse of host-progs functionality. Processing of host-progs related stuff are avoided when no host-progs are specified. Signed-off-by: Sam Ravnborg --- scripts/Makefile.build | 89 ++--------------------------- scripts/Makefile.host | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.lib | 49 ---------------- 3 files changed, 157 insertions(+), 133 deletions(-) create mode 100644 scripts/Makefile.host (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 008ac6cfd405..458bedea2e7b 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -14,6 +14,11 @@ include $(obj)/Makefile include scripts/Makefile.lib +# Do not include host-progs rules unles needed +ifdef host-progs +include scripts/Makefile.host +endif + ifneq ($(KBUILD_SRC),) # Create output directory if not already present _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) @@ -275,90 +280,6 @@ $(multi-used-m) : %.o: $(multi-objs-m) FORCE targets += $(multi-used-y) $(multi-used-m) -# Compile programs on the host -# =========================================================================== -# host-progs := bin2hex -# Will compile bin2hex.c and create an executable named bin2hex -# -# host-progs := lxdialog -# lxdialog-objs := checklist.o lxdialog.o -# Will compile lxdialog.c and checklist.c, and then link the executable -# lxdialog, based on checklist.o and lxdialog.o -# -# host-progs := qconf -# qconf-cxxobjs := qconf.o -# qconf-objs := menu.o -# Will compile qconf as a C++ program, and menu as a C program. -# They are linked as C++ code to the executable qconf - -# host-progs := conf -# conf-objs := conf.o libkconfig.so -# libkconfig-objs := expr.o type.o -# Will create a shared library named libkconfig.so that consist of -# expr.o and type.o (they are both compiled as C code and the object file -# are made as position independent code). -# conf.c is compiled as a c program, and conf.o is linked together with -# libkconfig.so as the executable conf. -# Note: Shared libraries consisting of C++ files are not supported -# - -# Create executable from a single .c file -# host-csingle -> Executable -quiet_cmd_host-csingle = HOSTCC $@ - cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) -o $@ $< -$(host-csingle): %: %.c FORCE - $(call if_changed_dep,host-csingle) - -# Link an executable based on list of .o files, all plain c -# host-cmulti -> executable -quiet_cmd_host-cmulti = HOSTLD $@ - cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ - $(addprefix $(obj)/,$($(@F)-objs)) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE - $(call if_changed,host-cmulti) - -# Create .o file from a single .c file -# host-cobjs -> .o -quiet_cmd_host-cobjs = HOSTCC $@ - cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< -$(host-cobjs): %.o: %.c FORCE - $(call if_changed_dep,host-cobjs) - -# Link an executable based on list of .o files, a mixture of .c and .cc -# host-cxxmulti -> executable -quiet_cmd_host-cxxmulti = HOSTLD $@ - cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \ - $(foreach o,objs cxxobjs,\ - $(addprefix $(obj)/,$($(@F)-$(o)))) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE - $(call if_changed,host-cxxmulti) - -# Create .o file from a single .cc (C++) file -quiet_cmd_host-cxxobjs = HOSTCXX $@ - cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< -$(host-cxxobjs): %.o: %.cc FORCE - $(call if_changed_dep,host-cxxobjs) - -# Compile .c file, create position independent .o file -# host-cshobjs -> .o -quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ - cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< -$(host-cshobjs): %.o: %.c FORCE - $(call if_changed_dep,host-cshobjs) - -# Link a shared library, based on position independent .o files -# *.o -> .so shared library (host-cshlib) -quiet_cmd_host-cshlib = HOSTLLD -shared $@ - cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ - $(addprefix $(obj)/,$($(@F:.so=-objs))) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cshlib): %: $(host-cshobjs) FORCE - $(call if_changed,host-cshlib) - -targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) # Descending # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.host b/scripts/Makefile.host new file mode 100644 index 000000000000..d21a9639deb9 --- /dev/null +++ b/scripts/Makefile.host @@ -0,0 +1,152 @@ +# ========================================================================== +# Building binaries on the host system +# Binaries are used during the compilation of the kernel, for example +# to preprocess a data file. +# +# Both C and C++ is supported, but preferred language is C for such utilities. +# +# Samle syntax (see Documentation/kbuild/makefile.txt for reference) +# host-progs := bin2hex +# Will compile bin2hex.c and create an executable named bin2hex +# +# host-progs := lxdialog +# lxdialog-objs := checklist.o lxdialog.o +# Will compile lxdialog.c and checklist.c, and then link the executable +# lxdialog, based on checklist.o and lxdialog.o +# +# host-progs := qconf +# qconf-cxxobjs := qconf.o +# qconf-objs := menu.o +# Will compile qconf as a C++ program, and menu as a C program. +# They are linked as C++ code to the executable qconf + +# host-progs := conf +# conf-objs := conf.o libkconfig.so +# libkconfig-objs := expr.o type.o +# Will create a shared library named libkconfig.so that consist of +# expr.o and type.o (they are both compiled as C code and the object file +# are made as position independent code). +# conf.c is compiled as a c program, and conf.o is linked together with +# libkconfig.so as the executable conf. +# Note: Shared libraries consisting of C++ files are not supported + +# host-progs := tools/build may have been specified. Retreive directory +obj-dirs += $(foreach f,$(host-progs), $(if $(dir $(f)),$(dir $(f)))) +obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs)))) + + +# C code +# Executables compiled from a single .c file +host-csingle := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) + +# C executables linked based on several .o files +host-cmulti := $(foreach m,$(host-progs),\ + $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) + +# Object (.o) files compiled from .c files +host-cobjs := $(sort $(foreach m,$(host-progs),$($(m)-objs))) + +# C++ code +# C++ executables compiled from at least on .cc file +# and zero or more .c files +host-cxxmulti := $(foreach m,$(host-progs),$(if $($(m)-cxxobjs),$(m))) + +# C++ Object (.o) files compiled from .cc files +host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) + +# Shared libaries (only .c supported) +# Shared libraries (.so) - all .so files referenced in "xxx-objs" +host-cshlib := $(sort $(filter %.so, $(host-cobjs))) +# Remove .so files from "xxx-objs" +host-cobjs := $(filter-out %.so,$(host-cobjs)) + +#Object (.o) files used by the shared libaries +host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) + +host-progs := $(addprefix $(obj)/,$(host-progs)) +host-csingle := $(addprefix $(obj)/,$(host-csingle)) +host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) +host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) +host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) +host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) +host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) +host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) + +##### +# Handle options to gcc. Support building with separate output directory + +_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o) +_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o) + +ifeq ($(KBUILD_SRC),) +__hostc_flags = $(_hostc_flags) +__hostcxx_flags = $(_hostcxx_flags) +else +__hostc_flags = -I$(obj) $(call flags,_hostc_flags) +__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) +endif + +hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) +hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) + +##### +# Compile programs on the host + +# Create executable from a single .c file +# host-csingle -> Executable +quiet_cmd_host-csingle = HOSTCC $@ + cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) -o $@ $< +$(host-csingle): %: %.c FORCE + $(call if_changed_dep,host-csingle) + +# Link an executable based on list of .o files, all plain c +# host-cmulti -> executable +quiet_cmd_host-cmulti = HOSTLD $@ + cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ + $(addprefix $(obj)/,$($(@F)-objs)) \ + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) +$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE + $(call if_changed,host-cmulti) + +# Create .o file from a single .c file +# host-cobjs -> .o +quiet_cmd_host-cobjs = HOSTCC $@ + cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< +$(host-cobjs): %.o: %.c FORCE + $(call if_changed_dep,host-cobjs) + +# Link an executable based on list of .o files, a mixture of .c and .cc +# host-cxxmulti -> executable +quiet_cmd_host-cxxmulti = HOSTLD $@ + cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \ + $(foreach o,objs cxxobjs,\ + $(addprefix $(obj)/,$($(@F)-$(o)))) \ + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) +$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE + $(call if_changed,host-cxxmulti) + +# Create .o file from a single .cc (C++) file +quiet_cmd_host-cxxobjs = HOSTCXX $@ + cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< +$(host-cxxobjs): %.o: %.cc FORCE + $(call if_changed_dep,host-cxxobjs) + +# Compile .c file, create position independent .o file +# host-cshobjs -> .o +quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ + cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< +$(host-cshobjs): %.o: %.c FORCE + $(call if_changed_dep,host-cshobjs) + +# Link a shared library, based on position independent .o files +# *.o -> .so shared library (host-cshlib) +quiet_cmd_host-cshlib = HOSTLLD -shared $@ + cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ + $(addprefix $(obj)/,$($(@F:.so=-objs))) \ + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) +$(host-cshlib): %: $(host-cshobjs) FORCE + $(call if_changed,host-cshlib) + +targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) + diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index a47abc8af0a6..0388023241fe 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -60,41 +60,11 @@ 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 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))) -# C code -# Executables compiled from a single .c file -host-csingle := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) - -# C executables linked based on several .o files -host-cmulti := $(foreach m,$(host-progs),\ - $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) - -# Object (.o) files compiled from .c files -host-cobjs := $(sort $(foreach m,$(host-progs),$($(m)-objs))) - -# C++ code -# C++ executables compiled from at least on .cc file -# and zero or more .c files -host-cxxmulti := $(foreach m,$(host-progs),$(if $($(m)-cxxobjs),$(m))) - -# C++ Object (.o) files compiled from .cc files -host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) - -# Shared libaries (only .c supported) -# Shared libraries (.so) - all .so files referenced in "xxx-objs" -host-cshlib := $(sort $(filter %.so, $(host-cobjs))) -# Remove .so files from "xxx-objs" -host-cobjs := $(filter-out %.so,$(host-cobjs)) - -#Object (.o) files used by the shared libaries -host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) - # Add subdir path extra-y := $(addprefix $(obj)/,$(extra-y)) @@ -113,14 +83,6 @@ multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) -host-progs := $(addprefix $(obj)/,$(host-progs)) -host-csingle := $(addprefix $(obj)/,$(host-csingle)) -host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) -host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) -host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) -host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) -host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) -host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) # The temporary file to save gcc -MD generated dependencies must not # contain a comma @@ -136,12 +98,8 @@ depfile = $(subst $(comma),_,$(@D)/.$(@F).d) basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname)))) - _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) -_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o) -_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o) - # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). @@ -149,8 +107,6 @@ _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o) ifeq ($(KBUILD_SRC),) __c_flags = $(_c_flags) __a_flags = $(_a_flags) -__hostc_flags = $(_hostc_flags) -__hostcxx_flags = $(_hostcxx_flags) else # Prefix -I with $(srctree) if it is not an absolute path @@ -164,8 +120,6 @@ flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) # FIXME: Replace both with specific CFLAGS* statements in the makefiles __c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags) __a_flags = $(call flags,_a_flags) -__hostc_flags = -I$(obj) $(call flags,_hostc_flags) -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ @@ -175,9 +129,6 @@ c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ 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) # Finds the multi-part object the current object will be linked into -- cgit v1.2.3 From 113b88ae284c577e332db1d6e6519355b8ca009a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 11 Aug 2004 01:38:42 +0200 Subject: kbuild: Introduce hostprogs-y, deprecate host-progs Introducing hostprogs-y allows a user to use the typical Kbuild pattern in a Kbuild file: hostprogs-$(CONFIG_KALLSYMS) += ... And then during cleaning the referenced file are still deleted. Deprecate the old host-progs assignment but kept the functionlity. External modules will continue to use host-progs for a while - drawback is that they now see a warning. Workaround - just assign both variables: hostprogs-y := foo host-progs := $(hostprogs-y) All in-kernel users will be converted in next patch. Signed-off-by: Sam Ravnborg --- Documentation/kbuild/makefiles.txt | 37 ++++++++++++++++++++++++++----------- scripts/Makefile.build | 7 ++++++- scripts/Makefile.clean | 6 ++++-- scripts/Makefile.host | 26 ++++++++++++++------------ 4 files changed, 50 insertions(+), 26 deletions(-) (limited to 'scripts') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 008228af6ec1..fe3e07728586 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -25,6 +25,7 @@ This document describes the Linux kernel Makefiles. --- 4.4 Using C++ for host programs --- 4.5 Controlling compiler options for host programs --- 4.6 When host programs are actually built + --- 4.7 Using hostprogs-$(CONFIG_FOO) === 5 Kbuild clean infrastructure @@ -387,7 +388,7 @@ compilation stage. Two steps are required in order to use a host executable. The first step is to tell kbuild that a host program exists. This is -done utilising the variable host-prog. +done utilising the variable hostprogs-y. The second step is to add an explicit dependency to the executable. This can be done in two ways. Either add the dependency in a rule, @@ -402,7 +403,7 @@ Both possibilities are described in the following. built on the build host. Example: - host-progs := bin2hex + hostprogs-y := bin2hex Kbuild assumes in the above example that bin2hex is made from a single c-source file named bin2hex.c located in the same directory as @@ -418,7 +419,7 @@ Both possibilities are described in the following. Example: #scripts/lxdialog/Makefile - host-progs := lxdialog + hostprogs-y := lxdialog lxdialog-objs := checklist.o lxdialog.o Objects with extension .o are compiled from the corresponding .c @@ -438,7 +439,7 @@ Both possibilities are described in the following. Example: #scripts/kconfig/Makefile - host-progs := conf + hostprogs-y := conf conf-objs := conf.o libkconfig.so libkconfig-objs := expr.o type.o @@ -457,7 +458,7 @@ Both possibilities are described in the following. Example: #scripts/kconfig/Makefile - host-progs := qconf + hostprogs-y := qconf qconf-cxxobjs := qconf.o In the example above the executable is composed of the C++ file @@ -468,7 +469,7 @@ Both possibilities are described in the following. Example: #scripts/kconfig/Makefile - host-progs := qconf + hostprogs-y := qconf qconf-cxxobjs := qconf.o qconf-objs := check.o @@ -509,7 +510,7 @@ Both possibilities are described in the following. Example: #drivers/pci/Makefile - host-progs := gen-devlist + hostprogs-y := gen-devlist $(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist ( cd $(obj); ./gen-devlist ) < $< @@ -524,18 +525,32 @@ Both possibilities are described in the following. Example: #scripts/lxdialog/Makefile - host-progs := lxdialog - always := $(host-progs) + hostprogs-y := lxdialog + always := $(hostprogs-y) This will tell kbuild to build lxdialog even if not referenced in any rule. +--- 4.7 Using hostprogs-$(CONFIG_FOO) + + A typcal pattern in a Kbuild file lok like this: + + Example: + #scripts/Makefile + hostprogs-$(CONFIG_KALLSYMS) += kallsyms + + Kbuild knows about both 'y' for built-in and 'm' for module. + So if a config symbol evaluate to 'm', kbuild will still build + the binary. In other words Kbuild handle hostprogs-m exactly + like hostprogs-y. But only hostprogs-y is recommend used + when no CONFIG symbol are involved. + === 5 Kbuild clean infrastructure "make clean" deletes most generated files in the src tree where the kernel is compiled. This includes generated files such as host programs. -Kbuild knows targets listed in $(host-progs), $(always), $(extra-y) and -$(targets). They are all deleted during "make clean". +Kbuild knows targets listed in $(hostprogs-y), $(hostprogs-m), $(always), +$(extra-y) and $(targets). They are all deleted during "make clean". Files matching the patterns "*.[oas]", "*.ko", plus some additional files generated by kbuild are deleted all over the kernel src tree when "make clean" is executed. diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 458bedea2e7b..707ad9d0353a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -14,8 +14,13 @@ include $(obj)/Makefile include scripts/Makefile.lib -# Do not include host-progs rules unles needed ifdef host-progs +$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!) +hostprogs-y += $(host-progs) +endif + +# Do not include host rules unles needed +ifneq ($(hostprogs-y)$(hostprogs-m),) include scripts/Makefile.host endif diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 1daba0623151..ab73032fc773 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -29,8 +29,10 @@ subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) # Add subdir path subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) -__clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) $(host-progs) \ - $(targets) $(clean-files) +__clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) \ + $(targets) $(clean-files) \ + $(host-progs) \ + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) __clean-files := $(wildcard \ $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \ $(filter /%, $(__clean-files))) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index d21a9639deb9..04a79033fbce 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -6,21 +6,21 @@ # Both C and C++ is supported, but preferred language is C for such utilities. # # Samle syntax (see Documentation/kbuild/makefile.txt for reference) -# host-progs := bin2hex +# hostprogs-y := bin2hex # Will compile bin2hex.c and create an executable named bin2hex # -# host-progs := lxdialog +# hostprogs-y := lxdialog # lxdialog-objs := checklist.o lxdialog.o # Will compile lxdialog.c and checklist.c, and then link the executable # lxdialog, based on checklist.o and lxdialog.o # -# host-progs := qconf +# hostprogs-y := qconf # qconf-cxxobjs := qconf.o # qconf-objs := menu.o # Will compile qconf as a C++ program, and menu as a C program. # They are linked as C++ code to the executable qconf -# host-progs := conf +# hostprogs-y := conf # conf-objs := conf.o libkconfig.so # libkconfig-objs := expr.o type.o # Will create a shared library named libkconfig.so that consist of @@ -28,28 +28,30 @@ # are made as position independent code). # conf.c is compiled as a c program, and conf.o is linked together with # libkconfig.so as the executable conf. -# Note: Shared libraries consisting of C++ files are not supported +# Note: Shared libraries consisting of C++ files are not supported -# host-progs := tools/build may have been specified. Retreive directory -obj-dirs += $(foreach f,$(host-progs), $(if $(dir $(f)),$(dir $(f)))) +__hostprogs := $(hostprogs-y)$(hostprogs-m) + +# hostprogs-y := tools/build may have been specified. Retreive directory +obj-dirs += $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs)))) # C code # Executables compiled from a single .c file -host-csingle := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) +host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) # C executables linked based on several .o files -host-cmulti := $(foreach m,$(host-progs),\ +host-cmulti := $(foreach m,$(__hostprogs),\ $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) # Object (.o) files compiled from .c files -host-cobjs := $(sort $(foreach m,$(host-progs),$($(m)-objs))) +host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) # C++ code # C++ executables compiled from at least on .cc file # and zero or more .c files -host-cxxmulti := $(foreach m,$(host-progs),$(if $($(m)-cxxobjs),$(m))) +host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) # C++ Object (.o) files compiled from .cc files host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) @@ -63,7 +65,7 @@ host-cobjs := $(filter-out %.so,$(host-cobjs)) #Object (.o) files used by the shared libaries host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) -host-progs := $(addprefix $(obj)/,$(host-progs)) +__hostprogs := $(addprefix $(obj)/,$(__hostprogs)) host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) -- cgit v1.2.3 From ff08974850158f4c4d815840f7c3e82a4aa12c34 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 11 Aug 2004 01:42:56 +0200 Subject: kbuild: Replace host-progs with hostprogs-y Signed-off-by: Sam Ravnborg --- arch/alpha/boot/Makefile | 2 +- arch/i386/boot/Makefile | 2 +- arch/ppc/boot/Makefile | 4 ++-- arch/ppc64/boot/Makefile | 2 +- arch/sparc/boot/Makefile | 2 +- arch/sparc64/boot/Makefile | 2 +- arch/um/sys-i386/util/Makefile | 4 ++-- arch/x86_64/boot/Makefile | 2 +- drivers/atm/Makefile | 2 +- drivers/md/Makefile | 2 +- drivers/media/dvb/ttpci/Makefile | 2 +- drivers/pci/Makefile | 2 +- drivers/zorro/Makefile | 2 +- lib/Makefile | 2 +- scripts/Makefile | 3 +-- scripts/basic/Makefile | 4 ++-- scripts/genksyms/Makefile | 4 ++-- scripts/kconfig/Makefile | 2 +- scripts/lxdialog/Makefile | 4 ++-- scripts/mod/Makefile | 4 ++-- sound/oss/Makefile | 2 +- usr/Makefile | 2 +- 22 files changed, 28 insertions(+), 29 deletions(-) (limited to 'scripts') diff --git a/arch/alpha/boot/Makefile b/arch/alpha/boot/Makefile index e30945095f70..e1ae14cd2b4e 100644 --- a/arch/alpha/boot/Makefile +++ b/arch/alpha/boot/Makefile @@ -8,7 +8,7 @@ # Copyright (C) 1994 by Linus Torvalds # -host-progs := tools/mkbb tools/objstrip +hostprogs-y := tools/mkbb tools/objstrip targets := vmlinux.gz vmlinux \ vmlinux.nh tools/lxboot tools/bootlx tools/bootph \ tools/bootpzh bootloader bootpheader bootpzheader diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile index ac2b3cd5c56d..aa7064a75ee6 100644 --- a/arch/i386/boot/Makefile +++ b/arch/i386/boot/Makefile @@ -29,7 +29,7 @@ targets := vmlinux.bin bootsect bootsect.o setup setup.o \ zImage bzImage subdir- := compressed -host-progs := tools/build +hostprogs-y := tools/build HOSTCFLAGS_build.o := $(LINUXINCLUDE) diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile index 8c1d7eb8b8fa..995f89bb049c 100644 --- a/arch/ppc/boot/Makefile +++ b/arch/ppc/boot/Makefile @@ -23,12 +23,12 @@ subdir-$(CONFIG_PPC_OF) += of1275 # for cleaning subdir- += simple openfirmware -host-progs := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) +hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) .PHONY: $(BOOT_TARGETS) $(bootdir-y) $(BOOT_TARGETS): $(bootdir-y) $(bootdir-y): $(addprefix $(obj)/,$(subdir-y)) \ - $(addprefix $(obj)/,$(host-progs)) + $(addprefix $(obj)/,$(hostprogs-y)) $(Q)$(MAKE) $(build)=$(obj)/$@ $(MAKECMDGOALS) diff --git a/arch/ppc64/boot/Makefile b/arch/ppc64/boot/Makefile index 0099f1cfc2b7..365cbaa4d4a6 100644 --- a/arch/ppc64/boot/Makefile +++ b/arch/ppc64/boot/Makefile @@ -58,7 +58,7 @@ obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section))) src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section))) gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section))) -host-progs := piggy addnote addSystemMap addRamDisk +hostprogs-y := piggy addnote addSystemMap addRamDisk targets += zImage zImage.initrd imagesize.c \ $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \ $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \ diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile index d62e32d39675..5d78c8e77140 100644 --- a/arch/sparc/boot/Makefile +++ b/arch/sparc/boot/Makefile @@ -7,7 +7,7 @@ ROOT_IMG := /usr/src/root.img ELFTOAOUT := elftoaout -host-progs := piggyback btfixupprep +hostprogs-y := piggyback btfixupprep targets := tftpboot.img btfix.o btfix.S image quiet_cmd_elftoaout = ELFTOAOUT $@ diff --git a/arch/sparc64/boot/Makefile b/arch/sparc64/boot/Makefile index 5eb14ff1c518..6968a6da57da 100644 --- a/arch/sparc64/boot/Makefile +++ b/arch/sparc64/boot/Makefile @@ -7,7 +7,7 @@ ROOT_IMG := /usr/src/root.img ELFTOAOUT := elftoaout -host-progs := piggyback +hostprogs-y := piggyback targets := image tftpboot.img vmlinux.aout quiet_cmd_elftoaout = ELF2AOUT $@ diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile index a3eca5f22f08..1fd4926b9b5a 100644 --- a/arch/um/sys-i386/util/Makefile +++ b/arch/um/sys-i386/util/Makefile @@ -1,6 +1,6 @@ -host-progs := mk_sc -always := $(host-progs) mk_thread +hostprogs-y := mk_sc +always := $(hostprogs-y) mk_thread targets := mk_thread_kern.o mk_thread_user.o mk_sc-objs := mk_sc.o diff --git a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile index 1c2d3cbcae43..99b790439514 100644 --- a/arch/x86_64/boot/Makefile +++ b/arch/x86_64/boot/Makefile @@ -30,7 +30,7 @@ targets := vmlinux.bin bootsect bootsect.o \ EXTRA_CFLAGS := -m32 -host-progs := tools/build +hostprogs-y := tools/build subdir- := compressed/ #Let make clean descend in compressed/ # --------------------------------------------------------------------------- diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile index bcd60fb8dae7..907c5933a30c 100644 --- a/drivers/atm/Makefile +++ b/drivers/atm/Makefile @@ -3,7 +3,7 @@ # fore_200e-objs := fore200e.o -host-progs := fore200e_mkfirm +hostprogs-y := fore200e_mkfirm # Files generated that shall be removed upon make clean clean-files := atmsar11.bin atmsar11.bin1 atmsar11.bin2 pca200e.bin \ diff --git a/drivers/md/Makefile b/drivers/md/Makefile index c8feb8346766..4f3ae7735fe6 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -10,7 +10,7 @@ raid6-objs := raid6main.o raid6algos.o raid6recov.o raid6tables.o \ raid6int1.o raid6int2.o raid6int4.o \ raid6int8.o raid6int16.o raid6int32.o \ raid6mmx.o raid6sse1.o raid6sse2.o -host-progs := mktables +hostprogs-y := mktables # Note: link order is important. All raid personalities # and xor.o must come before md.o, as they each initialise diff --git a/drivers/media/dvb/ttpci/Makefile b/drivers/media/dvb/ttpci/Makefile index 2e8403b89f7b..043468a1d749 100644 --- a/drivers/media/dvb/ttpci/Makefile +++ b/drivers/media/dvb/ttpci/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_DVB_AV7110) += dvb-ttpci.o ttpci-eeprom.o EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -host-progs := fdump +hostprogs-y := fdump ifdef CONFIG_DVB_AV7110_FIRMWARE $(obj)/av7110.o: $(obj)/fdump $(obj)/av7110_firm.h diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 377c7238c4cc..474eacd34741 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -35,7 +35,7 @@ ifndef CONFIG_X86 obj-y += syscall.o endif -host-progs := gen-devlist +hostprogs-y := gen-devlist # Dependencies on generated files need to be listed explicitly $(obj)/names.o: $(obj)/devlist.h $(obj)/classlist.h diff --git a/drivers/zorro/Makefile b/drivers/zorro/Makefile index 32f99d846edb..f62172603215 100644 --- a/drivers/zorro/Makefile +++ b/drivers/zorro/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_ZORRO) += zorro.o zorro-driver.o zorro-sysfs.o names.o obj-$(CONFIG_PROC_FS) += proc.o -host-progs := gen-devlist +hostprogs-y := gen-devlist # Files generated that shall be removed upon make clean clean-files := devlist.h diff --git a/lib/Makefile b/lib/Makefile index 295e70bcd223..f80da4580059 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -25,7 +25,7 @@ obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/ -host-progs := gen_crc32table +hostprogs-y := gen_crc32table clean-files := crc32table.h $(obj)/crc32.o: $(obj)/crc32table.h diff --git a/scripts/Makefile b/scripts/Makefile index ae375b1ff20c..67763eeb8a3e 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -13,8 +13,7 @@ hostprogs-$(CONFIG_VT) += conmakehash hostprogs-$(CONFIG_PROM_CONSOLE) += conmakehash hostprogs-$(CONFIG_IKCONFIG) += bin2c -host-progs := $(sort $(hostprogs-y)) -always := $(host-progs) +always := $(hostprogs-y) subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_MODULES) += mod diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index 3afb3bf4d12c..f22e94c3a2d1 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile @@ -11,8 +11,8 @@ # include/config/... # docproc: Used in Documentation/docbook -host-progs := fixdep split-include docproc -always := $(host-progs) +hostprogs-y := fixdep split-include docproc +always := $(hostprogs-y) # fixdep is needed to compile other host programs $(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index 76f1fd10e16f..5875f29a8602 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -1,6 +1,6 @@ -host-progs := genksyms -always := $(host-progs) +hostprogs-y := genksyms +always := $(hostprogs-y) genksyms-objs := genksyms.o parse.o lex.o diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 89b986abd753..6377641dd599 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -67,7 +67,7 @@ help: libkconfig-objs := zconf.tab.o -host-progs := conf mconf qconf gconf +hostprogs-y := conf mconf qconf gconf conf-objs := conf.o libkconfig.so mconf-objs := mconf.o libkconfig.so diff --git a/scripts/lxdialog/Makefile b/scripts/lxdialog/Makefile index 2f22b2f69d8c..cdc4024a8830 100644 --- a/scripts/lxdialog/Makefile +++ b/scripts/lxdialog/Makefile @@ -15,8 +15,8 @@ endif endif endif -host-progs := lxdialog -always := ncurses $(host-progs) +hostprogs-y := lxdialog +always := ncurses $(hostprogs-y) lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ util.o lxdialog.o msgbox.o diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index f66bf5262aae..11d69c35e5b4 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile @@ -1,5 +1,5 @@ -host-progs := modpost mk_elfconfig -always := $(host-progs) empty.o +hostprogs-y := modpost mk_elfconfig +always := $(hostprogs-y) empty.o modpost-objs := modpost.o file2alias.o sumversion.o diff --git a/sound/oss/Makefile b/sound/oss/Makefile index 6fc30dc7fe27..226b395bbe4c 100644 --- a/sound/oss/Makefile +++ b/sound/oss/Makefile @@ -103,7 +103,7 @@ sb_lib-objs := sb_common.o sb_audio.o sb_midi.o sb_mixer.o sb_ess.o vidc_mod-objs := vidc.o vidc_fill.o wavefront-objs := wavfront.o wf_midi.o yss225.o -host-progs := bin2hex hex2hex +hostprogs-y := bin2hex hex2hex # Files generated that shall be removed upon make clean clean-files := maui_boot.h msndperm.c msndinit.c pndsperm.c pndspini.c \ diff --git a/usr/Makefile b/usr/Makefile index fe62659ff483..965759fc16ad 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -1,7 +1,7 @@ obj-y := initramfs_data.o -host-progs := gen_init_cpio +hostprogs-y := gen_init_cpio clean-files := initramfs_data.cpio.gz -- cgit v1.2.3 From 3fe519b21b33a395c2e3b01ee70289a0899014ee Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 11 Aug 2004 01:56:40 +0200 Subject: kbuild: Fix hostprogs-y Allow the same target to be specified more than once without causing a warnign from make. The same target may be specified twice when using the following pattern: hostprogs-$(CONFIG_FOO) += program hostprogs-$(CONFIG_BAR) += program Signed-off-by: Sam Ravnborg --- scripts/Makefile.host | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 04a79033fbce..0a5d8cafa135 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -30,7 +30,7 @@ # libkconfig.so as the executable conf. # Note: Shared libraries consisting of C++ files are not supported -__hostprogs := $(hostprogs-y)$(hostprogs-m) +__hostprogs := $(sort $(hostprogs-y)$(hostprogs-m)) # hostprogs-y := tools/build may have been specified. Retreive directory obj-dirs += $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) -- cgit v1.2.3 From e78d165503d0dfefeed18f48f722f4bf4ad79014 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 11 Aug 2004 02:11:50 +0200 Subject: kbuild: Use POSIX headers for ntoh functions From: Benno When compiling Linux on Mac OSX I had trouble with scripts/sumversion.c. It includes to obtain to definitions of htonl and ntohl. On Mac OSX these are found in . After checking the POSIX specification it appears that this is the correct place to get the definitons for these functions. (http://www.opengroup.org/onlinepubs/009695399/functions/htonl.html) Using this header also appears to work on Linux (at least with Glibc-2.3.2). It seems clearer to me to go with the POSIX standard than implementing #if __APPLE__ style macros, but if such an approach is preferred I can supply patches for that instead. Signed-off-by: Sam Ravnborg --- scripts/basic/fixdep.c | 2 +- scripts/mod/sumversion.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 8bd6442229cf..9c03a6673aad 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -104,7 +104,7 @@ #include #include #include -#include +#include #define INT_CONF ntohl(0x434f4e46) #define INT_ONFI ntohl(0x4f4e4649) diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index b41b718edffe..631430d09e4d 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include -- cgit v1.2.3 From 29d28b2a027570e81d813f35d466c09ae54f4104 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 14 Aug 2004 00:14:30 +0200 Subject: kbuild: __crc_* symbols in System.map David S. Miller wrote: Shouldn't we be grepping __crc_ symbols out of the System.map file? For one thing, these can confuse readprofile. It's algorithm is to start at _stext, then stop when it sees a line in the System.map which is not text (mode is one of 'T' 't' 'W' or 'w') It will exit early if there are some intermixed __crc_* things in there (since they are are mode 'A'). For example, in my current sparc64 kernel I have this: 00000000004cef80 t do_split 00000000004cf2a0 t add_dirent_to_buf 00000000004cf5a7 A __crc_init_special_inode 00000000004cf640 t make_indexed_dir 00000000004cf900 t ext3_add_entry So no symbols after add_dirent_to_buf will be shown in the profiling output of readprofile. Implementation ported to mksysmap by Sam. Included two System.map related fixes: - Print "SYSMAP System.map" during build - Sort symbols in System.map Signed-off-by: Sam Ravnborg --- Makefile | 12 ++++++------ scripts/mksysmap | 9 ++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 56b4a072fa96..7f058727f244 100644 --- a/Makefile +++ b/Makefile @@ -608,12 +608,12 @@ endif define rule_vmlinux $(rule_vmlinux__); - $(Q)$(if $($(quiet)cmd_sysmap), \ - echo ' $($(quiet)cmd_sysmap) $@' &&) \ - $(cmd_sysmap) $@ System.map; \ - if [ $$? -ne 0 ]; then \ - rm -f $@; \ - /bin/false; \ + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) System.map' &&) \ + $(cmd_sysmap) $@ System.map; \ + if [ $$? -ne 0 ]; then \ + rm -f $@; \ + /bin/false; \ fi; $(rule_verify_kallsyms) endef diff --git a/scripts/mksysmap b/scripts/mksysmap index bb0fbef3db2b..279fb9214aa0 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -51,4 +51,11 @@ fi # U - undefined global symbols # w - local weak symbols -nm $1 | grep -v ' [aUw] ' > $2 +# readprofile starts reading symbols when _stext is found, and +# continue until it finds a symbol which is not either of 'T', 't', +# 'W' or 'w'. __crc_ are 'A' and placed in the middle +# so we just ignore them to let readprofile continue to work. +# (At least sparc64 has __crc_ in the middle). + +$NM -n $1 | grep -v '\( [aUw] \)\|\(__crc_\)' > $2 + -- cgit v1.2.3 From df9b2cbabd37daacece62bcd1be4593960d249d4 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sun, 15 Aug 2004 14:45:54 +0200 Subject: kerneldoc: Fix comma separated members. This patch teaches scripts/kernel-doc to print descriptions of comma separated variables correctly instead of ignoring them. Tested on 'make pdfdocs' and 'scripts/kernel-doc -text test.c'. Signed-off-by: Sam Ravnborg --- scripts/kernel-doc | 88 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 38 deletions(-) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index aa7ffee63b45..9c28fbbeaba9 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -26,6 +26,8 @@ use strict; # Still to do: # - add perldoc documentation # - Look more closely at some of the scarier bits :) +# - Clean up mess that #ifdefs and comments inside structs +# definitions leave. # 26/05/2001 - Support for separate source and object trees. # Return error code. @@ -36,6 +38,8 @@ use strict; # Small fixes (like spaces vs. \s in regex) # -- Tim Jansen +# 18/04/2004 - Comma separated members inside structs definitions are ok now. +# -- Alexey Dobriyan # # This will read a 'c' file and scan for embedded comments in the @@ -105,10 +109,7 @@ use strict; # enums and typedefs. Instead of the function name you must write the name # of the declaration; the struct/union/enum/typedef must always precede # the name. Nesting of declarations is not supported. -# Use the argument mechanism to document members or constants. In -# structs and unions you must declare one member per declaration -# (comma-separated members are not allowed - the parser does not support -# this). +# Use the argument mechanism to document members or constants. # e.g. # /** # * struct my_struct - short description @@ -1318,51 +1319,62 @@ sub create_parameterlist($$$) { $param = $1; $type = $arg; $type =~ s/([^\(]+\(\*)$param/$1/; + push_parameter($type, $param, $file); } else { # evil magic to get fixed array parameters to work + # 'char cb[48]' => 'char* cb' $arg =~ s/(.+\s+)(.+)\[.*/$1* $2/; - my @args = split('\s', $arg); - - $param = pop @args; - if ($param =~ m/^(\*+)(.*)/) { - $param = $2; - push @args, $1; - } - elsif ($param =~ m/(.*?)\s*:\s*(\d+)/) { - $param = $1; - push @args, ":$2"; + + my @args = split(',\s*', $arg); + + my @first_arg = split('\s', shift @args); + unshift(@args, pop @first_arg); + $type = join " ", @first_arg; + + foreach $param (@args) { + if ($param =~ m/^(\*+)(.*)/) { + # pointer + push_parameter("$type$1", $2, $file); + } elsif ($param =~ m/(.*?)\s*:\s*(\d+)/) { + # bitfield + push_parameter("$type:$2", $1, $file); + } else { + push_parameter($type, $param, $file); + } } - $type = join " ", @args; } + } +} - if ($type eq "" && $param eq "...") - { - $type="..."; - $param="..."; - $parameterdescs{"..."} = "variable arguments"; - } - elsif ($type eq "" && ($param eq "" or $param eq "void")) - { - $type=""; - $param="void"; - $parameterdescs{void} = "no arguments"; - } - if (defined $type && $type && !defined $parameterdescs{$param}) { - $parameterdescs{$param} = $undescribed; +sub push_parameter($$$) { + my $type = shift; + my $param = shift; + my $file = shift; - if (($type eq 'function') || ($type eq 'enum')) { - print STDERR "Warning(${file}:$.): Function parameter ". + if ($type eq "" && $param eq "...") { + $type="..."; + $param="..."; + $parameterdescs{"..."} = "variable arguments"; + } elsif ($type eq "" && ($param eq "" or $param eq "void")) { + $type=""; + $param="void"; + $parameterdescs{void} = "no arguments"; + } + if (defined $type && $type && !defined $parameterdescs{$param}) { + $parameterdescs{$param} = $undescribed; + + if (($type eq 'function') || ($type eq 'enum')) { + print STDERR "Warning(${file}:$.): Function parameter ". "or member '$param' not " . "described in '$declaration_name'\n"; - } - print STDERR "Warning(${file}:$.):". + } + print STDERR "Warning(${file}:$.):". " No description found for parameter '$param'\n"; - ++$warnings; - } - - push @parameterlist, $param; - $parametertypes{$param} = $type; + ++$warnings; } + + push @parameterlist, $param; + $parametertypes{$param} = $type; } ## -- cgit v1.2.3 From 8f36d53f6f2b3a5758a0b6f894d76051cf94403c Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 15 Aug 2004 15:54:27 +0200 Subject: kbuild: Bogus "has no CRC" in external module builds From: Pavel Roskin The recent fixes for the external module build have fixed the major breakage, but they left one annoyance unfixed. If CONFIG_MODVERSIONS is disabled, a warning is printed for every exported symbol that is has no CRC. For instance, I see this when compiling the standalone Orinoco driver on Linux 2.6.6-rc3: *** Warning: "__orinoco_down" [/usr/local/src/orinoco/spectrum_cs.ko] has no CRC! *** Warning: "hermes_struct_init" [/usr/local/src/orinoco/spectrum_cs.ko] has no CRC! *** Warning: "free_orinocodev" [/usr/local/src/orinoco/spectrum_cs.ko] has no CRC! [further warnings skipped] I have found that the "-i" option for modpost is used for external builds, whereas the internal modules use "-o". The "-i" option causes read_dump() in modpost.c to be called. This function sets "modversions" variable under some conditions that I don't understand. The comment before the modversions declarations says: "Are we using CONFIG_MODVERSIONS?" Apparently modpost fails to answer this question. I think it's better to use an explicit option rather than a kludge. The attached patch adds a new option "-m" that is specified if and only if CONFIG_MODVERSIONS is enabled. The patch has been successfully tested both with and without CONFIG_MODVERSIONS. Signed-off-by: Sam Ravnborg --- scripts/Makefile.modpost | 3 ++- scripts/mod/modpost.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 19f5345279ac..c5d201f660c9 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -50,7 +50,8 @@ _modpost: $(modules) # Step 2), invoke modpost # Includes step 3,4 quiet_cmd_modpost = MODPOST - cmd_modpost = scripts/mod/modpost \ + cmd_modpost = scripts/mod/modpost \ + $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(KBUILD_EXTMOD),-i,-o) $(symverfile) \ $(filter-out FORCE,$^) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 662e75b2f780..65072d76a101 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -343,7 +343,6 @@ handle_modversions(struct module *mod, struct elf_info *info, crc = (unsigned int) sym->st_value; add_exported_symbol(symname + strlen(CRC_PFX), mod, &crc); - modversions = 1; } break; case SHN_UNDEF: @@ -649,7 +648,6 @@ read_dump(const char *fname) if (!(mod = find_module(modname))) { if (is_vmlinux(modname)) { - modversions = 1; have_vmlinux = 1; } mod = new_module(NOFAIL(strdup(modname))); @@ -696,11 +694,14 @@ main(int argc, char **argv) char *dump_read = NULL, *dump_write = NULL; int opt; - while ((opt = getopt(argc, argv, "i:o:")) != -1) { + while ((opt = getopt(argc, argv, "i:mo:")) != -1) { switch(opt) { case 'i': dump_read = optarg; break; + case 'm': + modversions = 1; + break; case 'o': dump_write = optarg; break; -- cgit v1.2.3 From c51824f0bc491d1e00645426a36c69151abc85e9 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 15 Aug 2004 16:18:07 +0200 Subject: kbuild: Generate *.lds instead of *.lds.s When building a kernel on platforms where the filesytem do not distingush between upper and lower case the rule: .S -> .s did not work. In a normal build this is only used for linker scripts. So create a separate rule for .lds files, and use generic cpp flags. Patch from: Dan Aloni Modified to use cpp flags + added documentation. Signed-off-by: Sam Ravnborg --- Documentation/kbuild/makefiles.txt | 31 +++++++++++++++++++++++++++++++ Makefile | 14 +++++++------- arch/i386/kernel/Makefile | 2 +- scripts/Makefile.build | 8 ++++++++ scripts/Makefile.lib | 5 +++++ 5 files changed, 52 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index fe3e07728586..39d6e0a61e9a 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -938,6 +938,37 @@ When kbuild executes the following steps are followed (roughly): will be displayed with "make KBUILD_VERBOSE=0". +--- 6.8 Preprocessing linker scripts + + When the vmlinux image is build the linker script: + arch/$(ARCH)/kernel/vmlinux.lds is used. + The script is a preprocessed variant of the file vmlinux.lds.S + located in the same directory. + kbuild knows .lds file and includes a rule *lds.S -> *lds. + + Example: + #arch/i386/kernel/Makefile + always := vmlinux.lds + + #Makefile + export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) + + The assigment to $(always) is used to tell kbuild to build the + target: vmlinux.lds. + The assignment to $(CPPFLAGS_vmlinux.lds) tell kbuild to use the + specified options when building the target vmlinux.lds. + + When building the *.lds target kbuild used the variakles: + CPPFLAGS : Set in top-level Makefile + EXTRA_CPPFLAGS : May be set in the kbuild makefile + CPPFLAGS_$(@F) : Target specific flags. + Note that the full filename is used in this + assignment. + + The kbuild infrastructure for *lds file are used in several + architecture specific files. + + === 7 Kbuild Variables The top Makefile exports the following variables: diff --git a/Makefile b/Makefile index 7f058727f244..b886f08f9da0 100644 --- a/Makefile +++ b/Makefile @@ -545,7 +545,7 @@ endef quiet_cmd_sysmap = SYSMAP cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap -LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s +LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds # Generate section listing all symbols and add it into vmlinux # It's a three stage process: @@ -591,13 +591,13 @@ cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) $(foreach x,$(CONFIG_KALLSYMS_ALL),--al .tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) $(call cmd,kallsyms) -.tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE +.tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/kernel/vmlinux.lds FORCE $(call if_changed_rule,vmlinux__) -.tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE +.tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/kernel/vmlinux.lds FORCE $(call if_changed_rule,vmlinux__) -.tmp_vmlinux3: $(vmlinux-objs) .tmp_kallsyms2.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE +.tmp_vmlinux3: $(vmlinux-objs) .tmp_kallsyms2.o arch/$(ARCH)/kernel/vmlinux.lds FORCE $(call if_changed_rule,vmlinux__) endif @@ -618,13 +618,13 @@ define rule_vmlinux $(rule_verify_kallsyms) endef -vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE +vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/kernel/vmlinux.lds FORCE $(call if_changed_rule,vmlinux) # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds.s: $(vmlinux-dirs) ; +$(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds: $(vmlinux-dirs) ; # Handle descending into subdirectories listed in $(vmlinux-dirs) # Preset locale variables to speed up the build process. Limit locale @@ -687,7 +687,7 @@ prepare-all: prepare0 prepare # Leave this as default for preprocessing vmlinux.lds.S, which is now # done in arch/$(ARCH)/kernel/Makefile -export AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH) +export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) # Single targets # --------------------------------------------------------------------------- diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile index 00cc32e3383e..e03816e72f50 100644 --- a/arch/i386/kernel/Makefile +++ b/arch/i386/kernel/Makefile @@ -2,7 +2,7 @@ # Makefile for the linux kernel. # -extra-y := head.o init_task.o vmlinux.lds.s +extra-y := head.o init_task.o vmlinux.lds obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 707ad9d0353a..9312926161fe 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -219,6 +219,14 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< targets += $(real-objs-y) $(real-objs-m) $(lib-y) targets += $(extra-y) $(MAKECMDGOALS) $(always) +# Linker scripts preprocessor (.lds.S -> .lds) +# --------------------------------------------------------------------------- +quiet_cmd_cpp_lds_S = LDS $@ + cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< + +%.lds: %.lds.S FORCE + $(call if_changed_dep,cpp_lds_S) + # Build the compiled-in targets # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0388023241fe..3a7663b901f0 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -100,6 +100,7 @@ modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $ _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) +_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). @@ -107,6 +108,7 @@ _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) ifeq ($(KBUILD_SRC),) __c_flags = $(_c_flags) __a_flags = $(_a_flags) +__cpp_flags = $(_cpp_flags) else # Prefix -I with $(srctree) if it is not an absolute path @@ -120,6 +122,7 @@ flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) # FIXME: Replace both with specific CFLAGS* statements in the makefiles __c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags) __a_flags = $(call flags,_a_flags) +__cpp_flags = $(call flags,_cpp_flags) endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ @@ -129,6 +132,8 @@ c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ $(__a_flags) $(modkern_aflags) +cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags) + ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS) # Finds the multi-part object the current object will be linked into -- cgit v1.2.3 From b951afc0f636f9a60fd076a808246ce27387d0a7 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 16 Aug 2004 00:27:11 +0200 Subject: Cset exclude: adobriyan@mail.ru|ChangeSet|20040815084554|35832 --- scripts/kernel-doc | 88 +++++++++++++++++++++++------------------------------- 1 file changed, 38 insertions(+), 50 deletions(-) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 9c28fbbeaba9..aa7ffee63b45 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -26,8 +26,6 @@ use strict; # Still to do: # - add perldoc documentation # - Look more closely at some of the scarier bits :) -# - Clean up mess that #ifdefs and comments inside structs -# definitions leave. # 26/05/2001 - Support for separate source and object trees. # Return error code. @@ -38,8 +36,6 @@ use strict; # Small fixes (like spaces vs. \s in regex) # -- Tim Jansen -# 18/04/2004 - Comma separated members inside structs definitions are ok now. -# -- Alexey Dobriyan # # This will read a 'c' file and scan for embedded comments in the @@ -109,7 +105,10 @@ use strict; # enums and typedefs. Instead of the function name you must write the name # of the declaration; the struct/union/enum/typedef must always precede # the name. Nesting of declarations is not supported. -# Use the argument mechanism to document members or constants. +# Use the argument mechanism to document members or constants. In +# structs and unions you must declare one member per declaration +# (comma-separated members are not allowed - the parser does not support +# this). # e.g. # /** # * struct my_struct - short description @@ -1319,62 +1318,51 @@ sub create_parameterlist($$$) { $param = $1; $type = $arg; $type =~ s/([^\(]+\(\*)$param/$1/; - push_parameter($type, $param, $file); } else { # evil magic to get fixed array parameters to work - # 'char cb[48]' => 'char* cb' $arg =~ s/(.+\s+)(.+)\[.*/$1* $2/; - - my @args = split(',\s*', $arg); - - my @first_arg = split('\s', shift @args); - unshift(@args, pop @first_arg); - $type = join " ", @first_arg; - - foreach $param (@args) { - if ($param =~ m/^(\*+)(.*)/) { - # pointer - push_parameter("$type$1", $2, $file); - } elsif ($param =~ m/(.*?)\s*:\s*(\d+)/) { - # bitfield - push_parameter("$type:$2", $1, $file); - } else { - push_parameter($type, $param, $file); - } + my @args = split('\s', $arg); + + $param = pop @args; + if ($param =~ m/^(\*+)(.*)/) { + $param = $2; + push @args, $1; + } + elsif ($param =~ m/(.*?)\s*:\s*(\d+)/) { + $param = $1; + push @args, ":$2"; } + $type = join " ", @args; } - } -} - -sub push_parameter($$$) { - my $type = shift; - my $param = shift; - my $file = shift; - if ($type eq "" && $param eq "...") { - $type="..."; - $param="..."; - $parameterdescs{"..."} = "variable arguments"; - } elsif ($type eq "" && ($param eq "" or $param eq "void")) { - $type=""; - $param="void"; - $parameterdescs{void} = "no arguments"; - } - if (defined $type && $type && !defined $parameterdescs{$param}) { - $parameterdescs{$param} = $undescribed; + if ($type eq "" && $param eq "...") + { + $type="..."; + $param="..."; + $parameterdescs{"..."} = "variable arguments"; + } + elsif ($type eq "" && ($param eq "" or $param eq "void")) + { + $type=""; + $param="void"; + $parameterdescs{void} = "no arguments"; + } + if (defined $type && $type && !defined $parameterdescs{$param}) { + $parameterdescs{$param} = $undescribed; - if (($type eq 'function') || ($type eq 'enum')) { - print STDERR "Warning(${file}:$.): Function parameter ". + if (($type eq 'function') || ($type eq 'enum')) { + print STDERR "Warning(${file}:$.): Function parameter ". "or member '$param' not " . "described in '$declaration_name'\n"; - } - print STDERR "Warning(${file}:$.):". + } + print STDERR "Warning(${file}:$.):". " No description found for parameter '$param'\n"; - ++$warnings; - } + ++$warnings; + } - push @parameterlist, $param; - $parametertypes{$param} = $type; + push @parameterlist, $param; + $parametertypes{$param} = $type; + } } ## -- cgit v1.2.3 From a82bae6ec6eb34d0b25eb5d26fcf300d2a7fd27f Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 16 Aug 2004 01:54:22 +0200 Subject: kbuild: Allow external modules to use host-progs with no warning Only warn if $(host-progs) and $(hostptogs-y) are not equal. This allows external modules to use: hostprogs-y := file ... host-progs := $(hostprogs-y) This is backwards compatible and will not warn. Signed-off-by: Sam Ravnborg --- scripts/Makefile.build | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9312926161fe..c48adfe03a73 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -15,9 +15,11 @@ include $(obj)/Makefile include scripts/Makefile.lib ifdef host-progs +ifneq ($(hostprogs-y),$(host-progs)) $(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!) hostprogs-y += $(host-progs) endif +endif # Do not include host rules unles needed ifneq ($(hostprogs-y)$(hostprogs-m),) -- cgit v1.2.3 From a817884fa8bac6867eded68b5acde4fc11ebb98c Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 18 Aug 2004 03:02:08 +0200 Subject: kbuild: make C=2 now force sparse to be run for all .c files With make C=2 sparse ($(CHECK)) will be run on all .c files also if they do not need to be compiled. Usefull to run sparse on a fully compiled kernel tree. Implemented on request from Al Viro (although he liked to be able to run sparse without building any source). Signed-off-by: Sam Ravnborg --- Makefile | 3 ++- scripts/Makefile.build | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 1154e676430d..17606090b9f6 100644 --- a/Makefile +++ b/Makefile @@ -958,7 +958,8 @@ help: @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 $$CHECK (sparse)' + @echo ' make C=2 [targets] Force check of all c source with $$CHECK (sparse)' @echo '' @echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'For further info see the ./README file' diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c48adfe03a73..5204640c4649 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -83,8 +83,13 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ # Linus' kernel sanity checking tool ifneq ($(KBUILD_CHECKSRC),0) -quiet_cmd_checksrc = CHECK $< - cmd_checksrc = $(CHECK) $(c_flags) $< ; + ifeq ($(KBUILD_CHECKSRC),2) + quiet_cmd_force_checksrc = CHECK $< + cmd_force_checksrc = $(CHECK) $(c_flags) $< ; + else + quiet_cmd_checksrc = CHECK $< + cmd_checksrc = $(CHECK) $(c_flags) $< ; + endif endif @@ -182,11 +187,13 @@ endef # Built-in and composite module parts %.o: %.c FORCE + $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) $(single-used-m): %.o: %.c FORCE + $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) -- cgit v1.2.3 From d300a25d4a2c395e4d6cc55284142542cbb78140 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 18 Aug 2004 04:02:40 +0200 Subject: fix warnings in scripts/binoffset.c Correct gcc warnings for function return type, printf argument types, and signed/unsigned compare. Cross-compiled with no warnings/errors for alpha, ia64, ppc32, ppc64, sparc32, sparc64, x86_64, and native on i386. (-W -Wall) [pre-built tool chains are available from: http://developer.osdl.org/dev/plm/cross_compile/ ] Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/binoffset.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/binoffset.c b/scripts/binoffset.c index 7b8100d8e106..591309d85518 100644 --- a/scripts/binoffset.c +++ b/scripts/binoffset.c @@ -41,7 +41,7 @@ char *progname; char *inputname; int inputfd; -int bix; /* buf index */ +unsigned int bix; /* buf index */ unsigned char patterns [PAT_SIZE] = {0}; /* byte-sized pattern array */ int pat_len; /* actual number of pattern bytes */ unsigned char *madr; /* mmap address */ @@ -58,7 +58,7 @@ void usage (void) exit (1); } -int get_pattern (int pat_count, char *pats []) +void get_pattern (int pat_count, char *pats []) { int ix, err, tmp; @@ -81,7 +81,7 @@ int get_pattern (int pat_count, char *pats []) pat_len = pat_count; } -int search_pattern (void) +void search_pattern (void) { for (bix = 0; bix < filesize; bix++) { if (madr[bix] == patterns[0]) { @@ -109,7 +109,7 @@ size_t get_filesize (int fd) struct stat stat; err = fstat (fd, &stat); - fprintf (stderr, "filesize: %d\n", err < 0 ? err : stat.st_size); + fprintf (stderr, "filesize: %ld\n", err < 0 ? (long)err : stat.st_size); if (err < 0) return err; return (size_t) stat.st_size; @@ -154,8 +154,8 @@ int main (int argc, char *argv []) fprintf (stderr, "number of pattern matches = %d\n", num_matches); if (num_matches == 0) firstloc = ~0; - printf ("%d\n", firstloc); - fprintf (stderr, "%d\n", firstloc); + printf ("%ld\n", firstloc); + fprintf (stderr, "%ld\n", firstloc); exit (num_matches ? 0 : 2); } -- cgit v1.2.3 From ada1bab4401a9fd3a76b498f0c461133b658559b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 19 Aug 2004 03:05:28 +0200 Subject: kbuild: Remove check for undefined symbols in vmlinux Russell King reported that some gcc / bin-utils combination may result in undefined symbols in vmlinux and implemented a check for that. Though the cause is very valid this check has proved to be a real pain for other users, especially sparc and um. Short term a similar check is asked to be implemented in arch/arm*/Makefile and long-term to bail out if too old gcc / bin-utils is used. Long term plan awaits a new gcc / bin-utils release. Signed-off-by: Sam Ravnborg --- scripts/mksysmap | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'scripts') diff --git a/scripts/mksysmap b/scripts/mksysmap index 279fb9214aa0..2904d3b383ed 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -3,27 +3,10 @@ # System.map is used by module-init tools and some debugging # tools to retreive the actual addresses of symbols in the kernel. # -# Before creating the System.map file as a sideeffect check for -# undefined symbols. -# At least one version of the ARM bin-utils did not error out on -# undefined symbols, so catch them here instead. - # Usage # mksysmap vmlinux System.map -##### -# Check for undefined symbols. -# Undefined symbols with three leading underscores are ignored since -# they are used by the sparc BTFIXUP logic - and is assumed to be undefined. - - -if [ "`$NM -u $1 | grep -v ' ___'`" != "" ]; then - echo "$1: error: undefined symbol(s) found:" - $NM -u $1 | grep -v ' ___' - exit 1 -fi - ##### # Generate System.map (actual filename passed as second argument) -- cgit v1.2.3 From f5ce51c635d17d0e03e18400bc57b591df2712ca Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 19 Aug 2004 03:17:03 +0200 Subject: kbuild: add comments to Makefile.clean Chris Wedgwood wrote: > P.S. I'd love to see the rules in scripts/Makefile.* documented. I > would offer a patch for this but I don't understand the rules > myself... And provided the following patch, slightly modified by me. Signed-off-by: Sam Ravnborg --- scripts/Makefile.clean | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index ab73032fc773..b02ab1fb28e3 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -29,13 +29,25 @@ subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) # Add subdir path subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) + +# build a list of files to remove, usually releative to the current +# directory + __clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) \ $(targets) $(clean-files) \ $(host-progs) \ $(hostprogs-y) $(hostprogs-m) $(hostprogs-) + +# as clean-files is given relative to the current directory, this adds +# a $(obj) prefix, except for absolute paths + __clean-files := $(wildcard \ $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \ $(filter /%, $(__clean-files))) + +# as clean-dirs is given relative to the current directory, this adds +# a $(obj) prefix, except for absolute paths + __clean-dirs := $(wildcard \ $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \ $(filter /%, $(clean-dirs))) -- cgit v1.2.3 From f9a71d169c02064bf27d6be4993fee555c35c244 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 19 Aug 2004 03:31:32 +0200 Subject: kbuild/all archs: added CHECKFLAGS Using separate assignment for CHECKFLAGS allows convenient redefinition of CHECK on the command line: make CHECK=~/bin64/sparse C=2 to use a special 64 bit version. Introduced usage in all archs that assined values to CHECK. Signed-off-by: Sam Ravnborg --- Makefile | 3 ++- arch/alpha/Makefile | 2 +- arch/arm/Makefile | 2 +- arch/i386/Makefile | 2 +- arch/m68k/Makefile | 2 +- arch/ppc/Makefile | 2 +- arch/ppc64/Makefile | 2 +- arch/sparc/Makefile | 2 +- arch/sparc64/Makefile | 2 +- arch/x86_64/Makefile | 2 +- scripts/Makefile.build | 4 ++-- 11 files changed, 13 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 48445b2193eb..5a13059cd523 100644 --- a/Makefile +++ b/Makefile @@ -285,6 +285,7 @@ DEPMOD = /sbin/depmod KALLSYMS = scripts/kallsyms PERL = perl CHECK = sparse +CHECKFLAGS := MODFLAGS = -DMODULE CFLAGS_MODULE = $(MODFLAGS) AFLAGS_MODULE = $(MODFLAGS) @@ -308,7 +309,7 @@ AFLAGS := -D__ASSEMBLY__ export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ 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 CHECKFLAGS export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile index 0337f5f0d444..f63d72e08d97 100644 --- a/arch/alpha/Makefile +++ b/arch/alpha/Makefile @@ -11,7 +11,7 @@ NM := $(NM) -B LDFLAGS_vmlinux := -static -N #-relax -CHECK := $(CHECK) -D__alpha__=1 +CHECKFLAGS += -D__alpha__=1 cflags-y := -pipe -mno-fp-regs -ffixed-8 # Determine if we can use the BWX instructions with GAS. diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 3de505deb709..9a3aab7b84c2 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -58,7 +58,7 @@ tune-$(CONFIG_CPU_V6) :=-mtune=strongarm CFLAGS +=-mapcs-32 $(arch-y) $(tune-y) $(call check_gcc,-malignment-traps,-mshort-load-bytes) -msoft-float -Wa,-mno-fpu -Uarm AFLAGS +=-mapcs-32 $(arch-y) $(tune-y) -msoft-float -Wa,-mno-fpu -CHECK := $(CHECK) -D__arm__=1 +CHECKFLAGS += -D__arm__=1 #Default value DATAADDR := . diff --git a/arch/i386/Makefile b/arch/i386/Makefile index 1e446b2340a5..4a46f01adf34 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -18,7 +18,7 @@ LDFLAGS := -m elf_i386 OBJCOPYFLAGS := -O binary -R .note -R .comment -S LDFLAGS_vmlinux := -CHECK := $(CHECK) -D__i386__=1 +CHECKFLAGS += -D__i386__=1 CFLAGS += -pipe -msoft-float diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index bc79771e8953..5eb62709887a 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -28,7 +28,7 @@ ifdef CONFIG_SUN3 LDFLAGS_vmlinux = -N endif -CHECK := $(CHECK) -D__mc68000__=1 -I$(shell $(CC) -print-file-name=include) +CHECKFLAGS += -D__mc68000__=1 -I$(shell $(CC) -print-file-name=include) # without -fno-strength-reduce the 53c7xx.c driver fails ;-( CFLAGS += -pipe -fno-strength-reduce -ffixed-a2 diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile index 0cac2da3f94a..92307d7dcf20 100644 --- a/arch/ppc/Makefile +++ b/arch/ppc/Makefile @@ -27,7 +27,7 @@ CFLAGS += -Iarch/$(ARCH) -msoft-float -pipe \ -ffixed-r2 -Wno-uninitialized -mmultiple CPP = $(CC) -E $(CFLAGS) -CHECK := $(CHECK) -D__powerpc__=1 +CHECKFLAGS += -D__powerpc__=1 ifndef CONFIG_E500 CFLAGS += -mstring diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile index 10c1d6299eee..9b58c6644ff1 100644 --- a/arch/ppc64/Makefile +++ b/arch/ppc64/Makefile @@ -22,7 +22,7 @@ LD := $(LD) -m elf64ppc CC := $(CC) -m64 endif -CHECK := $(CHECK) -m64 -D__powerpc__=1 +CHECKFLAGS += -m64 -D__powerpc__=1 LDFLAGS := -m elf64ppc LDFLAGS_vmlinux := -Bstatic -e $(KERNELLOAD) -Ttext $(KERNELLOAD) diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index 15fcf89e1402..8852935b4f8b 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile @@ -13,7 +13,7 @@ AS := $(AS) -32 LDFLAGS := -m elf32_sparc -CHECK := $(CHECK) -D__sparc__=1 +CHECKFLAGS += -D__sparc__=1 #CFLAGS := $(CFLAGS) -g -pipe -fcall-used-g5 -fcall-used-g7 CFLAGS := $(CFLAGS) -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 diff --git a/arch/sparc64/Makefile b/arch/sparc64/Makefile index d34e500b63fc..49c59a1ad3a4 100644 --- a/arch/sparc64/Makefile +++ b/arch/sparc64/Makefile @@ -8,7 +8,7 @@ # Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) # -CHECK := $(CHECK) -D__sparc__=1 -D__sparc_v9__=1 +CHECKFLAGS += -D__sparc__=1 -D__sparc_v9__=1 CPPFLAGS_vmlinux.lds += -Usparc diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile index 9b9a504efa55..3e685634e0d3 100644 --- a/arch/x86_64/Makefile +++ b/arch/x86_64/Makefile @@ -37,7 +37,7 @@ LDFLAGS := -m elf_x86_64 OBJCOPYFLAGS := -O binary -R .note -R .comment -S LDFLAGS_vmlinux := -e stext -CHECK := $(CHECK) -D__x86_64__=1 +CHECKFLAGS += -D__x86_64__=1 cflags-$(CONFIG_MK8) += $(call check_gcc,-march=k8,) cflags-$(CONFIG_MPSC) += $(call check_gcc,-march=nocona,) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5204640c4649..21cb20586b47 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -85,10 +85,10 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ ifneq ($(KBUILD_CHECKSRC),0) ifeq ($(KBUILD_CHECKSRC),2) quiet_cmd_force_checksrc = CHECK $< - cmd_force_checksrc = $(CHECK) $(c_flags) $< ; + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; else quiet_cmd_checksrc = CHECK $< - cmd_checksrc = $(CHECK) $(c_flags) $< ; + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; endif endif -- cgit v1.2.3 From a2c665b04fb8acd2de0216cf38215ef11904fbcd Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 23 Aug 2004 02:39:01 +0200 Subject: scripts/patch-kernel: use EXTRAVERSION Update 'scripts/patch-kernel' to support EXTRAVERSION. Update usage message text. Fix some whitespace. Handle command line arg3 (stop-version) more carefully. No changes to -ac patch updates. EXTRAVERSION handling: any leading '.' and any trailing modifier (beginning with any punctuation, like "-ac" or "_kexec" or "+mm") are stripped, trying to get down to just a number. Then 'patch-kernel' increments EXTRAVERSION as long as it can apply "patch-V.P.S.X*". When that file isn't found, it resets EXTRAVERSION to "" and increments SUBLEVEL (as before this patch). Works for me. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/patch-kernel | 113 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 29 deletions(-) (limited to 'scripts') diff --git a/scripts/patch-kernel b/scripts/patch-kernel index 3f316b6c4d9c..43af01075612 100755 --- a/scripts/patch-kernel +++ b/scripts/patch-kernel @@ -40,17 +40,24 @@ # # Added -ac option, use -ac or -ac9 (say) to stop at a particular version # Dave Gilbert , 29th September 2001. +# +# Add support for (use of) EXTRAVERSION (to support 2.6.8.x, e.g.); +# update usage message; +# fix some whitespace damage; +# be smarter about stopping when current version is larger than requested; +# Randy Dunlap , 2004-AUG-18. # Set directories from arguments, or use defaults. sourcedir=${1-/usr/src/linux} patchdir=${2-.} -stopvers=${3-imnotaversion} +stopvers=${3-default} -if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then +if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then cat << USAGE usage: patch-kernel [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] - The source directory defaults to /usr/src/linux, and - the patch directory defaults to the current directory. + source directory defaults to /usr/src/linux, + patch directory defaults to the current directory, + stopversion defaults to . USAGE exit 1 fi @@ -77,7 +84,7 @@ findFile () { uncomp="gunzip -dc" elif [ -r ${filebase}.bz ]; then ext=".bz" - name="bzip" + name="bzip" uncomp="bunzip -dc" elif [ -r ${filebase}.bz2 ]; then ext=".bz2" @@ -96,8 +103,8 @@ findFile () { name="plaintext" uncomp="cat" else - return 1; - fi + return 1; + fi return 0; } @@ -126,48 +133,100 @@ applyPatch () { return 0; } -# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTERVERSION -eval `sed -n -e 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' -e 's/^\([A-Z]*\) = \(-[-a-z0-9]*\)$/\1=\2/p' $sourcedir/Makefile` +# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION +TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } +grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE +tr -d [:blank:] < $TMPFILE > $TMPFILE.1 +source $TMPFILE.1 +rm -f $TMPFILE* if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] then echo "unable to determine current kernel version" >&2 exit 1 fi -echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION}" +NAME=`grep ^NAME $sourcedir/Makefile` +NAME=${NAME##*=} +echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($NAME)" + +# strip EXTRAVERSION to just a number (drop leading '.' and trailing additions) +EXTRAVER= if [ x$EXTRAVERSION != "x" ] then - echo "I'm sorry but patch-kernel can't work with a kernel source tree that is not a base version" - exit 1; + if [ ${EXTRAVERSION:0:1} == "." ]; then + EXTRAVER=${EXTRAVERSION:1} + else + EXTRAVER=$EXTRAVERSION + fi + EXTRAVER=${EXTRAVER%%[[:punct:]]*} + #echo "patch-kernel: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER" +fi + +#echo "stopvers=$stopvers" +if [ $stopvers != "default" ]; then + STOPSUBLEVEL=`echo $stopvers | cut -d. -f3` + STOPEXTRA=`echo $stopvers | cut -d. -f4` + #echo "STOPSUBLEVEL=$STOPSUBLEVEL, STOPEXTRA=$STOPEXTRA" +else + STOPSUBLEVEL=9999 + STOPEXTRA=9999 fi -while : +while : # incrementing SUBLEVEL (s in v.p.s) do - CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" - if [ $stopvers = $CURRENTFULLVERSION ] - then - echo "Stoping at $CURRENTFULLVERSION base as requested." + if [ x$EXTRAVER != "x" ]; then + CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER" + else + CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" + fi + + if [ $stopvers == $CURRENTFULLVERSION ]; then + echo "Stopping at $CURRENTFULLVERSION base as requested." break fi - SUBLEVEL=`expr $SUBLEVEL + 1` + while : # incrementing EXTRAVER (x in v.p.s.x) + do + EXTRAVER=$((EXTRAVER + 1)) + FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER" + #echo "... trying $FULLVERSION ..." + + patch=patch-$FULLVERSION + + # See if the file exists and find extension + findFile $patchdir/${patch} || break + + # Apply the patch and check all is OK + applyPatch $patch || break + + continue 2 + done + + EXTRAVER= + SUBLEVEL=$((SUBLEVEL + 1)) FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" + #echo "___ trying $FULLVERSION ___" + + if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then + echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)" + exit 1 + fi patch=patch-$FULLVERSION - # See if the file exists and find extension - findFile $patchdir/${patch} || break + # See if the file exists and find extension + findFile $patchdir/${patch} || break # Apply the patch and check all is OK applyPatch $patch || break done +#echo "base all done" if [ x$gotac != x ]; then # Out great user wants the -ac patches # They could have done -ac (get latest) or -acxx where xx=version they want - if [ $gotac == "-ac" ] - then + if [ $gotac == "-ac" ]; then # They want the latest version HIGHESTPATCH=0 for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.* @@ -176,18 +235,16 @@ if [ x$gotac != x ]; then # Check it is actually a recognised patch type findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${ACVALUE} || break - if [ $ACVALUE -gt $HIGHESTPATCH ] - then + if [ $ACVALUE -gt $HIGHESTPATCH ]; then HIGHESTPATCH=$ACVALUE fi done - if [ $HIGHESTPATCH -ne 0 ] - then + if [ $HIGHESTPATCH -ne 0 ]; then findFile $patchdir/patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} || break applyPatch patch-${CURRENTFULLVERSION}-ac${HIGHESTPATCH} else - echo "No ac patches found" + echo "No -ac patches found" fi else # They want an exact version @@ -198,5 +255,3 @@ if [ x$gotac != x ]; then applyPatch patch-${CURRENTFULLVERSION}${gotac} fi fi - - -- cgit v1.2.3