2 # Generate files for all apps,
3 # maybe build all apps,
4 # and produce a report listing differences from checked in copies.
6 # NOTE: This script doesn't rm -rf the previous run since it can run
7 # different tests. If you want to start fresh, rm -rf tmp-all yourself.
9 # File ./gen-all.rc must exist and must define several env vars.
10 # It saves us from having to always pass the same long path names as
12 # The config file lives in "." instead of say "$HOME" so that multiple
13 # different configs are easily supported.
14 # Typical contents are:
16 ## Paths to src,gcc,rel relative to ${build_dir}.
17 #SRC_DIR="../../../src"
18 #GCC_DIR="../../../gcc"
20 ## Location of mpc (gmp,mpfr taken from /usr/{include,lib}).
21 #MPC_DIR="$HOME/gnu/rel32/mpc-0.8.1"
24 trap "echo ERROR: $(date)" 0
26 if [ ! -f ./gen-all.rc ]
28 echo "Missing gen-all.rc file." >&2
37 echo " gen-all [options] [todos] [apps]"
41 echo "cpus=\"space-separated-list-of-cpus\""
44 echo "config Configure the tree"
45 echo "build Build the tree"
46 echo "diffs Generate diffs from what's checked in"
49 echo "binutils, gcc, newlib, sim, sid, intrinsics"
52 echo "\"all\" can be specified which means \"all of the above\""
53 echo "Options, todos, and apps may be specified in any order."
56 echo "sh gen-all build binutils diffs cpus=m32r"
59 # Parameters to configure.
60 MPC_CONFIG="--with-mpc=${MPC_DIR}"
62 # Set up any env vars we need, blech.
63 export LD_LIBRARY_PATH="${MPC_DIR}/lib"
65 build_all_target_sys="fr30-elf"
67 all_cgen_cpus="arm cris fr30 frv ip2k iq2000 lm32 m32c m32r mep mt \
68 openrisc sh sh64 xc16x xstormy16"
70 all_sid_cpus="arm m32r mep mt sh xstormy16"
82 cgen_cpus="${all_cgen_cpus}"
83 sid_cpus="${all_sid_cpus}"
85 # Parameter processing.
90 help) usage ; trap "" 0 ; exit 0 ;;
91 cpus=*) cgen_cpus=${a/cpus=} sid_cpus=${cgen_cpus} ;;
92 config) do_config=yes ;;
93 build) do_build=yes ;;
94 binutils) do_binutils=yes ;;
96 newlib) do_newlib=yes ;;
99 intrinsics) do_intrinsics=yes ;;
100 diffs) do_diffs=yes ;;
112 *) echo "Invalid option: $a" >&2 ; exit 1 ;;
116 for c in ${cgen_cpus}
118 if echo " ${all_cgen_cpus} " | grep -q " ${c} "
122 echo "Invalid cgen cpu ${c}" >&2
126 if [ "${do_sid}" == "yes" ]
130 if echo " ${all_sid_cpus} " | grep -q " ${c} "
134 echo "Invalid sid cpu ${c}" >&2
147 if [ "${target_sys}" == "${build_all_target_sys}" ]
149 extra_config_args="${extra_config_args} --enable-targets=all"
154 true # already configured
155 elif [ "${do_config}" = "yes" ]
157 echo "Configuring: $(date)"
158 ../${SRC_DIR}/configure \
160 --build=${build_sys} \
162 --target=${target_sys} \
164 --enable-cgen-maint \
165 --enable-languages=c \
178 true # already configured
179 elif [ "${do_config}" = "yes" ]
181 echo "Configuring: $(date)"
182 ../${GCC_DIR}/configure \
184 --build=${build_sys} \
186 --target=${target_sys} \
187 --enable-languages=c \
196 PATH=${prefix}/bin:$PATH
198 echo "Building ${target_sys} binutils, $(date)"
199 mkdir -p tmp-src-${target_sys}
202 cd tmp-src-${target_sys}
204 config_src ${target_sys} ${prefix}
206 if [ "${do_build}" = "yes" ]
208 echo "Building: $(date)"
211 echo "Tree hasn't been configured."
214 make -j3 all-binutils all-gas all-ld
215 make -j1 install-binutils install-gas install-ld
216 echo "Build done: $(date)"
219 if [ $? != 0 ] ; then exit 1 ; fi
225 PATH=${prefix}/bin:$PATH
227 echo "Building ${target_sys} gcc, $(date)"
228 mkdir -p tmp-gcc-${target_sys}
231 cd tmp-gcc-${target_sys}
233 config_gcc ${target_sys} ${prefix}
235 if [ "${do_build}" = "yes" ]
237 echo "Building: $(date)"
240 echo "Tree hasn't been configured."
245 # FIXME: The toplevel makefile doesn't find ${target}-gcc,
246 # it sets CC_FOR_TARGET to ${target}-cc.
247 rm -f ${prefix}/bin/${target_sys}-cc
248 ln -s ${target_sys}-gcc ${prefix}/bin/${target_sys}-cc
249 echo "Build done: $(date)"
252 if [ $? != 0 ] ; then exit 1 ; fi
258 PATH=${prefix}/bin:$PATH
260 echo "Building ${target_sys} newlib, $(date)"
261 mkdir -p tmp-src-${target_sys}
264 cd tmp-src-${target_sys}
266 config_src ${target_sys} ${prefix}
268 if [ "${do_build}" = "yes" ]
270 echo "Building: $(date)"
273 echo "Tree hasn't been configured."
276 make -j3 all-target-newlib all-target-libgloss
277 make -j1 install-target-newlib install-target-libgloss
278 echo "Build done: $(date)"
281 if [ $? != 0 ] ; then exit 1 ; fi
287 PATH=${prefix}/bin:$PATH
289 echo "Building ${cpu} sim, $(date)"
290 mkdir -p tmp-src-${target_sys}
293 cd tmp-src-${target_sys}
295 config_src ${target_sys} ${prefix}
297 if [ "${do_build}" = "yes" ]
299 echo "Building: $(date)"
302 echo "Tree hasn't been configured."
305 make -j3 all-sim all-gdb
306 make -j1 install-sim install-gdb
307 echo "Build done: $(date)"
310 if [ $? != 0 ] ; then exit 1 ; fi
316 PATH=${prefix}/bin:$PATH
318 echo "Building ${cpu} sid, $(date)"
319 mkdir -p tmp-src-${target_sys}
322 cd tmp-src-${target_sys}
324 config_src ${target_sys} ${prefix}
326 if [ "${do_build}" = "yes" ]
328 echo "Building: $(date)"
331 echo "Tree hasn't been configured."
334 # SID doesn't support --enable-cgen-maint, sigh.
335 if [ ! -f sid/component/cgen-cpu/Makefile ]
337 make -j3 configure-sid
339 (cd sid/component/cgen-cpu && make cgen-all)
340 if [ $? != 0 ] ; then exit 1 ; fi
343 echo "Build done: $(date)"
346 if [ $? != 0 ] ; then exit 1 ; fi
349 build_intrinsics () {
350 (cd .. && sh ./gen-all-intrinsics ${build_dir}/${GCC_DIR})
351 if [ $? != 0 ] ; then exit 1 ; fi
355 # NOTE: cvs will return with a non-zero exit code if there are diffs.
356 (cd ${SRC_DIR}/opcodes && cvs diff -du >${build_dir}/opcodes.diffs)
357 (cd ${SRC_DIR}/sim && cvs diff -du >${build_dir}/sim.diffs)
358 (cd ${SRC_DIR}/sid/component/cgen-cpu && cvs diff -du >${build_dir}/sid.diffs)
359 (cd ${GCC_DIR}/gcc/config/mep && svn diff -x -u >${build_dir}/gcc.diffs)
364 echo "Starting gen-all: $(date)"
370 # We can't call config.guess until we've cd'd into the build_dir because
371 # SRC_DIR, if relative, is relative to build_dir.
372 build_sys=$(sh ${SRC_DIR}/config.guess)
373 host_sys=${build_sys}
375 for cpu in ${cgen_cpus}
377 # FIXME: arm-eabi is preferred over arm-elf
378 target_sys=${cpu}-elf
379 prefix=$(cd ${REL_DIR} && pwd -P)/rel-${target_sys}
380 [ $? != 0 ] && { echo "Error setting prefix" >&2 ; exit 1 ; }
383 if [ "${do_binutils}" = "yes" ]
385 build_binutils ${target_sys} ${prefix}
388 if [ "${do_sim}" = "yes" ]
390 build_sim ${target_sys} ${prefix}
393 if [ "${do_gcc}" = "yes" ]
395 # GCC doesn't support some cpus that cgen supports.
396 case ${target_sys} in
399 openrisc-* | or32-*) ;;
401 *) build_gcc ${target_sys} ${prefix} ;;
405 if [ "${do_newlib}" = "yes" ]
407 # Newlib doesn't support some cpus that cgen supports.
408 # We also can't build newlib if we don't have gcc.
409 case ${target_sys} in
412 openrisc-* | or32-*) ;;
414 *) build_newlib ${target_sys} ${prefix} ;;
419 for cpu in ${sid_cpus}
421 # FIXME: arm-eabi is preferred over arm-elf
422 target_sys=${cpu}-elf
423 prefix=$(cd ${REL_DIR} && pwd -P)/rel-${target_sys}
424 [ $? != 0 ] && { echo "Error setting prefix" >&2 ; exit 1 ; }
427 if [ "${do_sid}" = "yes" ]
429 build_sid ${target_sys} ${prefix}
433 if [ "${do_intrinsics}" = "yes" ]
435 build_intrinsics ${target_sys} ${prefix}
438 if [ "${do_diffs}" = "yes" ]
440 build_diffs ${target_sys} ${prefix}
443 echo "Ending gen-all: $(date)"