4 tools_dir="$PWD/tools/bin"
5 ecosconfig="$tools_dir/tools/configtool/standalone/common/ecosconfig"
6 src_dir="$PWD/packages"
13 cmd_prefix=${CROSS_COMPILE-arm-926ejs-linux-gnu-}
16 if [ -n "${target}" ];then
17 echo "${target} build aborted"
22 echo "Building host tools in $tools_dir"
23 # Debian packages tcl-dev and tk-dev are required for this build
25 local tcldirs="/usr/lib/tcl /usr/local/lib/tcl"
29 config_opts="$config_opts --with-tcl=${d%lib/tcl}"
33 if [ -z "$config_opts" ];then
34 for d in /usr/lib/tcl*;do
35 [ -d "$d" ] || continue
36 config_opts="$config_opts --with-tcl-version=${d##*tcl}"
39 if [ -z "$config_opts" ];then
40 echo "No Tcl installation found"
44 export TCL_INC_DIR="$(. /usr/lib/tclConfig.sh; echo $TCL_INCLUDE_SPEC | sed 's/^-I//')"
47 sh ../src/configure $config_opts
52 if [ `uname -s` = Linux ];then
53 PATH="/usr/local/arm/cross-gcc-4.2.0/i686-pc-linux-gnu/bin:$PATH"
56 while getopts "$options" opt;do
63 make_opts="${make_opts} -n"
78 echo "Unsupported option '$opt'"
82 shift $(($OPTIND - 1))
87 targets=$(cd config;ls *.ecc)
92 conf_dir="$PWD/config"
93 [ -d build ] || mkdir -p build
96 if [ ! -x "${ecosconfig}" ];then
99 for target in ${targets};do
100 target="${target%.ecc}"
101 if [ ! -d "${target}" ];then
102 echo "Creating build dir ${target}"
107 echo "Building ${target}"
109 build_dir="$PWD/${target}_build"
110 inst_dir="$PWD/${target}_install"
112 $quiet || echo "Checking configuration ${target}"
113 cp -p "${conf_dir}/${target}.ecc" "${conf_dir}/${target}.ecc.bak"
114 echo ecosconfig --srcdir="$src_dir" --config="${conf_dir}/${target}.ecc" check
116 stty -isig # prevent CTRL-C from trashing the config file
118 "${ecosconfig}" --srcdir="$src_dir" --config="${conf_dir}/${target}.ecc" check
120 mv "${conf_dir}/${target}.ecc.bak" "${conf_dir}/${target}.ecc"
128 echo "Removing build dir ${build_dir} and ${inst_dir}"
129 $doit && rm -rf "${build_dir}" "${inst_dir}"
131 if [ ! -d "${build_dir}" ];then
132 $quiet || echo "Creating build tree for ${target}"
133 echo mkdir "${build_dir}"
134 $doit && mkdir "${build_dir}"
136 $doit && cd "${build_dir}"
137 echo ecosconfig --srcdir="$src_dir" --prefix="${inst_dir}" \
138 --config="${conf_dir}/${target}.ecc" tree
141 "${ecosconfig}" --srcdir="$src_dir" --prefix="${inst_dir}" \
142 --config="${conf_dir}/${target}.ecc" tree
144 rm -f "${target}" ../../current && ln -svf "${target}" ../../current
145 rm -f ../install && ln -svf "${target}_install" ../install
146 rm -f ../build && ln -svf "${target}_build" ../build
150 $quiet || echo "Cleaning up build tree for ${target}"
151 #make ${make_opts} COMMAND_PREFIX=${cmd_prefix} clean
152 make ${make_opts} clean
155 $quiet || echo "Compiling ${target}"
156 [ -d "${build_dir}" ]
157 #make -C "${build_dir}" COMMAND_PREFIX=${cmd_prefix} ${make_opts}
158 make -C "${build_dir}" ${make_opts}
161 if $doit && [ -s "${inst_dir}/bin/redboot.elf" ];then
162 bootstrap_addr="$(${cmd_prefix}nm "${inst_dir}/bin/redboot.elf" \
163 | sed '/Now_in_SDRAM/!d;s/ .*$//')"
164 if [ -n "$bootstrap_addr" ] && ! echo "$bootstrap_addr" | grep -i '^[0-9a-f]\{4\}0[0-7]';then
165 echo "ERROR: Bootstrap does not fit into first NAND page!"
170 echo "${target} build finished"