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
28 if [ ! -f ./gen-all.rc ]
30 echo "Missing gen-all.rc file." >&2
39 echo " gen-all [options] [todos] [apps]"
43 echo "cpus=\"space-separated-list-of-cpus\""
44 echo "force Force cgen files to be regenerated"
47 echo "config Configure the tree"
48 echo "build Build the tree"
49 echo "diffs Generate diffs from what is checked in"
52 echo "binutils, gcc, newlib, sim, sid, intrinsics"
55 echo "\"all\" can be specified which means \"config, build, and diff everything\""
56 echo "Options, todos, and apps may be specified in any order."
59 echo "sh gen-all build binutils diffs cpus=m32r"
62 # Parameters to configure.
63 MPC_CONFIG="--with-mpc=${MPC_DIR}"
65 # Set up any env vars we need, blech.
66 export LD_LIBRARY_PATH="${MPC_DIR}/lib"
68 build_all_target_sys="fr30-elf"
70 all_cgen_cpus="arm cris fr30 frv ip2k iq2000 lm32 m32c m32r mep mt \
71 openrisc sh sh64 xc16x xstormy16"
73 all_sid_cpus="arm m32r mep mt sh xstormy16"
88 cgen_cpus="${all_cgen_cpus}"
89 sid_cpus="${all_sid_cpus}"
91 # Parameter processing.
96 help) usage ; trap "" 0 ; exit 0 ;;
97 cpus=*) cgen_cpus=${a/cpus=} sid_cpus=${cgen_cpus} ;;
98 force) do_force=yes ;;
99 config) do_config=yes ;;
100 build) do_build=yes ;;
101 diffs) do_diffs=yes ;;
102 binutils) do_binutils=yes ;;
104 newlib) do_newlib=yes ;;
107 intrinsics) do_intrinsics=yes ;;
119 *) echo "Invalid option: $a" >&2 ; exit 1 ;;
123 if [ "${do_config}" = "no" -a "${do_build}" = "no" -a "${do_diffs}" = "no" ]
125 echo "Nothing to do." >&2
129 for c in ${cgen_cpus}
131 if echo " ${all_cgen_cpus} " | grep -q " ${c} "
135 echo "Invalid cgen cpu ${c}" >&2
139 if [ "${do_sid}" == "yes" ]
143 if echo " ${all_sid_cpus} " | grep -q " ${c} "
147 echo "Invalid sid cpu ${c}" >&2
160 if [ "${target_sys}" == "${build_all_target_sys}" ]
162 extra_config_args="${extra_config_args} --enable-targets=all"
167 true # already configured
168 elif [ "${do_config}" = "yes" ]
170 echo "Configuring: $(date)"
171 ../${SRC_DIR}/configure \
173 --build=${build_sys} \
175 --target=${target_sys} \
177 --enable-cgen-maint \
178 --enable-languages=c \
191 true # already configured
192 elif [ "${do_config}" = "yes" ]
194 echo "Configuring: $(date)"
195 ../${GCC_DIR}/configure \
197 --build=${build_sys} \
199 --target=${target_sys} \
200 --enable-languages=c \
209 PATH=${prefix}/bin:$PATH
211 if [ "${do_force}" = "yes" ]
213 touch ${SRC_DIR}/cgen/opcodes.scm
216 echo "Building ${target_sys} binutils, $(date)"
217 mkdir -p tmp-src-${target_sys}
220 cd tmp-src-${target_sys}
222 config_src ${target_sys} ${prefix}
224 if [ "${do_build}" = "yes" ]
226 echo "Building: $(date)"
229 echo "Tree hasn't been configured."
232 make -j3 all-binutils all-gas all-ld
233 make -j1 install-binutils install-gas install-ld
234 echo "Build done: $(date)"
237 if [ $? != 0 ] ; then exit 1 ; fi
243 PATH=${prefix}/bin:$PATH
245 echo "Building ${target_sys} gcc, $(date)"
246 mkdir -p tmp-gcc-${target_sys}
249 cd tmp-gcc-${target_sys}
251 config_gcc ${target_sys} ${prefix}
253 if [ "${do_build}" = "yes" ]
255 echo "Building: $(date)"
258 echo "Tree hasn't been configured."
263 # FIXME: The toplevel makefile doesn't find ${target}-gcc,
264 # it sets CC_FOR_TARGET to ${target}-cc.
265 rm -f ${prefix}/bin/${target_sys}-cc
266 ln -s ${target_sys}-gcc ${prefix}/bin/${target_sys}-cc
267 echo "Build done: $(date)"
270 if [ $? != 0 ] ; then exit 1 ; fi
276 PATH=${prefix}/bin:$PATH
278 echo "Building ${target_sys} newlib, $(date)"
279 mkdir -p tmp-src-${target_sys}
282 cd tmp-src-${target_sys}
284 config_src ${target_sys} ${prefix}
286 if [ "${do_build}" = "yes" ]
288 echo "Building: $(date)"
291 echo "Tree hasn't been configured."
294 make -j3 all-target-newlib all-target-libgloss
295 make -j1 install-target-newlib install-target-libgloss
296 echo "Build done: $(date)"
299 if [ $? != 0 ] ; then exit 1 ; fi
305 PATH=${prefix}/bin:$PATH
307 if [ "${do_force}" = "yes" ]
309 touch ${SRC_DIR}/cgen/sim.scm
312 echo "Building ${cpu} sim, $(date)"
313 mkdir -p tmp-src-${target_sys}
316 cd tmp-src-${target_sys}
318 config_src ${target_sys} ${prefix}
320 if [ "${do_build}" = "yes" ]
322 echo "Building: $(date)"
325 echo "Tree hasn't been configured."
328 make -j3 all-sim all-gdb
329 make -j1 install-sim install-gdb
330 echo "Build done: $(date)"
333 if [ $? != 0 ] ; then exit 1 ; fi
339 PATH=${prefix}/bin:$PATH
341 if [ "${do_force}" = "yes" ]
343 touch ${SRC_DIR}/cgen/sid.scm
346 echo "Building ${cpu} sid, $(date)"
347 mkdir -p tmp-src-${target_sys}
350 cd tmp-src-${target_sys}
352 config_src ${target_sys} ${prefix}
354 if [ "${do_build}" = "yes" ]
356 echo "Building: $(date)"
359 echo "Tree hasn't been configured."
362 # SID doesn't support --enable-cgen-maint, sigh.
363 if [ ! -f sid/component/cgen-cpu/Makefile ]
365 make -j3 configure-sid
367 (cd sid/component/cgen-cpu && make cgen-all)
368 if [ $? != 0 ] ; then exit 1 ; fi
371 echo "Build done: $(date)"
374 if [ $? != 0 ] ; then exit 1 ; fi
377 build_intrinsics () {
378 if [ "${do_build}" = "yes" ]
380 echo "Building intrinsics: $(date)"
381 (cd ${SRC_DIR}/cgen && sh ./gen-all-intrinsics ${build_dir}/${GCC_DIR})
382 if [ $? != 0 ] ; then exit 1 ; fi
383 echo "Build done: $(date)"
388 # NOTE: cvs will return with a non-zero exit code if there are diffs.
389 if [ "${do_binutils}" = "yes" ]
391 (cd ${SRC_DIR}/opcodes && cvs diff -du >${build_dir}/opcodes.diffs)
393 if [ "${do_sim}" = "yes" ]
395 (cd ${SRC_DIR}/sim && cvs diff -du >${build_dir}/sim.diffs)
397 if [ "${do_sid}" = "yes" ]
399 (cd ${SRC_DIR}/sid/component/cgen-cpu && cvs diff -du >${build_dir}/sid.diffs)
401 if [ "${do_intrinsics}" = "yes" ]
403 (cd ${GCC_DIR}/gcc/config/mep && svn diff -x -u >${build_dir}/gcc.diffs)
409 echo "Starting gen-all: $(date)"
410 # Print the command line to make it easier to review old builds.
411 echo "Options: ${all_args}"
417 # We can't call config.guess until we've cd'd into the build_dir because
418 # SRC_DIR, if relative, is relative to build_dir.
419 build_sys=$(sh ${SRC_DIR}/config.guess)
420 host_sys=${build_sys}
422 for cpu in ${cgen_cpus}
424 # FIXME: arm-eabi is preferred over arm-elf
425 target_sys=${cpu}-elf
426 prefix=$(cd ${REL_DIR} && pwd -P)/rel-${target_sys}
427 [ $? != 0 ] && { echo "Error setting prefix" >&2 ; exit 1 ; }
430 if [ "${do_binutils}" = "yes" ]
432 build_binutils ${target_sys} ${prefix}
435 if [ "${do_sim}" = "yes" ]
437 build_sim ${target_sys} ${prefix}
440 if [ "${do_gcc}" = "yes" ]
442 # GCC doesn't support some cpus that cgen supports.
443 case ${target_sys} in
446 openrisc-* | or32-*) ;;
448 *) build_gcc ${target_sys} ${prefix} ;;
452 if [ "${do_newlib}" = "yes" ]
454 # Newlib doesn't support some cpus that cgen supports.
455 # We also can't build newlib if we don't have gcc.
456 case ${target_sys} in
459 openrisc-* | or32-*) ;;
461 *) build_newlib ${target_sys} ${prefix} ;;
466 for cpu in ${sid_cpus}
468 # FIXME: arm-eabi is preferred over arm-elf
469 target_sys=${cpu}-elf
470 prefix=$(cd ${REL_DIR} && pwd -P)/rel-${target_sys}
471 [ $? != 0 ] && { echo "Error setting prefix" >&2 ; exit 1 ; }
474 if [ "${do_sid}" = "yes" ]
476 build_sid ${target_sys} ${prefix}
480 if [ "${do_intrinsics}" = "yes" ]
482 build_intrinsics ${target_sys} ${prefix}
485 if [ "${do_diffs}" = "yes" ]
487 build_diffs ${target_sys} ${prefix}
490 echo "Ending gen-all: $(date)"