Commit 4f628248a578585472e19e4cba2c604643af8c6c

Authored by Jike Song
Committed by Sam Ravnborg
1 parent 40c8c85a47

kbuild: reintroduce ALLSOURCE_ARCHS support for tags/cscope

This patch reintroduce the ALLSOURCE_ARCHS support for tags/TAGS/
cscope targets. The Kbuild previously has this feature, but after
moving the targets into scripts/tags.sh, ALLSOURCE_ARCHS disappears.

It's something like this:

	$ make ALLSOURCE_ARCHS="x86 mips arm" tags cscope

Signed-off-by: Jike Song <albcamus@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 2 changed files with 20 additions and 5 deletions Inline Diff

Documentation/kbuild/kbuild.txt
1 Environment variables 1 Environment variables
2 2
3 KCPPFLAGS 3 KCPPFLAGS
4 -------------------------------------------------- 4 --------------------------------------------------
5 Additional options to pass when preprocessing. The preprocessing options 5 Additional options to pass when preprocessing. The preprocessing options
6 will be used in all cases where kbuild do preprocessing including 6 will be used in all cases where kbuild do preprocessing including
7 building C files and assembler files. 7 building C files and assembler files.
8 8
9 KAFLAGS 9 KAFLAGS
10 -------------------------------------------------- 10 --------------------------------------------------
11 Additional options to the assembler. 11 Additional options to the assembler.
12 12
13 KCFLAGS 13 KCFLAGS
14 -------------------------------------------------- 14 --------------------------------------------------
15 Additional options to the C compiler. 15 Additional options to the C compiler.
16 16
17 KBUILD_VERBOSE 17 KBUILD_VERBOSE
18 -------------------------------------------------- 18 --------------------------------------------------
19 Set the kbuild verbosity. Can be assinged same values as "V=...". 19 Set the kbuild verbosity. Can be assinged same values as "V=...".
20 See make help for the full list. 20 See make help for the full list.
21 Setting "V=..." takes precedence over KBUILD_VERBOSE. 21 Setting "V=..." takes precedence over KBUILD_VERBOSE.
22 22
23 KBUILD_EXTMOD 23 KBUILD_EXTMOD
24 -------------------------------------------------- 24 --------------------------------------------------
25 Set the directory to look for the kernel source when building external 25 Set the directory to look for the kernel source when building external
26 modules. 26 modules.
27 The directory can be specified in several ways: 27 The directory can be specified in several ways:
28 1) Use "M=..." on the command line 28 1) Use "M=..." on the command line
29 2) Environmnet variable KBUILD_EXTMOD 29 2) Environmnet variable KBUILD_EXTMOD
30 3) Environmnet variable SUBDIRS 30 3) Environmnet variable SUBDIRS
31 The possibilities are listed in the order they take precedence. 31 The possibilities are listed in the order they take precedence.
32 Using "M=..." will always override the others. 32 Using "M=..." will always override the others.
33 33
34 KBUILD_OUTPUT 34 KBUILD_OUTPUT
35 -------------------------------------------------- 35 --------------------------------------------------
36 Specify the output directory when building the kernel. 36 Specify the output directory when building the kernel.
37 The output directory can also be specificed using "O=...". 37 The output directory can also be specificed using "O=...".
38 Setting "O=..." takes precedence over KBUILD_OUTPUT 38 Setting "O=..." takes precedence over KBUILD_OUTPUT
39 39
40 ARCH 40 ARCH
41 -------------------------------------------------- 41 --------------------------------------------------
42 Set ARCH to the architecture to be built. 42 Set ARCH to the architecture to be built.
43 In most cases the name of the architecture is the same as the 43 In most cases the name of the architecture is the same as the
44 directory name found in the arch/ directory. 44 directory name found in the arch/ directory.
45 But some architectures suach as x86 and sparc has aliases. 45 But some architectures suach as x86 and sparc has aliases.
46 x86: i386 for 32 bit, x86_64 for 64 bit 46 x86: i386 for 32 bit, x86_64 for 64 bit
47 sparc: sparc for 32 bit, sparc64 for 64 bit 47 sparc: sparc for 32 bit, sparc64 for 64 bit
48 48
49 CROSS_COMPILE 49 CROSS_COMPILE
50 -------------------------------------------------- 50 --------------------------------------------------
51 Specify an optional fixed part of the binutils filename. 51 Specify an optional fixed part of the binutils filename.
52 CROSS_COMPILE can be a part of the filename or the full path. 52 CROSS_COMPILE can be a part of the filename or the full path.
53 53
54 CROSS_COMPILE is also used for ccache is some setups. 54 CROSS_COMPILE is also used for ccache is some setups.
55 55
56 CF 56 CF
57 -------------------------------------------------- 57 --------------------------------------------------
58 Additional options for sparse. 58 Additional options for sparse.
59 CF is often used on the command-line like this: 59 CF is often used on the command-line like this:
60 60
61 make CF=-Wbitwise C=2 61 make CF=-Wbitwise C=2
62 62
63 INSTALL_PATH 63 INSTALL_PATH
64 -------------------------------------------------- 64 --------------------------------------------------
65 INSTALL_PATH specifies where to place the updated kernel and system map 65 INSTALL_PATH specifies where to place the updated kernel and system map
66 images. Default is /boot, but you can set it to other values 66 images. Default is /boot, but you can set it to other values
67 67
68 68
69 MODLIB 69 MODLIB
70 -------------------------------------------------- 70 --------------------------------------------------
71 Specify where to install modules. 71 Specify where to install modules.
72 The default value is: 72 The default value is:
73 73
74 $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 74 $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
75 75
76 The value can be overridden in which case the default value is ignored. 76 The value can be overridden in which case the default value is ignored.
77 77
78 INSTALL_MOD_PATH 78 INSTALL_MOD_PATH
79 -------------------------------------------------- 79 --------------------------------------------------
80 INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 80 INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
81 relocations required by build roots. This is not defined in the 81 relocations required by build roots. This is not defined in the
82 makefile but the argument can be passed to make if needed. 82 makefile but the argument can be passed to make if needed.
83 83
84 INSTALL_MOD_STRIP 84 INSTALL_MOD_STRIP
85 -------------------------------------------------- 85 --------------------------------------------------
86 INSTALL_MOD_STRIP, if defined, will cause modules to be 86 INSTALL_MOD_STRIP, if defined, will cause modules to be
87 stripped after they are installed. If INSTALL_MOD_STRIP is '1', then 87 stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
88 the default option --strip-debug will be used. Otherwise, 88 the default option --strip-debug will be used. Otherwise,
89 INSTALL_MOD_STRIP will used as the options to the strip command. 89 INSTALL_MOD_STRIP will used as the options to the strip command.
90 90
91 INSTALL_FW_PATH 91 INSTALL_FW_PATH
92 -------------------------------------------------- 92 --------------------------------------------------
93 INSTALL_FW_PATH specify where to install the firmware blobs. 93 INSTALL_FW_PATH specify where to install the firmware blobs.
94 The default value is: 94 The default value is:
95 95
96 $(INSTALL_MOD_PATH)/lib/firmware 96 $(INSTALL_MOD_PATH)/lib/firmware
97 97
98 The value can be overridden in which case the default value is ignored. 98 The value can be overridden in which case the default value is ignored.
99 99
100 INSTALL_HDR_PATH 100 INSTALL_HDR_PATH
101 -------------------------------------------------- 101 --------------------------------------------------
102 INSTALL_HDR_PATH specify where to install user space headers when 102 INSTALL_HDR_PATH specify where to install user space headers when
103 executing "make headers_*". 103 executing "make headers_*".
104 The default value is: 104 The default value is:
105 105
106 $(objtree)/usr 106 $(objtree)/usr
107 107
108 $(objtree) is the directory where output files are saved. 108 $(objtree) is the directory where output files are saved.
109 The output directory is often set using "O=..." on the commandline. 109 The output directory is often set using "O=..." on the commandline.
110 110
111 The value can be overridden in which case the default value is ignored. 111 The value can be overridden in which case the default value is ignored.
112 112
113 KBUILD_MODPOST_WARN 113 KBUILD_MODPOST_WARN
114 -------------------------------------------------- 114 --------------------------------------------------
115 KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined 115 KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
116 symbols in the final module linking stage. 116 symbols in the final module linking stage.
117 117
118 KBUILD_MODPOST_FINAL 118 KBUILD_MODPOST_FINAL
119 -------------------------------------------------- 119 --------------------------------------------------
120 KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. 120 KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
121 This is solely usefull to speed up test compiles. 121 This is solely usefull to speed up test compiles.
122 122
123 KBUILD_EXTRA_SYMBOLS 123 KBUILD_EXTRA_SYMBOLS
124 -------------------------------------------------- 124 --------------------------------------------------
125 For modules use symbols from another modules. 125 For modules use symbols from another modules.
126 See more details in modules.txt. 126 See more details in modules.txt.
127
128 ALLSOURCE_ARCHS
129 --------------------------------------------------
130 For tags/TAGS/cscope targets, you can specify more than one archs
131 to be included in the databases, separated by blankspace. e.g.
132
133 $ make ALLSOURCE_ARCHS="x86 mips arm" tags
127 134
1 #!/bin/sh 1 #!/bin/sh
2 # Generate tags or cscope files 2 # Generate tags or cscope files
3 # Usage tags.sh <mode> 3 # Usage tags.sh <mode>
4 # 4 #
5 # mode may be any of: tags, TAGS, cscope 5 # mode may be any of: tags, TAGS, cscope
6 # 6 #
7 # Uses the following environment variables: 7 # Uses the following environment variables:
8 # ARCH, SUBARCH, srctree, src, obj 8 # ARCH, SUBARCH, srctree, src, obj
9 9
10 if [ "$KBUILD_VERBOSE" = "1" ]; then 10 if [ "$KBUILD_VERBOSE" = "1" ]; then
11 set -x 11 set -x
12 fi 12 fi
13 13
14 # This is a duplicate of RCS_FIND_IGNORE without escaped '()' 14 # This is a duplicate of RCS_FIND_IGNORE without escaped '()'
15 ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ 15 ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
16 -name CVS -o -name .pc -o -name .hg -o \ 16 -name CVS -o -name .pc -o -name .hg -o \
17 -name .git ) \ 17 -name .git ) \
18 -prune -o" 18 -prune -o"
19 19
20 # Do not use full path is we do not use O=.. builds 20 # Do not use full path is we do not use O=.. builds
21 if [ "${KBUILD_SRC}" = "" ]; then 21 if [ "${KBUILD_SRC}" = "" ]; then
22 tree= 22 tree=
23 else 23 else
24 tree=${srctree}/ 24 tree=${srctree}/
25 fi 25 fi
26 26
27 # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
28 if [ "${ALLSOURCE_ARCHS}" = "" ]; then
29 ALLSOURCE_ARCHS=${SRCARCH}
30 fi
31
27 # find sources in arch/$ARCH 32 # find sources in arch/$ARCH
28 find_arch_sources() 33 find_arch_sources()
29 { 34 {
30 find ${tree}arch/$1 $ignore -name "$2" -print; 35 find ${tree}arch/$1 $ignore -name "$2" -print;
31 } 36 }
32 37
33 # find sources in arch/$1/include 38 # find sources in arch/$1/include
34 find_arch_include_sources() 39 find_arch_include_sources()
35 { 40 {
36 find ${tree}arch/$1/include $ignore -name "$2" -print; 41 find ${tree}arch/$1/include $ignore -name "$2" -print;
37 } 42 }
38 43
39 # find sources in include/ 44 # find sources in include/
40 find_include_sources() 45 find_include_sources()
41 { 46 {
42 find ${tree}include $ignore -name config -prune -o -name "$1" -print; 47 find ${tree}include $ignore -name config -prune -o -name "$1" -print;
43 } 48 }
44 49
45 # find sources in rest of tree 50 # find sources in rest of tree
46 # we could benefit from a list of dirs to search in here 51 # we could benefit from a list of dirs to search in here
47 find_other_sources() 52 find_other_sources()
48 { 53 {
49 find ${tree}* $ignore \ 54 find ${tree}* $ignore \
50 \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ 55 \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
51 -name "$1" -print; 56 -name "$1" -print;
52 } 57 }
53 58
54 find_sources() 59 find_sources()
55 { 60 {
56 find_arch_sources $1 "$2" 61 find_arch_sources $1 "$2"
57 find_include_sources "$2"
58 find_other_sources "$2"
59 } 62 }
60 63
61 all_sources() 64 all_sources()
62 { 65 {
63 find_sources $SRCARCH '*.[chS]' 66 for arch in $ALLSOURCE_ARCHS
67 do
68 find_sources $arch '*.[chS]'
69 done
64 if [ ! -z "$archinclude" ]; then 70 if [ ! -z "$archinclude" ]; then
65 find_arch_include_sources $archinclude '*.[chS]' 71 find_arch_include_sources $archinclude '*.[chS]'
66 fi 72 fi
73 find_include_sources '*.[chS]'
74 find_other_sources '*.[chS]'
67 } 75 }
68 76
69 all_kconfigs() 77 all_kconfigs()
70 { 78 {
71 find_sources $SRCARCH 'Kconfig*' 79 find_sources $ALLSOURCE_ARCHS 'Kconfig*'
72 } 80 }
73 81
74 all_defconfigs() 82 all_defconfigs()
75 { 83 {
76 find_sources $SRCARCH "defconfig" 84 find_sources $ALLSOURCE_ARCHS "defconfig"
77 } 85 }
78 86
79 docscope() 87 docscope()
80 { 88 {
81 (echo \-k; echo \-q; all_sources) > cscope.files 89 (echo \-k; echo \-q; all_sources) > cscope.files
82 cscope -b -f cscope.out 90 cscope -b -f cscope.out
83 } 91 }
84 92
85 exuberant() 93 exuberant()
86 { 94 {
87 all_sources | xargs $1 -a \ 95 all_sources | xargs $1 -a \
88 -I __initdata,__exitdata,__acquires,__releases \ 96 -I __initdata,__exitdata,__acquires,__releases \
89 -I __read_mostly,____cacheline_aligned \ 97 -I __read_mostly,____cacheline_aligned \
90 -I ____cacheline_aligned_in_smp \ 98 -I ____cacheline_aligned_in_smp \
91 -I ____cacheline_internodealigned_in_smp \ 99 -I ____cacheline_internodealigned_in_smp \
92 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 100 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
93 --extra=+f --c-kinds=+px \ 101 --extra=+f --c-kinds=+px \
94 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' 102 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'
95 103
96 all_kconfigs | xargs $1 -a \ 104 all_kconfigs | xargs $1 -a \
97 --langdef=kconfig --language-force=kconfig \ 105 --langdef=kconfig --language-force=kconfig \
98 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' 106 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'
99 107
100 all_kconfigs | xargs $1 -a \ 108 all_kconfigs | xargs $1 -a \
101 --langdef=kconfig --language-force=kconfig \ 109 --langdef=kconfig --language-force=kconfig \
102 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' 110 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/'
103 111
104 all_defconfigs | xargs -r $1 -a \ 112 all_defconfigs | xargs -r $1 -a \
105 --langdef=dotconfig --language-force=dotconfig \ 113 --langdef=dotconfig --language-force=dotconfig \
106 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' 114 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
107 115
108 } 116 }
109 117
110 emacs() 118 emacs()
111 { 119 {
112 all_sources | xargs $1 -a 120 all_sources | xargs $1 -a
113 121
114 all_kconfigs | xargs $1 -a \ 122 all_kconfigs | xargs $1 -a \
115 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' 123 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
116 124
117 all_kconfigs | xargs $1 -a \ 125 all_kconfigs | xargs $1 -a \
118 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' 126 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/'
119 127
120 all_defconfigs | xargs -r $1 -a \ 128 all_defconfigs | xargs -r $1 -a \
121 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' 129 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'
122 } 130 }
123 131
124 xtags() 132 xtags()
125 { 133 {
126 if $1 --version 2>&1 | grep -iq exuberant; then 134 if $1 --version 2>&1 | grep -iq exuberant; then
127 exuberant $1 135 exuberant $1
128 elif $1 --version 2>&1 | grep -iq emacs; then 136 elif $1 --version 2>&1 | grep -iq emacs; then
129 emacs $1 137 emacs $1
130 else 138 else
131 all_sources | xargs $1 -a 139 all_sources | xargs $1 -a
132 fi 140 fi
133 } 141 }
134 142
135 143
136 # Support um (which uses SUBARCH) 144 # Support um (which uses SUBARCH)
137 if [ "${ARCH}" = "um" ]; then 145 if [ "${ARCH}" = "um" ]; then
138 if [ "$SUBARCH" = "i386" ]; then 146 if [ "$SUBARCH" = "i386" ]; then
139 archinclude=x86 147 archinclude=x86
140 elif [ "$SUBARCH" = "x86_64" ]; then 148 elif [ "$SUBARCH" = "x86_64" ]; then
141 archinclude=x86 149 archinclude=x86
142 else 150 else
143 archinclude=${SUBARCH} 151 archinclude=${SUBARCH}
144 fi 152 fi
145 fi 153 fi
146 154
147 case "$1" in 155 case "$1" in
148 "cscope") 156 "cscope")
149 docscope 157 docscope
150 ;; 158 ;;
151 159
152 "tags") 160 "tags")
153 xtags ctags 161 xtags ctags
154 ;; 162 ;;
155 163
156 "TAGS") 164 "TAGS")
157 xtags etags 165 xtags etags
158 ;; 166 ;;