]> git.saurik.com Git - apple/icu.git/blob - icuSources/acinclude.m4
ICU-57166.0.1.tar.gz
[apple/icu.git] / icuSources / acinclude.m4
1 # Copyright (c) 1999-2015, International Business Machines Corporation and
2 # others. All Rights Reserved.
3 # acinclude.m4 for ICU
4 # Don't edit aclocal.m4, do edit acinclude.m4
5 # Stephen F. Booth
6
7 # @TOP@
8
9 # ICU_CHECK_MH_FRAG
10 AC_DEFUN([ICU_CHECK_MH_FRAG], [
11 AC_CACHE_CHECK(
12 [which Makefile fragment to use for ${host}],
13 [icu_cv_host_frag],
14 [
15 case "${host}" in
16 *-*-solaris*)
17 if test "$GCC" = yes; then
18 icu_cv_host_frag=mh-solaris-gcc
19 else
20 icu_cv_host_frag=mh-solaris
21 fi ;;
22 alpha*-*-linux-gnu)
23 if test "$GCC" = yes; then
24 icu_cv_host_frag=mh-alpha-linux-gcc
25 else
26 icu_cv_host_frag=mh-alpha-linux-cc
27 fi ;;
28 powerpc*-*-linux*)
29 if test "$GCC" = yes; then
30 icu_cv_host_frag=mh-linux
31 else
32 icu_cv_host_frag=mh-linux-va
33 fi ;;
34 *-*-linux*|*-*-gnu|*-*-k*bsd*-gnu|*-*-kopensolaris*-gnu) icu_cv_host_frag=mh-linux ;;
35 i[[34567]]86-*-cygwin)
36 if test "$GCC" = yes; then
37 icu_cv_host_frag=mh-cygwin
38 else
39 icu_cv_host_frag=mh-cygwin-msvc
40 fi ;;
41 x86_64-*-cygwin)
42 if test "$GCC" = yes; then
43 icu_cv_host_frag=mh-cygwin64
44 else
45 icu_cv_host_frag=mh-cygwin-msvc
46 fi ;;
47 *-*-mingw*)
48 if test "$GCC" = yes; then
49 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
50 #ifndef __MINGW64__
51 #error This is not MinGW64
52 #endif]])], [icu_cv_host_frag=mh-mingw64],
53 [icu_cv_host_frag=mh-mingw])
54 else
55 case "${host}" in
56 *-*-mingw*) icu_cv_host_frag=mh-msys-msvc ;;
57 *-*-cygwin) icu_cv_host_frag=mh-cygwin-msvc ;;
58 esac
59 fi ;;
60 *-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
61 *-*-aix*)
62 if test "$GCC" = yes; then
63 icu_cv_host_frag=mh-aix-gcc
64 else
65 icu_cv_host_frag=mh-aix-va
66 fi ;;
67 *-*-hpux*)
68 if test "$GCC" = yes; then
69 icu_cv_host_frag=mh-hpux-gcc
70 else
71 case "$CXX" in
72 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
73 esac
74 fi ;;
75 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
76 *-*-os400*) icu_cv_host_frag=mh-os400 ;;
77 *-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
78 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
79 *-*-beos) icu_cv_host_frag=mh-beos ;;
80 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
81 *-*-irix*) icu_cv_host_frag=mh-irix ;;
82 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
83 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
84 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
85 *) icu_cv_host_frag=mh-unknown ;;
86 esac
87 ]
88 )
89 ])
90
91 # ICU_PROG_LINK - Make sure that the linker is usable
92 AC_DEFUN([ICU_PROG_LINK],
93 [
94 case "${host}" in
95 *-*-cygwin*|*-*-mingw*)
96 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
97 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
98 Please follow the directions in ICU's readme.])
99 fi;;
100 *);;
101 esac])
102
103 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
104 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
105 # Search for a library defining FUNC, then see if it's not already available.
106
107 AC_DEFUN([AC_SEARCH_LIBS_FIRST],
108 [AC_PREREQ([2.13])
109 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
110 [ac_func_search_save_LIBS="$LIBS"
111 ac_cv_search_$1="no"
112 for i in $2; do
113 LIBS="-l$i $5 $ac_func_search_save_LIBS"
114 AC_TRY_LINK_FUNC([$1],
115 [ac_cv_search_$1="-l$i"
116 break])
117 done
118 if test "$ac_cv_search_$1" = "no"; then
119 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
120 fi
121 LIBS="$ac_func_search_save_LIBS"])
122 if test "$ac_cv_search_$1" != "no"; then
123 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
124 $3
125 else :
126 $4
127 fi])
128
129
130
131 # Check if we can build and use 64-bit libraries
132 AC_DEFUN([AC_CHECK_64BIT_LIBS],
133 [
134 BITS_REQ=nochange
135 ENABLE_64BIT_LIBS=unknown
136 ## revisit this for cross-compile.
137
138 AC_ARG_ENABLE(64bit-libs,
139 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
140 [echo "note, use --with-library-bits instead of --*-64bit-libs"
141 case "${enableval}" in
142 no|false|32) with_library_bits=32; ;;
143 yes|true|64) with_library_bits=64else32 ;;
144 nochange) with_library_bits=nochange; ;;
145 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
146 esac] )
147
148
149 AC_ARG_WITH(library-bits,
150 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
151 [case "${withval}" in
152 ""|nochange) BITS_REQ=$withval ;;
153 32|64|64else32) BITS_REQ=$withval ;;
154 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
155 esac])
156
157 # don't use these for cross compiling
158 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
159 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
160 fi
161 AC_CHECK_SIZEOF([void *])
162 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
163 case $ac_cv_sizeof_void_p in
164 8) DEFAULT_64BIT=yes ;;
165 4) DEFAULT_64BIT=no ;;
166 *) DEFAULT_64BIT=unknown
167 esac
168 BITS_GOT=unknown
169
170 # 'OK' here means, we can exit any further checking, everything's copa
171 BITS_OK=yes
172
173 # do we need to check for buildable/runnable 32 or 64 bit?
174 BITS_CHECK_32=no
175 BITS_CHECK_64=no
176
177 # later, can we run the 32/64 bit binaries so made?
178 BITS_RUN_32=no
179 BITS_RUN_64=no
180
181 if test "$DEFAULT_64BIT" = "yes"; then
182 # we get 64 bits by default.
183 BITS_GOT=64
184 case "$BITS_REQ" in
185 32)
186 # need to look for 32 bit support.
187 BITS_CHECK_32=yes
188 # not copa.
189 BITS_OK=no;;
190 # everyone else is happy.
191 nochange) ;;
192 *) ;;
193 esac
194 elif test "$DEFAULT_64BIT" = "no"; then
195 # not 64 bit by default.
196 BITS_GOT=32
197 case "$BITS_REQ" in
198 64|64else32)
199 BITS_CHECK_64=yes
200 #BITS_CHECK_32=yes
201 BITS_OK=no;;
202 nochange) ;;
203 *) ;;
204 esac
205 elif test "$DEFAULT_64BIT" = "unknown"; then
206 # cross compiling.
207 BITS_GOT=unknown
208 case "$BITS_REQ" in
209 64|64else32) BITS_OK=no
210 BITS_CHECK_32=yes
211 BITS_CHECK_64=yes ;;
212 32) BITS_OK=no;;
213 nochange) ;;
214 *) ;;
215 esac
216 fi
217
218 AC_MSG_RESULT($DEFAULT_64BIT);
219
220 if test "$BITS_OK" != "yes"; then
221 # not copa. back these up.
222 CFLAGS_OLD="${CFLAGS}"
223 CXXFLAGS_OLD="${CXXFLAGS}"
224 LDFLAGS_OLD="${LDFLAGS}"
225 ARFLAGS_OLD="${ARFLAGS}"
226
227 CFLAGS_32="${CFLAGS}"
228 CXXFLAGS_32="${CXXFLAGS}"
229 LDFLAGS_32="${LDFLAGS}"
230 ARFLAGS_32="${ARFLAGS}"
231
232 CFLAGS_64="${CFLAGS}"
233 CXXFLAGS_64="${CXXFLAGS}"
234 LDFLAGS_64="${LDFLAGS}"
235 ARFLAGS_64="${ARFLAGS}"
236
237 CAN_BUILD_64=unknown
238 CAN_BUILD_32=unknown
239 # These results can't be cached because is sets compiler flags.
240 if test "$BITS_CHECK_64" = "yes"; then
241 AC_MSG_CHECKING([how to build 64-bit executables])
242 CAN_BUILD_64=no
243 ####
244 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
245 # Note, we don't have to actually check if the options work- we'll try them before using them.
246 # So, only try actually testing the options, if you are trying to decide between multiple options.
247 # On exit from the following clauses:
248 # if CAN_BUILD_64=yes:
249 # *FLAGS are assumed to contain the right settings for 64bit
250 # else if CAN_BUILD_64=no: (default)
251 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
252
253 if test "$GCC" = yes; then
254 CFLAGS="${CFLAGS} -m64"
255 CXXFLAGS="${CXXFLAGS} -m64"
256 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
257 CAN_BUILD_64=yes, CAN_BUILD_64=no)
258 else
259 case "${host}" in
260 sparc*-*-solaris*)
261 # 1. try -m64
262 CFLAGS="${CFLAGS} -m64"
263 CXXFLAGS="${CXXFLAGS} -m64"
264 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
265 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
266 if test "$CAN_BUILD_64" != yes; then
267 # Nope. back out changes.
268 CFLAGS="${CFLAGS_OLD}"
269 CXXFLAGS="${CXXFLAGS_OLD}"
270 # 2. try xarch=v9 [deprecated]
271 ## TODO: cross compile: the following won't work.
272 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
273 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
274 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
275 if test -z "$SOL64" && test -n "$SPARCV9"; then
276 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
277 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
278 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
279 CAN_BUILD_64=yes
280 fi
281 fi
282 ;;
283 i386-*-solaris*)
284 # 1. try -m64
285 CFLAGS="${CFLAGS} -m64"
286 CXXFLAGS="${CXXFLAGS} -m64"
287 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
288 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
289 if test "$CAN_BUILD_64" != yes; then
290 # Nope. back out changes.
291 CFLAGS="${CFLAGS_OLD}"
292 CXXFLAGS="${CXXFLAGS_OLD}"
293 # 2. try the older compiler option
294 ## TODO: cross compile problem
295 AMD64=`isainfo -n 2>&1 | grep amd64`
296 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
297 if test -z "$SOL64" && test -n "$AMD64"; then
298 CFLAGS="${CFLAGS} -xtarget=generic64"
299 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
300 CAN_BUILD_64=yes
301 fi
302 fi
303 ;;
304 ia64-*-linux*)
305 # check for ecc/ecpc compiler support
306 ## TODO: cross compiler problem
307 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
308 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
309 CAN_BUILD_64=yes
310 fi
311 fi
312 ;;
313 *-*-cygwin)
314 # vcvarsamd64.bat should have been used to enable 64-bit builds.
315 # We only do this check to display the correct answer.
316 ## TODO: cross compiler problem
317 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
318 CAN_BUILD_64=yes
319 fi
320 ;;
321 *-*-aix*|powerpc64-*-linux*)
322 CFLAGS="${CFLAGS} -q64"
323 CXXFLAGS="${CXXFLAGS} -q64"
324 LDFLAGS="${LDFLAGS} -q64"
325 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
326 CAN_BUILD_64=yes, CAN_BUILD_64=no)
327 if test "$CAN_BUILD_64" = yes; then
328 # worked- set other options.
329 case "${host}" in
330 *-*-aix*)
331 # tell AIX what executable mode to use.
332 ARFLAGS="${ARFLAGS} -X64"
333 esac
334 fi
335 ;;
336 *-*-hpux*)
337 # First we try the newer +DD64, if that doesn't work,
338 # try other options.
339
340 CFLAGS="${CFLAGS} +DD64"
341 CXXFLAGS="${CXXFLAGS} +DD64"
342 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
343 CAN_BUILD_64=yes, CAN_BUILD_64=no)
344 if test "$CAN_BUILD_64" != yes; then
345 # reset
346 CFLAGS="${CFLAGS_OLD}"
347 CXXFLAGS="${CXXFLAGS_OLD}"
348 # append
349 CFLAGS="${CFLAGS} +DA2.0W"
350 CXXFLAGS="${CXXFLAGS} +DA2.0W"
351 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
352 CAN_BUILD_64=yes, CAN_BUILD_64=no)
353 fi
354 ;;
355 *-*ibm-openedition*|*-*-os390*)
356 CFLAGS="${CFLAGS} -Wc,lp64"
357 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
358 LDFLAGS="${LDFLAGS} -Wl,lp64"
359 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
360 CAN_BUILD_64=yes, CAN_BUILD_64=no)
361 ;;
362 *)
363 # unknown platform.
364 ;;
365 esac
366 fi
367 AC_MSG_RESULT($CAN_BUILD_64)
368 if test "$CAN_BUILD_64" = yes; then
369 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
370 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
371 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
372 AC_MSG_RESULT($BITS_RUN_64);
373
374 CFLAGS_64="${CFLAGS}"
375 CXXFLAGS_64="${CXXFLAGS}"
376 LDFLAGS_64="${LDFLAGS}"
377 ARFLAGS_64="${ARFLAGS}"
378 fi
379 # put it back.
380 CFLAGS="${CFLAGS_OLD}"
381 CXXFLAGS="${CXXFLAGS_OLD}"
382 LDFLAGS="${LDFLAGS_OLD}"
383 ARFLAGS="${ARFLAGS_OLD}"
384 fi
385 if test "$BITS_CHECK_32" = "yes"; then
386 # see comment under 'if BITS_CHECK_64', above.
387 AC_MSG_CHECKING([how to build 32-bit executables])
388 if test "$GCC" = yes; then
389 CFLAGS="${CFLAGS} -m32"
390 CXXFLAGS="${CXXFLAGS} -m32"
391 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
392 CAN_BUILD_32=yes, CAN_BUILD_32=no)
393 fi
394 AC_MSG_RESULT($CAN_BUILD_32)
395 if test "$CAN_BUILD_32" = yes; then
396 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
397 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
398 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
399 AC_MSG_RESULT($BITS_RUN_32);
400 CFLAGS_32="${CFLAGS}"
401 CXXFLAGS_32="${CXXFLAGS}"
402 LDFLAGS_32="${LDFLAGS}"
403 ARFLAGS_32="${ARFLAGS}"
404 fi
405 # put it back.
406 CFLAGS="${CFLAGS_OLD}"
407 CXXFLAGS="${CXXFLAGS_OLD}"
408 LDFLAGS="${LDFLAGS_OLD}"
409 ARFLAGS="${ARFLAGS_OLD}"
410 fi
411
412 ##
413 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
414 #
415
416 # First, implement 64else32
417 if test "$BITS_REQ" = "64else32"; then
418 if test "$BITS_RUN_64" = "yes"; then
419 BITS_REQ=64
420 else
421 # no changes.
422 BITS_OK=yes
423 fi
424 fi
425
426 # implement.
427 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
428 CFLAGS="${CFLAGS_32}"
429 CXXFLAGS="${CXXFLAGS_32}"
430 LDFLAGS="${LDFLAGS_32}"
431 ARFLAGS="${ARFLAGS_32}"
432 BITS_OK=yes
433 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
434 CFLAGS="${CFLAGS_64}"
435 CXXFLAGS="${CXXFLAGS_64}"
436 LDFLAGS="${LDFLAGS_64}"
437 ARFLAGS="${ARFLAGS_64}"
438 BITS_OK=yes
439 elif test "$BITS_OK" != "yes"; then
440 AC_MSG_ERROR([Requested $BITS_REQ bit binaries but could not compile and execute them. See readme.html for help with cross compilation., and set compiler options manually.])
441 fi
442 fi
443 ])
444
445 # Strict compilation options.
446 AC_DEFUN([AC_CHECK_STRICT_COMPILE],
447 [
448 AC_MSG_CHECKING([whether strict compiling is on])
449 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
450 if test "$enableval" = no
451 then
452 ac_use_strict_options=no
453 else
454 ac_use_strict_options=yes
455 fi
456 ], [ac_use_strict_options=yes])
457 AC_MSG_RESULT($ac_use_strict_options)
458
459 if test "$ac_use_strict_options" = yes
460 then
461 if test "$GCC" = yes
462 then
463 case "${host}" in
464 *)
465 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
466 # We use -std=c99 to disable the gnu99 defaults and its associated warnings
467 CFLAGS="$CFLAGS -std=c99"
468 ;;
469 esac
470
471 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
472 else
473 case "${host}" in
474 *-*-cygwin)
475 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
476 then
477 CFLAGS="$CFLAGS /W4"
478 fi ;;
479 *-*-mingw*)
480 CFLAGS="$CFLAGS -W4" ;;
481 esac
482 fi
483 if test "$GXX" = yes
484 then
485 CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
486 else
487 case "${host}" in
488 *-*-cygwin)
489 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
490 then
491 CXXFLAGS="$CXXFLAGS /W4"
492 fi ;;
493 *-*-mingw*)
494 CFLAGS="$CFLAGS -W4" ;;
495 esac
496 fi
497 fi
498 ])
499
500