Radix cross Linux Toolchains for ARC architecture

ARC Toolchains for boot loaders components of some SoCs (such as Amlogic System on Chip)

20 Commits   0 Branches   8 Tags
Index: 3pp/sources/README
===================================================================
--- 3pp/sources/README	(nonexistent)
+++ 3pp/sources/README	(revision 5)
@@ -0,0 +1,3 @@
+
+This directory may contains download procedures for 3pp tarballs.
+
Index: 3pp/sources
===================================================================
--- 3pp/sources	(nonexistent)
+++ 3pp/sources	(revision 5)

Property changes on: 3pp/sources
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,34 ##
+
+# Target build dirs
+.noarch/
+.host/
+
+.s8xx-newlib/
+
+# Hidden files (each file)
+.makefile
+
+# Tarballs
+*.gz
+*.bz2
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Default linux config files
+*.defconfig
+
+# Object Files
+*.[ao]
+
+# backup copies
+*~
Index: 3pp
===================================================================
--- 3pp	(nonexistent)
+++ 3pp	(revision 5)

Property changes on: 3pp
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,34 ##
+
+# Target build dirs
+.noarch/
+.host/
+
+.s8xx-newlib/
+
+# Hidden files (each file)
+.makefile
+
+# Tarballs
+*.gz
+*.bz2
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Default linux config files
+*.defconfig
+
+# Object Files
+*.[ao]
+
+# backup copies
+*~
Index: Makefile
===================================================================
--- Makefile	(nonexistent)
+++ Makefile	(revision 5)
@@ -0,0 +1,27 @@
+
+COMPONENT_TARGETS = $(TOOLCHAIN_HOST)
+
+
+include config.mk
+
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+config_makefile = targets-config.mk
+
+
+CLEANUP_FILES += $(config_makefile)
+
+
+BUILD_TARGETS = $(config_makefile)
+
+# CORE Makefile:
+
+include core.mk
+
+# Dependencies:
+
+$(config_makefile): $(config_makefile).template
+	@echo "Creating $(config_makefile) ..."
+	@cp $(config_makefile).template $@
Index: _kxLab.pm
===================================================================
--- _kxLab.pm	(nonexistent)
+++ _kxLab.pm	(revision 5)
@@ -0,0 +1,39 @@
+
+use strict;
+use warnings FATAL => 'all';
+
+package _kxLab;
+
+sub error
+{
+  my $message = shift;
+  my $func = shift;
+
+  print STDERR "Error: $message\n";
+  if( defined( $func ) )
+  {
+    &$func();
+  }
+  exit 1;
+}
+
+sub command_error
+{
+  my $command = shift;
+  my $context = shift;
+
+  error( "$command failed at @{$context}[1] line @{$context}[2]" );
+}
+
+sub system
+{
+  my $command = shift;
+
+  if( system( $command ) )
+  {
+    my @context = caller;
+    command_error($command, \@context);
+  }
+}
+
+1;
Index: apply_patches
===================================================================
--- apply_patches	(nonexistent)
+++ apply_patches	(revision 5)
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+use FindBin;
+use lib $FindBin::Bin;
+
+use strict;
+use warnings FATAL => 'all';
+use _kxLab;
+
+my $filename = shift or die "Error: Need a patch file";
+my $arg2 = shift;
+my $depmode = 0;
+my $dir = ".";
+if( defined( $arg2 ) )
+{
+  if( $arg2 eq "-dep-" )
+  {
+    $depmode = 1;
+  }
+  else
+  {
+    $dir = $arg2;
+  }
+}
+
+open( PATCH, "<$filename" ) or die "Error: Could not open patch file: $filename: $!";
+while( <PATCH> )
+{
+  next if /^#/;
+  if (/(\S+)\s*(.*)/)
+  {
+    if( $depmode )
+    {
+      print "$1 ";
+    }
+    else
+    {
+      my $arg = $2 || "-p0";
+      print "=== Applying $1 ===\n";
+      _kxLab::system( "patch -d $dir $arg < $1" );
+    }
+  }
+}
+close PATCH;
+if( $depmode )
+{
+  print "$filename\n";
+}
+

