History

Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild

Pull misc kbuild updates from Michal Marek: "Non-critical kbuild changes: - make coccicheck improvements, but no new semantic patches this time - make rpm improvements - make tar-pkg change to include the architecture in the filename. This is a deliberate incompatibility, but nobody has complained so far and it is useful if you build for different architectures. It also matches what the deb-pkg and rpm-pkg targets produce. - kbuild documentation fix" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: rpm-pkg: Remove pointless set -e statements rpm-pkg: Always regenerate the specfile rpm-pkg: Do not write to the parent directory rpm-pkg: Do not package the whole source directory buildtar: Add ARCH to the archive name Coccinelle: Fix patch output when coccicheck is used with M= and C= Coccinelle: Add support to the SPFLAGS variable Coccinelle: Cleanup the setting of the FLAGS and OPTIONS variables Coccinelle: Restore coccicheck verbosity in ONLINE mode (C=1 or C=2) scripts/package/Makefile: compare objtree with srctree instead of test KBUILD_OUTPUT doc: change example to existing Makefile fragment scripts/tags.sh: Add magic for OFFSET and DEFINE

Linus Torvalds committed 13 years ago

Commit b9e306e2 parents 685e56d a0f9c6f7 files · +52 −42Browse files

Unified · Split

7 files
  1. Documentation/coccinelle.txt +10 −1
  2. Documentation/kbuild/makefiles.txt +3 −2
  3. Makefile +2 −0
  4. scripts/coccicheck +18 −13
  5. scripts/package/Makefile +15 −24
  6. scripts/package/buildtar +1 −1
  7. scripts/tags.sh +3 −1
