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"
46 sh ../src/configure $config_opts
51 if [ `uname -s` = Linux ];then
52 PATH="/usr/local/arm/cross-gcc-4.2.0/i686-pc-linux-gnu/bin:$PATH"
55 while getopts "$options" opt;do
62 make_opts="${make_opts} -n"
77 echo "Unsupported option '$opt'"
81 shift $(($OPTIND - 1))
86 targets=$(cd config; ls *.ecc)
91 conf_dir="$PWD/config"
92 [ -d build ] || mkdir -p build
95 if [ ! -x "${ecosconfig}" ];then
98 for target in ${targets};do
99 target="${target%.ecc}"
100 if [ ! -d "${target}" ];then
101 echo "Creating build dir ${target}"
106 echo "Building ${target}"
108 build_dir="$PWD/${target}_build"
109 inst_dir="$PWD/${target}_install"
111 $quiet || echo "Checking configuration ${target}"
112 cp -p "${conf_dir}/${target}.ecc" "${conf_dir}/${target}.ecc.bak"
113 echo ecosconfig --srcdir="$src_dir" --config="${conf_dir}/${target}.ecc" check
115 stty -isig # prevent CTRL-C from trashing the config file
117 "${ecosconfig}" --srcdir="$src_dir" --config="${conf_dir}/${target}.ecc" check
119 mv "${conf_dir}/${target}.ecc.bak" "${conf_dir}/${target}.ecc"
127 echo "Removing build dir ${build_dir} and ${inst_dir}"
128 $doit && rm -rf "${build_dir}" "${inst_dir}"
130 if [ ! -d "${build_dir}" ];then
131 $quiet || echo "Creating build tree for ${target}"
132 echo mkdir "${build_dir}"
133 $doit && mkdir "${build_dir}"
135 $doit && cd "${build_dir}"
136 echo ecosconfig --srcdir="$src_dir" --prefix="${inst_dir}" \
137 --config="${conf_dir}/${target}.ecc" tree
140 "${ecosconfig}" --srcdir="$src_dir" --prefix="${inst_dir}" \
141 --config="${conf_dir}/${target}.ecc" tree
143 rm -f "${target}" ../../current && ln -svf "${target}" ../../current
144 rm -f ../install && ln -svf "${target}_install" ../install
145 rm -f ../build && ln -svf "${target}_build" ../build
149 $quiet || echo "Cleaning up build tree for ${target}"
150 make ${make_opts} COMMAND_PREFIX=${cmd_prefix} clean
153 $quiet || echo "Compiling ${target}"
154 [ -d "${build_dir}" ]
155 make -C "${build_dir}" COMMAND_PREFIX=${cmd_prefix} ${make_opts}
158 if $doit && [ -s "${inst_dir}/bin/redboot.elf" ];then
159 bootstrap_addr="$(${cmd_prefix}nm "${inst_dir}/bin/redboot.elf" \
160 | sed '/Now_in_SDRAM/!d;s/ .*$//')"
161 if ! echo "$bootstrap_addr" | grep -i '^[0-9a-f]\{4\}0[0-7]';then
162 # if ! ${cmd_prefix}nm "${inst_dir}/bin/redboot.elf" \
163 # | grep 'Now_in_SDRAM' | grep -i '^[0-9a-f]\{4\}0[0-7]';then
164 echo "ERROR: Bootstrap does not fit into first NAND page!"
169 echo "${target} build finished"