Property changes on: apply_patches
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: build_requires
===================================================================
--- build_requires	(nonexistent)
+++ build_requires	(revision 5)
@@ -0,0 +1,305 @@
+#!/usr/bin/perl
+
+use FindBin;
+use lib $FindBin::Bin;
+
+use strict;
+use warnings FATAL => 'all';
+
+use IO::Handle;
+use File::Basename;
+use File::Temp;
+use Getopt::Long;
+
+use _kxLab;
+
+#
+# Generate .$(HARDWARE)_requires file for current directory
+#
+# usage:
+#   $0 [options] topdir toolchain flavour
+#
+# where:
+#      'topdir' - is a absolute path to the top directory of checked out branch
+#   'toolchain' - is a TOOLCHAIN name
+#     'flavour' - is a HARDWARE variant
+#
+
+# global variables
+my (%all_requires, $top_dir, $opt_max_depth, %requires_depend, $requires_file, %skip_dirs);
+
+my ($toolchain, $flavour, $target_build_dir);
+
+
+sub usage
+{
+  print <<EOF;
+
+Usage: build_requires [options] topdir toolchain flavour
+Options:
+   --max-depth=i - where 'i' is a maximal directory depth for finding requires;
+      --skip-dir - directory to be skipped (such as dist or TARGET_BUILD_DIR);
+          topdir - is a absolute path to the top of checked out branch;
+       toolchain - is a TOOLCHAIN name;
+         flavour - is a HARDWARE variant.
+
+EOF
+  exit;
+}
+
+
+sub requires_depend
+{
+  my $makefile = shift;
+
+  if( ! exists $requires_depend{$makefile} )
+  {
+    print REQUIRES_DEPEND_FILE "$requires_file: $makefile\n\n";
+    print REQUIRES_DEPEND_FILE "$makefile:\n\n";
+    $requires_depend{$makefile} = "";
+  }
+}
+
+sub read_requires
+{
+  my $makefile = shift;
+  my $flavour  = shift;
+
+  # Add a dependency to the Makefile
+  requires_depend( $makefile );
+
+  my $cdir = dirname( $makefile );
+
+  my %requires;
+
+  #
+  # We read the head of Makefile until '__END_OF_REQUIRES__' keyword.
+  # The 'build-system/constants.mk' should be included before requires.
+  #
+  my $shell_output = <<`SHELL`;
+cd $cdir
+head -n `cat Makefile | grep -n "__END_OF_REQUIRES__" | cut -f 1 -d ':'` Makefile | \
+  make TOOLCHAIN=$toolchain FLAVOUR=$flavour -f - -p __build_requires__ 2>/dev/null | grep "REQUIRES"
+exit 0
+SHELL
+
+  while( $shell_output =~ m/^REQUIRES(.+= +)(.+)/gm )
+  {
+    my @n = split( " ", $2 );
+    foreach my $req ( @n )
+    {
+      my ($d, $f);
+
+      $d = `echo $req | cut -f 1 -d '^'`;
+      $d =~ s/^\s+|\s+$//;
+      if( $req =~ m/\^/ )
+      {
+        $f = `echo $req | cut -f 2 -d '^'`;
+        $f =~ s/^\s+|\s+$//;
+      }
+      else
+      {
+        $f = "";
+      }
+
+      if( $d eq "ALL_DIRS" )
+      {
+        my $dirname = dirname( $makefile );
+
+        opendir( DIR, "$dirname" ) or
+          _kxLab::error( "build_requires: Could not open directory: $dirname: $!" );
+        my @dirs = grep { ! /^\./ && -d "$_" && -f "$_/Makefile" } readdir( DIR );
+        closedir DIR;
+
+        foreach my $dir (@dirs)
+        {
+          requires_depend( "$dirname/$dir/Makefile" );
+          "$dirname/$dir" =~ m!$top_dir/(.+)!;
+          $requires{$1} = "";
+        }
+      }
+      else
+      {
+        # Print a nice error message if the REQUIRES statement points to a missing directory
+        _kxLab::error( "build_requires: REQUIRES '$d' in $makefile not found. Exit" ) if( ! -d "$top_dir/$d" );
+
+        if( -f "$top_dir/$d/Makefile" )
+        {
+          if( $f eq "" ) { $requires{$d} = "";            }
+          else           { $requires{$d . "^" . $f} = ""; }
+        }
+      }
+    }
+  }
+  return %requires;
+}
+
+sub start_depend
+{
+  my $req = shift;
+
+  print REQUIRES_FILE "$req:";
+}
+
+sub depend
+{
+  my $req = shift;
+
+  print REQUIRES_FILE " $req";
+}
+
+sub end_depend
+{
+  print REQUIRES_FILE "\n\n";
+}
+
+sub make_sub_requires
+{
+  my $req = shift;
+
+  if( ! exists $all_requires{$req} )
+  {
+    $all_requires{$req} = "";
+
+    my ($d, $f);
+
+    $d = `echo $req | cut -f 1 -d '^'`;
+    $d =~ s/^\s+|\s+$//;
+    if( $req =~ m/\^/ )
+    {
+      $f = `echo $req | cut -f 2 -d '^'`;
+      $f =~ s/^\s+|\s+$//;
+    }
+    else
+    {
+      $f = "";
+    }
+
+    # Read sub requires
+    my $makefile = "$top_dir/$d/Makefile";
+    my %sub_requires = read_requires( $makefile, $f );
+    if( scalar(%sub_requires) )
+    {
+      my @sorted_sub_requires = sort(keys %sub_requires);
+
+      # Build dependencies for sub requires
+      if( $f eq "" ) { start_depend( $d );            }
+      else           { start_depend( $d . "^" . $f ); }
+      foreach my $sub_req ( @sorted_sub_requires )
+      {
+        depend( $sub_req );
+      }
+      end_depend();
+
+      # Make sub sub requires
+      foreach my $sub_req ( @sorted_sub_requires )
+      {
+        make_sub_requires( $sub_req );
+      }
+    }
+  }
+}
+
+
+#
+# Parse the command line options
+#
+$opt_max_depth = 10;
+my @opt_skip_dirs;
+GetOptions( "max-depth=i" => \$opt_max_depth, "skip-dir=s" => \@opt_skip_dirs );
+%skip_dirs = map { $_ => "" } @opt_skip_dirs;
+
+# Get the rest of the command line
+my $topdir = shift;
+$toolchain = shift;
+$flavour   = shift;
+
+
+my $makefile = "Makefile";
+
+if( ! defined $topdir    or $topdir eq "" )    { usage; }
+if( ! defined $toolchain or $toolchain eq "" ) { usage; }
+if( ! defined $flavour   or $flavour eq "" )
+{
+  $flavour = "";
+  $target_build_dir = "." . $toolchain ;
+}
+else
+{
+  $target_build_dir = "." . $toolchain . "/" . $flavour;
+}
+
+_kxLab::error( "build_requires: $topdir is not a directory" ) if( ! -d $topdir );
+_kxLab::error( "build_requires: Makefile missing: $makefile" ) if ( ! -f $makefile );
+
+# setup $top_build_dir
+$top_dir = $topdir;
+my $build_system = $top_dir . "/build-system";
+#my $build_system = "build-system";
+
+_kxLab::system( "mkdir -p $target_build_dir" );
+
+$requires_file = $target_build_dir . "/" . ".requires";
+my $requires_depend_file = $requires_file . "_depend";
+
+# open the output files
+open(REQUIRES_FILE, "> $requires_file") or
+  _kxLab::error( "build_requires: Could not open $requires_file file: $!" );
+open(REQUIRES_DEPEND_FILE, "> $requires_depend_file") or
+  _kxLab::error( "build_requires: Could not open $requires_depend_file file: $!" );
+
+
+# root component
+my $pwd = `pwd`;
+chomp $pwd;
+$pwd =~ m!$top_dir(.*)!;
+my $root;
+if( $1 eq "" )
+{
+  $root = "all";
+}
+else
+{
+  $1 =~ m!/(.+)!;
+  $root = $1;
+}
+
+print REQUIRES_FILE "# ROOT=$root\n\n";
+print REQUIRES_DEPEND_FILE "\n";
+
+
+# read the makefile
+my %requires = read_requires( "$pwd/$makefile", $flavour );
+
+# ignore the "build-system" dependency (if any), since this dependency is implicit
+delete $requires{"build-system"};
+
+my @sorted_requires = sort(keys %requires);
+
+# build the all: rule
+start_depend( "all" );
+foreach my $req ( @sorted_requires )
+{
+  depend( $req );
+}
+end_depend();
+
+# build sub dependencies
+foreach my $req ( @sorted_requires )
+{
+  make_sub_requires( $req );
+}
+
+# Finish by including tree.mk
+print REQUIRES_FILE "TREEDIRS = ", join(" ", sort(keys %all_requires)), "\n\n";
+if( $pwd =~ m/$build_system/ )
+{
+  print REQUIRES_FILE "include \$(BUILDSYSTEM)/tree-bs.mk\n";
+}
+else
+{
+  print REQUIRES_FILE "include \$(BUILDSYSTEM)/tree.mk\n";
+}
+
+close REQUIRES_FILE;
+close REQUIRES_DEPEND_FILE;

