* [PATCH 1/8] kbuild: expand -I in KBUILD_CPPFLAGS
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 2/8] kbuild: kill output in silent mode of mkcompile_h Sam Ravnborg
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Sam Ravnborg
kbuild failed to expand include flags in KBUILD_CPPFLAGS
resulting in code like this in arch Makefiles:
ifeq ($(KBUILD_SRC),)
KBUILD_CPPFLAGS += -Iinclude/foo
else
KBUILD_CPPFLAGS += -I$(srctree)/include/foo
endif
Move use of LINUXINCLUDE into Makefile.lib to allow
us to expand -I directives of KBUILD_CPPFLAGS so
we can avoid the above code.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
Makefile | 2 +-
scripts/Makefile.lib | 15 ++++++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 7b1f238..54720a5 100644
--- a/Makefile
+++ b/Makefile
@@ -336,7 +336,7 @@ LINUXINCLUDE := -Iinclude \
-I$(srctree)/arch/$(hdr-arch)/include \
-include include/linux/autoconf.h
-KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
+KBUILD_CPPFLAGS :=
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b4ca38a..b8a67ec 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -104,9 +104,11 @@ else
debug_flags =
endif
-orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
+orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
+ $(ccflags-y) $(CFLAGS_$(basetarget).o)
_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
-_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
+_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
+ $(asflags-y) $(AFLAGS_$(basetarget).o)
_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
# If building the kernel in a separate objtree expand all occurrences
@@ -127,15 +129,18 @@ __a_flags = $(call flags,_a_flags)
__cpp_flags = $(call flags,_cpp_flags)
endif
-c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
+c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) \
+ -D__KERNEL__ $(LINUXINCLUDE) \
$(__c_flags) $(modkern_cflags) \
-D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \
$(debug_flags)
-a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
+a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) \
+ -D__KERNEL__ $(LINUXINCLUDE) \
$(__a_flags) $(modkern_aflags)
-cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
+cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) \
+ -D__KERNEL__ $(LINUXINCLUDE) $(__cpp_flags)
ld_flags = $(LDFLAGS) $(ldflags-y)
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 2/8] kbuild: kill output in silent mode of mkcompile_h
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
2008-11-24 20:54 ` [PATCH 1/8] kbuild: expand -I in KBUILD_CPPFLAGS Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 3/8] kbuild: introduce $(kecho) convenience echo Sam Ravnborg
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Mike Frysinger, Sam Ravnborg
From: Mike Frysinger <vapier@gentoo.org>
The mkcompile_h script does `echo` regardless of silent mode the make is
running at, so have it respect $quiet from kbuild and only echo when not in
silent mode.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
scripts/mkcompile_h | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index a8740df..6a12dd9 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -4,6 +4,8 @@ SMP=$3
PREEMPT=$4
CC=$5
+vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
+
# If compile.h exists already and we don't own autoconf.h
# (i.e. we're not the same user who did make *config), don't
# modify compile.h
@@ -11,7 +13,7 @@ CC=$5
# do "compiled by root"
if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then
- echo " SKIPPED $TARGET"
+ vecho " SKIPPED $TARGET"
exit 0
fi
@@ -89,7 +91,7 @@ if [ -r $TARGET ] && \
cmp -s .tmpver.1 .tmpver.2; then
rm -f .tmpcompile
else
- echo " UPD $TARGET"
+ vecho " UPD $TARGET"
mv -f .tmpcompile $TARGET
fi
rm -f .tmpver.1 .tmpver.2
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 3/8] kbuild: introduce $(kecho) convenience echo
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
2008-11-24 20:54 ` [PATCH 1/8] kbuild: expand -I in KBUILD_CPPFLAGS Sam Ravnborg
2008-11-24 20:54 ` [PATCH 2/8] kbuild: kill output in silent mode of mkcompile_h Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 4/8] kbuild: use KECHO " Sam Ravnborg
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Mike Frysinger, Sam Ravnborg
From: Mike Frysinger <vapier@gentoo.org>
There is a bunch of places in the build system where we do 'echo' to show
some nice status lines. This means we still get output when running in
silent mode. So declare a new KECHO variable that only does 'echo' when we
are in a suitable verbose build mode.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
[sam: added Documentation]
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
Documentation/kbuild/makefiles.txt | 14 ++++++++++++++
scripts/Kbuild.include | 7 +++++++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 7a77533..51104f9 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -383,6 +383,20 @@ more details, with real examples.
to prerequisites are referenced with $(src) (because they are not
generated files).
+ $(kecho)
+ echoing information to user in a rule is often a good practice
+ but when execution "make -s" one does not expect to see any output
+ except for warnings/errors.
+ To support this kbuild define $(kecho) which will echo out the
+ text following $(kecho) to stdout except if "make -s" is used.
+
+ Example:
+ #arch/blackfin/boot/Makefile
+ $(obj)/vmImage: $(obj)/vmlinux.gz
+ $(call if_changed,uimage)
+ @$(kecho) 'Kernel: $@ is ready'
+
+
--- 3.11 $(CC) support functions
The kernel may be built with several different versions of
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 982dcae..e637e28 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -25,6 +25,13 @@ basetarget = $(basename $(notdir $@))
escsq = $(subst $(squote),'\$(squote)',$1)
###
+# Easy method for doing a status message
+ kecho := :
+ quiet_kecho := echo
+silent_kecho := :
+kecho := $($(quiet)kecho)
+
+###
# filechk is used to check if the content of a generated file is updated.
# Sample usage:
# define filechk_sample
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 4/8] kbuild: use KECHO convenience echo
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
` (2 preceding siblings ...)
2008-11-24 20:54 ` [PATCH 3/8] kbuild: introduce $(kecho) convenience echo Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 5/8] kbuild: teach mkmakfile to be silent Sam Ravnborg
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Mike Frysinger, Sam Ravnborg
From: Mike Frysinger <vapier@gentoo.org>
Convert a few echos in the build system to new $(kecho) so we get correct
output according to build verbosity.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
[sam: added kecho in a few more places for O=... builds]
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
Makefile | 8 ++++----
arch/blackfin/boot/Makefile | 2 +-
scripts/Kbuild.include | 11 ++---------
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/Makefile b/Makefile
index 54720a5..391b2da 100644
--- a/Makefile
+++ b/Makefile
@@ -926,7 +926,7 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
# 2) Create the include2 directory, used for the second asm symlink
prepare3: include/config/kernel.release
ifneq ($(KBUILD_SRC),)
- @echo ' Using $(srctree) as source for kernel'
+ @$(kecho) ' Using $(srctree) as source for kernel'
$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
echo " $(srctree) is not clean, please run 'make mrproper'";\
echo " in the '$(srctree)' directory.";\
@@ -983,7 +983,7 @@ endef
# directory for generated filesas used by some architectures.
define create-symlink
if [ ! -L include/asm ]; then \
- echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
+ $(kecho) ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
if [ ! -d include/asm-$(SRCARCH) ]; then \
mkdir -p include/asm-$(SRCARCH); \
fi; \
@@ -1096,7 +1096,7 @@ all: modules
PHONY += modules
modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
- @echo ' Building modules, stage 2.';
+ @$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
@@ -1360,7 +1360,7 @@ $(module-dirs): crmodverdir $(objtree)/Module.symvers
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
modules: $(module-dirs)
- @echo ' Building modules, stage 2.';
+ @$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
PHONY += modules_install
diff --git a/arch/blackfin/boot/Makefile b/arch/blackfin/boot/Makefile
index 522f3c1..e028d13 100644
--- a/arch/blackfin/boot/Makefile
+++ b/arch/blackfin/boot/Makefile
@@ -25,7 +25,7 @@ $(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
$(obj)/vmImage: $(obj)/vmlinux.gz
$(call if_changed,uimage)
- @echo 'Kernel: $@ is ready'
+ @$(kecho) 'Kernel: $@ is ready'
install:
sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index e637e28..2cf1516 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -46,22 +46,15 @@ kecho := $($(quiet)kecho)
# - If they are equal no change, and no timestamp update
# - stdin is piped in from the first prerequisite ($<) so one has
# to specify a valid file as first prerequisite (often the kbuild file)
- chk_filechk = :
- quiet_chk_filechk = echo ' CHK $@'
-silent_chk_filechk = :
- upd_filechk = :
- quiet_upd_filechk = echo ' UPD $@'
-silent_upd_filechk = :
-
define filechk
$(Q)set -e; \
- $($(quiet)chk_filechk); \
+ $(kecho) ' CHK $@'; \
mkdir -p $(dir $@); \
$(filechk_$(1)) < $< > $@.tmp; \
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \
else \
- $($(quiet)upd_filechk); \
+ $(kecho) ' UPD $@'; \
mv -f $@.tmp $@; \
fi
endef
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 5/8] kbuild: teach mkmakfile to be silent
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
` (3 preceding siblings ...)
2008-11-24 20:54 ` [PATCH 4/8] kbuild: use KECHO " Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 6/8] remove bashisms from scripts/extract-ikconfig Sam Ravnborg
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Sam Ravnborg
With this fix a "make -s" is now really silent
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
scripts/mkmakefile | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index e65d8b3..67d59c7 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -17,7 +17,9 @@ if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
then
exit 0
fi
-echo " GEN $2/Makefile"
+if [ "${quiet}" != "silent_" ]; then
+ echo " GEN $2/Makefile"
+fi
cat << EOF > $2/Makefile
# Automatically generated by $0: don't edit
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 6/8] remove bashisms from scripts/extract-ikconfig
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
` (4 preceding siblings ...)
2008-11-24 20:54 ` [PATCH 5/8] kbuild: teach mkmakfile to be silent Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 7/8] kbuild: gen_init_cpio expands shell variables in file names Sam Ravnborg
2008-11-24 20:54 ` [PATCH 8/8] kbuild: move tags support to a shell script Sam Ravnborg
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Werner Almesberger, Sam Ravnborg
From: Werner Almesberger <werner@openmoko.org>
unbashify-extract-ikconfig.patch
scripts/extract-ikconfig contains a lot of gratuituous bashisms,
which make it fail if /bin/sh isn't bash. This patch replaces them
with regular Bourne shell constructs.
Signed-off-by: Werner Almesberger <werner@openmoko.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com> # as file author
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
| 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
--git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index 8187e6f..72997c3 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -8,8 +8,8 @@ test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
-function dump_config {
- typeset file="$1"
+dump_config() {
+ file="$1"
start=`$binoffset $file $IKCFG_ST 2>/dev/null`
[ "$?" != "0" ] && start="-1"
@@ -18,8 +18,8 @@ function dump_config {
fi
end=`$binoffset $file $IKCFG_ED 2>/dev/null`
- let start="$start + 8"
- let size="$end - $start"
+ start=`expr $start + 8`
+ size=`expr $end - $start`
dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 7/8] kbuild: gen_init_cpio expands shell variables in file names
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
` (5 preceding siblings ...)
2008-11-24 20:54 ` [PATCH 6/8] remove bashisms from scripts/extract-ikconfig Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 20:54 ` [PATCH 8/8] kbuild: move tags support to a shell script Sam Ravnborg
7 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Sally, Gene, gene.sally, Sam Ravnborg
From: Sally, Gene <Gene.Sally@timesys.com>
Modify gen_init_cpio so that lines that specify files can contain
what looks like a shell variable that's expanded during processing.
For example:
file /sbin/kinit ${RFS_BASE}/usr/src/klibc/kinit/kinit 0755 0 0
given RFS_BASE is "/some/directory" in the environment
would be expanded to
file /sbin/kinit /some/directory/usr/src/klibc/kinit/kinit 0755 0 0
If several environment variables appear in a line, they are all expanded
with processing happening from left to right.
Undefined variables expand to a null string.
Syntax errors stop processing, letting the existing error handling
show the user offending line.
This patch helps embedded folks who frequently create several
RFS directories and then switch between them as they're tuning
an initramfs.
Signed-off-by: gene.sally@timesys.com
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
usr/gen_init_cpio.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index 7abc07f..f1d3fe3 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -370,6 +370,30 @@ error:
return rc;
}
+static char *cpio_replace_env(char *new_location)
+{
+ char expanded[PATH_MAX + 1];
+ char env_var[PATH_MAX + 1];
+ char *start;
+ char *end;
+
+ for (start = NULL; (start = strstr(new_location, "${")); ) {
+ end = strchr(start, '}');
+ if (start < end) {
+ *env_var = *expanded = '\0';
+ strncat(env_var, start + 2, end - start - 2);
+ strncat(expanded, new_location, start - new_location);
+ strncat(expanded, getenv(env_var), PATH_MAX);
+ strncat(expanded, end + 1, PATH_MAX);
+ strncpy(new_location, expanded, PATH_MAX);
+ } else
+ break;
+ }
+
+ return new_location;
+}
+
+
static int cpio_mkfile_line(const char *line)
{
char name[PATH_MAX + 1];
@@ -415,7 +439,8 @@ static int cpio_mkfile_line(const char *line)
} else {
dname = name;
}
- rc = cpio_mkfile(dname, location, mode, uid, gid, nlinks);
+ rc = cpio_mkfile(dname, cpio_replace_env(location),
+ mode, uid, gid, nlinks);
fail:
if (dname_len) free(dname);
return rc;
@@ -439,6 +464,7 @@ void usage(const char *prog)
"\n"
"<name> name of the file/dir/nod/etc in the archive\n"
"<location> location of the file in the current filesystem\n"
+ " expands shell variables quoted with ${}\n"
"<target> link target\n"
"<mode> mode/permissions of the file\n"
"<uid> user id (0=root)\n"
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 8/8] kbuild: move tags support to a shell script
2008-11-24 20:51 [GIT] kbuild patches Sam Ravnborg
` (6 preceding siblings ...)
2008-11-24 20:54 ` [PATCH 7/8] kbuild: gen_init_cpio expands shell variables in file names Sam Ravnborg
@ 2008-11-24 20:54 ` Sam Ravnborg
2008-11-24 22:07 ` Ian Campbell
7 siblings, 1 reply; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-24 20:54 UTC (permalink / raw)
To: lkml, kbuild; +Cc: Sam Ravnborg, Alexey Dobriyan
tags and cscope support really belongs in a shell script
as they do not benefit from the make functionality.
Moving the support to a shell script has several benefits:
- The readability of the code has increased a lot
- More people is able to extend the tags support
- We see less changes to the top-level Makefile
The shell script version includes improvements from:
Alexey Dobriyan <adobriyan@gmail.com> (jump to kconfig symbols)
Ian Campbell <ijc@hellion.org.uk> (simplified find algorithms)
This version has a few caveats:
=> It does not support ALLSOURCE_ARCHS
- it is easy to add if it is really used
=> It assumes all archs have moved to arch/$ARCH/include
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Tested-by: Ian Campbell <ijc@hellion.org.uk>
---
Makefile | 117 +------------------------------------------
scripts/tags.sh | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 150 insertions(+), 114 deletions(-)
create mode 100644 scripts/tags.sh
diff --git a/Makefile b/Makefile
index 391b2da..483c36d 100644
--- a/Makefile
+++ b/Makefile
@@ -1409,123 +1409,12 @@ endif # KBUILD_EXTMOD
# Generate tags for editors
# ---------------------------------------------------------------------------
+quiet_cmd_tags = GEN $@
+ cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
-#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
-#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
-#Adding $(srctree) adds about 20M on i386 to the size of the output file!
-
-ifeq ($(src),$(obj))
-__srctree =
-else
-__srctree = $(srctree)/
-endif
-
-ifeq ($(ALLSOURCE_ARCHS),)
-ifeq ($(ARCH),um)
-ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
-else
-ALLINCLUDE_ARCHS := $(SRCARCH)
-endif
-else
-#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
-ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
-endif
-
-ALLSOURCE_ARCHS := $(SRCARCH)
-
-define find-sources
- ( for arch in $(ALLSOURCE_ARCHS) ; do \
- find $(__srctree)arch/$${arch} $(RCS_FIND_IGNORE) \
- -wholename $(__srctree)arch/$${arch}/include/asm -type d -prune \
- -o -name $1 -print; \
- done ; \
- find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
- -name $1 -print; \
- find $(__srctree)include $(RCS_FIND_IGNORE) \
- \( -name config -o -name 'asm-*' \) -prune \
- -o -name $1 -print; \
- for arch in $(ALLINCLUDE_ARCHS) ; do \
- test -e $(__srctree)include/asm-$${arch} && \
- find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
- -name $1 -print; \
- test -e $(__srctree)arch/$${arch}/include/asm && \
- find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
- -name $1 -print; \
- done ; \
- find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
- -name $1 -print; \
- find $(__srctree) $(RCS_FIND_IGNORE) \
- \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
- -name $1 -print; \
- )
-endef
-
-define all-sources
- $(call find-sources,'*.[chS]')
-endef
-define all-kconfigs
- $(call find-sources,'Kconfig*')
-endef
-define all-defconfigs
- $(call find-sources,'defconfig')
-endef
-
-define xtags
- if $1 --version 2>&1 | grep -iq exuberant; then \
- $(all-sources) | xargs $1 -a \
- -I __initdata,__exitdata,__acquires,__releases \
- -I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \
- -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
- --extra=+f --c-kinds=+px \
- --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \
- $(all-kconfigs) | xargs $1 -a \
- --langdef=kconfig \
- --language-force=kconfig \
- --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'; \
- $(all-defconfigs) | xargs -r $1 -a \
- --langdef=dotconfig \
- --language-force=dotconfig \
- --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
- elif $1 --version 2>&1 | grep -iq emacs; then \
- $(all-sources) | xargs $1 -a; \
- $(all-kconfigs) | xargs $1 -a \
- --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'; \
- $(all-defconfigs) | xargs -r $1 -a \
- --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
- else \
- $(all-sources) | xargs $1 -a; \
- fi
-endef
-
-quiet_cmd_cscope-file = FILELST cscope.files
- cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
-
-quiet_cmd_cscope = MAKE cscope.out
- cmd_cscope = cscope -b -f cscope.out
-
-cscope: FORCE
- $(call cmd,cscope-file)
- $(call cmd,cscope)
-
-quiet_cmd_TAGS = MAKE $@
-define cmd_TAGS
- rm -f $@; \
- $(call xtags,etags)
-endef
-
-TAGS: FORCE
- $(call cmd,TAGS)
-
-quiet_cmd_tags = MAKE $@
-define cmd_tags
- rm -f $@; \
- $(call xtags,ctags)
-endef
-
-tags: FORCE
+tags TAGS cscope: FORCE
$(call cmd,tags)
-
# Scripts to check various things for consistency
# ---------------------------------------------------------------------------
diff --git a/scripts/tags.sh b/scripts/tags.sh
new file mode 100644
index 0000000..5db7c54
--- /dev/null
+++ b/scripts/tags.sh
@@ -0,0 +1,147 @@
+#!/bin/sh
+# Generate tags or cscope files
+# Usage tags.sh <mode>
+#
+# mode may be any of: tags, TAGS, cscope
+#
+# Uses the following environment variables:
+# ARCH, SUBARCH, srctree, src, obj
+
+# This is a duplicate of RCS_FIND_IGNORE without escaped '()'
+ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
+ -name CVS -o -name .pc -o -name .hg -o \
+ -name .git ) \
+ -prune -o"
+
+# Do not use full path is we do not use O=.. builds
+if [ ${src} == ${obj} ]; then
+ tree=
+else
+ tree=${srctree}
+fi
+
+# find sources in arch/$ARCH
+find_arch_sources()
+{
+ find ${tree}arch/$1 $ignore -name $2 -print;
+}
+
+# find sources in include/
+find_include_sources()
+{
+ find ${tree}include $ignore -name config -prune -o -name $1 -print;
+}
+
+# find sources in rest of tree
+# we could benefit from a list of dirs to search in here
+find_other_sources()
+{
+ find ${tree}* $ignore \
+ \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
+ -name $1 -print;
+}
+
+find_sources()
+{
+ for arch in $1; do
+ find_arch_sources $arch $2
+ done
+
+ find_include_sources "$2"
+ find_other_sources "$2"
+}
+
+all_sources()
+{
+ find_sources "${archs}" *.[chS]
+}
+
+all_kconfigs()
+{
+ find_sources "${archs}" "Kconfig*"
+}
+
+all_defconfigs()
+{
+ find_sources "${archs}" "defconfig"
+}
+
+docscope()
+{
+ (echo \-k; echo \-q; all_sources) > cscope.files
+ cscope -b -f cscope.out
+}
+
+exuberant()
+{
+ all_sources > all
+ all_sources | xargs $1 -a \
+ -I __initdata,__exitdata,__acquires,__releases \
+ -I __read_mostly,____cacheline_aligned \
+ -I ____cacheline_aligned_in_smp \
+ -I ____cacheline_internodealigned_in_smp \
+ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
+ --extra=+f --c-kinds=+px \
+ --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'
+
+ all_kconfigs | xargs $1 -a \
+ --langdef=kconfig --language-force=kconfig \
+ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'
+
+ all_kconfigs | xargs $1 -a \
+ --langdef=kconfig --language-force=kconfig \
+ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/'
+
+ all_defconfigs | xargs -r $1 -a \
+ --langdef=dotconfig --language-force=dotconfig \
+ --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
+
+}
+
+emacs()
+{
+ all_sources | xargs $1 -a
+
+ all_kconfigs | xargs $1 -a \
+ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
+
+ all_kconfigs | xargs $1 -a \
+ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/'
+
+ all_defconfigs | xargs -r $1 -a \
+ --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'
+}
+
+xtags()
+{
+ if $1 --version 2>&1 | grep -iq exuberant; then
+ exuberant $1
+ elif $1 --version 2>&1 | grep -iq emacs; then
+ emacs $1
+ else
+ all_sources | xargs $1 -a
+ fi
+}
+
+
+# Support um (which has SUBARCH)
+# FIXME: add support for ALLSOURCE_ARCHS if really used
+if [ "${ARCH}" == "${SUBARCH}" ]; then
+ archs="${ARCH} ${SUBARCH}"
+else
+ archs="${SRCARCH}"
+fi
+
+case "$1" in
+ "cscope")
+ docscope
+ ;;
+
+ "tags")
+ xtags ctags
+ ;;
+
+ "TAGS")
+ xtags etags
+ ;;
+esac
--
1.5.6.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 8/8] kbuild: move tags support to a shell script
2008-11-24 20:54 ` [PATCH 8/8] kbuild: move tags support to a shell script Sam Ravnborg
@ 2008-11-24 22:07 ` Ian Campbell
2008-11-24 23:16 ` Jeff Dike
2008-11-25 9:46 ` Sam Ravnborg
0 siblings, 2 replies; 12+ messages in thread
From: Ian Campbell @ 2008-11-24 22:07 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: lkml, kbuild, Alexey Dobriyan
[-- Attachment #1: Type: text/plain, Size: 856 bytes --]
On Mon, 2008-11-24 at 21:54 +0100, Sam Ravnborg wrote:
>
> +# Support um (which has SUBARCH)
> +# FIXME: add support for ALLSOURCE_ARCHS if really used
> +if [ "${ARCH}" == "${SUBARCH}" ]; then
> + archs="${ARCH} ${SUBARCH}"
> +else
> + archs="${SRCARCH}"
> +fi
I've never used um but is this conditional backwards? If ${ARCH} ==
${SUBARCH} then archs="${ARCH} ${SUBARCH}" is equivalent to archs="
${ARCH} ${ARCH}", isn't it?
I'm not quite sure I understand the distinction between ARCH, SRCARCH
and SUBARCH either but is it expected that for ARCH=um, SUBARCH will be
i386/x86_64 or x86? I think it's the former in which case I'd expect
these days nothing will be found in arch/i386 or arch/x86_64? is a
SRCSUBARCH required?
Ian.
--
Ian Campbell
To do two things at once is to do neither.
-- Publilius Syrus
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 8/8] kbuild: move tags support to a shell script
2008-11-24 22:07 ` Ian Campbell
@ 2008-11-24 23:16 ` Jeff Dike
2008-11-25 9:46 ` Sam Ravnborg
1 sibling, 0 replies; 12+ messages in thread
From: Jeff Dike @ 2008-11-24 23:16 UTC (permalink / raw)
To: Ian Campbell; +Cc: Sam Ravnborg, lkml, kbuild, Alexey Dobriyan
On Mon, Nov 24, 2008 at 10:07:14PM +0000, Ian Campbell wrote:
> I'm not quite sure I understand the distinction between ARCH, SRCARCH
> and SUBARCH either but is it expected that for ARCH=um, SUBARCH will be
> i386/x86_64 or x86?
Yes, this is for UML to be able to tell what the underlying arch is.
Jeff
--
Work email - jdike at linux dot intel dot com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 8/8] kbuild: move tags support to a shell script
2008-11-24 22:07 ` Ian Campbell
2008-11-24 23:16 ` Jeff Dike
@ 2008-11-25 9:46 ` Sam Ravnborg
1 sibling, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-11-25 9:46 UTC (permalink / raw)
To: Ian Campbell; +Cc: lkml, kbuild, Alexey Dobriyan
On Mon, Nov 24, 2008 at 10:07:14PM +0000, Ian Campbell wrote:
> On Mon, 2008-11-24 at 21:54 +0100, Sam Ravnborg wrote:
> >
> > +# Support um (which has SUBARCH)
> > +# FIXME: add support for ALLSOURCE_ARCHS if really used
> > +if [ "${ARCH}" == "${SUBARCH}" ]; then
> > + archs="${ARCH} ${SUBARCH}"
> > +else
> > + archs="${SRCARCH}"
> > +fi
>
> I've never used um but is this conditional backwards? If ${ARCH} ==
> ${SUBARCH} then archs="${ARCH} ${SUBARCH}" is equivalent to archs="
> ${ARCH} ${ARCH}", isn't it?
It is buggy.
>
> I'm not quite sure I understand the distinction between ARCH, SRCARCH
> and SUBARCH either but is it expected that for ARCH=um, SUBARCH will be
> i386/x86_64 or x86? I think it's the former in which case I'd expect
> these days nothing will be found in arch/i386 or arch/x86_64? is a
> SRCSUBARCH required?
Something like that. But we only need to include headers for the
relavant SUBARCH. I will give it a closer look.
Sam
^ permalink raw reply [flat|nested] 12+ messages in thread