tl_canon.m4 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. # Our own versions of the other canonicalizing stuff
  2. dnl replace AC_CANONICAL_xxx
  3. undefine([AC_CANONICAL_HOST])
  4. define([AC_CANONICAL_HOST], [tl_CANONICAL_HOST])
  5. undefine([AC_CANONICAL_BUILD])
  6. define([AC_CANONICAL_BUILD], [tl_CANONICAL_BUILD])
  7. undefine([AC_CANONICAL_TARGET])
  8. define([AC_CANONICAL_TARGET], [tl_CANONICAL_TARGET])
  9. undefine([AC_CANONICAL_SYSTEM])
  10. define([AC_CANONICAL_SYSTEM], [tl_CANONICAL_SYSTEM])
  11. dnl Canonicalize the host, target, and build system types.
  12. AC_DEFUN(tl_CANONICAL_SYSTEM,
  13. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  14. AC_PROVIDE([AC_CANONICAL_SYSTEM])dnl
  15. AC_BEFORE([$0], [AC_ARG_PROGRAM])
  16. # Do some error checking and defaulting for the host and target type.
  17. # The inputs are:
  18. # configure --host=HOST --target=TARGET --build=BUILD NONOPT
  19. #
  20. # The rules are:
  21. # 1. You are not allowed to specify --host, --target, and nonopt at the
  22. # same time.
  23. # 2. Host defaults to nonopt.
  24. # 3. If nonopt is not specified, then host defaults to the current host,
  25. # as determined by config.guess.
  26. # 4. Target and build default to nonopt.
  27. # 5. If nonopt is not specified, then target and build default to host.
  28. # The aliases save the names the user supplied, while $host etc.
  29. # will get canonicalized.
  30. case $host---$target---$nonopt in
  31. NONE---*---* | *---NONE---* | *---*---NONE) ;;
  32. *) AC_MSG_ERROR(can only configure for one host and one target at a time) ;;
  33. esac
  34. tl_CANONICAL_HOST
  35. tl_CANONICAL_TARGET
  36. tl_CANONICAL_BUILD
  37. test "$host_alias" != "$target_alias" &&
  38. test "$program_prefix$program_suffix$program_transform_name" = \
  39. NONENONEs,x,x, &&
  40. program_prefix=${target_alias}-
  41. AC_CHECK_TOOL_PREFIX
  42. ])
  43. dnl Subroutines of tl_CANONICAL_SYSTEM.
  44. AC_DEFUN(tl_CANONICAL_HOST,
  45. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  46. AC_PROVIDE([AC_CANONICAL_HOST])dnl
  47. # Make sure we can run config.sub.
  48. if $ac_config_sub sun4 >/dev/null 2>&1; then :
  49. else AC_MSG_ERROR(can not run $ac_config_sub)
  50. fi
  51. AC_MSG_CHECKING(host system type)
  52. dnl Set host_alias.
  53. if test "${GCC-no}" = "yes"; then
  54. changequote(, )dnl
  55. libgcc="`${CC} --print-libgcc-file-name`"
  56. host_alias="`echo ${libgcc} |
  57. sed -e 's,^.*/gcc-lib/,,; s,/libgcc\.a$,,; s,/egcs-,/,; s,/[0-9.][0-9.]*$,,'`"
  58. case ${host_alias} in
  59. *-linux{,elf,aout})
  60. host_alias="`echo ${host_alias} | sed 's/\([^-]*\)-linux.*/\1/'`"
  61. changequote([, ])dnl
  62. if ar p "${libgcc}" __main.o 2>/dev/null | file - 2>/dev/null | grep ELF >/dev/null; then
  63. host_alias="${host_alias}-linux"
  64. else
  65. host_alias="${host_alias}-linuxaout"
  66. fi ;;
  67. esac
  68. else
  69. host_alias=$host
  70. case "$host_alias" in
  71. NONE)
  72. case "$nonopt" in
  73. NONE)
  74. if host_alias=`$ac_config_guess`; then host_guessed=y
  75. else AC_MSG_ERROR(can not guess host type; you must specify one)
  76. fi ;;
  77. *) host_alias=$nonopt ;;
  78. esac ;;
  79. esac
  80. fi
  81. dnl Set the other host vars.
  82. changequote(<<, >>)dnl
  83. host=`$ac_config_sub $host_alias`
  84. host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
  85. host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
  86. host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
  87. changequote([, ])dnl
  88. AC_MSG_RESULT($host)
  89. AC_SUBST(host)dnl
  90. AC_SUBST(host_alias)dnl
  91. AC_SUBST(host_cpu)dnl
  92. AC_SUBST(host_vendor)dnl
  93. AC_SUBST(host_os)dnl
  94. ])
  95. dnl Internal use only.
  96. AC_DEFUN(tl_CANONICAL_TARGET,
  97. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  98. AC_REQUIRE([AC_PROG_CC])dnl
  99. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  100. AC_PROVIDE([AC_CANONICAL_TARGET])dnl
  101. AC_MSG_CHECKING(target system type)
  102. dnl Set target_alias.
  103. target_alias=$target
  104. case "$target_alias" in
  105. NONE)
  106. case $nonopt in
  107. NONE)
  108. target_cpu="`dpkg --print-architecture`"
  109. if test "$target_cpu" = ""; then
  110. target_alias=$host_alias
  111. else
  112. target_alias="`echo ${host_alias} | sed 's/[^-]*-/${target_cpu}-/'`"
  113. fi
  114. ;;
  115. *) target_alias=$nonopt ;;
  116. esac ;;
  117. esac
  118. dnl Set the other target vars.
  119. if test $target_alias = $host_alias; then
  120. target=$host
  121. target_cpu=$host_cpu
  122. target_vendor=$host_vendor
  123. target_os=$host_os
  124. elif test $target_alias = "$build_alias"; then
  125. target=$build
  126. target_cpu=$build_cpu
  127. target_vendor=$build_vendor
  128. target_os=$build_os
  129. else
  130. changequote(<<, >>)dnl
  131. target=`$ac_config_sub $target_alias`
  132. target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
  133. target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
  134. target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
  135. changequote([, ])dnl
  136. fi
  137. AC_MSG_RESULT($target)
  138. AC_SUBST(target)dnl
  139. AC_SUBST(target_alias)dnl
  140. AC_SUBST(target_cpu)dnl
  141. AC_SUBST(target_vendor)dnl
  142. AC_SUBST(target_os)dnl
  143. ])
  144. AC_DEFUN(tl_CANONICAL_BUILD,
  145. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  146. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  147. AC_PROVIDE([AC_CANONICAL_BUILD])dnl
  148. # Make sure we can run config.sub.
  149. #if $ac_config_sub sun4 >/dev/null 2>&1; then :
  150. #else AC_MSG_ERROR(can not run $ac_config_sub)
  151. #fi
  152. AC_MSG_CHECKING(build system type)
  153. dnl Set build_alias.
  154. build_alias=$build
  155. case "$build_alias" in
  156. NONE)
  157. case $nonopt in
  158. NONE)
  159. if test "$host_guessed" = "y"; then
  160. build_alias=$host_alias
  161. else
  162. if build_alias=`$ac_config_guess`; then :
  163. else build_alias=$host_alias
  164. fi
  165. fi ;;
  166. *) build_alias=$nonopt ;;
  167. esac ;;
  168. esac
  169. dnl Set the other build vars.
  170. if test $build_alias = $host_alias; then
  171. build=$host
  172. build_cpu=$host_cpu
  173. build_vendor=$host_vendor
  174. build_os=$host_os
  175. else
  176. changequote(<<, >>)dnl
  177. build=`$ac_config_sub $build_alias`
  178. build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
  179. build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
  180. build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
  181. changequote([, ])dnl
  182. fi
  183. AC_MSG_RESULT($build)
  184. AC_SUBST(build)dnl
  185. AC_SUBST(build_alias)dnl
  186. AC_SUBST(build_cpu)dnl
  187. AC_SUBST(build_vendor)dnl
  188. AC_SUBST(build_os)dnl
  189. ])