Documentation/coccinelle.txt+10−1
@@ -114,7 +114,7 @@ To apply Coccinelle to a specific directory, M= can be used. · 113 unmodified lines
114For example, to check drivers/net/wireless/ one may write:114For example, to check drivers/net/wireless/ one may write:
115 115
116 make coccicheck M=drivers/net/wireless/116 make coccicheck M=drivers/net/wireless/
117 117
118To apply Coccinelle on a file basis, instead of a directory basis, the118To apply Coccinelle on a file basis, instead of a directory basis, the
119following command may be used:119following command may be used:
120 120
@@ -134,6 +134,15 @@ MODE variable explained above. · 13 unmodified lines
134In this mode, there is no information about semantic patches134In this mode, there is no information about semantic patches
135displayed, and no commit message proposed.135displayed, and no commit message proposed.
136 136
137 Additional flags
138~~~~~~~~~~~~~~~~~~
139
140Additional flags can be passed to spatch through the SPFLAGS
141variable.
142
143 make SPFLAGS=--use_glimpse coccicheck
144
145See spatch --help to learn more about spatch options.
137 146
138 Proposing new semantic patches147 Proposing new semantic patches
139~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~148~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Documentation/kbuild/makefiles.txt+3−2
@@ -921,8 +921,9 @@ When kbuild executes, the following steps are followed (roughly): · 920 unmodified lines
921 Often, the KBUILD_CFLAGS variable depends on the configuration.921 Often, the KBUILD_CFLAGS variable depends on the configuration.
922 922
923 Example:923 Example:
924 #arch/x86/Makefile924 #arch/x86/boot/compressed/Makefile
925 cflags-$(CONFIG_M386) += -march=i386925 cflags-$(CONFIG_X86_32) := -march=i386
926 cflags-$(CONFIG_X86_64) := -mcmodel=small
926 KBUILD_CFLAGS += $(cflags-y)927 KBUILD_CFLAGS += $(cflags-y)
927 928
928 Many arch Makefiles dynamically run the target C compiler to929 Many arch Makefiles dynamically run the target C compiler to
Makefile+2−0
@@ -757,6 +757,8 @@ export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) · 756 unmodified lines
757export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y)757export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y)
758export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds758export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
759export LDFLAGS_vmlinux759export LDFLAGS_vmlinux
760# used by scripts/pacmage/Makefile
761export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools virt)
760 762
761vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)763vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
762 764
scripts/coccicheck+18−13
@@ -1,4 +1,4 @@
1#!/bin/sh1#!/bin/bash
2 2
3SPATCH="`which ${SPATCH:=spatch}`"3SPATCH="`which ${SPATCH:=spatch}`"
4 4
@@ -11,27 +11,32 @@ else · 6 unmodified lines
11 VERBOSE=011 VERBOSE=0
12fi12fi
13 13
14FLAGS="$SPFLAGS -very_quiet"
15
16# spatch only allows include directories with the syntax "-I include"
17# while gcc also allows "-Iinclude" and "-include include"
18COCCIINCLUDE=${LINUXINCLUDE//-I/-I }
19COCCIINCLUDE=${COCCIINCLUDE//-include/-I}
20
14if [ "$C" = "1" -o "$C" = "2" ]; then21if [ "$C" = "1" -o "$C" = "2" ]; then
15 ONLINE=122 ONLINE=1
16 23
17# This requires Coccinelle >= 0.2.324 # Take only the last argument, which is the C file to test
18# FLAGS="-ignore_unknown_options -very_quiet"25 shift $(( $# - 1 ))
19# OPTIONS=$*26 OPTIONS="$COCCIINCLUDE $1"
20
21# Workaround for Coccinelle < 0.2.3
22 FLAGS="-I $srctree/include -very_quiet"
23 shift $(( $# - 1 ))
24 OPTIONS=$1
25else27else
26 ONLINE=028 ONLINE=0
27 FLAGS="-very_quiet"
28 if [ "$KBUILD_EXTMOD" = "" ] ; then29 if [ "$KBUILD_EXTMOD" = "" ] ; then
29 OPTIONS="-dir $srctree"30 OPTIONS="-dir $srctree $COCCIINCLUDE"
30 else31 else
31 OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree -I $srctree/include -I $KBUILD_EXTMOD/include"32 OPTIONS="-dir $KBUILD_EXTMOD $COCCIINCLUDE"
32 fi33 fi
33fi34fi
34 35
36if [ "$KBUILD_EXTMOD" != "" ] ; then
37 OPTIONS="-patch $srctree $OPTIONS"
38fi
39
35if [ ! -x "$SPATCH" ]; then40if [ ! -x "$SPATCH" ]; then
36 echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'41 echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
37 exit 142 exit 1
@@ -72,7 +77,7 @@ coccinelle () { · 34 unmodified lines
72#77#
73# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null78# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
74 79
75 if [ $VERBOSE -ne 0 ] ; then80 if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
76 81
77 FILE=`echo $COCCI | sed "s|$srctree/||"`82 FILE=`echo $COCCI | sed "s|$srctree/||"`
78 83
scripts/package/Makefile+15−24
@@ -27,53 +27,44 @@ RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ · 26 unmodified lines
27 27
28# Remove hyphens since they have special meaning in RPM filenames28# Remove hyphens since they have special meaning in RPM filenames
29KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))29KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
30# Include only those top-level files that are needed by make, plus the GPL copy
31TAR_CONTENT := $(KBUILD_ALLDIRS) kernel.spec .config .scmversion Makefile \
32 Kbuild Kconfig COPYING $(wildcard localversion*)
33TAR_CONTENT := $(addprefix $(KERNELPATH)/,$(TAR_CONTENT))
30MKSPEC := $(srctree)/scripts/package/mkspec34MKSPEC := $(srctree)/scripts/package/mkspec
31PREV := set -e; cd -P ..;
32 35
33# rpm-pkg36# rpm-pkg
34# ---------------------------------------------------------------------------37# ---------------------------------------------------------------------------
35$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile38rpm-pkg rpm: FORCE
36 $(CONFIG_SHELL) $(MKSPEC) > $@39 @if test "$(objtree)" != "$(srctree)"; then \
37
38rpm-pkg rpm: $(objtree)/kernel.spec FORCE
39 @if test -n "$(KBUILD_OUTPUT)"; then \
40 echo "Building source + binary RPM is not possible outside the"; \40 echo "Building source + binary RPM is not possible outside the"; \
41 echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \41 echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
42 echo "binrpm-pkg target instead."; \42 echo "binrpm-pkg target instead."; \
43 false; \43 false; \
44 fi44 fi
45 $(MAKE) clean45 $(MAKE) clean
46 $(PREV) ln -sf $(srctree) $(KERNELPATH)46 ln -sf $(srctree) $(KERNELPATH)
47 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
47 $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion48 $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion
48 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.49 tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(TAR_CONTENT)
49 $(PREV) rm $(KERNELPATH)50 rm $(KERNELPATH)
50 rm -f $(objtree)/.scmversion51 rm -f $(objtree)/.scmversion
51 set -e; \
52 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version52 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
53 set -e; \
54 mv -f $(objtree)/.tmp_version $(objtree)/.version53 mv -f $(objtree)/.tmp_version $(objtree)/.version
55 54 $(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
56 $(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz55 rm $(KERNELPATH).tar.gz kernel.spec
57 rm ../$(KERNELPATH).tar.gz
58
59clean-files := $(objtree)/kernel.spec
60 56
61# binrpm-pkg57# binrpm-pkg
62# ---------------------------------------------------------------------------58# ---------------------------------------------------------------------------
63$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile59binrpm-pkg: FORCE
64 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
65
66binrpm-pkg: $(objtree)/binkernel.spec FORCE
67 $(MAKE) KBUILD_SRC=60 $(MAKE) KBUILD_SRC=
68 set -e; \61 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
69 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version62 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
70 set -e; \
71 mv -f $(objtree)/.tmp_version $(objtree)/.version63 mv -f $(objtree)/.tmp_version $(objtree)/.version
72 64
73 $(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \65 $(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \
74 $(UTS_MACHINE) -bb $<66 $(UTS_MACHINE) -bb $<
75 67 rm binkernel.spec
76clean-files += $(objtree)/binkernel.spec
77 68
78# Deb target69# Deb target
79# ---------------------------------------------------------------------------70# ---------------------------------------------------------------------------
scripts/package/buildtar+1−1
@@ -16,7 +16,7 @@ set -e · 15 unmodified lines
16# Some variables and settings used throughout the script16# Some variables and settings used throughout the script
17#17#
18tmpdir="${objtree}/tar-install"18tmpdir="${objtree}/tar-install"
19tarball="${objtree}/linux-${KERNELRELEASE}.tar"19tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
20 20
21 21
22#22#
scripts/tags.sh+3−1
@@ -199,7 +199,9 @@ exuberant() · 198 unmodified lines
199 --regex-c='/DEFINE_PER_CPU_SHARED_ALIGNED\(([^,]*,\s*)(\w*).*\)/\2/v/' \199 --regex-c='/DEFINE_PER_CPU_SHARED_ALIGNED\(([^,]*,\s*)(\w*).*\)/\2/v/' \
200 --regex-c='/DECLARE_WAIT_QUEUE_HEAD\((\w*)/\1/v/' \200 --regex-c='/DECLARE_WAIT_QUEUE_HEAD\((\w*)/\1/v/' \
201 --regex-c='/DECLARE_(TASKLET|WORK|DELAYED_WORK)\((\w*)/\2/v/' \201 --regex-c='/DECLARE_(TASKLET|WORK|DELAYED_WORK)\((\w*)/\2/v/' \
202 --regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/'202 --regex-c='/DEFINE_PCI_DEVICE_TABLE\((\w*)/\1/v/' \
203 --regex-c='/(^\s)OFFSET\((\w*)/\2/v/' \
204 --regex-c='/(^\s)DEFINE\((\w*)/\2/v/'
203 205
204 all_kconfigs | xargs $1 -a \206 all_kconfigs | xargs $1 -a \
205 --langdef=kconfig --language-force=kconfig \207 --langdef=kconfig --language-force=kconfig \