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"
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 config_opts="$config_opts --with-tcl-version=${d##*tcl}"
38 if [ -z "$config_opts" ];then
39 echo "No Tcl installation found"
45 sh ../src/configure $config_opts
50 if [ `uname -s` = Linux ];then
51 PATH="/usr/local/arm/cross-gcc-4.2.0/i686-pc-linux-gnu/bin:$PATH"
54 while getopts "$options" opt;do
61 make_opts="${make_opts} -n"
76 echo "Unsupported option '$opt'"
80 shift $(($OPTIND - 1))
85 targets=$(cd config; ls *.ecc)
90 conf_dir="$PWD/config"
91 [ -d build ] || mkdir -p build
94 if [ ! -x "${ecosconfig}" ];then
97 for target in ${targets};do
98 target="${target%.ecc}"
99 if [ ! -d "${target}" ];then
100 echo "Creating build dir ${target}"
105 echo "Building ${target}"
107 build_dir="$PWD/${target}_build"
108 inst_dir="$PWD/${target}_install"
110 $quiet || echo "Checking configuration ${target}"
111 cp -p "${conf_dir}/${target}.ecc" "${conf_dir}/${target}.ecc.bak"
112 echo ecosconfig --srcdir="$src_dir" --config="${conf_dir}/${target}.ecc" check
114 stty -isig # prevent CTRL-C from trashing the config file
116 "${ecosconfig}" --srcdir="$src_dir" --config="${conf_dir}/${target}.ecc" check
118 mv "${conf_dir}/${target}.ecc.bak" "${conf_dir}/${target}.ecc"
126 echo "Removing build dir ${build_dir} and ${inst_dir}"
127 $doit && rm -rf "${build_dir}" "${inst_dir}"
129 if [ ! -d "${build_dir}" ];then
130 $quiet || echo "Creating build tree for ${target}"
131 echo mkdir "${build_dir}"
132 $doit && mkdir "${build_dir}"
134 $doit && cd "${build_dir}"
135 echo ecosconfig --srcdir="$src_dir" --prefix="${inst_dir}" \
136 --config="${conf_dir}/${target}.ecc" tree
139 "${ecosconfig}" --srcdir="$src_dir" --prefix="${inst_dir}" \
140 --config="${conf_dir}/${target}.ecc" tree
142 rm -f "${target}" ../../current && ln -svf "${target}" ../../current
143 rm -f ../install && ln -svf "${target}_install" ../install
144 rm -f ../build && ln -svf "${target}_build" ../build
148 $quiet || echo "Cleaning up build tree for ${target}"
149 make ${make_opts} COMMAND_PREFIX=${cmd_prefix} clean
152 $quiet || echo "Compiling ${target}"
153 [ -d "${build_dir}" ]
154 make -C "${build_dir}" COMMAND_PREFIX=${cmd_prefix} ${make_opts}
157 if $doit && [ -s "${inst_dir}/bin/redboot.elf" ];then
158 bootstrap_addr="$(${cmd_prefix}nm "${inst_dir}/bin/redboot.elf" \
159 | sed '/Now_in_SDRAM/!d;s/ .*$//')"
160 if ! echo "$bootstrap_addr" | grep -i '^[0-9a-f]\{4\}0[0-7]';then
161 # if ! ${cmd_prefix}nm "${inst_dir}/bin/redboot.elf" \
162 # | grep 'Now_in_SDRAM' | grep -i '^[0-9a-f]\{4\}0[0-7]';then
163 echo "ERROR: Bootstrap does not fit into first NAND page!"
168 echo "${target} build finished"