mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
Makefile: Move some scripts imported from Linux
We have some scripts imported from Linux Kernel: setlocalversion, checkstack.pl, checkpatch.pl, cleanpatch They are located under tools/ directory in U-Boot now. But they were originally located under scripts/ directory in Linux Kernel. This commit moves them to the original location. It is true that binutils-version.sh and dtc-version.sh do not originate in Linux Kernel, but they should be moved by analogy to gcc-version.sh. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
This commit is contained in:
parent
392ba5256a
commit
dd88ab325c
9 changed files with 5 additions and 5 deletions
20
scripts/binutils-version.sh
Normal file
20
scripts/binutils-version.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# binutils-version [-p] gas-command
|
||||
#
|
||||
# Prints the binutils version of `gas-command' in a canonical 4-digit form
|
||||
# such as `0222' for binutils 2.22
|
||||
#
|
||||
|
||||
gas="$*"
|
||||
|
||||
if [ ${#gas} -eq 0 ]; then
|
||||
echo "Error: No assembler specified."
|
||||
printf "Usage:\n\t$0 <gas-command>\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAJOR=$($gas --version | head -1 | awk '{print $NF}' | cut -d . -f 1)
|
||||
MINOR=$($gas --version | head -1 | awk '{print $NF}' | cut -d . -f 2)
|
||||
|
||||
printf "%02d%02d\\n" $MAJOR $MINOR
|
3709
scripts/checkpatch.pl
Executable file
3709
scripts/checkpatch.pl
Executable file
File diff suppressed because it is too large
Load diff
171
scripts/checkstack.pl
Executable file
171
scripts/checkstack.pl
Executable file
|
@ -0,0 +1,171 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Check the stack usage of functions
|
||||
#
|
||||
# Copyright Joern Engel <joern@lazybastard.org>
|
||||
# Inspired by Linus Torvalds
|
||||
# Original idea maybe from Keith Owens
|
||||
# s390 port and big speedup by Arnd Bergmann <arnd@bergmann-dalldorf.de>
|
||||
# Mips port by Juan Quintela <quintela@mandrakesoft.com>
|
||||
# IA64 port via Andreas Dilger
|
||||
# Arm port by Holger Schurig
|
||||
# sh64 port by Paul Mundt
|
||||
# Random bits by Matt Mackall <mpm@selenic.com>
|
||||
# M68k port by Geert Uytterhoeven and Andreas Schwab
|
||||
# AVR32 port by Haavard Skinnemoen (Atmel)
|
||||
# PARISC port by Kyle McMartin <kyle@parisc-linux.org>
|
||||
# sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk>
|
||||
#
|
||||
# Usage:
|
||||
# objdump -d vmlinux | scripts/checkstack.pl [arch]
|
||||
#
|
||||
# TODO : Port to all architectures (one regex per arch)
|
||||
|
||||
use strict;
|
||||
|
||||
# check for arch
|
||||
#
|
||||
# $re is used for two matches:
|
||||
# $& (whole re) matches the complete objdump line with the stack growth
|
||||
# $1 (first bracket) matches the size of the stack growth
|
||||
#
|
||||
# $dre is similar, but for dynamic stack redutions:
|
||||
# $& (whole re) matches the complete objdump line with the stack growth
|
||||
# $1 (first bracket) matches the dynamic amount of the stack growth
|
||||
#
|
||||
# use anything else and feel the pain ;)
|
||||
my (@stack, $re, $dre, $x, $xs);
|
||||
{
|
||||
my $arch = shift;
|
||||
if ($arch eq "") {
|
||||
$arch = `uname -m`;
|
||||
chomp($arch);
|
||||
}
|
||||
|
||||
$x = "[0-9a-f]"; # hex character
|
||||
$xs = "[0-9a-f ]"; # hex character or space
|
||||
if ($arch eq 'arm') {
|
||||
#c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
|
||||
$re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
|
||||
} elsif ($arch eq 'avr32') {
|
||||
#8000008a: 20 1d sub sp,4
|
||||
#80000ca8: fa cd 05 b0 sub sp,sp,1456
|
||||
$re = qr/^.*sub.*sp.*,([0-9]{1,8})/o;
|
||||
} elsif ($arch =~ /^i[3456]86$/) {
|
||||
#c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
|
||||
$re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
|
||||
$dre = qr/^.*[as][du][db] (%.*),\%esp$/o;
|
||||
} elsif ($arch eq 'x86_64') {
|
||||
# 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
|
||||
$re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o;
|
||||
$dre = qr/^.*[as][du][db] (\%.*),\%rsp$/o;
|
||||
} elsif ($arch eq 'ia64') {
|
||||
#e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
|
||||
$re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
|
||||
} elsif ($arch eq 'm68k') {
|
||||
# 2b6c: 4e56 fb70 linkw %fp,#-1168
|
||||
# 1df770: defc ffe4 addaw #-28,%sp
|
||||
$re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
|
||||
} elsif ($arch eq 'mips64') {
|
||||
#8800402c: 67bdfff0 daddiu sp,sp,-16
|
||||
$re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
|
||||
} elsif ($arch eq 'mips') {
|
||||
#88003254: 27bdffe0 addiu sp,sp,-32
|
||||
$re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
|
||||
} elsif ($arch eq 'parisc' || $arch eq 'parisc64') {
|
||||
$re = qr/.*ldo ($x{1,8})\(sp\),sp/o;
|
||||
} elsif ($arch eq 'ppc') {
|
||||
#c00029f4: 94 21 ff 30 stwu r1,-208(r1)
|
||||
$re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
|
||||
} elsif ($arch eq 'ppc64') {
|
||||
#XXX
|
||||
$re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
|
||||
} elsif ($arch eq 'powerpc') {
|
||||
$re = qr/.*st[dw]u.*r1,-($x{1,8})\(r1\)/o;
|
||||
} elsif ($arch =~ /^s390x?$/) {
|
||||
# 11160: a7 fb ff 60 aghi %r15,-160
|
||||
# or
|
||||
# 100092: e3 f0 ff c8 ff 71 lay %r15,-56(%r15)
|
||||
$re = qr/.*(?:lay|ag?hi).*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})
|
||||
(?:\(\%r15\))?$/ox;
|
||||
} elsif ($arch =~ /^sh64$/) {
|
||||
#XXX: we only check for the immediate case presently,
|
||||
# though we will want to check for the movi/sub
|
||||
# pair for larger users. -- PFM.
|
||||
#a00048e0: d4fc40f0 addi.l r15,-240,r15
|
||||
$re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
|
||||
} elsif ($arch =~ /^blackfin$/) {
|
||||
# 0: 00 e8 38 01 LINK 0x4e0;
|
||||
$re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
|
||||
} elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
|
||||
# f0019d10: 9d e3 bf 90 save %sp, -112, %sp
|
||||
$re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
|
||||
} else {
|
||||
print("wrong or unknown architecture \"$arch\"\n");
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# main()
|
||||
#
|
||||
my $funcre = qr/^$x* <(.*)>:$/;
|
||||
my ($func, $file, $lastslash);
|
||||
|
||||
while (my $line = <STDIN>) {
|
||||
if ($line =~ m/$funcre/) {
|
||||
$func = $1;
|
||||
}
|
||||
elsif ($line =~ m/(.*):\s*file format/) {
|
||||
$file = $1;
|
||||
$file =~ s/\.ko//;
|
||||
$lastslash = rindex($file, "/");
|
||||
if ($lastslash != -1) {
|
||||
$file = substr($file, $lastslash + 1);
|
||||
}
|
||||
}
|
||||
elsif ($line =~ m/$re/) {
|
||||
my $size = $1;
|
||||
$size = hex($size) if ($size =~ /^0x/);
|
||||
|
||||
if ($size > 0xf0000000) {
|
||||
$size = - $size;
|
||||
$size += 0x80000000;
|
||||
$size += 0x80000000;
|
||||
}
|
||||
next if ($size > 0x10000000);
|
||||
|
||||
next if $line !~ m/^($xs*)/;
|
||||
my $addr = $1;
|
||||
$addr =~ s/ /0/g;
|
||||
$addr = "0x$addr";
|
||||
|
||||
my $intro = "$addr $func [$file]:";
|
||||
my $padlen = 56 - length($intro);
|
||||
while ($padlen > 0) {
|
||||
$intro .= ' ';
|
||||
$padlen -= 8;
|
||||
}
|
||||
next if ($size < 100);
|
||||
push @stack, "$intro$size\n";
|
||||
}
|
||||
elsif (defined $dre && $line =~ m/$dre/) {
|
||||
my $size = "Dynamic ($1)";
|
||||
|
||||
next if $line !~ m/^($xs*)/;
|
||||
my $addr = $1;
|
||||
$addr =~ s/ /0/g;
|
||||
$addr = "0x$addr";
|
||||
|
||||
my $intro = "$addr $func [$file]:";
|
||||
my $padlen = 56 - length($intro);
|
||||
while ($padlen > 0) {
|
||||
$intro .= ' ';
|
||||
$padlen -= 8;
|
||||
}
|
||||
push @stack, "$intro$size\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Sort output by size (last field)
|
||||
print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
|
258
scripts/cleanpatch
Executable file
258
scripts/cleanpatch
Executable file
|
@ -0,0 +1,258 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Clean a patch file -- or directory of patch files -- of stealth whitespace.
|
||||
# WARNING: this can be a highly destructive operation. Use with caution.
|
||||
#
|
||||
|
||||
use bytes;
|
||||
use File::Basename;
|
||||
|
||||
# Default options
|
||||
$max_width = 79;
|
||||
|
||||
# Clean up space-tab sequences, either by removing spaces or
|
||||
# replacing them with tabs.
|
||||
sub clean_space_tabs($)
|
||||
{
|
||||
no bytes; # Tab alignment depends on characters
|
||||
|
||||
my($li) = @_;
|
||||
my($lo) = '';
|
||||
my $pos = 0;
|
||||
my $nsp = 0;
|
||||
my($i, $c);
|
||||
|
||||
for ($i = 0; $i < length($li); $i++) {
|
||||
$c = substr($li, $i, 1);
|
||||
if ($c eq "\t") {
|
||||
my $npos = ($pos+$nsp+8) & ~7;
|
||||
my $ntab = ($npos >> 3) - ($pos >> 3);
|
||||
$lo .= "\t" x $ntab;
|
||||
$pos = $npos;
|
||||
$nsp = 0;
|
||||
} elsif ($c eq "\n" || $c eq "\r") {
|
||||
$lo .= " " x $nsp;
|
||||
$pos += $nsp;
|
||||
$nsp = 0;
|
||||
$lo .= $c;
|
||||
$pos = 0;
|
||||
} elsif ($c eq " ") {
|
||||
$nsp++;
|
||||
} else {
|
||||
$lo .= " " x $nsp;
|
||||
$pos += $nsp;
|
||||
$nsp = 0;
|
||||
$lo .= $c;
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
$lo .= " " x $nsp;
|
||||
return $lo;
|
||||
}
|
||||
|
||||
# Compute the visual width of a string
|
||||
sub strwidth($) {
|
||||
no bytes; # Tab alignment depends on characters
|
||||
|
||||
my($li) = @_;
|
||||
my($c, $i);
|
||||
my $pos = 0;
|
||||
my $mlen = 0;
|
||||
|
||||
for ($i = 0; $i < length($li); $i++) {
|
||||
$c = substr($li,$i,1);
|
||||
if ($c eq "\t") {
|
||||
$pos = ($pos+8) & ~7;
|
||||
} elsif ($c eq "\n") {
|
||||
$mlen = $pos if ($pos > $mlen);
|
||||
$pos = 0;
|
||||
} else {
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
$mlen = $pos if ($pos > $mlen);
|
||||
return $mlen;
|
||||
}
|
||||
|
||||
$name = basename($0);
|
||||
|
||||
@files = ();
|
||||
|
||||
while (defined($a = shift(@ARGV))) {
|
||||
if ($a =~ /^-/) {
|
||||
if ($a eq '-width' || $a eq '-w') {
|
||||
$max_width = shift(@ARGV)+0;
|
||||
} else {
|
||||
print STDERR "Usage: $name [-width #] files...\n";
|
||||
exit 1;
|
||||
}
|
||||
} else {
|
||||
push(@files, $a);
|
||||
}
|
||||
}
|
||||
|
||||
foreach $f ( @files ) {
|
||||
print STDERR "$name: $f\n";
|
||||
|
||||
if (! -f $f) {
|
||||
print STDERR "$f: not a file\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if (!open(FILE, '+<', $f)) {
|
||||
print STDERR "$name: Cannot open file: $f: $!\n";
|
||||
next;
|
||||
}
|
||||
|
||||
binmode FILE;
|
||||
|
||||
# First, verify that it is not a binary file; consider any file
|
||||
# with a zero byte to be a binary file. Is there any better, or
|
||||
# additional, heuristic that should be applied?
|
||||
$is_binary = 0;
|
||||
|
||||
while (read(FILE, $data, 65536) > 0) {
|
||||
if ($data =~ /\0/) {
|
||||
$is_binary = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_binary) {
|
||||
print STDERR "$name: $f: binary file\n";
|
||||
next;
|
||||
}
|
||||
|
||||
seek(FILE, 0, 0);
|
||||
|
||||
$in_bytes = 0;
|
||||
$out_bytes = 0;
|
||||
$lineno = 0;
|
||||
|
||||
@lines = ();
|
||||
|
||||
$in_hunk = 0;
|
||||
$err = 0;
|
||||
|
||||
while ( defined($line = <FILE>) ) {
|
||||
$lineno++;
|
||||
$in_bytes += length($line);
|
||||
|
||||
if (!$in_hunk) {
|
||||
if ($line =~
|
||||
/^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {
|
||||
$minus_lines = $2;
|
||||
$plus_lines = $4;
|
||||
if ($minus_lines || $plus_lines) {
|
||||
$in_hunk = 1;
|
||||
@hunk_lines = ($line);
|
||||
}
|
||||
} else {
|
||||
push(@lines, $line);
|
||||
$out_bytes += length($line);
|
||||
}
|
||||
} else {
|
||||
# We're in a hunk
|
||||
|
||||
if ($line =~ /^\+/) {
|
||||
$plus_lines--;
|
||||
|
||||
$text = substr($line, 1);
|
||||
$text =~ s/[ \t\r]*$//; # Remove trailing spaces
|
||||
$text = clean_space_tabs($text);
|
||||
|
||||
$l_width = strwidth($text);
|
||||
if ($max_width && $l_width > $max_width) {
|
||||
print STDERR
|
||||
"$f:$lineno: adds line exceeds $max_width ",
|
||||
"characters ($l_width)\n";
|
||||
}
|
||||
|
||||
push(@hunk_lines, '+'.$text);
|
||||
} elsif ($line =~ /^\-/) {
|
||||
$minus_lines--;
|
||||
push(@hunk_lines, $line);
|
||||
} elsif ($line =~ /^ /) {
|
||||
$plus_lines--;
|
||||
$minus_lines--;
|
||||
push(@hunk_lines, $line);
|
||||
} else {
|
||||
print STDERR "$name: $f: malformed patch\n";
|
||||
$err = 1;
|
||||
last;
|
||||
}
|
||||
|
||||
if ($plus_lines < 0 || $minus_lines < 0) {
|
||||
print STDERR "$name: $f: malformed patch\n";
|
||||
$err = 1;
|
||||
last;
|
||||
} elsif ($plus_lines == 0 && $minus_lines == 0) {
|
||||
# End of a hunk. Process this hunk.
|
||||
my $i;
|
||||
my $l;
|
||||
my @h = ();
|
||||
my $adj = 0;
|
||||
my $done = 0;
|
||||
|
||||
for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) {
|
||||
$l = $hunk_lines[$i];
|
||||
if (!$done && $l eq "+\n") {
|
||||
$adj++; # Skip this line
|
||||
} elsif ($l =~ /^[ +]/) {
|
||||
$done = 1;
|
||||
unshift(@h, $l);
|
||||
} else {
|
||||
unshift(@h, $l);
|
||||
}
|
||||
}
|
||||
|
||||
$l = $hunk_lines[0]; # Hunk header
|
||||
undef @hunk_lines; # Free memory
|
||||
|
||||
if ($adj) {
|
||||
die unless
|
||||
($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/);
|
||||
my $mstart = $1;
|
||||
my $mlin = $2;
|
||||
my $pstart = $3;
|
||||
my $plin = $4;
|
||||
my $tail = $5; # doesn't include the final newline
|
||||
|
||||
$l = sprintf("@@ -%d,%d +%d,%d @@%s\n",
|
||||
$mstart, $mlin, $pstart, $plin-$adj,
|
||||
$tail);
|
||||
}
|
||||
unshift(@h, $l);
|
||||
|
||||
# Transfer to the output array
|
||||
foreach $l (@h) {
|
||||
$out_bytes += length($l);
|
||||
push(@lines, $l);
|
||||
}
|
||||
|
||||
$in_hunk = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($in_hunk) {
|
||||
print STDERR "$name: $f: malformed patch\n";
|
||||
$err = 1;
|
||||
}
|
||||
|
||||
if (!$err) {
|
||||
if ($in_bytes != $out_bytes) {
|
||||
# Only write to the file if changed
|
||||
seek(FILE, 0, 0);
|
||||
print FILE @lines;
|
||||
|
||||
if ( !defined($where = tell(FILE)) ||
|
||||
!truncate(FILE, $where) ) {
|
||||
die "$name: Failed to truncate modified file: $f: $!\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
}
|
20
scripts/dtc-version.sh
Normal file
20
scripts/dtc-version.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# dtc-version dtc-command
|
||||
#
|
||||
# Prints the dtc version of `dtc-command' in a canonical 4-digit form
|
||||
# such as `0222' for binutils 2.22
|
||||
#
|
||||
|
||||
dtc="$*"
|
||||
|
||||
if [ ${#dtc} -eq 0 ]; then
|
||||
echo "Error: No dtc command specified."
|
||||
printf "Usage:\n\t$0 <dtc-command>\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAJOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 1)
|
||||
MINOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 2)
|
||||
|
||||
printf "%02d%02d\\n" $MAJOR $MINOR
|
32
scripts/gcc-version.sh
Normal file
32
scripts/gcc-version.sh
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# gcc-version [-p] gcc-command
|
||||
#
|
||||
# Prints the gcc version of `gcc-command' in a canonical 4-digit form
|
||||
# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
|
||||
#
|
||||
# With the -p option, prints the patchlevel as well, for example `029503' for
|
||||
# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
|
||||
#
|
||||
|
||||
if [ "$1" = "-p" ] ; then
|
||||
with_patchlevel=1;
|
||||
shift;
|
||||
fi
|
||||
|
||||
compiler="$*"
|
||||
|
||||
if [ ${#compiler} -eq 0 ]; then
|
||||
echo "Error: No compiler specified."
|
||||
printf "Usage:\n\t$0 <gcc-command>\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
|
||||
MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
|
||||
if [ "x$with_patchlevel" != "x" ] ; then
|
||||
PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
|
||||
printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
|
||||
else
|
||||
printf "%02d%02d\\n" $MAJOR $MINOR
|
||||
fi
|
177
scripts/setlocalversion
Executable file
177
scripts/setlocalversion
Executable file
|
@ -0,0 +1,177 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This scripts adds local version information from the version
|
||||
# control systems git, mercurial (hg) and subversion (svn).
|
||||
#
|
||||
# It was originally copied from the Linux kernel v3.2.0-rc4 and modified
|
||||
# to support the U-Boot build-system.
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [--save-scmversion] [srctree]" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
scm_only=false
|
||||
srctree=.
|
||||
if test "$1" = "--save-scmversion"; then
|
||||
scm_only=true
|
||||
shift
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
srctree=$1
|
||||
shift
|
||||
fi
|
||||
if test $# -gt 0 -o ! -d "$srctree"; then
|
||||
usage
|
||||
fi
|
||||
|
||||
scm_version()
|
||||
{
|
||||
local short
|
||||
short=false
|
||||
|
||||
cd "$srctree"
|
||||
if test -e .scmversion; then
|
||||
cat .scmversion
|
||||
return
|
||||
fi
|
||||
if test "$1" = "--short"; then
|
||||
short=true
|
||||
fi
|
||||
|
||||
# Check for git and a git repo.
|
||||
if test -e .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
|
||||
|
||||
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
|
||||
# it, because this version is defined in the top level Makefile.
|
||||
if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
|
||||
|
||||
# If only the short version is requested, don't bother
|
||||
# running further git commands
|
||||
if $short; then
|
||||
echo "+"
|
||||
return
|
||||
fi
|
||||
# If we are past a tagged commit (like
|
||||
# "v2.6.30-rc5-302-g72357d5"), we pretty print it.
|
||||
if atag="`git describe 2>/dev/null`"; then
|
||||
echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
|
||||
|
||||
# If we don't have a tag at all we print -g{commitish}.
|
||||
else
|
||||
printf '%s%s' -g $head
|
||||
fi
|
||||
fi
|
||||
|
||||
# Is this git on svn?
|
||||
if git config --get svn-remote.svn.url >/dev/null; then
|
||||
printf -- '-svn%s' "`git svn find-rev $head`"
|
||||
fi
|
||||
|
||||
# Update index only on r/w media
|
||||
[ -w . ] && git update-index --refresh --unmerged > /dev/null
|
||||
|
||||
# Check for uncommitted changes
|
||||
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
|
||||
| read dummy; then
|
||||
printf '%s' -dirty
|
||||
fi
|
||||
|
||||
# All done with git
|
||||
return
|
||||
fi
|
||||
|
||||
# Check for mercurial and a mercurial repo.
|
||||
if test -d .hg && hgid=`hg id 2>/dev/null`; then
|
||||
# Do we have an tagged version? If so, latesttagdistance == 1
|
||||
if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
|
||||
id=`hg log -r . --template '{latesttag}'`
|
||||
printf '%s%s' -hg "$id"
|
||||
else
|
||||
tag=`printf '%s' "$hgid" | cut -d' ' -f2`
|
||||
if [ -z "$tag" -o "$tag" = tip ]; then
|
||||
id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
|
||||
printf '%s%s' -hg "$id"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Are there uncommitted changes?
|
||||
# These are represented by + after the changeset id.
|
||||
case "$hgid" in
|
||||
*+|*+\ *) printf '%s' -dirty ;;
|
||||
esac
|
||||
|
||||
# All done with mercurial
|
||||
return
|
||||
fi
|
||||
|
||||
# Check for svn and a svn repo.
|
||||
if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
|
||||
rev=`echo $rev | awk '{print $NF}'`
|
||||
printf -- '-svn%s' "$rev"
|
||||
|
||||
# All done with svn
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
collect_files()
|
||||
{
|
||||
local file res
|
||||
|
||||
for file; do
|
||||
case "$file" in
|
||||
*\~*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
if test -e "$file"; then
|
||||
res="$res$(cat "$file")"
|
||||
fi
|
||||
done
|
||||
echo "$res"
|
||||
}
|
||||
|
||||
if $scm_only; then
|
||||
if test ! -e .scmversion; then
|
||||
res=$(scm_version)
|
||||
echo "$res" >.scmversion
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
#if test -e include/config/auto.conf; then
|
||||
# . include/config/auto.conf
|
||||
#else
|
||||
# echo "Error: kernelrelease not valid - run 'make prepare' to update it"
|
||||
# exit 1
|
||||
#fi
|
||||
CONFIG_LOCALVERSION=
|
||||
CONFIG_LOCALVERSION_AUTO=y
|
||||
|
||||
# localversion* files in the build and source directory
|
||||
res="$(collect_files localversion*)"
|
||||
if test ! "$srctree" -ef .; then
|
||||
res="$res$(collect_files "$srctree"/localversion*)"
|
||||
fi
|
||||
|
||||
# CONFIG_LOCALVERSION and LOCALVERSION (if set)
|
||||
res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"
|
||||
|
||||
# scm version string if not at a tagged commit
|
||||
if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
|
||||
# full scm version string
|
||||
res="$res$(scm_version)"
|
||||
else
|
||||
# append a plus sign if the repository is not in a clean
|
||||
# annotated or signed tagged state (as git describe only
|
||||
# looks at signed or annotated tags - git tag -a/-s) and
|
||||
# LOCALVERSION= is not specified
|
||||
if test "${LOCALVERSION+set}" != "set"; then
|
||||
scm=$(scm_version --short)
|
||||
res="$res${scm:++}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$res"
|
Loading…
Add table
Add a link
Reference in a new issue