1 # Our own versions of the other canonicalizing stuff
3 dnl replace AC_CANONICAL_xxx
5 undefine([AC_CANONICAL_HOST])
6 define([AC_CANONICAL_HOST], [tl_CANONICAL_HOST])
7 undefine([AC_CANONICAL_BUILD])
8 define([AC_CANONICAL_BUILD], [tl_CANONICAL_BUILD])
9 undefine([AC_CANONICAL_TARGET])
10 define([AC_CANONICAL_TARGET], [tl_CANONICAL_TARGET])
11 undefine([AC_CANONICAL_SYSTEM])
12 define([AC_CANONICAL_SYSTEM], [tl_CANONICAL_SYSTEM])
14 dnl Canonicalize the host, target, and build system types.
15 AC_DEFUN(tl_CANONICAL_SYSTEM,
16 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
17 AC_PROVIDE([AC_CANONICAL_SYSTEM])dnl
18 AC_BEFORE([$0], [AC_ARG_PROGRAM])
19 # Do some error checking and defaulting for the host and target type.
21 # configure --host=HOST --target=TARGET --build=BUILD NONOPT
24 # 1. You are not allowed to specify --host, --target, and nonopt at the
26 # 2. Host defaults to nonopt.
27 # 3. If nonopt is not specified, then host defaults to the current host,
28 # as determined by config.guess.
29 # 4. Target and build default to nonopt.
30 # 5. If nonopt is not specified, then target and build default to host.
32 # The aliases save the names the user supplied, while $host etc.
33 # will get canonicalized.
34 case $host---$target---$nonopt in
35 NONE---*---* | *---NONE---* | *---*---NONE) ;;
36 *) AC_MSG_ERROR(can only configure for one host and one target at a time) ;;
42 test "$host_alias" != "$target_alias" &&
43 test "$program_prefix$program_suffix$program_transform_name" = \
45 program_prefix=${target_alias}-
49 dnl Subroutines of tl_CANONICAL_SYSTEM.
51 AC_DEFUN(tl_CANONICAL_HOST,
52 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
53 AC_PROVIDE([AC_CANONICAL_HOST])dnl
55 # Make sure we can run config.sub.
56 if $ac_config_sub sun4 >/dev/null 2>&1; then :
57 else AC_MSG_ERROR(can not run $ac_config_sub)
60 AC_MSG_CHECKING(host system type)
64 if test "${GCC-no}" = "yes" -a "$nonopt" = "NONE"; then
66 libgcc="`${CC} --print-libgcc-file-name`"
67 host_alias="`expr ${libgcc} : '.*/gcc-lib/\([^/]*\)/.*'`"
70 host_alias="`echo ${host_alias} | sed 's/\([^-]*\)-linux.*/\1/'`"
72 if ar p "${libgcc}" __main.o 2>/dev/null | file - 2>/dev/null | grep ELF >/dev/null; then
73 host_alias="${host_alias}-linux"
75 host_alias="${host_alias}-linuxaout"
85 if host_alias=`$ac_config_guess`; then host_guessed=y
86 else AC_MSG_ERROR(can not guess host type; you must specify one)
88 *) host_alias=$nonopt ;;
93 dnl Set the other host vars.
94 changequote(<<, >>)dnl
95 host=`$ac_config_sub $host_alias`
96 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
97 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
98 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
102 AC_SUBST(host_alias)dnl
103 AC_SUBST(host_cpu)dnl
104 AC_SUBST(host_vendor)dnl
108 dnl Internal use only.
109 AC_DEFUN(tl_CANONICAL_TARGET,
110 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
111 AC_REQUIRE([AC_PROG_CC])dnl
112 AC_REQUIRE([AC_CANONICAL_HOST])dnl
113 AC_PROVIDE([AC_CANONICAL_TARGET])dnl
114 AC_MSG_CHECKING(target system type)
116 dnl Set target_alias.
118 case "$target_alias" in
122 target_cpu="`dpkg --print-architecture`"
123 if test "$target_cpu" = ""; then
124 target_alias=$host_alias
126 target_alias="`echo ${host_alias} | sed 's/[^-]*-/${target_cpu}-/'`"
129 *) target_alias=$nonopt ;;
133 dnl Set the other target vars.
134 if test $target_alias = $host_alias; then
137 target_vendor=$host_vendor
139 elif test $target_alias = "$build_alias"; then
141 target_cpu=$build_cpu
142 target_vendor=$build_vendor
145 changequote(<<, >>)dnl
146 target=`$ac_config_sub $target_alias`
147 target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
148 target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
149 target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
152 AC_MSG_RESULT($target)
154 AC_SUBST(target_alias)dnl
155 AC_SUBST(target_cpu)dnl
156 AC_SUBST(target_vendor)dnl
157 AC_SUBST(target_os)dnl
160 AC_DEFUN(tl_CANONICAL_BUILD,
161 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
162 AC_REQUIRE([AC_CANONICAL_HOST])dnl
163 AC_PROVIDE([AC_CANONICAL_BUILD])dnl
165 # Make sure we can run config.sub.
166 #if $ac_config_sub sun4 >/dev/null 2>&1; then :
167 #else AC_MSG_ERROR(can not run $ac_config_sub)
170 AC_MSG_CHECKING(build system type)
174 case "$build_alias" in
178 if test "$host_guessed" = "y"; then
179 build_alias=$host_alias
181 if build_alias=`$ac_config_guess`; then :
182 else build_alias=$host_alias
185 *) build_alias=$nonopt ;;
189 dnl Set the other build vars.
190 if test $build_alias = $host_alias; then
193 build_vendor=$host_vendor
196 changequote(<<, >>)dnl
197 build=`$ac_config_sub $build_alias`
198 build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
199 build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
200 build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
203 AC_MSG_RESULT($build)
205 AC_SUBST(build_alias)dnl
206 AC_SUBST(build_cpu)dnl
207 AC_SUBST(build_vendor)dnl
208 AC_SUBST(build_os)dnl