mkconfig.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #! /bin/sh
  2. # Copyright (C) 2001-2015 Free Software Foundation, Inc.
  3. # This file is part of GCC.
  4. # GCC is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3, or (at your option)
  7. # any later version.
  8. # GCC is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with GCC; see the file COPYING3. If not see
  14. # <http://www.gnu.org/licenses/>.
  15. # Generate gcc's various configuration headers:
  16. # config.h, tconfig.h, bconfig.h, tm.h, libgcc_tm.h, and tm_p.h.
  17. # $1 is the file to generate. DEFINES, HEADERS, and possibly
  18. # TARGET_CPU_DEFAULT are expected to be set in the environment.
  19. if [ -z "$1" ]; then
  20. echo "Usage: DEFINES='list' HEADERS='list' \\" >&2
  21. echo " [TARGET_CPU_DEFAULT='default'] mkconfig.sh FILE" >&2
  22. exit 1
  23. fi
  24. output=$1
  25. rm -f ${output}T
  26. # This converts a file name into header guard macro format.
  27. hg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,'
  28. header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}`
  29. # Add multiple inclusion protection guard, part one.
  30. echo "#ifndef ${header_guard}" >> ${output}T
  31. echo "#define ${header_guard}" >> ${output}T
  32. # A special test to ensure that build-time files don't blindly use
  33. # config.h.
  34. if test x"$output" = x"config.h"; then
  35. echo "#ifdef GENERATOR_FILE" >> ${output}T
  36. echo "#error config.h is for the host, not build, machine." >> ${output}T
  37. echo "#endif" >> ${output}T
  38. fi
  39. # Define TARGET_CPU_DEFAULT if the system wants one.
  40. # This substitutes for lots of *.h files.
  41. if [ "$TARGET_CPU_DEFAULT" != "" ]; then
  42. echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
  43. fi
  44. # Provide defines for other macros set in config.gcc for this file.
  45. for def in $DEFINES; do
  46. echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
  47. echo "# define $def" | sed 's/=/ /' >> ${output}T
  48. echo "#endif" >> ${output}T
  49. done
  50. # The first entry in HEADERS may be auto-FOO.h ;
  51. # it wants to be included even when not -DIN_GCC.
  52. # Postpone including defaults.h until after the insn-*
  53. # headers, so that the HAVE_* flags are available
  54. # when defaults.h gets included.
  55. postpone_defaults_h="no"
  56. if [ -n "$HEADERS" ]; then
  57. set $HEADERS
  58. case "$1" in auto-* )
  59. echo "#include \"$1\"" >> ${output}T
  60. shift
  61. ;;
  62. esac
  63. if [ $# -ge 1 ]; then
  64. echo '#ifdef IN_GCC' >> ${output}T
  65. for file in "$@"; do
  66. if test x"$file" = x"defaults.h"; then
  67. postpone_defaults_h="yes"
  68. else
  69. echo "# include \"$file\"" >> ${output}T
  70. fi
  71. done
  72. echo '#endif' >> ${output}T
  73. fi
  74. fi
  75. # If this is tm.h, now include insn-flags.h only if IN_GCC is defined
  76. # but neither GENERATOR_FILE nor USED_FOR_TARGET is defined. (Much of this
  77. # is temporary.)
  78. case $output in
  79. tm.h )
  80. cat >> ${output}T <<EOF
  81. #if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
  82. # include "insn-flags.h"
  83. #endif
  84. #if defined IN_GCC && !defined GENERATOR_FILE
  85. # include "insn-modes.h"
  86. #endif
  87. #if defined IN_GCC && defined GENERATOR_FILE && !defined BITS_PER_UNIT
  88. #include "machmode.h"
  89. #endif
  90. EOF
  91. ;;
  92. esac
  93. # If we postponed including defaults.h, add the #include now.
  94. if test x"$postpone_defaults_h" = x"yes"; then
  95. echo "# include \"defaults.h\"" >> ${output}T
  96. fi
  97. # Add multiple inclusion protection guard, part two.
  98. echo "#endif /* ${header_guard} */" >> ${output}T
  99. # Avoid changing the actual file if possible.
  100. if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
  101. echo $output is unchanged >&2
  102. rm -f ${output}T
  103. else
  104. mv -f ${output}T $output
  105. fi
  106. # Touch a stamp file for Make's benefit.
  107. rm -f cs-$output
  108. echo timestamp > cs-$output