aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include13
-rw-r--r--scripts/Makefile.build4
-rw-r--r--scripts/Makefile.modpost2
-rw-r--r--scripts/bloat-o-meter58
-rw-r--r--scripts/kconfig/Makefile8
-rw-r--r--scripts/kconfig/conf.c18
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/gconf.c2
-rw-r--r--scripts/kconfig/lxdialog/Makefile51
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh84
-rw-r--r--scripts/kconfig/mconf.c2
-rw-r--r--scripts/kconfig/qconf.h6
-rw-r--r--scripts/kconfig/symbol.c4
-rwxr-xr-xscripts/kernel-doc92
-rw-r--r--scripts/mksysmap2
-rw-r--r--scripts/mod/file2alias.c4
-rw-r--r--scripts/mod/modpost.c9
-rw-r--r--scripts/reference_discarded.pl6
-rw-r--r--scripts/setlocalversion68
19 files changed, 274 insertions, 161 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index db3c708e546b..0168d6c37075 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -3,6 +3,7 @@
3 3
4# Convinient variables 4# Convinient variables
5comma := , 5comma := ,
6squote := '
6empty := 7empty :=
7space := $(empty) $(empty) 8space := $(empty) $(empty)
8 9
@@ -12,6 +13,10 @@ space := $(empty) $(empty)
12depfile = $(subst $(comma),_,$(@D)/.$(@F).d) 13depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
13 14
14### 15###
16# Escape single quote for use in echo statements
17escsq = $(subst $(squote),'\$(squote)',$1)
18
19###
15# filechk is used to check if the content of a generated file is updated. 20# filechk is used to check if the content of a generated file is updated.
16# Sample usage: 21# Sample usage:
17# define filechk_sample 22# define filechk_sample
@@ -47,7 +52,7 @@ build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
47 52
48# If quiet is set, only print short version of command 53# If quiet is set, only print short version of command
49cmd = @$(if $($(quiet)cmd_$(1)),\ 54cmd = @$(if $($(quiet)cmd_$(1)),\
50 echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1)) 55 echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
51 56
52# Add $(obj)/ for paths that is not absolute 57# Add $(obj)/ for paths that is not absolute
53objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) 58objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -68,7 +73,7 @@ endif
68 73
69# echo command. Short version is $(quiet) equals quiet, otherwise full command 74# echo command. Short version is $(quiet) equals quiet, otherwise full command
70echo-cmd = $(if $($(quiet)cmd_$(1)), \ 75echo-cmd = $(if $($(quiet)cmd_$(1)), \
71 echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) 76 echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
72 77
73# function to only execute the passed command if necessary 78# function to only execute the passed command if necessary
74# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file 79# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
@@ -78,7 +83,7 @@ if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
78 @set -e; \ 83 @set -e; \
79 $(echo-cmd) \ 84 $(echo-cmd) \
80 $(cmd_$(1)); \ 85 $(cmd_$(1)); \
81 echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd) 86 echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
82 87
83# execute the command and also postprocess generated .d dependencies 88# execute the command and also postprocess generated .d dependencies
84# file 89# file
@@ -87,7 +92,7 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
87 @set -e; \ 92 @set -e; \
88 $(echo-cmd) \ 93 $(echo-cmd) \
89 $(cmd_$(1)); \ 94 $(cmd_$(1)); \
90 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ 95 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
91 rm -f $(depfile); \ 96 rm -f $(depfile); \
92 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) 97 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
93 98
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 506e3f3befe3..c33e62bde6b0 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -179,10 +179,10 @@ endif
179define rule_cc_o_c 179define rule_cc_o_c
180 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ 180 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \
181 $(cmd_checksrc) \ 181 $(cmd_checksrc) \
182 $(if $($(quiet)cmd_cc_o_c),echo ' $(subst ','\'',$($(quiet)cmd_cc_o_c))';) \ 182 $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \
183 $(cmd_cc_o_c); \ 183 $(cmd_cc_o_c); \
184 $(cmd_modversions) \ 184 $(cmd_modversions) \
185 scripts/basic/fixdep $(depfile) $@ '$(subst ','\'',$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \ 185 scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \
186 rm -f $(depfile); \ 186 rm -f $(depfile); \
187 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd 187 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
188endef 188endef
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 0c4f3a9f2ea9..bf96a61d4b86 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -30,7 +30,7 @@
30# - See include/linux/module.h for more details 30# - See include/linux/module.h for more details
31 31
32# Step 4 is solely used to allow module versioning in external modules, 32# Step 4 is solely used to allow module versioning in external modules,
33# where the CRC of each module is retreived from the Module.symers file. 33# where the CRC of each module is retrieved from the Module.symers file.
34 34
35.PHONY: _modpost 35.PHONY: _modpost
36_modpost: __modpost 36_modpost: __modpost
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
new file mode 100644
index 000000000000..75f21d843c1d
--- /dev/null
+++ b/scripts/bloat-o-meter
@@ -0,0 +1,58 @@
1#!/usr/bin/python
2#
3# Copyright 2004 Matt Mackall <mpm@selenic.com>
4#
5# inspired by perl Bloat-O-Meter (c) 1997 by Andi Kleen
6#
7# This software may be used and distributed according to the terms
8# of the GNU General Public License, incorporated herein by reference.
9
10import sys, os, re
11
12if len(sys.argv) != 3:
13 sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
14 sys.exit(-1)
15
16def getsizes(file):
17 sym = {}
18 for l in os.popen("nm --size-sort " + file).readlines():
19 size, type, name = l[:-1].split()
20 if type in "tTdDbB":
21 sym[name] = int(size, 16)
22 return sym
23
24old = getsizes(sys.argv[1])
25new = getsizes(sys.argv[2])
26grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
27delta, common = [], {}
28
29for a in old:
30 if a in new:
31 common[a] = 1
32
33for name in old:
34 if name not in common:
35 remove += 1
36 down += old[name]
37 delta.append((-old[name], name))
38
39for name in new:
40 if name not in common:
41 add += 1
42 up += new[name]
43 delta.append((new[name], name))
44
45for name in common:
46 d = new.get(name, 0) - old.get(name, 0)
47 if d>0: grow, up = grow+1, up+d
48 if d<0: shrink, down = shrink+1, down-d
49 delta.append((d, name))
50
51delta.sort()
52delta.reverse()
53
54print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
55 (add, remove, grow, shrink, up, -down, up-down)
56print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")
57for d, n in delta:
58 if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 3d7f1ac9e00c..5760e057ecba 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -133,8 +133,8 @@ HOSTCFLAGS_zconf.tab.o := -I$(src)
133HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl 133HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
134HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK 134HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
135 135
136HOSTLOADLIBES_gconf = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --libs` 136HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
137HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \ 137HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
138 -D LKC_DIRECT_LINK 138 -D LKC_DIRECT_LINK
139 139
140$(obj)/qconf.o: $(obj)/.tmp_qtcheck 140$(obj)/qconf.o: $(obj)/.tmp_qtcheck
@@ -193,8 +193,8 @@ ifeq ($(gconf-target),1)
193 193
194# GTK needs some extra effort, too... 194# GTK needs some extra effort, too...
195$(obj)/.tmp_gtkcheck: 195$(obj)/.tmp_gtkcheck:
196 @if `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --exists`; then \ 196 @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \
197 if `pkg-config gtk+-2.0 --atleast-version=2.0.0`; then \ 197 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
198 touch $@; \ 198 touch $@; \
199 else \ 199 else \
200 echo "*"; \ 200 echo "*"; \
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 8ba5d29d3d42..10eeae53d827 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -63,6 +63,20 @@ static void check_stdin(void)
63 } 63 }
64} 64}
65 65
66static char *fgets_check_stream(char *s, int size, FILE *stream)
67{
68 char *ret = fgets(s, size, stream);
69
70 if (ret == NULL && feof(stream)) {
71 printf(_("aborted!\n\n"));
72 printf(_("Console input is closed. "));
73 printf(_("Run 'make oldconfig' to update configuration.\n\n"));
74 exit(1);
75 }
76
77 return ret;
78}
79
66static void conf_askvalue(struct symbol *sym, const char *def) 80static void conf_askvalue(struct symbol *sym, const char *def)
67{ 81{
68 enum symbol_type type = sym_get_type(sym); 82 enum symbol_type type = sym_get_type(sym);
@@ -100,7 +114,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
100 check_stdin(); 114 check_stdin();
101 case ask_all: 115 case ask_all:
102 fflush(stdout); 116 fflush(stdout);
103 fgets(line, 128, stdin); 117 fgets_check_stream(line, 128, stdin);
104 return; 118 return;
105 case set_default: 119 case set_default:
106 printf("%s\n", def); 120 printf("%s\n", def);
@@ -356,7 +370,7 @@ static int conf_choice(struct menu *menu)
356 check_stdin(); 370 check_stdin();
357 case ask_all: 371 case ask_all:
358 fflush(stdout); 372 fflush(stdout);
359 fgets(line, 128, stdin); 373 fgets_check_stream(line, 128, stdin);
360 strip(line); 374 strip(line);
361 if (line[0] == '?') { 375 if (line[0] == '?') {
362 printf("\n%s\n", menu->sym->help ? 376 printf("\n%s\n", menu->sym->help ?
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ccd45130c482..b0cbbe2e41bb 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -375,7 +375,7 @@ int conf_write(const char *name)
375 if (!out_h) 375 if (!out_h)
376 return 1; 376 return 1;
377 } 377 }
378 sym = sym_lookup("KERNELRELEASE", 0); 378 sym = sym_lookup("KERNELVERSION", 0);
379 sym_calc_value(sym); 379 sym_calc_value(sym);
380 time(&now); 380 time(&now);
381 env = getenv("KCONFIG_NOTIMESTAMP"); 381 env = getenv("KCONFIG_NOTIMESTAMP");
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 9f5aabd58fa9..665bd5300a19 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -276,7 +276,7 @@ void init_main_window(const gchar * glade_file)
276 NULL); 276 NULL);
277 277
278 sprintf(title, _("Linux Kernel v%s Configuration"), 278 sprintf(title, _("Linux Kernel v%s Configuration"),
279 getenv("KERNELRELEASE")); 279 getenv("KERNELVERSION"));
280 gtk_window_set_title(GTK_WINDOW(main_wnd), title); 280 gtk_window_set_title(GTK_WINDOW(main_wnd), title);
281 281
282 gtk_widget_show(main_wnd); 282 gtk_widget_show(main_wnd);
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile
index a45a13fb26ed..bbf4887cff74 100644
--- a/scripts/kconfig/lxdialog/Makefile
+++ b/scripts/kconfig/lxdialog/Makefile
@@ -1,42 +1,21 @@
1HOST_EXTRACFLAGS := -DLOCALE 1# Makefile to build lxdialog package
2ifeq ($(shell uname),SunOS) 2#
3HOST_LOADLIBES := -lcurses
4else
5HOST_LOADLIBES := -lncurses
6endif
7 3
8ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) 4check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
9 HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" 5
10else 6# Use reursively expanded variables so we do not call gcc unless
11ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) 7# we really need to do so. (Do not call gcc as part of make mrproper)
12 HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>" 8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
13else 9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
14ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) 10
15 HOST_EXTRACFLAGS += -DCURSES_LOC="<ncurses.h>" 11HOST_EXTRACFLAGS += -DLOCALE
16else 12
17 HOST_EXTRACFLAGS += -DCURSES_LOC="<curses.h>" 13.PHONY: dochecklxdialog
18endif 14$(obj)/dochecklxdialog:
19endif 15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
20endif
21 16
22hostprogs-y := lxdialog 17hostprogs-y := lxdialog
23always := ncurses $(hostprogs-y) 18always := $(hostprogs-y) dochecklxdialog
24 19
25lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ 20lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \
26 util.o lxdialog.o msgbox.o 21 util.o lxdialog.o msgbox.o
27
28.PHONY: $(obj)/ncurses
29$(obj)/ncurses:
30 @echo "main() {}" > lxtemp.c
31 @if $(HOSTCC) lxtemp.c $(HOST_LOADLIBES); then \
32 rm -f lxtemp.c a.out; \
33 else \
34 rm -f lxtemp.c; \
35 echo -e "\007" ;\
36 echo ">> Unable to find the Ncurses libraries." ;\
37 echo ">>" ;\
38 echo ">> You must install ncurses-devel in order" ;\
39 echo ">> to use 'make menuconfig'" ;\
40 echo ;\
41 exit 1 ;\
42 fi
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
new file mode 100644
index 000000000000..120d624e672c
--- /dev/null
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -0,0 +1,84 @@
1#!/bin/sh
2# Check ncurses compatibility
3
4# What library to link
5ldflags()
6{
7 $cc -print-file-name=libncursesw.so | grep -q /
8 if [ $? -eq 0 ]; then
9 echo '-lncursesw'
10 exit
11 fi
12 $cc -print-file-name=libncurses.so | grep -q /
13 if [ $? -eq 0 ]; then
14 echo '-lncurses'
15 exit
16 fi
17 $cc -print-file-name=libcurses.so | grep -q /
18 if [ $? -eq 0 ]; then
19 echo '-lcurses'
20 exit
21 fi
22 exit 1
23}
24
25# Where is ncurses.h?
26ccflags()
27{
28 if [ -f /usr/include/ncurses/ncurses.h ]; then
29 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
30 elif [ -f /usr/include/ncurses/curses.h ]; then
31 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
32 elif [ -f /usr/include/ncurses.h ]; then
33 echo '-DCURSES_LOC="<ncurses.h>"'
34 else
35 echo '-DCURSES_LOC="<curses.h>"'
36 fi
37}
38
39# Temp file, try to clean up after us
40tmp=.lxdialog.tmp
41trap "rm -f $tmp" 0 1 2 3 15
42
43# Check if we can link to ncurses
44check() {
45 echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
46 if [ $? != 0 ]; then
47 echo " *** Unable to find the ncurses libraries." 1>&2
48 echo " *** make menuconfig require the ncurses libraries" 1>&2
49 echo " *** " 1>&2
50 echo " *** Install ncurses (ncurses-devel) and try again" 1>&2
51 echo " *** " 1>&2
52 exit 1
53 fi
54}
55
56usage() {
57 printf "Usage: $0 [-check compiler options|-header|-library]\n"
58}
59
60if [ $# == 0 ]; then
61 usage
62 exit 1
63fi
64
65cc=""
66case "$1" in
67 "-check")
68 shift
69 cc="$@"
70 check
71 ;;
72 "-ccflags")
73 ccflags
74 ;;
75 "-ldflags")
76 shift
77 cc="$@"
78 ldflags
79 ;;
80 "*")
81 usage
82 exit 1
83 ;;
84esac
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d63d7fb677e4..7f973195e79a 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -1051,7 +1051,7 @@ int main(int ac, char **av)
1051 conf_parse(av[1]); 1051 conf_parse(av[1]);
1052 conf_read(NULL); 1052 conf_read(NULL);
1053 1053
1054 sym = sym_lookup("KERNELRELEASE", 0); 1054 sym = sym_lookup("KERNELVERSION", 0);
1055 sym_calc_value(sym); 1055 sym_calc_value(sym);
1056 sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), 1056 sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"),
1057 sym_get_string_value(sym)); 1057 sym_get_string_value(sym));
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index 7c03927d4c7c..e52f3e90bf0c 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -22,8 +22,8 @@ public:
22 22
23#if QT_VERSION >= 300 23#if QT_VERSION >= 300
24 void readListSettings(); 24 void readListSettings();
25 QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok); 25 QValueList<int> readSizes(const QString& key, bool *ok);
26 bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value); 26 bool writeSizes(const QString& key, const QValueList<int>& value);
27#endif 27#endif
28 28
29 bool showAll; 29 bool showAll;
@@ -124,7 +124,7 @@ public:
124 void setParentMenu(void); 124 void setParentMenu(void);
125 125
126 template <class P> 126 template <class P>
127 void ConfigList::updateMenuList(P*, struct menu*); 127 void updateMenuList(P*, struct menu*);
128 128
129 bool updateAll; 129 bool updateAll;
130 130
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 69c2549c0baa..3d7877afccd5 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -61,10 +61,10 @@ void sym_init(void)
61 if (p) 61 if (p)
62 sym_add_default(sym, p); 62 sym_add_default(sym, p);
63 63
64 sym = sym_lookup("KERNELRELEASE", 0); 64 sym = sym_lookup("KERNELVERSION", 0);
65 sym->type = S_STRING; 65 sym->type = S_STRING;
66 sym->flags |= SYMBOL_AUTO; 66 sym->flags |= SYMBOL_AUTO;
67 p = getenv("KERNELRELEASE"); 67 p = getenv("KERNELVERSION");
68 if (p) 68 if (p)
69 sym_add_default(sym, p); 69 sym_add_default(sym, p);
70 70
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 2f45fd2969d0..99fe4b7fb2f1 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -45,7 +45,7 @@ use strict;
45# Note: This only supports 'c'. 45# Note: This only supports 'c'.
46 46
47# usage: 47# usage:
48# kerneldoc [ -docbook | -html | -text | -man ] 48# kernel-doc [ -docbook | -html | -text | -man ]
49# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile 49# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
50# or 50# or
51# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile 51# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
@@ -59,7 +59,7 @@ use strict;
59# -nofunction funcname 59# -nofunction funcname
60# If set, then only generate documentation for the other function(s). All 60# If set, then only generate documentation for the other function(s). All
61# other functions are ignored. Cannot be used with -function together 61# other functions are ignored. Cannot be used with -function together
62# (yes thats a bug - perl hackers can fix it 8)) 62# (yes, that's a bug -- perl hackers can fix it 8))
63# 63#
64# c files - list of 'c' files to process 64# c files - list of 'c' files to process
65# 65#
@@ -90,28 +90,28 @@ use strict;
90# * my_function - does my stuff 90# * my_function - does my stuff
91# * @my_arg: its mine damnit 91# * @my_arg: its mine damnit
92# * 92# *
93# * Does my stuff explained. 93# * Does my stuff explained.
94# */ 94# */
95# 95#
96# or, could also use: 96# or, could also use:
97# /** 97# /**
98# * my_function - does my stuff 98# * my_function - does my stuff
99# * @my_arg: its mine damnit 99# * @my_arg: its mine damnit
100# * Description: Does my stuff explained. 100# * Description: Does my stuff explained.
101# */ 101# */
102# etc. 102# etc.
103# 103#
104# Beside functions you can also write documentation for structs, unions, 104# Beside functions you can also write documentation for structs, unions,
105# enums and typedefs. Instead of the function name you must write the name 105# enums and typedefs. Instead of the function name you must write the name
106# of the declaration; the struct/union/enum/typedef must always precede 106# of the declaration; the struct/union/enum/typedef must always precede
107# the name. Nesting of declarations is not supported. 107# the name. Nesting of declarations is not supported.
108# Use the argument mechanism to document members or constants. 108# Use the argument mechanism to document members or constants.
109# e.g. 109# e.g.
110# /** 110# /**
111# * struct my_struct - short description 111# * struct my_struct - short description
112# * @a: first member 112# * @a: first member
113# * @b: second member 113# * @b: second member
114# * 114# *
115# * Longer description 115# * Longer description
116# */ 116# */
117# struct my_struct { 117# struct my_struct {
@@ -122,12 +122,12 @@ use strict;
122# }; 122# };
123# 123#
124# All descriptions can be multiline, except the short function description. 124# All descriptions can be multiline, except the short function description.
125# 125#
126# You can also add additional sections. When documenting kernel functions you 126# You can also add additional sections. When documenting kernel functions you
127# should document the "Context:" of the function, e.g. whether the functions 127# should document the "Context:" of the function, e.g. whether the functions
128# can be called form interrupts. Unlike other sections you can end it with an 128# can be called form interrupts. Unlike other sections you can end it with an
129# empty line. 129# empty line.
130# Example-sections should contain the string EXAMPLE so that they are marked 130# Example-sections should contain the string EXAMPLE so that they are marked
131# appropriately in DocBook. 131# appropriately in DocBook.
132# 132#
133# Example: 133# Example:
@@ -135,7 +135,7 @@ use strict;
135# * user_function - function that can only be called in user context 135# * user_function - function that can only be called in user context
136# * @a: some argument 136# * @a: some argument
137# * Context: !in_interrupt() 137# * Context: !in_interrupt()
138# * 138# *
139# * Some description 139# * Some description
140# * Example: 140# * Example:
141# * user_function(22); 141# * user_function(22);
@@ -223,9 +223,9 @@ my %highlights = %highlights_man;
223my $blankline = $blankline_man; 223my $blankline = $blankline_man;
224my $modulename = "Kernel API"; 224my $modulename = "Kernel API";
225my $function_only = 0; 225my $function_only = 0;
226my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', 226my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
227 'July', 'August', 'September', 'October', 227 'July', 'August', 'September', 'October',
228 'November', 'December')[(localtime)[4]] . 228 'November', 'December')[(localtime)[4]] .
229 " " . ((localtime)[5]+1900); 229 " " . ((localtime)[5]+1900);
230 230
231# Essentially these are globals 231# Essentially these are globals
@@ -236,7 +236,7 @@ my ($function, %function_table,%parametertypes,$declaration_purpose);
236my ($type,$declaration_name,$return_type); 236my ($type,$declaration_name,$return_type);
237my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map); 237my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map);
238 238
239# Generated docbook code is inserted in a template at a point where 239# Generated docbook code is inserted in a template at a point where
240# docbook v3.1 requires a non-zero sequence of RefEntry's; see: 240# docbook v3.1 requires a non-zero sequence of RefEntry's; see:
241# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html 241# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
242# We keep track of number of generated entries and generate a dummy 242# We keep track of number of generated entries and generate a dummy
@@ -365,7 +365,7 @@ sub dump_section {
365# parameterdescs => %parameter descriptions 365# parameterdescs => %parameter descriptions
366# sectionlist => @list of sections 366# sectionlist => @list of sections
367# sections => %descriont descriptions 367# sections => %descriont descriptions
368# 368#
369 369
370sub output_highlight { 370sub output_highlight {
371 my $contents = join "\n",@_; 371 my $contents = join "\n",@_;
@@ -400,7 +400,7 @@ sub output_section_html(%) {
400 print "<blockquote>\n"; 400 print "<blockquote>\n";
401 output_highlight($args{'sections'}{$section}); 401 output_highlight($args{'sections'}{$section});
402 print "</blockquote>\n"; 402 print "</blockquote>\n";
403 } 403 }
404} 404}
405 405
406# output enum in html 406# output enum in html
@@ -434,7 +434,7 @@ sub output_enum_html(%) {
434 print "<hr>\n"; 434 print "<hr>\n";
435} 435}
436 436
437# output tyepdef in html 437# output typedef in html
438sub output_typedef_html(%) { 438sub output_typedef_html(%) {
439 my %args = %{$_[0]}; 439 my %args = %{$_[0]};
440 my ($parameter); 440 my ($parameter);
@@ -551,7 +551,7 @@ sub output_intro_html(%) {
551 551
552sub output_section_xml(%) { 552sub output_section_xml(%) {
553 my %args = %{$_[0]}; 553 my %args = %{$_[0]};
554 my $section; 554 my $section;
555 # print out each section 555 # print out each section
556 $lineprefix=" "; 556 $lineprefix=" ";
557 foreach $section (@{$args{'sectionlist'}}) { 557 foreach $section (@{$args{'sectionlist'}}) {
@@ -778,7 +778,7 @@ sub output_enum_xml(%) {
778 print "</refsynopsisdiv>\n"; 778 print "</refsynopsisdiv>\n";
779 779
780 print "<refsect1>\n"; 780 print "<refsect1>\n";
781 print " <title>Constants</title>\n"; 781 print " <title>Constants</title>\n";
782 print " <variablelist>\n"; 782 print " <variablelist>\n";
783 foreach $parameter (@{$args{'parameterlist'}}) { 783 foreach $parameter (@{$args{'parameterlist'}}) {
784 my $parameter_name = $parameter; 784 my $parameter_name = $parameter;
@@ -1157,7 +1157,7 @@ sub output_section_text(%) {
1157 foreach $section (@{$args{'sectionlist'}}) { 1157 foreach $section (@{$args{'sectionlist'}}) {
1158 print "$section:\n\n"; 1158 print "$section:\n\n";
1159 output_highlight($args{'sections'}{$section}); 1159 output_highlight($args{'sections'}{$section});
1160 } 1160 }
1161 print "\n\n"; 1161 print "\n\n";
1162} 1162}
1163 1163
@@ -1262,8 +1262,8 @@ sub output_declaration {
1262 my $name = shift; 1262 my $name = shift;
1263 my $functype = shift; 1263 my $functype = shift;
1264 my $func = "output_${functype}_$output_mode"; 1264 my $func = "output_${functype}_$output_mode";
1265 if (($function_only==0) || 1265 if (($function_only==0) ||
1266 ( $function_only == 1 && defined($function_table{$name})) || 1266 ( $function_only == 1 && defined($function_table{$name})) ||
1267 ( $function_only == 2 && !defined($function_table{$name}))) 1267 ( $function_only == 2 && !defined($function_table{$name})))
1268 { 1268 {
1269 &$func(@_); 1269 &$func(@_);
@@ -1282,7 +1282,7 @@ sub output_intro {
1282} 1282}
1283 1283
1284## 1284##
1285# takes a declaration (struct, union, enum, typedef) and 1285# takes a declaration (struct, union, enum, typedef) and
1286# invokes the right handler. NOT called for functions. 1286# invokes the right handler. NOT called for functions.
1287sub dump_declaration($$) { 1287sub dump_declaration($$) {
1288 no strict 'refs'; 1288 no strict 'refs';
@@ -1352,7 +1352,7 @@ sub dump_enum($$) {
1352 } 1352 }
1353 1353
1354 } 1354 }
1355 1355
1356 output_declaration($declaration_name, 1356 output_declaration($declaration_name,
1357 'enum', 1357 'enum',
1358 {'enum' => $declaration_name, 1358 {'enum' => $declaration_name,
@@ -1405,10 +1405,11 @@ sub create_parameterlist($$$) {
1405 my $type; 1405 my $type;
1406 my $param; 1406 my $param;
1407 1407
1408 # temporarily replace commas inside function pointer definition
1408 while ($args =~ /(\([^\),]+),/) { 1409 while ($args =~ /(\([^\),]+),/) {
1409 $args =~ s/(\([^\),]+),/$1#/g; 1410 $args =~ s/(\([^\),]+),/$1#/g;
1410 } 1411 }
1411 1412
1412 foreach my $arg (split($splitter, $args)) { 1413 foreach my $arg (split($splitter, $args)) {
1413 # strip comments 1414 # strip comments
1414 $arg =~ s/\/\*.*\*\///; 1415 $arg =~ s/\/\*.*\*\///;
@@ -1465,11 +1466,10 @@ sub push_parameter($$$) {
1465 my $param_name = $param; 1466 my $param_name = $param;
1466 $param_name =~ s/\[.*//; 1467 $param_name =~ s/\[.*//;
1467 1468
1468 if ($type eq "" && $param eq "...") 1469 if ($type eq "" && $param =~ /\.\.\.$/)
1469 { 1470 {
1470 $type=""; 1471 $type="";
1471 $param="..."; 1472 $parameterdescs{$param} = "variable arguments";
1472 $parameterdescs{"..."} = "variable arguments";
1473 } 1473 }
1474 elsif ($type eq "" && ($param eq "" or $param eq "void")) 1474 elsif ($type eq "" && ($param eq "" or $param eq "void"))
1475 { 1475 {
@@ -1477,7 +1477,11 @@ sub push_parameter($$$) {
1477 $param="void"; 1477 $param="void";
1478 $parameterdescs{void} = "no arguments"; 1478 $parameterdescs{void} = "no arguments";
1479 } 1479 }
1480 if (defined $type && $type && !defined $parameterdescs{$param_name}) { 1480 # warn if parameter has no description
1481 # (but ignore ones starting with # as these are no parameters
1482 # but inline preprocessor statements
1483 if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) {
1484
1481 $parameterdescs{$param_name} = $undescribed; 1485 $parameterdescs{$param_name} = $undescribed;
1482 1486
1483 if (($type eq 'function') || ($type eq 'enum')) { 1487 if (($type eq 'function') || ($type eq 'enum')) {
@@ -1525,7 +1529,7 @@ sub dump_function($$) {
1525 # the following functions' documentation still comes out right: 1529 # the following functions' documentation still comes out right:
1526 # - parport_register_device (function pointer parameters) 1530 # - parport_register_device (function pointer parameters)
1527 # - atomic_set (macro) 1531 # - atomic_set (macro)
1528 # - pci_match_device (long return type) 1532 # - pci_match_device, __copy_to_user (long return type)
1529 1533
1530 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 1534 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1531 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 1535 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
@@ -1540,7 +1544,9 @@ sub dump_function($$) {
1540 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1544 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1541 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1545 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1542 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1546 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1543 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { 1547 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1548 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1549 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
1544 $return_type = $1; 1550 $return_type = $1;
1545 $declaration_name = $2; 1551 $declaration_name = $2;
1546 my $args = $3; 1552 my $args = $3;
@@ -1552,7 +1558,7 @@ sub dump_function($$) {
1552 return; 1558 return;
1553 } 1559 }
1554 1560
1555 output_declaration($declaration_name, 1561 output_declaration($declaration_name,
1556 'function', 1562 'function',
1557 {'function' => $declaration_name, 1563 {'function' => $declaration_name,
1558 'module' => $modulename, 1564 'module' => $modulename,
@@ -1611,11 +1617,11 @@ sub reset_state {
1611 %sections = (); 1617 %sections = ();
1612 @sectionlist = (); 1618 @sectionlist = ();
1613 $prototype = ""; 1619 $prototype = "";
1614 1620
1615 $state = 0; 1621 $state = 0;
1616} 1622}
1617 1623
1618sub process_state3_function($$) { 1624sub process_state3_function($$) {
1619 my $x = shift; 1625 my $x = shift;
1620 my $file = shift; 1626 my $file = shift;
1621 1627
@@ -1634,7 +1640,7 @@ sub process_state3_function($$) {
1634 } 1640 }
1635} 1641}
1636 1642
1637sub process_state3_type($$) { 1643sub process_state3_type($$) {
1638 my $x = shift; 1644 my $x = shift;
1639 my $file = shift; 1645 my $file = shift;
1640 1646
@@ -1774,7 +1780,7 @@ sub process_file($) {
1774 } elsif (/$doc_content/) { 1780 } elsif (/$doc_content/) {
1775 # miguel-style comment kludge, look for blank lines after 1781 # miguel-style comment kludge, look for blank lines after
1776 # @parameter line to signify start of description 1782 # @parameter line to signify start of description
1777 if ($1 eq "" && 1783 if ($1 eq "" &&
1778 ($section =~ m/^@/ || $section eq $section_context)) { 1784 ($section =~ m/^@/ || $section eq $section_context)) {
1779 dump_section($section, xml_escape($contents)); 1785 dump_section($section, xml_escape($contents));
1780 $section = $section_default; 1786 $section = $section_default;
@@ -1784,7 +1790,7 @@ sub process_file($) {
1784 } 1790 }
1785 } else { 1791 } else {
1786 # i dont know - bad line? ignore. 1792 # i dont know - bad line? ignore.
1787 print STDERR "Warning(${file}:$.): bad line: $_"; 1793 print STDERR "Warning(${file}:$.): bad line: $_";
1788 ++$warnings; 1794 ++$warnings;
1789 } 1795 }
1790 } elsif ($state == 3) { # scanning for function { (end of prototype) 1796 } elsif ($state == 3) { # scanning for function { (end of prototype)
@@ -1839,7 +1845,7 @@ sub process_file($) {
1839 else 1845 else
1840 { 1846 {
1841 $contents .= $1 . "\n"; 1847 $contents .= $1 . "\n";
1842 } 1848 }
1843 } 1849 }
1844 } 1850 }
1845 } 1851 }
diff --git a/scripts/mksysmap b/scripts/mksysmap
index a6430e05972d..4390fab9f5bd 100644
--- a/scripts/mksysmap
+++ b/scripts/mksysmap
@@ -1,7 +1,7 @@
1#!/bin/sh -x 1#!/bin/sh -x
2# Based on the vmlinux file create the System.map file 2# Based on the vmlinux file create the System.map file
3# System.map is used by module-init tools and some debugging 3# System.map is used by module-init tools and some debugging
4# tools to retreive the actual addresses of symbols in the kernel. 4# tools to retrieve the actual addresses of symbols in the kernel.
5# 5#
6# Usage 6# Usage
7# mksysmap vmlinux System.map 7# mksysmap vmlinux System.map
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e0eedffe565b..c164b230ad6f 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -246,7 +246,7 @@ static int do_ccw_entry(const char *filename,
246 id->cu_model); 246 id->cu_model);
247 ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, 247 ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
248 id->dev_type); 248 id->dev_type);
249 ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE, 249 ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL,
250 id->dev_model); 250 id->dev_model);
251 return 1; 251 return 1;
252} 252}
@@ -417,7 +417,7 @@ static int do_input_entry(const char *filename, struct input_device_id *id,
417 do_input(alias, id->sndbit, 0, SND_MAX); 417 do_input(alias, id->sndbit, 0, SND_MAX);
418 sprintf(alias + strlen(alias), "f*"); 418 sprintf(alias + strlen(alias), "f*");
419 if (id->flags&INPUT_DEVICE_ID_MATCH_FFBIT) 419 if (id->flags&INPUT_DEVICE_ID_MATCH_FFBIT)
420 do_input(alias, id->ffbit, 0, SND_MAX); 420 do_input(alias, id->ffbit, 0, FF_MAX);
421 sprintf(alias + strlen(alias), "w*"); 421 sprintf(alias + strlen(alias), "w*");
422 if (id->flags&INPUT_DEVICE_ID_MATCH_SWBIT) 422 if (id->flags&INPUT_DEVICE_ID_MATCH_SWBIT)
423 do_input(alias, id->swbit, 0, SW_MAX); 423 do_input(alias, id->swbit, 0, SW_MAX);
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index f70ff13d4818..b8b2a560b26b 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -508,12 +508,7 @@ buf_printf(struct buffer *buf, const char *fmt, ...)
508 508
509 va_start(ap, fmt); 509 va_start(ap, fmt);
510 len = vsnprintf(tmp, SZ, fmt, ap); 510 len = vsnprintf(tmp, SZ, fmt, ap);
511 if (buf->size - buf->pos < len + 1) { 511 buf_write(buf, tmp, len);
512 buf->size += 128;
513 buf->p = realloc(buf->p, buf->size);
514 }
515 strncpy(buf->p + buf->pos, tmp, len + 1);
516 buf->pos += len;
517 va_end(ap); 512 va_end(ap);
518} 513}
519 514
@@ -521,7 +516,7 @@ void
521buf_write(struct buffer *buf, const char *s, int len) 516buf_write(struct buffer *buf, const char *s, int len)
522{ 517{
523 if (buf->size - buf->pos < len) { 518 if (buf->size - buf->pos < len) {
524 buf->size += len; 519 buf->size += len + SZ;
525 buf->p = realloc(buf->p, buf->size); 520 buf->p = realloc(buf->p, buf->size);
526 } 521 }
527 strncpy(buf->p + buf->pos, s, len); 522 strncpy(buf->p + buf->pos, s, len);
diff --git a/scripts/reference_discarded.pl b/scripts/reference_discarded.pl
index c2d54148a91f..4ee6ab2135b3 100644
--- a/scripts/reference_discarded.pl
+++ b/scripts/reference_discarded.pl
@@ -71,6 +71,11 @@ foreach $object (keys(%object)) {
71# printf("ignoring %d conglomerate(s)\n", $ignore); 71# printf("ignoring %d conglomerate(s)\n", $ignore);
72 72
73# printf("Scanning objects\n"); 73# printf("Scanning objects\n");
74
75# Keith Ownes <kaos@sgi.com> commented:
76# For our future {in}sanity, add a comment that this is the ppc .opd
77# section, not the ia64 .opd section.
78# ia64 .opd should not point to discarded sections.
74$errorcount = 0; 79$errorcount = 0;
75foreach $object (keys(%object)) { 80foreach $object (keys(%object)) {
76 my $from; 81 my $from;
@@ -88,6 +93,7 @@ foreach $object (keys(%object)) {
88 ($from !~ /\.text\.exit$/ && 93 ($from !~ /\.text\.exit$/ &&
89 $from !~ /\.exit\.text$/ && 94 $from !~ /\.exit\.text$/ &&
90 $from !~ /\.data\.exit$/ && 95 $from !~ /\.data\.exit$/ &&
96 $from !~ /\.opd$/ &&
91 $from !~ /\.exit\.data$/ && 97 $from !~ /\.exit\.data$/ &&
92 $from !~ /\.altinstructions$/ && 98 $from !~ /\.altinstructions$/ &&
93 $from !~ /\.pdr$/ && 99 $from !~ /\.pdr$/ &&
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 7c805c8fccd2..9a23825218f2 100644
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -1,56 +1,22 @@
1#!/usr/bin/perl 1#!/bin/sh
2# Copyright 2004 - Ryan Anderson <ryan@michonline.com> GPL v2 2# Print additional version information for non-release trees.
3 3
4use strict; 4usage() {
5use warnings; 5 echo "Usage: $0 [srctree]" >&2
6use Digest::MD5; 6 exit 1
7require 5.006;
8
9if (@ARGV != 1) {
10 print <<EOT;
11Usage: setlocalversion <srctree>
12EOT
13 exit(1);
14} 7}
15 8
16my ($srctree) = @ARGV; 9cd "${1:-.}" || usage
17chdir($srctree);
18
19my @LOCALVERSIONS = ();
20
21# We are going to use the following commands to try and determine if this
22# repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We
23# currently assume that all meaningful version boundaries are marked by a tag.
24# We don't care what the tag is, just that something exists.
25
26# Git/Cogito store the top-of-tree "commit" in .git/HEAD
27# A list of known tags sits in .git/refs/tags/
28#
29# The simple trick here is to just compare the two of these, and if we get a
30# match, return nothing, otherwise, return a subset of the SHA-1 hash in
31# .git/HEAD
32
33sub do_git_checks {
34 open(H,"<.git/HEAD") or return;
35 my $head = <H>;
36 chomp $head;
37 close(H);
38 10
39 opendir(D,".git/refs/tags") or return; 11# Check for git and a git repo.
40 foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) { 12if head=`git rev-parse --verify HEAD 2>/dev/null`; then
41 open(F,"<.git/refs/tags/" . $tagfile) or return; 13 # Do we have an untagged version?
42 my $tag = <F>; 14 if [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
43 chomp $tag; 15 printf '%s%s' -g `echo "$head" | cut -c1-8`
44 close(F); 16 fi
45 return if ($tag eq $head);
46 }
47 closedir(D);
48
49 push @LOCALVERSIONS, "g" . substr($head,0,8);
50}
51
52if ( -d ".git") {
53 do_git_checks();
54}
55 17
56printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0); 18 # Are there uncommitted changes?
19 if git diff-files | read dummy; then
20 printf '%s' -dirty
21 fi
22fi