regen.sh
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:2k
源码类别:

VxWorks

开发平台:

C/C++

  1. #!/bin/sh
  2. # regen.sh
  3. #
  4. # A shell script to regenerate cross-target linker scripts.
  5. #
  6. # All templated scripts are generated into the current directory, then
  7. # compared against previous versions (already present), which need not be
  8. # writable. Messages are printed to indicate which files should be updated.
  9. #
  10. # modification history
  11. # --------------------
  12. # 01d,24apr02,sn   SPR 75835 - added OUT script
  13. # 01c,29jan02,tpw  GNU: add AOUT,RAM and AOUT,ROM scripts.
  14. # 01b,05dec01,tpw  Add .boot and .reset section support, for PPC 4xx series
  15. #                  and Book E.
  16. # 01a,01nov01,tpw  written
  17. usage()
  18. {
  19. [ -n "$*" ] && echo "$*" 1>&2
  20. echo Usage: $0 '[-update] TOOL' 1>&2
  21. exit 1
  22. }
  23. [ -z "$1" ] && usage
  24. dash_update=no
  25. if [ "X-update" = "X$1" ]; then
  26.     dash_update=yes
  27.     shift
  28. fi
  29. TOOL="$1"
  30. shift
  31. [ -n "$*" ] && usage Extra junk after TOOL argument: "$*"
  32. if [ -z "$WIND_BASE" ]; then
  33.     echo $0: 'No value for $WIND_BASE set.' 1>&2
  34.     exit 1
  35. fi
  36. TGT_DIR=$WIND_BASE/target
  37. GEN_DIR=$TGT_DIR/h/tool/common/ldscripts
  38. GEN_SH=$GEN_DIR/genScript.sh
  39. # regen_one_file <old-script-name> <tool>> <property-list>
  40. regen_one_file ()
  41. {
  42.     # TODO keep blank lines we do want but 
  43.     # get rid of blank lines we don't want!
  44.     sh $GEN_SH "$@" #| sed '/^[  ]*$/d'
  45. }
  46. regen ()
  47. {
  48. variant="$1"
  49. suffix=`echo "$variant" | tr -d ,`
  50. old=link.$suffix
  51. new=new-link.$suffix
  52. gen_args=`echo "$variant" | tr ',' ' '`
  53. rm -f $new
  54. if regen_one_file $old $TOOL $gen_args > $new ; then
  55.     if cmp -s $old $new ; then
  56. echo "$old has not changed."
  57. rm -f $new
  58.     elif [ $dash_update = yes ]; then
  59. echo "$old has changed, updating with new version."
  60. mv $new $old
  61.     else
  62. echo "$old has changed, new version placed in $new"
  63.     fi
  64. else
  65.     rm -f $new
  66. fi
  67. }
  68. case "$TOOL" in
  69.     gnu) tool_script_list="AOUT,RAM AOUT,ROM OUT" ;;
  70.     *) tool_script_list="" ;;
  71. esac
  72. common_script_list="RAM ROM DOTBOOT,RAM DOTBOOT,ROM"
  73. for v in $common_script_list $tool_script_list
  74. do
  75.     regen $v
  76. done
  77. exit 0