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