4 tools_dir="$PWD/tools/bin"
5 ecosconfig="$tools_dir/tools/configtool/standalone/common/ecosconfig"
6 src_dir="$PWD/packages"
15 if [ -n "${target}" ];then
16 echo "${target} build aborted"
21 echo "Building host tools in $tools_dir"
22 # Debian packages tcl-dev and tk-dev are required for this build
24 local tcldirs="/usr/lib/tcl /usr/local/lib/tcl"
28 config_opts="$config_opts --with-tcl=${d%lib/tcl}"
32 if [ -z "$config_opts" ];then
33 for d in /usr/lib/tcl*;do
34 [ -d "$d" ] || continue
35 config_opts="$config_opts --with-tcl-version=${d##*tcl}"
38 if [ -z "$config_opts" ];then
39 echo "No Tcl installation found"
43 export TCL_INC_DIR="$(. /usr/lib/tclConfig.sh; echo $TCL_INCLUDE_SPEC | sed 's/^-I//')"
46 sh ../src/configure $config_opts
51 while getopts "$options" opt;do
58 make_opts="${make_opts} -n"
76 echo "Unsupported option '$opt'"
80 shift $(($OPTIND - 1))
85 targets=$(cd config;ls $pattern.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} clean
152 $quiet || echo "Compiling ${target}"
153 [ -d "${build_dir}" ]
154 make -C "${build_dir}" ${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 [ -n "$bootstrap_addr" ] && ! echo "$bootstrap_addr" | grep -i '^[0-9a-f]\{4\}0[0-7]';then
161 echo "ERROR: Bootstrap does not fit into first NAND page!"
166 echo "${target} build finished"