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