aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include72
-rwxr-xr-xscripts/kernel-doc51
2 files changed, 70 insertions, 53 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index a1880e854d..06c1a377c4 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -1,7 +1,7 @@
1#### 1####
2# kbuild: Generic definitions 2# kbuild: Generic definitions
3 3
4# Convenient constants 4# Convenient variables
5comma := , 5comma := ,
6squote := ' 6squote := '
7empty := 7empty :=
@@ -56,44 +56,48 @@ endef
56# gcc support functions 56# gcc support functions
57# See documentation in Documentation/kbuild/makefiles.txt 57# See documentation in Documentation/kbuild/makefiles.txt
58 58
59# checker-shell 59# output directory for tests below
60# Usage: option = $(call checker-shell,$(CC)...-o $$OUT,option-ok,otherwise) 60TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
61# Exit code chooses option. $$OUT is safe location for needless output. 61
62define checker-shell 62# try-run
63$(shell set -e; \ 63# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
64 DIR=$(KBUILD_EXTMOD); \ 64# Exit code chooses option. "$$TMP" is can be used as temporary file and
65 cd $${DIR:-$(objtree)}; \ 65# is automatically cleaned up.
66 OUT=$$PWD/.$$$$.null; \ 66try-run = $(shell set -e; \
67 if $(1) >/dev/null 2>&1; \ 67 TMP="$(TMPOUT).$$$$.tmp"; \
68 then echo "$(2)"; \ 68 if ($(1)) >/dev/null 2>&1; \
69 else echo "$(3)"; \ 69 then echo "$(2)"; \
70 fi; \ 70 else echo "$(3)"; \
71 rm -f $$OUT) 71 fi; \
72endef 72 rm -f "$$TMP")
73 73
74# as-option 74# as-option
75# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 75# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
76as-option = $(call checker-shell,\ 76
77 $(CC) $(CFLAGS) $(1) -c -xassembler /dev/null -o $$OUT,$(1),$(2)) 77as-option = $(call try-run,\
78 $(CC) $(CFLAGS) $(1) -c -xassembler /dev/null -o "$$TMP",$(1),$(2))
78 79
79# as-instr 80# as-instr
80# Usage: cflags-y += $(call as-instr,instr,option1,option2) 81# Usage: cflags-y += $(call as-instr,instr,option1,option2)
81as-instr = $(call checker-shell,\ 82
82 printf "$(1)" | $(CC) $(AFLAGS) -c -xassembler -o $$OUT -,$(2),$(3)) 83as-instr = $(call try-run,\
84 echo -e "$(1)" | $(CC) $(AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
83 85
84# cc-option 86# cc-option
85# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 87# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
86cc-option = $(call checker-shell,\ 88
87 $(CC) $(CFLAGS) $(if $(3),$(3),$(1)) -S -xc /dev/null -o $$OUT,$(1),$(2)) 89cc-option = $(call try-run,\
90 $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",$(1),$(2))
88 91
89# cc-option-yn 92# cc-option-yn
90# Usage: flag := $(call cc-option-yn,-march=winchip-c6) 93# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
91cc-option-yn = $(call cc-option,"y","n",$(1)) 94cc-option-yn = $(call try-run,\
95 $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
92 96
93# cc-option-align 97# cc-option-align
94# Prefix align with either -falign or -malign 98# Prefix align with either -falign or -malign
95cc-option-align = $(subst -functions=0,,\ 99cc-option-align = $(subst -functions=0,,\
96 $(call cc-option,-falign-functions=0,-malign-functions=0)) 100 $(call cc-option,-falign-functions=0,-malign-functions=0))
97 101
98# cc-version 102# cc-version
99# Usage gcc-ver := $(call cc-version,$(CC)) 103# Usage gcc-ver := $(call cc-version,$(CC))
@@ -105,24 +109,22 @@ cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
105 109
106# ld-option 110# ld-option
107# Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both) 111# Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
108ld-option = $(call checker-shell,\ 112ld-option = $(call try-run,\
109 $(CC) $(1) -nostdlib -xc /dev/null -o $$OUT,$(1),$(2)) 113 $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2))
110 114
111###### 115######
112 116
117###
113# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= 118# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
114# Usage: 119# Usage:
115# $(Q)$(MAKE) $(build)=dir 120# $(Q)$(MAKE) $(build)=dir
116build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj 121build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
117 122
118# Prefix -I with $(srctree) if it is not an absolute path, 123# Prefix -I with $(srctree) if it is not an absolute path.
119# add original to the end 124addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
120addtree = $(if \
121 $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
122 125
123# Find all -I options and call addtree 126# Find all -I options and call addtree
124flags = $(foreach o,$($(1)),\ 127flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
125 $(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
126 128
127# echo command. 129# echo command.
128# Short version is used, if $(quiet) equals `quiet_', otherwise full one. 130# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
@@ -144,7 +146,7 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
144# See Documentation/kbuild/makefiles.txt for more info 146# See Documentation/kbuild/makefiles.txt for more info
145 147
146ifneq ($(KBUILD_NOCMDDEP),1) 148ifneq ($(KBUILD_NOCMDDEP),1)
147# Check if both arguments has same arguments. Result is empty string, if equal. 149# Check if both arguments has same arguments. Result is empty string if equal.
148# User may override this check using make KBUILD_NOCMDDEP=1 150# User may override this check using make KBUILD_NOCMDDEP=1
149arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ 151arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
150 $(filter-out $(cmd_$@), $(cmd_$(1))) ) 152 $(filter-out $(cmd_$@), $(cmd_$(1))) )
@@ -168,7 +170,6 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
168 echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) 170 echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
169 171
170# Execute the command and also postprocess generated .d dependencies file. 172# Execute the command and also postprocess generated .d dependencies file.
171#
172if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ 173if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
173 @set -e; \ 174 @set -e; \
174 $(echo-cmd) $(cmd_$(1)); \ 175 $(echo-cmd) $(cmd_$(1)); \
@@ -176,10 +177,9 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
176 rm -f $(depfile); \ 177 rm -f $(depfile); \
177 mv -f $(dot-target).tmp $(dot-target).cmd) 178 mv -f $(dot-target).tmp $(dot-target).cmd)
178 179
179# Will check if $(cmd_foo) changed, or any of the prerequisites changed,
180# and if so will execute $(rule_foo).
181# Usage: $(call if_changed_rule,foo) 180# Usage: $(call if_changed_rule,foo)
182# 181# Will check if $(cmd_foo) or any of the prerequisites changed,
182# and if so will execute $(rule_foo).
183if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ 183if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \
184 @set -e; \ 184 @set -e; \
185 $(rule_$(1))) 185 $(rule_$(1)))
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index f50a70f550..4d928b8598 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -83,7 +83,7 @@ use strict;
83# * my_function 83# * my_function
84# **/ 84# **/
85# 85#
86# If the Description: header tag is ommitted, then there must be a blank line 86# If the Description: header tag is omitted, then there must be a blank line
87# after the last parameter specification. 87# after the last parameter specification.
88# e.g. 88# e.g.
89# /** 89# /**
@@ -265,7 +265,7 @@ my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
265my $doc_end = '\*/'; 265my $doc_end = '\*/';
266my $doc_com = '\s*\*\s*'; 266my $doc_com = '\s*\*\s*';
267my $doc_decl = $doc_com.'(\w+)'; 267my $doc_decl = $doc_com.'(\w+)';
268my $doc_sect = $doc_com.'(['.$doc_special.']?[\w ]+):(.*)'; 268my $doc_sect = $doc_com.'(['.$doc_special.']?[\w\s]+):(.*)';
269my $doc_content = $doc_com.'(.*)'; 269my $doc_content = $doc_com.'(.*)';
270my $doc_block = $doc_com.'DOC:\s*(.*)?'; 270my $doc_block = $doc_com.'DOC:\s*(.*)?';
271 271
@@ -365,7 +365,7 @@ sub dump_section {
365# parameterlist => @list of parameters 365# parameterlist => @list of parameters
366# parameterdescs => %parameter descriptions 366# parameterdescs => %parameter descriptions
367# sectionlist => @list of sections 367# sectionlist => @list of sections
368# sections => %descriont descriptions 368# sections => %section descriptions
369# 369#
370 370
371sub output_highlight { 371sub output_highlight {
@@ -583,14 +583,14 @@ sub output_function_xml(%) {
583 $id = "API-".$args{'function'}; 583 $id = "API-".$args{'function'};
584 $id =~ s/[^A-Za-z0-9]/-/g; 584 $id =~ s/[^A-Za-z0-9]/-/g;
585 585
586 print "<refentry>\n"; 586 print "<refentry id=\"$id\">\n";
587 print "<refentryinfo>\n"; 587 print "<refentryinfo>\n";
588 print " <title>LINUX</title>\n"; 588 print " <title>LINUX</title>\n";
589 print " <productname>Kernel Hackers Manual</productname>\n"; 589 print " <productname>Kernel Hackers Manual</productname>\n";
590 print " <date>$man_date</date>\n"; 590 print " <date>$man_date</date>\n";
591 print "</refentryinfo>\n"; 591 print "</refentryinfo>\n";
592 print "<refmeta>\n"; 592 print "<refmeta>\n";
593 print " <refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n"; 593 print " <refentrytitle><phrase>".$args{'function'}."</phrase></refentrytitle>\n";
594 print " <manvolnum>9</manvolnum>\n"; 594 print " <manvolnum>9</manvolnum>\n";
595 print "</refmeta>\n"; 595 print "</refmeta>\n";
596 print "<refnamediv>\n"; 596 print "<refnamediv>\n";
@@ -659,14 +659,14 @@ sub output_struct_xml(%) {
659 $id = "API-struct-".$args{'struct'}; 659 $id = "API-struct-".$args{'struct'};
660 $id =~ s/[^A-Za-z0-9]/-/g; 660 $id =~ s/[^A-Za-z0-9]/-/g;
661 661
662 print "<refentry>\n"; 662 print "<refentry id=\"$id\">\n";
663 print "<refentryinfo>\n"; 663 print "<refentryinfo>\n";
664 print " <title>LINUX</title>\n"; 664 print " <title>LINUX</title>\n";
665 print " <productname>Kernel Hackers Manual</productname>\n"; 665 print " <productname>Kernel Hackers Manual</productname>\n";
666 print " <date>$man_date</date>\n"; 666 print " <date>$man_date</date>\n";
667 print "</refentryinfo>\n"; 667 print "</refentryinfo>\n";
668 print "<refmeta>\n"; 668 print "<refmeta>\n";
669 print " <refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n"; 669 print " <refentrytitle><phrase>".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
670 print " <manvolnum>9</manvolnum>\n"; 670 print " <manvolnum>9</manvolnum>\n";
671 print "</refmeta>\n"; 671 print "</refmeta>\n";
672 print "<refnamediv>\n"; 672 print "<refnamediv>\n";
@@ -743,14 +743,14 @@ sub output_enum_xml(%) {
743 $id = "API-enum-".$args{'enum'}; 743 $id = "API-enum-".$args{'enum'};
744 $id =~ s/[^A-Za-z0-9]/-/g; 744 $id =~ s/[^A-Za-z0-9]/-/g;
745 745
746 print "<refentry>\n"; 746 print "<refentry id=\"$id\">\n";
747 print "<refentryinfo>\n"; 747 print "<refentryinfo>\n";
748 print " <title>LINUX</title>\n"; 748 print " <title>LINUX</title>\n";
749 print " <productname>Kernel Hackers Manual</productname>\n"; 749 print " <productname>Kernel Hackers Manual</productname>\n";
750 print " <date>$man_date</date>\n"; 750 print " <date>$man_date</date>\n";
751 print "</refentryinfo>\n"; 751 print "</refentryinfo>\n";
752 print "<refmeta>\n"; 752 print "<refmeta>\n";
753 print " <refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n"; 753 print " <refentrytitle><phrase>enum ".$args{'enum'}."</phrase></refentrytitle>\n";
754 print " <manvolnum>9</manvolnum>\n"; 754 print " <manvolnum>9</manvolnum>\n";
755 print "</refmeta>\n"; 755 print "</refmeta>\n";
756 print "<refnamediv>\n"; 756 print "<refnamediv>\n";
@@ -809,14 +809,14 @@ sub output_typedef_xml(%) {
809 $id = "API-typedef-".$args{'typedef'}; 809 $id = "API-typedef-".$args{'typedef'};
810 $id =~ s/[^A-Za-z0-9]/-/g; 810 $id =~ s/[^A-Za-z0-9]/-/g;
811 811
812 print "<refentry>\n"; 812 print "<refentry id=\"$id\">\n";
813 print "<refentryinfo>\n"; 813 print "<refentryinfo>\n";
814 print " <title>LINUX</title>\n"; 814 print " <title>LINUX</title>\n";
815 print " <productname>Kernel Hackers Manual</productname>\n"; 815 print " <productname>Kernel Hackers Manual</productname>\n";
816 print " <date>$man_date</date>\n"; 816 print " <date>$man_date</date>\n";
817 print "</refentryinfo>\n"; 817 print "</refentryinfo>\n";
818 print "<refmeta>\n"; 818 print "<refmeta>\n";
819 print " <refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n"; 819 print " <refentrytitle><phrase>typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
820 print " <manvolnum>9</manvolnum>\n"; 820 print " <manvolnum>9</manvolnum>\n";
821 print "</refmeta>\n"; 821 print "</refmeta>\n";
822 print "<refnamediv>\n"; 822 print "<refnamediv>\n";
@@ -953,7 +953,11 @@ sub output_function_man(%) {
953 print $args{'function'}." \\- ".$args{'purpose'}."\n"; 953 print $args{'function'}." \\- ".$args{'purpose'}."\n";
954 954
955 print ".SH SYNOPSIS\n"; 955 print ".SH SYNOPSIS\n";
956 print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n"; 956 if ($args{'functiontype'} ne "") {
957 print ".B \"".$args{'functiontype'}."\" ".$args{'function'}."\n";
958 } else {
959 print ".B \"".$args{'function'}."\n";
960 }
957 $count = 0; 961 $count = 0;
958 my $parenth = "("; 962 my $parenth = "(";
959 my $post = ","; 963 my $post = ",";
@@ -1118,13 +1122,19 @@ sub output_intro_man(%) {
1118sub output_function_text(%) { 1122sub output_function_text(%) {
1119 my %args = %{$_[0]}; 1123 my %args = %{$_[0]};
1120 my ($parameter, $section); 1124 my ($parameter, $section);
1125 my $start;
1121 1126
1122 print "Name:\n\n"; 1127 print "Name:\n\n";
1123 print $args{'function'}." - ".$args{'purpose'}."\n"; 1128 print $args{'function'}." - ".$args{'purpose'}."\n";
1124 1129
1125 print "\nSynopsis:\n\n"; 1130 print "\nSynopsis:\n\n";
1126 my $start=$args{'functiontype'}." ".$args{'function'}." ("; 1131 if ($args{'functiontype'} ne "") {
1132 $start = $args{'functiontype'}." ".$args{'function'}." (";
1133 } else {
1134 $start = $args{'function'}." (";
1135 }
1127 print $start; 1136 print $start;
1137
1128 my $count = 0; 1138 my $count = 0;
1129 foreach my $parameter (@{$args{'parameterlist'}}) { 1139 foreach my $parameter (@{$args{'parameterlist'}}) {
1130 $type = $args{'parametertypes'}{$parameter}; 1140 $type = $args{'parametertypes'}{$parameter};
@@ -1433,7 +1443,7 @@ sub create_parameterlist($$$) {
1433 } elsif ($arg =~ m/\(.*\*/) { 1443 } elsif ($arg =~ m/\(.*\*/) {
1434 # pointer-to-function 1444 # pointer-to-function
1435 $arg =~ tr/#/,/; 1445 $arg =~ tr/#/,/;
1436 $arg =~ m/[^\(]+\(\*([^\)]+)\)/; 1446 $arg =~ m/[^\(]+\(\*\s*([^\)]+)\)/;
1437 $param = $1; 1447 $param = $1;
1438 $type = $arg; 1448 $type = $arg;
1439 $type =~ s/([^\(]+\(\*)$param/$1/; 1449 $type =~ s/([^\(]+\(\*)$param/$1/;
@@ -1536,7 +1546,7 @@ sub dump_function($$) {
1536 $prototype =~ s/^__always_inline +//; 1546 $prototype =~ s/^__always_inline +//;
1537 $prototype =~ s/^noinline +//; 1547 $prototype =~ s/^noinline +//;
1538 $prototype =~ s/__devinit +//; 1548 $prototype =~ s/__devinit +//;
1539 $prototype =~ s/^#define +//; #ak added 1549 $prototype =~ s/^#define\s+//; #ak added
1540 $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//; 1550 $prototype =~ s/__attribute__ \(\([a-z,]*\)\)//;
1541 1551
1542 # Yes, this truly is vile. We are looking for: 1552 # Yes, this truly is vile. We are looking for:
@@ -1570,7 +1580,8 @@ sub dump_function($$) {
1570 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1580 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1571 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1581 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1572 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1582 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1573 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { 1583 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1584 $prototype =~ m/^(\w+\s+\w+\s*\*\s*\w+\s*\*\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
1574 $return_type = $1; 1585 $return_type = $1;
1575 $declaration_name = $2; 1586 $declaration_name = $2;
1576 my $args = $3; 1587 my $args = $3;
@@ -1710,6 +1721,7 @@ sub process_file($) {
1710 my $file; 1721 my $file;
1711 my $identifier; 1722 my $identifier;
1712 my $func; 1723 my $func;
1724 my $descr;
1713 my $initial_section_counter = $section_counter; 1725 my $initial_section_counter = $section_counter;
1714 1726
1715 if (defined($ENV{'SRCTREE'})) { 1727 if (defined($ENV{'SRCTREE'})) {
@@ -1753,7 +1765,12 @@ sub process_file($) {
1753 1765
1754 $state = 2; 1766 $state = 2;
1755 if (/-(.*)/) { 1767 if (/-(.*)/) {
1756 $declaration_purpose = xml_escape($1); 1768 # strip leading/trailing/multiple spaces #RDD:T:
1769 $descr= $1;
1770 $descr =~ s/^\s*//;
1771 $descr =~ s/\s*$//;
1772 $descr =~ s/\s+/ /;
1773 $declaration_purpose = xml_escape($descr);
1757 } else { 1774 } else {
1758 $declaration_purpose = ""; 1775 $declaration_purpose = "";
1759 } 1776 }