]> git.saurik.com Git - apt.git/blob - buildlib/tl_canon.m4
fixed makefile
[apt.git] / buildlib / tl_canon.m4
1 # Our own versions of the other canonicalizing stuff
2
3 dnl replace AC_CANONICAL_xxx
4
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])
13
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.
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.
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) ;;
37 esac
38
39 tl_CANONICAL_HOST
40 tl_CANONICAL_TARGET
41 tl_CANONICAL_BUILD
42 test "$host_alias" != "$target_alias" &&
43 test "$program_prefix$program_suffix$program_transform_name" = \
44 NONENONEs,x,x, &&
45 program_prefix=${target_alias}-
46 AC_CHECK_TOOL_PREFIX
47 ])
48
49 dnl Subroutines of tl_CANONICAL_SYSTEM.
50
51 AC_DEFUN(tl_CANONICAL_HOST,
52 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
53 AC_PROVIDE([AC_CANONICAL_HOST])dnl
54
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)
58 fi
59
60 AC_MSG_CHECKING(host system type)
61
62 dnl Set host_alias.
63
64 if test "${GCC-no}" = "yes" -a "$nonopt" = "NONE"; then
65 changequote(, )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/'`"
71 changequote([, ])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
79 else
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
91 fi
92
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/'`
99 changequote([, ])dnl
100 AC_MSG_RESULT($host)
101 AC_SUBST(host)dnl
102 AC_SUBST(host_alias)dnl
103 AC_SUBST(host_cpu)dnl
104 AC_SUBST(host_vendor)dnl
105 AC_SUBST(host_os)dnl
106 ])
107
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)
115
116 dnl Set target_alias.
117 target_alias=$target
118 case "$target_alias" in
119 NONE)
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 ;;
131 esac
132
133 dnl Set the other target vars.
134 if test $target_alias = $host_alias; then
135 target=$host
136 target_cpu=$host_cpu
137 target_vendor=$host_vendor
138 target_os=$host_os
139 elif test $target_alias = "$build_alias"; then
140 target=$build
141 target_cpu=$build_cpu
142 target_vendor=$build_vendor
143 target_os=$build_os
144 else
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/'`
150 changequote([, ])dnl
151 fi
152 AC_MSG_RESULT($target)
153 AC_SUBST(target)dnl
154 AC_SUBST(target_alias)dnl
155 AC_SUBST(target_cpu)dnl
156 AC_SUBST(target_vendor)dnl
157 AC_SUBST(target_os)dnl
158 ])
159
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
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
170 AC_MSG_CHECKING(build system type)
171
172 dnl Set build_alias.
173 build_alias=$build
174 case "$build_alias" in
175 NONE)
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 ;;
187 esac
188
189 dnl Set the other build vars.
190 if test $build_alias = $host_alias; then
191 build=$host
192 build_cpu=$host_cpu
193 build_vendor=$host_vendor
194 build_os=$host_os
195 else
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/'`
201 changequote([, ])dnl
202 fi
203 AC_MSG_RESULT($build)
204 AC_SUBST(build)dnl
205 AC_SUBST(build_alias)dnl
206 AC_SUBST(build_cpu)dnl
207 AC_SUBST(build_vendor)dnl
208 AC_SUBST(build_os)dnl
209 ])