update-setup-h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/sh
  2. ##############################################################################
  3. # Name: build/update-setup.h
  4. # Purpose: run from root wx directory to update wx/*/setup.h files: those
  5. # having special comment markers in them will be update using
  6. # include/wx/setup_inc.h contents
  7. # Created: 2005-01-15
  8. # Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
  9. # Licence: wxWindows licence
  10. ##############################################################################
  11. rc=0
  12. error()
  13. {
  14. echo $* 1>&2
  15. }
  16. msg()
  17. {
  18. # TODO: only output from here if "quiet" option is not given
  19. echo "$*"
  20. }
  21. # write all the common options to stdout, massaging them specially if they are
  22. # meant to be included in a configure input file setup.h.in
  23. #
  24. # usage: cat_common_options_for setup_inc.h setup0.h
  25. cat_common_options_for()
  26. {
  27. # get rid of the copyright header on top of the file
  28. cmd="sed '1,/^\$/d' $1"
  29. # the file used for configure is special: we need to get rid of C++
  30. # comments in it because it is included by some C code and we also have to
  31. # set all options to 0 by default as they're put to 1 only by configure
  32. # (and hence any #ifdefs setting default values for them become unneeded)
  33. if [ $2 = "setup.h.in" ]; then
  34. cmd="$cmd | sed -e '/^\/\//d' \
  35. -e 's@ *//.*\$@@' \
  36. -e 's/# *define \(.\+\) \+1 *\$/#define \1 0/'"
  37. fi
  38. eval $cmd
  39. }
  40. # update the single setup.h file passed in as the parameter if it is out of
  41. # date
  42. #
  43. # usage: update_single_setup_h {common|MSW} setup_inc.h setup0.h
  44. update_single_setup_h()
  45. {
  46. section=$1
  47. shift
  48. setup_inc=$1
  49. shift
  50. if [ $setup_inc -ot $1 ]; then
  51. echo "Skipping $1 which is already up to date."
  52. return 0
  53. fi
  54. echo -n "Updating $1 ..."
  55. tmp=$i.$$.tmp
  56. sed -e "/^\/\* --- start $section options --- \*\/\$/q" $1 > $tmp &&
  57. cat_common_options_for $setup_inc $1 >> $tmp &&
  58. sed -n -e "/^\/\* --- end $section options --- \*\/\$/,\$p" $1 >> $tmp &&
  59. mv $tmp $1
  60. if [ $? -ne 0 ]; then
  61. msg " FAILED"
  62. error "$0: failed to update file $1"
  63. rc=2
  64. else
  65. msg " ok"
  66. fi
  67. }
  68. # wrapper for update_single_setup_h which only updates the common options
  69. update_common_setup_h()
  70. {
  71. update_single_setup_h common include/wx/setup_inc.h $1
  72. }
  73. # wrapper for update_single_setup_h which only updates the MSW options
  74. update_msw_setup_h()
  75. {
  76. update_single_setup_h MSW include/wx/msw/setup_inc.h $1
  77. }
  78. # entry point
  79. if [ ! -f wxwin.m4 ]; then
  80. error "$0: must be ran from root wx directory"
  81. exit 1
  82. fi
  83. update_common_setup_h include/wx/motif/setup0.h
  84. update_common_setup_h include/wx/msw/setup0.h
  85. update_common_setup_h include/wx/msw/wince/setup.h
  86. update_common_setup_h include/wx/gtk/setup0.h
  87. update_common_setup_h include/wx/osx/setup0.h
  88. update_common_setup_h include/wx/os2/setup0.h
  89. update_common_setup_h include/wx/univ/setup0.h
  90. update_common_setup_h setup.h.in
  91. update_msw_setup_h include/wx/msw/setup0.h
  92. update_msw_setup_h include/wx/gtk/setup0.h
  93. update_msw_setup_h setup.h.in
  94. update_single_setup_h wxUniv include/wx/univ/setup_inc.h include/wx/univ/setup0.h
  95. exit $rc