• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl aclocal.m4 for ICU
2dnl Copyright (c) 1999-2007, International Business Machines Corporation and
3dnl others. All Rights Reserved.
4dnl Stephen F. Booth
5
6dnl @TOP@
7
8dnl ICU_CHECK_MH_FRAG
9AC_DEFUN(ICU_CHECK_MH_FRAG, [
10	AC_CACHE_CHECK(
11		[which Makefile fragment to use],
12		[icu_cv_host_frag],
13		[
14case "${host}" in
15*-*-solaris*)
16	if test "$GCC" = yes; then
17		icu_cv_host_frag=mh-solaris-gcc
18	else
19		icu_cv_host_frag=mh-solaris
20	fi ;;
21alpha*-*-linux-gnu)
22	if test "$GCC" = yes; then
23		icu_cv_host_frag=mh-alpha-linux-gcc
24	else
25		icu_cv_host_frag=mh-alpha-linux-cc
26	fi ;;
27powerpc*-*-linux*)
28	if test "$GCC" = yes; then
29		icu_cv_host_frag=mh-linux
30	else
31		icu_cv_host_frag=mh-linux-va
32	fi ;;
33*-*-linux*|*-pc-gnu) icu_cv_host_frag=mh-linux ;;
34*-*-cygwin|*-*-mingw32)
35	if test "$GCC" = yes; then
36		AC_TRY_COMPILE([
37#ifndef __MINGW32__
38#error This is not MinGW
39#endif], [], icu_cv_host_frag=mh-mingw, icu_cv_host_frag=mh-cygwin)
40	else
41		icu_cv_host_frag=mh-cygwin-msvc
42	fi ;;
43*-*-*bsd*|*-*-dragonfly*) 	icu_cv_host_frag=mh-bsd-gcc ;;
44*-*-aix*)
45	if test "$GCC" = yes; then
46		icu_cv_host_frag=mh-aix-gcc
47	else
48		icu_cv_host_frag=mh-aix-va
49	fi ;;
50*-*-hpux*)
51	if test "$GCC" = yes; then
52		icu_cv_host_frag=mh-hpux-gcc
53	else
54		case "$CXX" in
55		*aCC)    icu_cv_host_frag=mh-hpux-acc ;;
56		esac
57	fi ;;
58*-*ibm-openedition*|*-*-os390*)	icu_cv_host_frag=mh-os390 ;;
59*-*-os400*)	icu_cv_host_frag=mh-os400 ;;
60*-apple-rhapsody*)	icu_cv_host_frag=mh-darwin ;;
61*-apple-darwin*)	icu_cv_host_frag=mh-darwin ;;
62*-*-beos)	icu_cv_host_frag=mh-beos ;;
63*-*-irix*)	icu_cv_host_frag=mh-irix ;;
64*-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
65*-*-nto*)	icu_cv_host_frag=mh-qnx ;;
66*-ncr-*)	icu_cv_host_frag=mh-mpras ;;
67*) 		icu_cv_host_frag=mh-unknown ;;
68esac
69		]
70	)
71])
72
73dnl ICU_CONDITIONAL - similar example taken from Automake 1.4
74AC_DEFUN(ICU_CONDITIONAL,
75[AC_SUBST($1_TRUE)
76if $2; then
77  $1_TRUE=
78else
79  $1_TRUE='#'
80fi])
81
82dnl ICU_PROG_LINK - Make sure that the linker is usable
83AC_DEFUN(ICU_PROG_LINK,
84[
85case "${host}" in
86    *-*-cygwin*|*-*-mingw*)
87        if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
88            AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
89                  Please follow the directions in ICU's readme.])
90        fi;;
91    *);;
92esac])
93
94dnl AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
95dnl            [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
96dnl Search for a library defining FUNC, then see if it's not already available.
97
98AC_DEFUN(AC_SEARCH_LIBS_FIRST,
99[AC_PREREQ([2.13])
100AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
101[ac_func_search_save_LIBS="$LIBS"
102ac_cv_search_$1="no"
103for i in $2; do
104LIBS="-l$i $5 $ac_func_search_save_LIBS"
105AC_TRY_LINK_FUNC([$1],
106[ac_cv_search_$1="-l$i"
107break])
108done
109if test "$ac_cv_search_$1" = "no"; then
110AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
111fi
112LIBS="$ac_func_search_save_LIBS"])
113if test "$ac_cv_search_$1" != "no"; then
114  test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
115  $3
116else :
117  $4
118fi])
119
120dnl Check if we can build and use 64-bit libraries
121AC_DEFUN(AC_CHECK_64BIT_LIBS,
122[
123    AC_ARG_ENABLE(64bit-libs,
124        [  --enable-64bit-libs     build 64-bit libraries [default=yes]],
125        [ENABLE_64BIT_LIBS=${enableval}],
126        [ENABLE_64BIT_LIBS=yes]
127    )
128    dnl These results can't be cached because is sets compiler flags.
129    AC_MSG_CHECKING([for 64-bit executable support])
130    if test "$ENABLE_64BIT_LIBS" != no; then
131        if test "$GCC" = yes; then
132            dnl First we check that gcc already compiles as 64-bit
133            if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
134                ENABLE_64BIT_LIBS=yes
135            else
136                dnl Now we check a little more forcefully.
137                dnl Maybe the compiler builds as 32-bit on a 64-bit machine.
138                OLD_CFLAGS="${CFLAGS}"
139                OLD_CXXFLAGS="${CXXFLAGS}"
140                CFLAGS="${CFLAGS} -m64"
141                CXXFLAGS="${CXXFLAGS} -m64"
142                AC_TRY_RUN(int main(void) {return 0;},
143                   ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
144                if test "$ENABLE_64BIT_LIBS" = no; then
145                    # Nope. We're on a 32-bit machine with a 32-bit compiler.
146                    CFLAGS="${OLD_CFLAGS}"
147                    CXXFLAGS="${OLD_CXXFLAGS}"
148                fi
149            fi
150        else
151            case "${host}" in
152            sparc*-*-solaris*)
153                SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
154                SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
155                if test -z "$SOL64" && test -n "$SPARCV9"; then
156                    CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
157                    CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
158                    LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
159                    ENABLE_64BIT_LIBS=yes
160                else
161                    ENABLE_64BIT_LIBS=no
162                fi
163                ;;
164            i386-*-solaris*)
165                AMD64=`isainfo -n 2>&1 | grep amd64`
166                # The new compiler option
167                SOL64=`$CXX -m64 2>&1 && $CC -m64 2>&1 | grep -v usage:`
168                if test -z "$SOL64" && test -n "$AMD64"; then
169                    CFLAGS="${CFLAGS} -m64"
170                    CXXFLAGS="${CXXFLAGS} -m64"
171                    ENABLE_64BIT_LIBS=yes
172                else
173                    # The older compiler option
174                    SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
175                    if test -z "$SOL64" && test -n "$AMD64"; then
176                        CFLAGS="${CFLAGS} -xtarget=generic64"
177                        CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
178                        ENABLE_64BIT_LIBS=yes
179                    else
180                        ENABLE_64BIT_LIBS=no
181                    fi
182                fi
183                ;;
184            ia64-*-linux*)
185                # check for ecc/ecpc compiler support
186                if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
187                    if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
188                        ENABLE_64BIT_LIBS=yes
189                    else
190                        ENABLE_64BIT_LIBS=no
191                    fi
192                else
193                    # unknown
194                    ENABLE_64BIT_LIBS=no
195                fi
196                ;;
197            *-*-cygwin)
198                dnl vcvarsamd64.bat should have been used to enable 64-bit builds.
199                dnl We only do this check to display the correct answer.
200                if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
201                    ENABLE_64BIT_LIBS=yes
202                else
203                    # unknown
204                    ENABLE_64BIT_LIBS=no
205                fi
206                ;;
207            *-*-aix*|powerpc64-*-linux*)
208                OLD_CFLAGS="${CFLAGS}"
209                OLD_CXXFLAGS="${CXXFLAGS}"
210                OLD_LDFLAGS="${LDFLAGS}"
211                CFLAGS="${CFLAGS} -q64"
212                CXXFLAGS="${CXXFLAGS} -q64"
213                LDFLAGS="${LDFLAGS} -q64"
214                AC_TRY_RUN(int main(void) {return 0;},
215                   ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
216                if test "$ENABLE_64BIT_LIBS" = no; then
217                    CFLAGS="${OLD_CFLAGS}"
218                    CXXFLAGS="${OLD_CXXFLAGS}"
219                    LDFLAGS="${OLD_LDFLAGS}"
220                else
221                    case "${host}" in
222                    *-*-aix*)
223                        ARFLAGS="${ARFLAGS} -X64"
224                    esac
225                fi
226                ;;
227            *-*-hpux*)
228                dnl First we try the newer +DD64, if that doesn't work,
229                dnl try other options.
230
231                OLD_CFLAGS="${CFLAGS}"
232                OLD_CXXFLAGS="${CXXFLAGS}"
233                CFLAGS="${CFLAGS} +DD64"
234                CXXFLAGS="${CXXFLAGS} +DD64"
235                AC_TRY_RUN(int main(void) {return 0;},
236                    ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
237                if test "$ENABLE_64BIT_LIBS" = no; then
238                    CFLAGS="${OLD_CFLAGS}"
239                    CXXFLAGS="${OLD_CXXFLAGS}"
240                    CFLAGS="${CFLAGS} +DA2.0W"
241                    CXXFLAGS="${CXXFLAGS} +DA2.0W"
242                    AC_TRY_RUN(int main(void) {return 0;},
243                        ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
244                    if test "$ENABLE_64BIT_LIBS" = no; then
245                        CFLAGS="${OLD_CFLAGS}"
246                        CXXFLAGS="${OLD_CXXFLAGS}"
247                    fi
248                fi
249                ;;
250            *-*ibm-openedition*|*-*-os390*)
251                OLD_CFLAGS="${CFLAGS}"
252                OLD_CXXFLAGS="${CXXFLAGS}"
253                OLD_LDFLAGS="${LDFLAGS}"
254                CFLAGS="${CFLAGS} -Wc,lp64"
255                CXXFLAGS="${CXXFLAGS} -Wc,lp64"
256                LDFLAGS="${LDFLAGS} -Wl,lp64"
257                AC_TRY_RUN(int main(void) {return 0;},
258                   ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
259                if test "$ENABLE_64BIT_LIBS" = no; then
260                    CFLAGS="${OLD_CFLAGS}"
261                    CXXFLAGS="${OLD_CXXFLAGS}"
262                    LDFLAGS="${OLD_LDFLAGS}"
263                fi
264                ;;
265            *)
266                ENABLE_64BIT_LIBS=no
267                ;;
268            esac
269        fi
270    else
271        if test "$GCC" = yes; then
272            OLD_CFLAGS="${CFLAGS}"
273            OLD_CXXFLAGS="${CXXFLAGS}"
274            CFLAGS="${CFLAGS} -m32"
275            CXXFLAGS="${CXXFLAGS} -m32"
276            AC_TRY_RUN(int main(void) {return 0;},
277               ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=yes)
278            if test "$ENABLE_64BIT_LIBS" = yes; then
279                CFLAGS="${OLD_CFLAGS}"
280                CXXFLAGS="${OLD_CXXFLAGS}"
281            fi
282        fi
283    fi
284    dnl Individual tests that fail should reset their own flags.
285    AC_MSG_RESULT($ENABLE_64BIT_LIBS)
286])
287
288dnl Strict compilation options.
289AC_DEFUN(AC_CHECK_STRICT_COMPILE,
290[
291    AC_MSG_CHECKING([whether strict compiling is on])
292    AC_ARG_ENABLE(strict,[  --enable-strict         compile with strict compiler options [default=no]], [
293        if test "$enableval" = no
294        then
295            ac_use_strict_options=no
296        else
297            ac_use_strict_options=yes
298        fi
299      ], [ac_use_strict_options=no])
300    AC_MSG_RESULT($ac_use_strict_options)
301
302    if test "$ac_use_strict_options" = yes
303    then
304        if test "$GCC" = yes
305        then
306            CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long"
307            case "${host}" in
308            *-*-solaris*)
309                CFLAGS="$CFLAGS -D__STDC__=0";;
310            esac
311        else
312            case "${host}" in
313            *-*-cygwin)
314                if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
315                then
316                    CFLAGS="$CFLAGS /W4"
317                fi
318            esac
319        fi
320        if test "$GXX" = yes
321        then
322            CXXFLAGS="$CXXFLAGS -W -Wall -ansi -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
323            case "${host}" in
324            *-*-solaris*)
325                CXXFLAGS="$CXXFLAGS -D__STDC__=0";;
326            esac
327        else
328            case "${host}" in
329            *-*-cygwin)
330                if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
331                then
332                    CXXFLAGS="$CXXFLAGS /W4"
333                fi
334            esac
335        fi
336    fi
337])
338
339
340