Property changes on: build_requires
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: build_src_requires
===================================================================
--- build_src_requires	(nonexistent)
+++ build_src_requires	(revision 5)
@@ -0,0 +1,299 @@
+#!/usr/bin/perl
+
+use FindBin;
+use lib $FindBin::Bin;
+
+use strict;
+use warnings FATAL => 'all';
+
+use IO::Handle;
+use File::Basename;
+use File::Temp;
+use Getopt::Long;
+
+use _kxLab;
+
+#
+# Generate .src_requires file for current directory
+#
+# usage:
+#   $0 [options] topdir
+#
+# where:
+#   'topdir' - is a absolute path to the top directory of checked out branch
+#
+
+
+# global variables
+my (%all_requires, $top_dir, $opt_max_depth, %requires_depend, $requires_file, %skip_dirs);
+
+my %all_src_requires;
+
+sub usage
+{
+  print <<EOF;
+
+Usage: build_src_requires [options] topdir
+Options:
+   --max-depth=i - where 'i' is a maximal directory depth for finding requires;
+      --skip-dir - directory to be skipped (such as dist or TARGET_BUILD_DIR);
+          topdir - is a absolute path to the top of checked out branch.
+
+EOF
+  exit;
+}
+
+
+sub requires_depend
+{
+  my $makefile = shift;
+
+  if( ! exists $requires_depend{$makefile} )
+  {
+    print REQUIRES_DEPEND_FILE "$requires_file: $makefile\n\n";
+    print REQUIRES_DEPEND_FILE "$makefile:\n\n";
+    $requires_depend{$makefile} = "";
+  }
+}
+
+sub read_src_requires
+{
+  my $makefile  = shift;
+
+  # add a dependency to the Makefile
+  requires_depend($makefile);
+
+  my %requires;
+
+  my $shell_output = `cat $makefile`;
+
+  while( $shell_output =~ m/^SOURCE_REQUIRES(.+= +)(.+)/gm )
+  {
+    my @n = split( " ", $2 );
+    foreach my $d ( @n )
+    {
+      if( $d eq "ALL_DIRS" )
+      {
+        my $dirname = dirname($makefile);
+
+        opendir( DIR, "$dirname" ) or
+          _kxLab::error( "build_src_requires: Could not open directory: $dirname: $!" );
+        my @dirs = grep { ! /^\./ && -d "$_" && -f "$_/Makefile" } readdir( DIR );
+        closedir DIR;
+
+        foreach my $dir (@dirs)
+        {
+          requires_depend("$dirname/$dir/Makefile");
+          "$dirname/$dir" =~ m!$top_dir/(.+)!;
+          $requires{$1} = "";
+        }
+      }
+      else
+      {
+        # Print a nice error message if the SOURCE_REQUIRES statement points to a missing directory
+        _kxLab::error( "build_src_requires: SOURCE_REQUIRES '$d' in $makefile not found. Exit" ) if( ! -d "$top_dir/$d" );
+
+        if( -f "$top_dir/$d/Makefile" )
+        {
+          $requires{$d} = "";
+          requires_depend("$top_dir/$d/Makefile");
+        }
+      }
+    }
+  }
+  return %requires;
+}
+
+sub read_requires
+{
+  my $makefile  = shift;
+
+  # add a dependency to the Makefile
+  requires_depend($makefile);
+
+  my %requires;
+
+  my $shell_output = `cat $makefile`;
+
+  while( $shell_output =~ m/^REQUIRES(.+= +)(.+)/gm )
+  {
+    my @n = split( " ", $2 );
+    foreach my $req ( @n )
+    {
+      my $d = `echo $req | cut -f 1 -d '^'`;
+      $d =~ s/^\s+|\s+$//;
+
+      if( $d eq "ALL_DIRS" )
+      {
+        my $dirname = dirname($makefile);
+
+        opendir( DIR, "$dirname" ) or
+          _kxLab::error( "build_src_requires: Could not open directory: $dirname: $!" );
+        my @dirs = grep { ! /^\./ && -d "$_" && -f "$_/Makefile" } readdir( DIR );
+        closedir DIR;
+
+        foreach my $dir (@dirs)
+        {
+          requires_depend( "$dirname/$dir/Makefile" );
+          "$dirname/$dir" =~ m!$top_dir/(.+)!;
+          $requires{$1} = "";
+
+          my %src_requires = read_src_requires( "$dirname/$dir/Makefile" );
+          my @sort_src_requires = sort(keys %src_requires);
+          foreach my $req ( @sort_src_requires )
+          {
+            $all_src_requires{$req} = "";
+          }
+        }
+      }
+      else
+      {
+        # Print a nice error message if the REQUIRES statement points to a missing directory
+        _kxLab::error( "build_src_requires: REQUIRES '$d' in $makefile not found. Exit" ) if( ! -d "$top_dir/$d" );
+
+        if( -f "$top_dir/$d/Makefile" )
+        {
+          $requires{$d} = "";
+
+          my %src_requires = read_src_requires( "$top_dir/$d/Makefile" );
+          my @sort_src_requires = sort(keys %src_requires);
+          foreach my $req ( @sort_src_requires )
+          {
+            $all_src_requires{$req} = "";
+          }
+        }
+      }
+    }
+  }
+  return %requires;
+}
+
+sub start_depend
+{
+  my $req = shift;
+
+  print REQUIRES_FILE "$req:";
+}
+
+sub depend
+{
+  my $req = shift;
+
+  print REQUIRES_FILE " $req";
+}
+
+sub end_depend
+{
+  print REQUIRES_FILE "\n\n";
+}
+
+sub make_sub_requires
+{
+  my $req = shift;
+
+  if( ! exists $all_requires{$req} )
+  {
+    $all_requires{$req} = "";
+
+    my $d = `echo $req | cut -f 1 -d '^'`;
+    $d =~ s/^\s+|\s+$//;
+
+    # Read sub requires
+    my $makefile = "$top_dir/$d/Makefile";
+    my %sub_requires = read_requires( $makefile );
+    if( scalar(%sub_requires) )
+    {
+      # Make sub sub requires
+      my @sorted_sub_requires = sort(keys %sub_requires);
+      foreach my $sub_req ( @sorted_sub_requires )
+      {
+        make_sub_requires( $sub_req );
+      }
+    }
+  }
+}
+
+
+#
+# Parse the command line options
+#
+$opt_max_depth = 10;
+my @opt_skip_dirs;
+GetOptions( "max-depth=i" => \$opt_max_depth, "skip-dir=s" => \@opt_skip_dirs );
+%skip_dirs = map { $_ => "" } @opt_skip_dirs;
+
+# get the rest of the command line
+my $topdir   = shift;
+my $makefile = "Makefile";
+
+if( ! defined $topdir or $topdir eq "" ) { usage; }
+
+_kxLab::error( "build_requires: $topdir is not a directory" ) if( ! -d $topdir );
+_kxLab::error( "build_requires: Makefile missing: $makefile" ) if ( ! -f $makefile );
+
+# setup $top_build_dir
+$top_dir = $topdir;
+
+$requires_file = ".src_requires";
+my $requires_depend_file = $requires_file . "_depend";
+
+
+# open the output files
+open(REQUIRES_FILE, "> $requires_file") or
+  _kxLab::error( "build_requires: Could not open $requires_file file: $!" );
+open(REQUIRES_DEPEND_FILE, "> $requires_depend_file") or
+  _kxLab::error( "build_requires: Could not open $requires_depend_file file: $!" );
+
+
+# root component
+my $pwd = `pwd`;
+chomp $pwd;
+$pwd =~ m!$top_dir(.*)!;
+my $root;
+if( $1 eq "" )
+{
+  $root = "all";
+}
+else
+{
+  $1 =~ m!/(.+)!;
+  $root = $1;
+}
+
+print REQUIRES_FILE "# ROOT=$root\n\n";
+print REQUIRES_DEPEND_FILE "\n";
+
+# read the makefile
+%all_src_requires = read_src_requires( "$pwd/$makefile" );
+my %requires = read_requires( "$pwd/$makefile" );
+
+
+# check the "build-system" sub dependencies implicitly (excluding sources directories)
+#$requires{"build-system"} = "";
+
+
+# build sub dependencies
+my @sorted_requires = sort(keys %requires);
+foreach my $req ( @sorted_requires )
+{
+  make_sub_requires( $req );
+}
+
+# build the all: rule
+start_depend( "all" );
+my @sorted_src_requires = sort(keys %all_src_requires);
+foreach my $req ( @sorted_src_requires )
+{
+  depend( $req );
+}
+end_depend();
+
+
+# Finish by including tree.mk
+print REQUIRES_FILE "TREEDIRS = ", join(" ", sort(keys %all_src_requires)), "\n\n";
+print REQUIRES_FILE "include \$(BUILDSYSTEM)/tree-src.mk\n";
+
+
+# close output files
+close REQUIRES_FILE;
+close REQUIRES_DEPEND_FILE;

Property changes on: build_src_requires
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: canonical-build
===================================================================
--- canonical-build	(nonexistent)
+++ canonical-build	(revision 5)
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+  i*:CYGWIN*:*)
+    echo ${UNAME_MACHINE}-pc-cygwin
+    exit ;;
+  *:MINGW*:*)
+    echo ${UNAME_MACHINE}-pc-mingw32
+    exit ;;
+  amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+    echo x86_64-unknown-cygwin
+    exit ;;
+  i*86:Linux:*:*)
+    if [ -f /etc/slackware-version ]; then
+      system=`cat /etc/slackware-version | cut -f 1 -d ' ' | tr 'S' 's'`
+      echo ${UNAME_MACHINE}-${system}-linux
+    else
+      echo ${UNAME_MACHINE}-unknown-linux-gnu
+    fi
+    exit ;;
+  x86_64:Linux:*:*)
+    if [ -f /etc/slamd64-version ]; then
+      system=`cat /etc/slamd64-version | cut -f 1 -d ' ' | tr 'S' 's'`
+      echo x86_64-${system}-linux
+    elif [ -f /etc/slackware-version ]; then
+      system=`cat /etc/slackware-version | cut -f 1 -d ' ' | tr 'S' 's'`
+      echo x86_64-${system}-linux
+    elif [ -f /etc/os-release ]; then
+      system=`cat /etc/os-release | grep -e '^ID=' | cut -f 2 -d '='`
+      echo x86_64-linux-gnu
+    else
+      echo x86_64-unknown-linux-gnu
+    fi
+    exit ;;
+esac
+
+####### echo "unknown-unknown-unknown-unknown"
+
+cat >&2 <<EOF
+
+`basename $0`: unable to reciognize build system type
+
+   MACHINE = '${UNAME_MACHINE}'
+   SYSTEM  = '${UNAME_SYSTEM}'
+   RELEASE = '${UNAME_RELEASE}'
+   VERSION = '${UNAME_VERSION}'
+
+EOF
+
+exit 1

