1#! /usr/bin/env bash
2
3# file      : build/system/configure
4# copyright : Copyright (c) 2004-2012 Code Synthesis Tools CC
5# license   : GNU GPL v2; see accompanying LICENSE file
6
7# $1  out file
8#
9# bld_root     - build root
10# project_name - project name
11#
12
13source $bld_root/dialog.bash
14
15$echo
16$echo
17$echo "configuring '$project_name'"
18$echo
19$echo
20
21# Build system.
22#
23
24build=`$bld_root/system/config.guess`
25
26if [ $? != 0 ]; then
27
28  $echo "unable to determine build system type"
29  exit 1
30fi
31
32$echo "build system is $build"
33
34build_cpu=`echo $build | cut -f 1 -d -`
35build_mf=`echo $build | cut -f 2 -d -`
36build_kernel=`echo $build | cut -f 3 -d -`
37build_os=`echo $build | cut -f 4 -d -`
38
39if [ -z "$build_os" ]; then
40
41  # Old format: cpu-mf-os
42  #
43  build_os=$build_kernel
44  build_kernel=
45fi
46
47
48# Host system.
49#
50
51if [ -n "$host_system" ]; then
52
53  host=`$bld_root/system/config.sub "$host_system"`
54
55  if [ $? != 0 ]; then
56
57    $echo "unable to canonicalize host system '$host_system'"
58    exit 1
59  fi
60else
61  host=$build
62fi
63
64$echo "host system is $host"
65
66host_cpu=`echo $host | cut -f 1 -d -`
67host_mf=`echo $host | cut -f 2 -d -`
68host_kernel=`echo $host | cut -f 3 -d -`
69host_os=`echo $host | cut -f 4 -d -`
70
71if [ -z "$host_os" ]; then
72
73  # Old format: cpu-mf-os
74  #
75  host_os=$host_kernel
76  host_kernel=
77fi
78
79
80# Target system.
81#
82if [ -n "$target_system" ]; then
83
84  target=`$bld_root/system/config.sub "$target_system"`
85
86  if [ $? != 0 ]; then
87
88    $echo "unable to canonicalize target system '$target_system'"
89    exit 1
90  fi
91
92  $echo "target system is $target"
93
94  target_cpu=`echo $target | cut -f 1 -d -`
95  target_mf=`echo $target | cut -f 2 -d -`
96  target_kernel=`echo $target | cut -f 3 -d -`
97  target_os=`echo $target | cut -f 4 -d -`
98
99  if [ -z "$target_os" ]; then
100
101    # Old format: cpu-mf-os
102    #
103    target_os=$target_kernel
104    target_kernel=
105  fi
106
107else
108target=
109target_cpu=
110target_mf=
111target_kernel=
112target_os=
113fi
114
115
116
117# Write the configuration out.
118#
119echo "system_configuration := y"              >$1
120echo                                         >>$1
121echo "build_system        := $build"         >>$1
122echo "build_cpu           := $build_cpu"     >>$1
123echo "build_manufacturer  := $build_mf"      >>$1
124echo "build_os            := $build_os"      >>$1
125echo "build_kernel        := $build_kernel"  >>$1
126echo                                         >>$1
127echo "host_system         := $host"          >>$1
128echo "host_cpu            := $host_cpu"      >>$1
129echo "host_manufacturer   := $host_mf"       >>$1
130echo "host_os             := $host_os"       >>$1
131echo "host_kernel         := $host_kernel"   >>$1
132echo                                         >>$1
133echo "target_system       := $target"        >>$1
134echo "target_cpu          := $target_cpu"    >>$1
135echo "target_manufacturer := $target_mf"     >>$1
136echo "target_os           := $target_os"     >>$1
137echo "target_kernel       := $target_kernel" >>$1
138