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\""
42 echo "force Force cgen files to be regenerated"
45 echo "config Configure the tree"
46 echo "build Build the tree"
47 echo "diffs Generate diffs from what is checked in"
50 echo "binutils, gcc, newlib, sim, sid, intrinsics"
53 echo "\"all\" can be specified which means \"config, build, and diff everything\""
54 echo "Options, todos, and apps may be specified in any order."
57 echo "sh gen-all build binutils diffs cpus=m32r"
60 # Parameters to configure.
61 MPC_CONFIG="--with-mpc=${MPC_DIR}"
63 # Set up any env vars we need, blech.
64 export LD_LIBRARY_PATH="${MPC_DIR}/lib"
66 build_all_target_sys="fr30-elf"
68 all_cgen_cpus="arm cris fr30 frv ip2k iq2000 lm32 m32c m32r mep mt \
69 openrisc sh sh64 xc16x xstormy16"
71 all_sid_cpus="arm m32r mep mt sh xstormy16"
86 cgen_cpus="${all_cgen_cpus}"
87 sid_cpus="${all_sid_cpus}"
89 # Parameter processing.
94 help) usage ; trap "" 0 ; exit 0 ;;
95 cpus=*) cgen_cpus=${a/cpus=} sid_cpus=${cgen_cpus} ;;
96 force) do_force=yes ;;
97 config) do_config=yes ;;
98 build) do_build=yes ;;
99 diffs) do_diffs=yes ;;
100 binutils) do_binutils=yes ;;
102 newlib) do_newlib=yes ;;
105 intrinsics) do_intrinsics=yes ;;
117 *) echo "Invalid option: $a" >&2 ; exit 1 ;;
121 if [ "${do_config}" = "no" -a "${do_build}" = "no" -a "${do_diffs}" = "no" ]
123 echo "Nothing to do." >&2
127 for c in ${cgen_cpus}
129 if echo " ${all_cgen_cpus} " | grep -q " ${c} "
133 echo "Invalid cgen cpu ${c}" >&2
137 if [ "${do_sid}" == "yes" ]
141 if echo " ${all_sid_cpus} " | grep -q " ${c} "
145 echo "Invalid sid cpu ${c}" >&2
158 if [ "${target_sys}" == "${build_all_target_sys}" ]
160 extra_config_args="${extra_config_args} --enable-targets=all"
165 true # already configured
166 elif [ "${do_config}" = "yes" ]
168 echo "Configuring: $(date)"
169 ../${SRC_DIR}/configure \
171 --build=${build_sys} \
173 --target=${target_sys} \
175 --enable-cgen-maint \
176 --enable-languages=c \
189 true # already configured
190 elif [ "${do_config}" = "yes" ]
192 echo "Configuring: $(date)"
193 ../${GCC_DIR}/configure \
195 --build=${build_sys} \
197 --target=${target_sys} \
198 --enable-languages=c \
207 PATH=${prefix}/bin:$PATH
209 if [ "${do_force}" = "yes" ]
211 touch ${SRC_DIR}/cgen/opcodes.scm
214 echo "Building ${target_sys} binutils, $(date)"
215 mkdir -p tmp-src-${target_sys}
218 cd tmp-src-${target_sys}
220 config_src ${target_sys} ${prefix}
222 if [ "${do_build}" = "yes" ]
224 echo "Building: $(date)"
227 echo "Tree hasn't been configured."
230 make -j3 all-binutils all-gas all-ld
231 make -j1 install-binutils install-gas install-ld
232 echo "Build done: $(date)"
235 if [ $? != 0 ] ; then exit 1 ; fi
241 PATH=${prefix}/bin:$PATH
243 echo "Building ${target_sys} gcc, $(date)"
244 mkdir -p tmp-gcc-${target_sys}
247 cd tmp-gcc-${target_sys}
249 config_gcc ${target_sys} ${prefix}
251 if [ "${do_build}" = "yes" ]
253 echo "Building: $(date)"
256 echo "Tree hasn't been configured."
261 # FIXME: The toplevel makefile doesn't find ${target}-gcc,
262 # it sets CC_FOR_TARGET to ${target}-cc.
263 rm -f ${prefix}/bin/${target_sys}-cc
264 ln -s ${target_sys}-gcc ${prefix}/bin/${target_sys}-cc
265 echo "Build done: $(date)"
268 if [ $? != 0 ] ; then exit 1 ; fi
274 PATH=${prefix}/bin:$PATH
276 echo "Building ${target_sys} newlib, $(date)"
277 mkdir -p tmp-src-${target_sys}
280 cd tmp-src-${target_sys}
282 config_src ${target_sys} ${prefix}
284 if [ "${do_build}" = "yes" ]
286 echo "Building: $(date)"
289 echo "Tree hasn't been configured."
292 make -j3 all-target-newlib all-target-libgloss
293 make -j1 install-target-newlib install-target-libgloss
294 echo "Build done: $(date)"
297 if [ $? != 0 ] ; then exit 1 ; fi
303 PATH=${prefix}/bin:$PATH
305 if [ "${do_force}" = "yes" ]
307 touch ${SRC_DIR}/cgen/sim.scm
310 echo "Building ${cpu} sim, $(date)"
311 mkdir -p tmp-src-${target_sys}
314 cd tmp-src-${target_sys}
316 config_src ${target_sys} ${prefix}
318 if [ "${do_build}" = "yes" ]
320 echo "Building: $(date)"
323 echo "Tree hasn't been configured."
326 make -j3 all-sim all-gdb
327 make -j1 install-sim install-gdb
328 echo "Build done: $(date)"
331 if [ $? != 0 ] ; then exit 1 ; fi
337 PATH=${prefix}/bin:$PATH
339 if [ "${do_force}" = "yes" ]
341 touch ${SRC_DIR}/cgen/sid.scm
344 echo "Building ${cpu} sid, $(date)"
345 mkdir -p tmp-src-${target_sys}
348 cd tmp-src-${target_sys}
350 config_src ${target_sys} ${prefix}
352 if [ "${do_build}" = "yes" ]
354 echo "Building: $(date)"
357 echo "Tree hasn't been configured."
360 # SID doesn't support --enable-cgen-maint, sigh.
361 if [ ! -f sid/component/cgen-cpu/Makefile ]
363 make -j3 configure-sid
365 (cd sid/component/cgen-cpu && make cgen-all)
366 if [ $? != 0 ] ; then exit 1 ; fi
369 echo "Build done: $(date)"
372 if [ $? != 0 ] ; then exit 1 ; fi
375 build_intrinsics () {
376 if [ "${do_build}" = "yes" ]
378 echo "Building intrinsics: $(date)"
379 (cd ${SRC_DIR}/cgen && sh ./gen-all-intrinsics ${build_dir}/${GCC_DIR})
380 if [ $? != 0 ] ; then exit 1 ; fi
381 echo "Build done: $(date)"
386 # NOTE: cvs will return with a non-zero exit code if there are diffs.
387 if [ "${do_binutils}" = "yes" ]
389 (cd ${SRC_DIR}/opcodes && cvs diff -du >${build_dir}/opcodes.diffs)
391 if [ "${do_sim}" = "yes" ]
393 (cd ${SRC_DIR}/sim && cvs diff -du >${build_dir}/sim.diffs)
395 if [ "${do_sid}" = "yes" ]
397 (cd ${SRC_DIR}/sid/component/cgen-cpu && cvs diff -du >${build_dir}/sid.diffs)
399 if [ "${do_intrinsics}" = "yes" ]
401 (cd ${GCC_DIR}/gcc/config/mep && svn diff -x -u >${build_dir}/gcc.diffs)
407 echo "Starting gen-all: $(date)"
413 # We can't call config.guess until we've cd'd into the build_dir because
414 # SRC_DIR, if relative, is relative to build_dir.
415 build_sys=$(sh ${SRC_DIR}/config.guess)
416 host_sys=${build_sys}
418 for cpu in ${cgen_cpus}
420 # FIXME: arm-eabi is preferred over arm-elf
421 target_sys=${cpu}-elf
422 prefix=$(cd ${REL_DIR} && pwd -P)/rel-${target_sys}
423 [ $? != 0 ] && { echo "Error setting prefix" >&2 ; exit 1 ; }
426 if [ "${do_binutils}" = "yes" ]
428 build_binutils ${target_sys} ${prefix}
431 if [ "${do_sim}" = "yes" ]
433 build_sim ${target_sys} ${prefix}
436 if [ "${do_gcc}" = "yes" ]
438 # GCC doesn't support some cpus that cgen supports.
439 case ${target_sys} in
442 openrisc-* | or32-*) ;;
444 *) build_gcc ${target_sys} ${prefix} ;;
448 if [ "${do_newlib}" = "yes" ]
450 # Newlib doesn't support some cpus that cgen supports.
451 # We also can't build newlib if we don't have gcc.
452 case ${target_sys} in
455 openrisc-* | or32-*) ;;
457 *) build_newlib ${target_sys} ${prefix} ;;
462 for cpu in ${sid_cpus}
464 # FIXME: arm-eabi is preferred over arm-elf
465 target_sys=${cpu}-elf
466 prefix=$(cd ${REL_DIR} && pwd -P)/rel-${target_sys}
467 [ $? != 0 ] && { echo "Error setting prefix" >&2 ; exit 1 ; }
470 if [ "${do_sid}" = "yes" ]
472 build_sid ${target_sys} ${prefix}
476 if [ "${do_intrinsics}" = "yes" ]
478 build_intrinsics ${target_sys} ${prefix}
481 if [ "${do_diffs}" = "yes" ]
483 build_diffs ${target_sys} ${prefix}
486 echo "Ending gen-all: $(date)"