Property changes on: canonical-build
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: config.mk
===================================================================
--- config.mk	(nonexistent)
+++ config.mk	(revision 5)
@@ -0,0 +1,74 @@
+# include once
+ifndef CONFIG_MK
+
+#######
+####### Constants:
+#######
+
+
+DOWNLOAD_SERVER      = ftp://ftp.radix.pro
+
+WGET_OPTIONS         = -q -N
+
+CACHED_CC_OUTPUT     = /opt/extra/ccache
+
+TOOLCHAINS_BASE_PATH = /opt/toolchains
+
+TOOLCHAINS_VERSION   = 1.0.0
+
+
+# Build machine architrcture:
+
+BUILD_ARCH = x86_64-pc-linux-gnu
+#
+# HOST and BUILD variables should be set up for each makefile.
+# NOTE: the HOST is equal to BUILD because our toolchains work on BUILD machine.
+#
+ HOST = $(BUILD_ARCH)
+BUILD = $(BUILD_ARCH)
+
+
+#######
+####### Standard Available Toolchains:
+#######
+
+#
+# NOTE:
+# ====
+#   Toolchain names defined by 'TOOLCHAIN_...' variables.
+#   Configuration variable names such as HOST_ARCH, HOST_DIR, HOST_PATH should have prefix
+#   which is equal to $(TOOLCHAIN_...) in upper case letters and symbol '-' should be replaced with '_'.
+#   In other words the PREFIX is equal to PREFIX = $(shell echo $(TOOLCHAIN_...) | tr '[a-z-]' '[A-Z_]').
+#
+
+# NOARCH
+TOOLCHAIN_NOARCH = noarch
+
+NOARCH_ARCH = noarch
+NOARCH_DIR  = noarch
+NOARCH_PATH = $(TOOLCHAINS_BASE_PATH)/noarch
+
+
+# HOST
+TOOLCHAIN_HOST = host
+
+HOST_ARCH = $(BUILD_ARCH)
+HOST_DIR  = $(word 1, $(subst -, ,$(BUILD_ARCH)))
+HOST_PATH = $(TOOLCHAINS_BASE_PATH)/$(HOST_DIR)
+
+
+#######
+####### Additional Available Toolchains:
+#######
+
+# Amlogic S8XX
+TOOLCHAIN_S8XX_NEWLIB = s8xx-newlib
+
+S8XX_NEWLIB_ARCH = arc-s8xx-elf32
+S8XX_NEWLIB_DIR  = arc-S8XX-elf32-newlib
+S8XX_NEWLIB_PATH = $(TOOLCHAINS_BASE_PATH)/$(S8XX_NEWLIB_DIR)
+
+
+
+CONFIG_MK=1
+endif
Index: core.mk
===================================================================
--- core.mk	(nonexistent)
+++ core.mk	(revision 5)
@@ -0,0 +1,772 @@
+
+# include once
+ifndef CORE_MK
+
+#######
+####### helpful variables
+#######
+
+comma := ,
+empty :=
+space := $(empty) $(empty)
+
+
+#######
+####### Set up TOP_BUILD_DIR, TOP_BUILD_DIR_ABS and BUILDSYSTEM variables
+#######
+
+ifndef MAKEFILE_LIST
+
+# Work-around for GNU make pre-3.80, which lacks MAKEFILE_LIST and $(eval ...)
+
+TOP_BUILD_DIR := $(shell perl -e 'for ($$_ = "$(CURDIR)"; ! -d "$$_/build-system"; s!(.*)/(.*)!\1!) { $$q .= "../"; } chop $$q; print "$$q"')
+ifeq ($(TOP_BUILD_DIR),)
+TOP_BUILD_DIR=.
+endif
+export TOP_BUILD_DIR_ABS := $(shell perl -e 'for ($$_ = "$(CURDIR)"; ! -d "$$_/build-system"; s!(.*)/(.*)!\1!) { } print')
+export BUILDSYSTEM := $(TOP_BUILD_DIR_ABS)/build-system
+
+else
+
+# Normal operation for GNU make 3.80 and above
+
+__pop = $(patsubst %/,%,$(dir $(1)))
+__tmp := $(call __pop,$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+# Special case for build-system/Makefile
+ifeq ($(__tmp),.)
+__tmp := ../$(notdir $(CURDIR))
+endif
+
+ifndef TOP_BUILD_DIR
+TOP_BUILD_DIR := $(call __pop,$(__tmp))
+endif
+
+ifndef TOP_BUILD_DIR_ABS
+TOP_BUILD_DIR_ABS := $(CURDIR)
+ifneq ($(TOP_BUILD_DIR),.)
+$(foreach ,$(subst /, ,$(TOP_BUILD_DIR)),$(eval TOP_BUILD_DIR_ABS := $(call __pop,$(TOP_BUILD_DIR_ABS))))
+endif
+export TOP_BUILD_DIR_ABS
+endif
+
+ifndef BUILDSYSTEM
+export BUILDSYSTEM := $(TOP_BUILD_DIR_ABS)/$(notdir $(__tmp))
+endif
+
+endif
+
+#######
+####### Set up SOURCE PACKAGE directory:
+#######
+
+export SRC_PACKAGE_DIR      := sources
+export SRC_PACKAGE_PATH     := $(TOP_BUILD_DIR)/$(SRC_PACKAGE_DIR)
+export SRC_PACKAGE_PATH_ABS := $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR)
+
+
+
+#######
+####### Config:
+#######
+
+include $(BUILDSYSTEM)/config.mk
+
+TOOLCHAIN_ALL = $(strip $(foreach t, $(filter TOOLCHAIN_%,       \
+                                 $(filter-out TOOLCHAIN_ALL      \
+                                              TOOLCHAIN_NAMES    \
+                                              TOOLCHAIN_DIR      \
+                                              TOOLCHAIN_PATH     \
+                                              TOOLCHAIN_VERSION, \
+                                              $(.VARIABLES))), $($(t))))
+
+TOOLCHAIN_NAMES = $(filter-out $(TOOLCHAIN_NOARCH), $(TOOLCHAIN_ALL))
+
+COMPONENT_TOOLCHAINS = $(TOOLCHAIN_ALL)
+
+
+#######
+####### Set up targets etc
+#######
+
+ifneq ($(wildcard $(BUILDSYSTEM)/targets-config.mk),)
+include $(BUILDSYSTEM)/targets-config.mk
+else
+include $(BUILDSYSTEM)/targets-config.mk.template
+endif
+
+# Reading targets-config.mk:
+
+# BUILD_NOARCH always enabled:
+BUILD_NOARCH = true
+
+enabled = $(filter BUILD_%, $(filter-out BUILD_TARGETS BUILD_ARCH, $(.VARIABLES)))
+
+toolchain_filter = $(strip $(foreach t, \
+                     $(strip $(foreach b, \
+                       $(enabled), $(if $(filter true, $($(b))), \
+                         $(subst BUILD_, TOOLCHAIN_, $(b))))), $($(t))))
+
+
+# If no TOOLCHAIN set
+ifeq ($(TOOLCHAIN),)
+
+# COMPONENT_TARGETS must have a value specified in the Makefile
+ifeq ($(COMPONENT_TARGETS),)
+$(error Error: COMPONENT_TARGETS must have a value)
+endif
+
+# End if no TARGET set
+endif
+
+# Error ff TOOLCHAIN is invalid
+ifneq ($(TOOLCHAIN),)
+ifeq ($(filter $(TOOLCHAIN), $(TOOLCHAIN_ALL)),)
+$(error Error: TOOLCHAIN is invalid)
+endif
+endif
+
+
+#######
+####### Filter out disabled targets
+#######
+
+COMPONENT_TARGETS := $(filter $(toolchain_filter), $(COMPONENT_TARGETS))
+
+
+#######
+####### Targets setup:
+#######
+
+COMPONENT_TOOLCHAINS := $(filter $(COMPONENT_TARGETS),$(COMPONENT_TOOLCHAINS))
+
+
+#
+# TARGET, TOOLCHAIN_PATH variables should be set up for each makefile
+#
+
+# If toolchain version is not exported then we use default one 
+ifeq ($(TOOLCHAIN_VERSION),)
+TOOLCHAIN_VERSION = $(TOOLCHAINS_VERSION)
+endif
+
+#
+# Setup current toolchain variables
+#
+
+TOOLCHAIN_DIR  = $($(shell echo $(TOOLCHAIN) | tr '[a-z-]' '[A-Z_]')_DIR)
+TOOLCHAIN_PATH = $($(shell echo $(TOOLCHAIN) | tr '[a-z-]' '[A-Z_]')_PATH)/$(TOOLCHAIN_VERSION)
+TARGET         = $($(shell echo $(TOOLCHAIN) | tr '[a-z-]' '[A-Z_]')_ARCH)
+
+
+#######
+####### Configuration:
+#######
+
+# Build environment:
+
+DEST_DIR_ABS           = $(TOP_BUILD_DIR_ABS)/dist
+
+ifeq ($(NEEDS_ABS_PATHS),)
+DEST_DIR               = $(TOP_BUILD_DIR)/dist
+else
+DEST_DIR               = $(DEST_DIR_ABS)
+endif
+
+TARGET_DEST_DIR        = $(DEST_DIR)/$(TOOLCHAIN)
+
+
+################################################################
+# Check the list of available targets for current Makefile
+#
+__available_targets =                                                                 \
+  $(foreach arch, $(shell echo $(COMPONENT_TOOLCHAINS) | sed -e 's/x86_64/x86-64/g'), \
+    $(if $(FLAVOURS),                                                                 \
+      $(foreach flavour, $(FLAVOURS),                                                 \
+        .target_$(arch)_$(flavour)                                                    \
+       ) .target_$(arch),                                                             \
+      .target_$(arch)                                                                 \
+     )                                                                                \
+   )
+
+__available_targets := $(strip $(__available_targets))
+__available_targets := $(sort $(__available_targets))
+#
+#
+################################################################
+
+
+
+#######
+####### Parallel control:
+#######
+
+ifneq ($(NO_PARALLEL),)
+MAKEFLAGS += -j1
+.NOTPARALLEL:
+endif
+
+ifeq ($(VERBOSE),)
+guiet = @
+else
+quiet =
+endif
+
+
+
+#######
+####### Default PREFIX:
+#######
+
+PREFIX ?= $(DEST_DIR)
+
+
+#######
+####### Setup ccache:
+#######
+
+ifeq ($(NO_CCACHE),)
+CCACHE = /usr/bin/ccache$(space)
+
+ifeq ($(wildcard $(CCACHE)),)
+$(info )
+$(info #######)
+$(info ####### Please install 'ccache' package)
+$(info ####### or disable ccache with "NO_CCACHE=1 make ...")
+$(info #######)
+$(info )
+$(error Error: ccache not found)
+endif
+
+ifeq ($(wildcard $(CACHED_CC_OUTPUT)),)
+$(info )
+$(info #######)
+$(info ####### Please create directory $(CACHED_CC_OUTPUT) for cached compiler output)
+$(info ####### or disable ccache with "NO_CCACHE=1 make ...")
+$(info #######)
+$(info )
+$(error Error: cached compiler output directory doesn't exist)
+endif
+
+export CCACHE_BASEDIR = $(TOP_BUILD_DIR_ABS)
+export CCACHE_DIR     = $(CACHED_CC_OUTPUT)
+export CCACHE_UMASK   = 000
+
+unexport CCACHE_PREFIX
+else
+CCACHE =
+endif
+
+
+
+#######
+####### Cleanup files:
+#######
+
+CLEANUP_FILES += .dist.*
+CLEANUP_FILES += $(addprefix ., $(TOOLCHAIN))
+CLEANUP_FILES += .*requires*
+CLEANUP_FILES += $(SRC_DIR)
+CLEANUP_FILES += $(SRC_DIR).back.??????
+
+
+#######
+####### Build rules:
+#######
+
+all: BUILD_TREE := true
+export BUILD_TREE
+
+all:
+	@$(MAKE) local_all
+
+#
+# clean is equal to local_clean
+#
+clean:
+	@$(MAKE) local_clean
+
+
+__quick_targets := help local_clean downloads_clean targets-config.mk $(HACK_TARGETS)
+
+
+#
+# GLOBAL setup targets:
+# ====================
+#   These targets are built before all targets. For example, source tarballs
+#   have to be downloaded before starting the build.
+#
+#   NOTE:
+#     BUILDSYSTEM is a setup target for other directories and the BUILDSYSTEM
+#     requires only '.sources' target as a setup target.
+#
+ifeq ($(filter %_clean,$(MAKECMDGOALS)),)
+ifeq ($(shell pwd),$(BUILDSYSTEM))
+__setup_targets = .sources
+else
+__setup_targets = .sources .build_system
+endif
+endif
+
+
+
+.setup:
+ifeq ($(__final__),)
+.setup: $(__setup_targets)
+else
+.setup: .makefile
+endif
+
+
+# Check if Makefile has been changed:
+
+.makefile: Makefile
+ifneq ($(shell pwd),$(TOP_BUILD_DIR_ABS))
+ifneq ($(if $(MAKECMDGOALS),$(filter-out $(__quick_targets),$(MAKECMDGOALS)),true),)
+	@touch $@
+ifeq ($(shell pwd | grep $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR))$(shell pwd | grep $(BUILDSYSTEM)/3pp/sources),)
+	@echo -e "\n======= New makefile ($(<F)), clean! ======="
+	@$(MAKE) dist_clean
+	@if $(MAKE) local_clean ; then true ; else rm -f $@ ; fi
+else
+	@if $(MAKE) download_clean ; then true ; else rm -f $@; fi
+endif
+endif
+endif
+
+
+
+#######
+####### Build directory dependencies into .src_requires  which
+####### is used as a Makefile for srource tarballs downloading
+#######
+
+.sources: .src_requires
+
+.src_requires_depend: .src_requires ;
+
+.src_requires: .makefile
+ifneq ($(shell pwd),$(TOP_BUILD_DIR_ABS))
+ifeq ($(filter %_clean,$(MAKECMDGOALS)),)
+ifeq ($(__final__),)
+	@echo ""
+	@echo -e "################################################################"
+	@echo -e "#######"
+	@echo -e "####### Start of building source requires for '$(subst $(TOP_BUILD_DIR_ABS)/,,$(CURDIR))':"
+	@echo -e "#######"
+	@$(BUILDSYSTEM)/build_src_requires $(TOP_BUILD_DIR_ABS)
+	@__final__= TREE_RULE=local_all $(MAKE) TOOLCHAIN=$(TOOLCHAIN_NOARCH) FLAVOUR= -f .src_requires
+	@echo -e "#######"
+	@echo -e "####### End of building source requires for '$(subst $(TOP_BUILD_DIR_ABS)/,,$(CURDIR))'."
+	@echo -e "#######"
+	@echo -e "################################################################"
+	@echo ""
+	@touch $@
+	@touch .src_requires_depend
+endif
+endif
+endif
+
+
+
+.build_system:
+ifneq ($(shell pwd),$(TOP_BUILD_DIR_ABS))
+ifeq ($(shell pwd | grep $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR))$(shell pwd | grep $(BUILDSYSTEM)/3pp/sources),)
+ifeq ($(shell pwd | grep $(BUILDSYSTEM)),)
+	@echo -e "################################################################"
+	@echo -e "#######"
+	@echo -e "####### Start to Check the BUILDSYSTEM is ready:"
+	@echo -e "#######"
+	@( cd $(BUILDSYSTEM) ; __final__= $(MAKE) TOOLCHAIN=$(TOOLCHAIN_HOST) FLAVOUR= all )
+	@echo -e "#######"
+	@echo -e "####### End of checking the BUILDSYSTEM."
+	@echo -e "#######"
+	@echo -e "################################################################"
+endif
+endif
+endif
+
+
+
+#######
+####### Clean up default rules (not depend of TOOLCHAIN):
+#######
+
+dist_clean:
+	@if [ -f .dist ]; then $(BUILDSYSTEM)/dist_clean $(DEST_DIR); rm .dist; fi
+
+
+# NOTE:
+# ====
+#   Do not create directories with names that match the names of architectures!!!
+#
+tree_clean: .tree_clean
+
+.tree_clean:
+	@echo "Tree Clean..."
+	@$(BUILDSYSTEM)/tree_clean $(addprefix ., $(TOOLCHAIN_NAMES)) $(TOP_BUILD_DIR_ABS)
+
+
+#######
+####### Clean all downloaded source tarballs
+#######
+
+downloads_clean: .downloads_clean
+
+.downloads_clean:
+	@echo ""
+	@echo -e "#######"
+	@echo -e "####### Cleaning Up all downloaded sources..."
+	@echo -e "#######"
+	@$(BUILDSYSTEM)/downloads_clean $(addprefix ., $(TOOLCHAIN_NOARCH)) $(BUILDSYSTEM)/3pp/sources
+ifneq ($(wildcard $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR)),)
+	@$(BUILDSYSTEM)/downloads_clean $(addprefix ., $(TOOLCHAIN_NOARCH)) $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR)
+endif
+
+
+
+#######
+####### Source archive and patch handling
+#######
+
+# Patch dependency:
+PATCHES_DEP = $(foreach patch,$(PATCHES),\
+	$(shell $(BUILDSYSTEM)/apply_patches $(patch) -dep-))
+
+SRC_DIR_BASE = $(dir $(SRC_DIR))
+
+# Unpack SRC_ARCHIVE in SRC_DIR and backup old SRC_DIR:
+UNPACK_SRC_ARCHIVE = \
+	@echo "Expanding $(SRC_ARCHIVE)"; \
+	if [ -d $(SRC_DIR) ]; then mv $(SRC_DIR) $$(mktemp -d $(SRC_DIR).bak.XXXXXX); fi; \
+	mkdir -p $(SRC_DIR_BASE); \
+	$(if $(findstring .rpm,$(SRC_ARCHIVE)), \
+	  cd $(SRC_DIR_BASE) && rpm2cpio $(SRC_ARCHIVE) | cpio -id --quiet, \
+	  $(if $(findstring .zip,$(SRC_ARCHIVE)), \
+	    unzip -q -d $(SRC_DIR_BASE) $(SRC_ARCHIVE), \
+	    tar $(if $(findstring .bz2,$(SRC_ARCHIVE)),-xjf, \
+	             $(if $(findstring .xz,$(SRC_ARCHIVE)),-xJf, \
+	             $(if $(findstring .txz,$(SRC_ARCHIVE)),-xJf,-xzf))) \
+	      $(SRC_ARCHIVE) -C $(SRC_DIR_BASE))); \
+	chmod -R u+w $(SRC_DIR)
+
+# Apply patches in PATCHES on SRC_DIR_BASE:
+APPLY_PATCHES = $(quiet)$(foreach patch,$(PATCHES),\
+	$(BUILDSYSTEM)/apply_patches $(patch) $(SRC_DIR_BASE) &&) true
+
+# Apply optional patches in OPT_PATCHES on SRC_DIR_BASE:
+APPLY_OPT_PATCHES = $(quiet)$(foreach patch,$(OPT_PATCHES),\
+	$(BUILDSYSTEM)/apply_patches $(patch) $(SRC_DIR_BASE) &&) true
+
+
+# Example rule:
+#
+# src_done = $(SRC_DIR)/.source-done
+#
+# $(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+# 	$(UNPACK_SRC_ARCHIVE)
+# 	$(APPLY_PATCHES)
+# 	 <other stuff that needs to be done to the source,
+# 	   should be empty in most cases>
+# 	@touch $@
+
+
+
+
+################################################################
+#
+# No '__final__' target selected:
+# ==============================
+#
+# Parse TOOLCHAIN, HARDWARE, FLAVOUR selected in command line
+# and build the list of '__final__' targets.
+#
+ifeq ($(__final__),)
+
+#
+# The FLAVOUR can be defined in command line.
+# If command line defines empty flavour FLAVOUR= then
+# we define that variable is set but has no values.
+#
+__cmdline_flavour_defined = $(if $(filter FLAVOUR,$(.VARIABLES)),true,false)
+ifeq ($(__cmdline_flavour_defined),true)
+__cmdline_flavour_value = $(FLAVOUR)
+else
+__cmdline_flavour_value =
+endif
+
+
+##################################################
+# -----------+---------+-------------------+-----
+#  TOOLCHAIN | FLAVOUR | FLAVOUR has VALUE | REF
+# -----------+---------+-------------------+-----
+#    defined | defined |         no        | (0)
+#    defined | defined |         yes       | (1)
+#    defined |    ~    |         ~         | (2)
+#       ~    | defined |         no        | (3)
+#       ~    | defined |         yes       | (4)
+#       ~    |    ~    |         ~         | (5)
+# -----------+---------+-------------------+-----
+##################################################
+
+ifeq ($(TOOLCHAIN),)
+ifeq ($(__cmdline_flavour_defined),false)
+ifeq ($(FLAVOUR),)
+# (5) then we loop over all available flavours
+__target_args = $(__available_targets)
+endif
+else
+ifneq ($(FLAVOUR),)
+# (4) then we use only one defined flavour
+__target_args = $(foreach toolchain,                                                          \
+                    $(shell echo $(COMPONENT_TOOLCHAINS) | sed -e 's/x86_64/x86-64/g'),       \
+                    .target_$(toolchain)_$(FLAVOUR)                                           \
+                 )
+else
+# (3) then we define flavour as empty
+__target_args = $(foreach toolchain,                                                          \
+                    $(shell echo $(COMPONENT_TOOLCHAINS) | sed -e 's/x86_64/x86-64/g'),       \
+                    .target_$(toolchain)                                                      \
+                 )
+endif
+endif
+else
+ifeq ($(__cmdline_flavour_defined),false)
+ifeq ($(FLAVOUR),)
+# (2) then we loop over all available flavours
+__target_args = .target_$(shell echo $(TOOLCHAIN) | sed -e 's/x86_64/x86-64/g') $(if $(FLAVOURS), $(foreach flavour, $(FLAVOURS), .target_$(shell echo $(TOOLCHAIN) | sed -e 's/x86_64/x86-64/g')_$(flavour)),)
+endif
+else
+ifneq ($(FLAVOUR),)
+# (1) then we use only one defined flavour
+__target_args = .target_$(shell echo $(TOOLCHAIN) | sed -e 's/x86_64/x86-64/g')_$(FLAVOUR)
+else
+# (0) then we define flavour as empty
+__target_args = .target_$(shell echo $(TOOLCHAIN) | sed -e 's/x86_64/x86-64/g')
+endif
+endif
+endif
+
+
+__target_args := $(strip $(__target_args))
+
+
+__targets = $(filter $(__target_args), $(__available_targets))
+
+# Now we have to sort targets for that the main targets should be built before flavours!
+__targets := $(sort $(__targets))
+
+
+ifeq ($(__targets),)
+$(error Error: Selected combination [TOOLCHAIN=$(TOOLCHAIN), FLAVOUR=$(FLAVOUR)] is invalid for this Makefile)
+endif
+
+
+$(__targets): .setup
+
+local_all: GOAL = local_all
+local_all: $(__targets)
+
+local_clean: GOAL = local_clean
+local_clean: $(__targets)
+
+
+.target_%: TOOLCHAIN = $(shell echo $(word 2, $(subst _, , $@)) | sed -e 's/x86-64/x86_64/g')
+.target_%: FLAVOUR = $(word 3, $(subst _, , $@))
+.target_%:
+	@echo ""
+	@echo "======="
+	@echo "======= TOOLCHAIN: $(TOOLCHAIN); FLAVOUR =$(if $(FLAVOUR), $(FLAVOUR));  ====="
+	@echo "======="
+	@__final__=true $(MAKE) TOOLCHAIN=$(TOOLCHAIN) FLAVOUR=$(FLAVOUR) $(GOAL)
+
+else
+#
+################################################################
+#
+# The '__final__' target is defined, run the build process.
+
+
+# Target is selected, build it
+
+ifneq ($(NO_CREATE_DIST_FILES),true)
+local_all: CREATE_DIST_FILES = 1
+endif
+
+ifneq ($(findstring $(TOOLCHAIN),$(TOOLCHAIN_NAMES)),)
+ifeq ($(shell pwd),$(BUILDSYSTEM))
+$(shell mkdir -p .$(TOOLCHAIN))
+else
+$(shell mkdir -p .$(TOOLCHAIN)$(if $(FLAVOUR),/$(FLAVOUR)))
+endif
+endif
+
+# TOOLCHAIN/FLAVOUR depended directories
+
+ifneq ($(TOOLCHAIN),$(TOOLCHAIN_NOARCH))
+ifeq ($(shell pwd),$(BUILDSYSTEM))
+targetflavour = .$(TOOLCHAIN)
+else
+targetflavour = .$(TOOLCHAIN)$(if $(FLAVOUR),/$(FLAVOUR))
+endif
+else
+targetflavour = $(CURDIR)
+endif
+
+TARGET_BUILD_DIR = $(targetflavour)
+
+
+
+ifeq ($(BUILD_TREE),true)
+_tree := .tree_all
+else
+_tree := .requires_tree
+endif
+
+
+local_all: $(_tree) install
+
+local_clean:
+
+
+.tree_all: $(TARGET_BUILD_DIR)/.requires
+ifneq ($(shell pwd),$(TOP_BUILD_DIR_ABS))
+ifeq ($(shell pwd | grep $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR))$(shell pwd | grep $(BUILDSYSTEM)/3pp/sources),)
+	@echo -e "################################################################"
+	@echo -e "#######"
+ifeq ($(shell pwd),$(BUILDSYSTEM))
+	@echo -e "####### Start of building requires for '$(subst $(TOP_BUILD_DIR_ABS)/,,$(CURDIR))':"
+else
+	@echo -e "####### Start of building requires for TOOLCHAIN=$(TOOLCHAIN) FLAVOUR=$(FLAVOUR) in '$(subst $(TOP_BUILD_DIR_ABS)/,,$(CURDIR))':"
+endif
+	@echo -e "#######"
+ifeq ($(shell pwd),$(BUILDSYSTEM))
+	@__final__=true TREE_RULE=local_all $(MAKE) TOOLCHAIN=$(TOOLCHAIN_HOST) FLAVOUR= -f $(TARGET_BUILD_DIR)/.requires
+else
+	@__final__=true TREE_RULE=local_all $(MAKE) TOOLCHAIN=$(TOOLCHAIN) FLAVOUR= -f $(TARGET_BUILD_DIR)/.requires
+endif
+	@echo -e "#######"
+	@echo -e "####### End of building requires for '$(subst $(TOP_BUILD_DIR_ABS)/,,$(CURDIR))'."
+	@echo -e "#######"
+	@echo -e "################################################################"
+endif
+endif
+
+
+.requires_tree: $(TARGET_BUILD_DIR)/.requires
+
+#######
+####### Build directory dependencies into $(TARGET_BUILD_DIR)/.requires
+####### file which is used as a Makefile for tree builds.
+#######
+
+$(TARGET_BUILD_DIR)/.requires_depend: $(TARGET_BUILD_DIR)/.requires ;
+
+$(TARGET_BUILD_DIR)/.requires: .makefile
+ifeq ($(filter %_clean,$(MAKECMDGOALS)),)
+ifneq ($(shell pwd),$(TOP_BUILD_DIR_ABS))
+ifeq ($(shell pwd | grep $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR))$(shell pwd | grep $(BUILDSYSTEM)/3pp/sources),)
+ifeq ($(shell pwd),$(BUILDSYSTEM))
+	@$(BUILDSYSTEM)/build_requires $(TOP_BUILD_DIR_ABS) $(TOOLCHAIN_HOST) ; wait
+else
+	@$(BUILDSYSTEM)/build_requires $(TOP_BUILD_DIR_ABS) $(TOOLCHAIN) $(FLAVOUR) ; wait
+endif
+endif
+endif
+endif
+
+
+
+
+################################################################
+#######
+####### Waiting for build whole required tree:
+#######
+
+$(BUILD_TARGETS): | $(_tree)
+
+#######
+####### End of waiting for build whole required tree.
+#######
+################################################################
+
+$(PRODUCT_TARGETS) : | $(BUILD_TARGETS)
+
+
+#######
+####### Install:
+#######
+
+install: .install
+	@if [ "$$(echo .dist*)" != ".dist*" ]; then \
+	  sort -o .dist.tmp -u .dist* && mv .dist.tmp .dist; \
+	fi
+	@rm -f .dist.*
+
+
+.install: .install_builds .install_products
+
+
+
+
+.install_builds: $(BUILD_TARGETS)
+# Do nothing
+
+.install_products: DO_CREATE_DIST_FILES = $(CREATE_DIST_FILES)
+export DO_CREATE_DIST_FILES
+
+.install_products: $(PRODUCT_TARGETS)
+ifdef PRODUCT_TARGETS
+	@$(BUILDSYSTEM)/install_targets $^ $(PREFIX)/products
+endif
+
+
+
+
+#######
+####### Clean up default rules:
+#######
+
+clean: local_clean
+
+local_clean: .local_clean
+
+.local_clean:
+ifeq ($(shell pwd | grep $(TOP_BUILD_DIR_ABS)/$(SRC_PACKAGE_DIR))$(shell pwd | grep $(BUILDSYSTEM)/3pp/sources),)
+ifneq ($(wildcard .$(TOOLCHAIN)),)
+	@echo "Cleaning... $(TOOLCHAIN)"
+	@rm -rf $(CLEANUP_FILES)
+endif
+endif
+
+
+
+
+-include .src_requires_depend
+-include $(TARGET_BUILD_DIR)/.requires_depend
+
+
+endif
+#
+# end of ifeq ($(__final__),)
+#
+################################################################
+
+### Declare some targets as phony
+
+.PHONY: .target*
+.PHONY: .setup .sources .build_system .gnat_tools
+
+.PHONY: .tree_all .requites_tree
+
+.PHONY: all local_all .clean local_clean clean
+.PHONY: .install
+
+.PHONY:  downloads_clean
+.PHONY: .downloads_clean
+
+.SUFFIXES:
+
+
+
+CORE_MK = 1
+endif
Index: dist_clean
===================================================================
--- dist_clean	(nonexistent)
+++ dist_clean	(revision 5)
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use File::Basename;
+
+$base = $ARGV[0];
+
+open( F, '<', '.dist' ) or die "Could not open .dist";
+
+while( <F> )
+{
+  chomp;
+  $f = "$base/$_";
+  unlink $f;
+  $dirs{dirname($f)}++;
+}
+
+foreach ( sort { length($b) <=> length($a) } keys %dirs )
+{
+  while( rmdir )
+  {
+    $_ = dirname( $_ );
+  }
+}

Property changes on: dist_clean
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: downloads_clean
===================================================================
--- downloads_clean	(nonexistent)
+++ downloads_clean	(revision 5)
@@ -0,0 +1,116 @@
+#!/usr/bin/perl
+
+use FindBin;
+use lib $FindBin::Bin;
+
+use strict;
+use warnings FATAL => 'all';
+
+use File::Find;
+use _kxLab;
+
+
+# Global variables
+my $header_printed = 0;
+
+my $top_dir;
+my @targets;
+my $verbose = $ENV{VERBOSE};
+
+my %seen;
+my ( @dist_clean_dirs, @clean_dirs, @dist_clean_dirs_all, @clean_dirs_all );
+my ( $dist_clean_count, $clean_count );
+
+sub do_clean
+{
+  unlink "$top_dir/.makefile";
+
+  foreach my $d ( @clean_dirs )
+  {
+    my $printed_d;
+
+    $printed_d = $d;
+    $printed_d =~ s/^$top_dir\///;
+
+    print "\n=======\n" if ( $verbose );
+    print "======= Cleaning in $printed_d...\n" if ( $verbose );
+    print "=======\n" if ( $verbose );
+    _kxLab::system( "make -C $d download_clean" );
+    unlink "$d/.makefile";
+    unlink <$d/.*_requires*>;
+  }
+}
+
+sub do_clean_list
+{
+  my $dir = shift;
+  my $cwd = `pwd`;
+
+  chomp $cwd;
+
+  # skip not our directories where we create patches
+  return if( $cwd =~ m/.*create\-.*\-patch.*/ );
+
+  return if( ! -f "$cwd/Makefile" );
+
+  # needs clean:
+  push @clean_dirs_all, $cwd;
+}
+
+sub process_clean
+{
+  return if( ! $File::Find::dir =~ m/$top_dir\/sources/ );
+
+  # add directory which contains 'Makefile' too.
+  if( $_ eq "Makefile" ) { do_clean_list( $File::Find::dir ); }
+
+  return if( ! -d $_ );
+
+  foreach my $d ( @targets )
+  {
+    if( $d eq $_ ) { do_clean_list( $File::Find::dir ); }
+  }
+}
+
+
+foreach ( @ARGV )
+{
+  push @targets, $_;
+}
+$top_dir = pop @targets;
+
+if( ! -d $top_dir )
+{
+  die "\nTop: $top_dir: is not a directory\n\n";
+}
+if( ! $top_dir =~ m/^\// )
+{
+  die "\nTop: $top_dir: is not absolute path\n\n";
+}
+
+find( \&process_clean, "$top_dir" );
+
+# get unique names:
+%seen = ();
+@clean_dirs = grep { ! $seen{ $_ }++ } @clean_dirs_all;
+@clean_dirs = reverse( keys %seen );
+
+$clean_count = @clean_dirs;
+
+if( $clean_count != 0 )
+{
+  if( !$header_printed )
+  {
+    print "\n======= Cleaning downloads tree =======\n\n" if ( $verbose );
+    $header_printed = 1;
+  }
+
+  do_clean();
+
+  print "\n";
+}
+else
+{
+  print "\nCleaning...   (nothing to be done).\n\n";
+}
+

Property changes on: downloads_clean
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: install_targets
===================================================================
--- install_targets	(nonexistent)
+++ install_targets	(revision 5)
@@ -0,0 +1,131 @@
+#!/usr/bin/perl
+
+use FindBin;
+use lib $FindBin::Bin;
+
+use strict;
+use warnings FATAL => 'all';
+
+use File::Basename;
+use File::Temp;
+use _kxLab;
+
+# Global variables
+my $header_printed = 0;
+
+my $cleanup = $ENV{DO_CREATE_DIST_FILES} ? 0 : 1;
+my ($tempfd, $tempname) = File::Temp::tempfile(".dist.XXXXXX", UNLINK => $cleanup);
+
+# cleanpath( path )
+sub cleanpath
+{
+  my $path = shift;
+  $path =~ s!/{2,}!/!g;
+  return $path;
+}
+
+# dist( file )
+sub dist
+{
+  my $file = cleanpath(shift);
+  $file =~ s!^.*dist/!!;
+  print $tempfd "$file\n";
+}
+
+# newer_than( file1, file2 )
+sub newer_than
+{
+  my $file1 = shift;
+  my $file2 = shift;
+  _kxLab::error( "install_targets: Source file missing: $file1" ) if ( ! -f $file1 );
+  return( ! -f $file2 or -M $file1 < -M $file2 );
+}
+
+# install_tree( install_dir, file, target, verbose )
+sub install_tree
+{
+  my $install_dir = cleanpath(shift);
+  my $file = shift;
+  my $target = shift;
+  my $verbose = shift;
+
+  opendir(DIR, "$target");
+  my @files = readdir(DIR);
+  closedir DIR;
+  foreach my $f ( @files )
+  {
+    next if ($f eq "." or $f eq "..");
+    if( -d "$target/$f" )
+    {
+      install_tree( "$install_dir/$f", "$file/$f", "$target/$f", $verbose );
+    }
+    elsif( newer_than( "$target/$f", "$install_dir/$f" ) )
+    {
+      if( !$header_printed )
+      {
+        print "\n======= Installing files =======\n";
+        $header_printed = 1;
+      }
+      print "Installing $f in $install_dir\n" if ( $verbose );
+      _kxLab::system( "mkdir -p $install_dir" );
+      _kxLab::system( "cp -fa $target/$f $install_dir" );
+      dist( "$install_dir/$f" );
+    }
+  }
+}
+
+# install( install_dir, preserve_source_dir, verbose, targets )
+sub install
+{
+  my $install_dir = cleanpath(shift);
+  my $preserve_source_dir = shift;
+  my $verbose = shift;
+  my $targets = shift;
+
+  foreach my $target ( @{$targets} )
+  {
+    my $file = basename($target);
+    my $path = "";
+    if( $preserve_source_dir eq "true" )
+    {
+      $path = dirname( $target );
+    }
+
+    if( -d $target )
+    {
+      install_tree( "$install_dir/$path/$file", "$file", "$target", $verbose );
+    }
+    elsif( newer_than( $target, "$install_dir/$path/$file" ) )
+    {
+      if( !$header_printed )
+      {
+        print "\n======= Installing files =======\n";
+        $header_printed = 1;
+      }
+      print "Installing $file in $install_dir/$path\n" if ( $verbose );
+      _kxLab::system( "mkdir -p $install_dir/$path" );
+      _kxLab::system( "cp -fa $target $install_dir/$path" );
+      dist( "$install_dir/$path/$file" );
+    }
+  }
+}
+
+my $preserve_source_dir = "";
+my $dest_dir;
+my @targets;
+my $verbose = $ENV{VERBOSE};
+
+foreach ( @ARGV )
+{
+  if( /--preserve-source-dir=(\S*)/ )
+  {
+    $preserve_source_dir = $1;
+  }
+  else
+  {
+    push @targets, $_;
+  }
+}
+$dest_dir = pop @targets;
+
+install( $dest_dir, $preserve_source_dir, $verbose, \@targets );

Property changes on: install_targets
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: targets-config.mk.template
===================================================================
--- targets-config.mk.template	(nonexistent)
+++ targets-config.mk.template	(revision 5)
@@ -0,0 +1,7 @@
+
+# host
+BUILD_HOST = true
+
+
+# s8xx-newlib:
+BUILD_S8XX_NEWLIB = true
Index: tree-bs.mk
===================================================================
--- tree-bs.mk	(nonexistent)
+++ tree-bs.mk	(revision 5)
@@ -0,0 +1,9 @@
+
+# Generic rule used for directories
+
+all $(TREEDIRS):
+
+$(TREEDIRS):
+	@$(MAKE) FLAVOUR= -C $(TOP_BUILD_DIR_ABS)/$@ $(TREE_RULE)
+
+.PHONY: all $(TREEDIRS)
Index: tree-src.mk
===================================================================
--- tree-src.mk	(nonexistent)
+++ tree-src.mk	(revision 5)
@@ -0,0 +1,9 @@
+
+# Generic rule used for source directories
+
+all $(TREEDIRS):
+
+$(TREEDIRS):
+	@$(MAKE) -C $(TOP_BUILD_DIR_ABS)/$@ $(TREE_RULE)
+
+.PHONY: all $(TREEDIRS)
Index: tree.mk
===================================================================
--- tree.mk	(nonexistent)
+++ tree.mk	(revision 5)
@@ -0,0 +1,11 @@
+
+# Generic rule used for directories
+
+all $(TREEDIRS):
+
+get-flavour = $(if $(shell echo $1 | grep "\^"),$(shell echo $1 | cut -f 2 -d '^'),)
+
+$(TREEDIRS):
+	@$(MAKE) FLAVOUR=$(call get-flavour,$@) -C $(TOP_BUILD_DIR_ABS)/$(shell echo $@ | cut -f 1 -d '^') $(TREE_RULE)
+
+.PHONY: all $(TREEDIRS)
Index: tree_clean
===================================================================
--- tree_clean	(nonexistent)
+++ tree_clean	(revision 5)
@@ -0,0 +1,149 @@
+#!/usr/bin/perl
+
+use FindBin;
+use lib $FindBin::Bin;
+
+use strict;
+use warnings FATAL => 'all';
+
+use File::Find;
+use _kxLab;
+
+
+# Global variables
+my $header_printed = 0;
+
+my $top_dir;
+my @targets;
+my $verbose = $ENV{VERBOSE};
+
+my %seen;
+my ( @dist_clean_dirs, @clean_dirs, @dist_clean_dirs_all, @clean_dirs_all );
+my ( $dist_clean_count, $clean_count );
+
+sub do_clean
+{
+  unlink "$top_dir/.makefile";
+
+  foreach my $d ( @dist_clean_dirs )
+  {
+    my $printed_d;
+
+    $printed_d = $d;
+    $printed_d =~ s/^$top_dir\///;
+
+    print "\n===\n" if ( $verbose );
+    print "=== Dist cleaning in $printed_d...\n" if ( $verbose );
+    print "===\n" if ( $verbose );
+    _kxLab::system( "make -C $d dist_clean" );
+  }
+
+  foreach my $d ( @clean_dirs )
+  {
+    my $printed_d;
+
+    $printed_d = $d;
+    $printed_d =~ s/^$top_dir\///;
+
+    print "\n===\n" if ( $verbose );
+    print "=== Cleaning in $printed_d...\n" if ( $verbose );
+    print "===\n" if ( $verbose );
+    _kxLab::system( "make -C $d local_clean" );
+    unlink "$d/.makefile";
+  }
+}
+
+sub do_clean_list
+{
+  my $dir = shift;
+  my $cwd = `pwd`;
+
+  chomp $cwd;
+
+  return if( ! -f "$cwd/Makefile" );
+
+  # needs dist clean:
+  if( -f "$cwd/.dist" ) { push @dist_clean_dirs_all, $cwd; }
+
+  # needs clean:
+  push @clean_dirs_all, $cwd;
+}
+
+sub process_clean
+{
+  # add directory which contains '.makefile' too.
+  if( $_ eq ".makefile" ) { do_clean_list( $File::Find::dir ); }
+
+  return if( ! -d $_ );
+
+  return if( $File::Find::name =~ m/build-system/ );
+  return if( $File::Find::name =~ m/dist/ );
+  return if( $File::Find::name =~ m/sources/ );
+
+  foreach my $d ( @targets )
+  {
+    if( $d eq $_ ) { do_clean_list( $File::Find::dir ); }
+  }
+}
+
+
+foreach ( @ARGV )
+{
+  push @targets, $_;
+}
+$top_dir = pop @targets;
+
+if( ! -d $top_dir )
+{
+  die "\nTop: $top_dir: is not a directory\n\n";
+}
+if( ! $top_dir =~ m/^\// )
+{
+  die "\nTop: $top_dir: is not absolute path\n\n";
+}
+
+find( \&process_clean, "$top_dir" );
+
+# get unique names:
+%seen = ();
+@dist_clean_dirs = grep { ! $seen{ $_ }++ } @dist_clean_dirs_all;
+# delete subdirs which already contains TARGET name:
+foreach my $target ( @targets )
+{
+  my @match = ();
+  @match = grep { /$target/ } keys %seen;
+  foreach my $subdir ( @match ) { delete( $seen{"$subdir"} ); }
+}
+@dist_clean_dirs = reverse( keys %seen );
+
+# get unique names:
+%seen = ();
+@clean_dirs = grep { ! $seen{ $_ }++ } @clean_dirs_all;
+foreach my $target ( @targets )
+{
+  my @match = ();
+  @match = grep { /$target/ } keys %seen;
+  foreach my $subdir ( @match ) { delete( $seen{"$subdir"} ); }
+}
+@clean_dirs = reverse( keys %seen );
+
+$dist_clean_count = @dist_clean_dirs;
+$clean_count = @clean_dirs;
+
+if( $dist_clean_count != 0 || $clean_count != 0 )
+{
+  if( !$header_printed )
+  {
+    print "\n======= Cleaning build tree =======\n";
+    $header_printed = 1;
+  }
+
+  do_clean();
+
+  print "\n";
+}
+else
+{
+  print "Cleaning...   (nothing to be done).\n";
+}
+

Property changes on: tree_clean
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: .
===================================================================
--- .	(nonexistent)
+++ .	(revision 5)

Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,34 ##
+
+# Target build dirs
+.noarch/
+.host/
+
+.s8xx-newlib/
+
+# Hidden files (each file)
+.makefile
+
+# Tarballs
+*.gz
+*.bz2
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Default linux config files
+*.defconfig
+
+# Object Files
+*.[ao]
+
+# backup copies
+*~