1
2# AX_ENABLE_SUFFIX
3# ----------------
4#  Create the configure option --enable-suffix[=suffix] to generate suffix
5# strings for the installed commands. This allows for shared installs of
6# different builds. Remember to change the default suffix string to some
7# value appropriate for the current version.
8AC_DEFUN([AX_ENABLE_SUFFIX],
9[AC_ARG_ENABLE([suffix],[AC_HELP_STRING([--enable-suffix],
10                                        [Use/set the installation command suffix])],
11               [true],[enable_suffix=no])
12if test X$enable_suffix = Xyes; then
13  install_suffix='-0.10'
14elif test X$enable_suffix = Xno; then
15  install_suffix=''
16else
17  install_suffix="$enable_suffix"
18fi
19AC_SUBST(install_suffix)
20])# AX_ENABLE_SUFFIX
21
22# _AX_C_UNDERSCORES_MATCH_IFELSE(PATTERN, ACTION-IF-MATCH, ACTION-IF-NOMATCH)
23# ------------------------------
24# Sub-macro for AX_C_UNDERSCORES_LEADING and AX_C_UNDERSCORES_TRAILING.
25# Unwarranted assumptions:
26#   - the object file produced by AC_COMPILE_IFELSE is called
27#     "conftest.$ac_objext"
28#   - the nm(1) utility or an equivalent is available, and its name
29#     is defined by the $NM variable.
30AC_DEFUN([_AX_C_UNDERSCORES_MATCH_IF],
31[AC_COMPILE_IFELSE([AC_LANG_SOURCE([void underscore(void){}])],
32[AS_IF([$NM conftest.$ac_objext|grep $1 >/dev/null 2>/dev/null],[$2],[$3])],
33[AC_MSG_ERROR([underscore test crashed])]
34)])
35
36
37# AX_C_UNDERSCORES_LEADING
38# ---------------------------------
39# Check if symbol names in object files produced by C compiler have
40# leading underscores. Define NEED_LU if so.
41AC_DEFUN([AX_C_UNDERSCORES_LEADING],
42[AC_CACHE_CHECK([for leading underscores], ax_cv_c_underscores_leading,
43[_AX_C_UNDERSCORES_MATCH_IF([_underscore],
44[AS_VAR_SET(ax_cv_c_underscores_leading, yes)],
45[AS_VAR_SET(ax_cv_c_underscores_leading, no)])])
46if test $ax_cv_c_underscores_leading = yes -a "$CYGWIN" != "yes" -a "$MINGW32" != "yes"; then
47 AC_DEFINE([NEED_LU], [1], [Symbol names in object files produced by C compiler have leading underscores.])
48fi
49])# AX_C_UNDERSCORES_LEADING
50
51
52# AX_C_UNDERSCORES_TRAILING
53# ---------------------------------
54# Check if symbol names in object files produced by C compiler have
55# trailing underscores.  Define NEED_TU if so.
56AC_DEFUN([AX_C_UNDERSCORES_TRAILING],
57[AC_CACHE_CHECK([for trailing underscores], ax_cv_c_underscores_trailing,
58[_AX_C_UNDERSCORES_MATCH_IF([underscore_],
59[AS_VAR_SET(ax_cv_c_underscores_trailing, yes)],
60[AS_VAR_SET(ax_cv_c_underscores_trailing, no)])])
61if test $ax_cv_c_underscores_trailing = yes; then
62 AC_DEFINE([NEED_TU], [1], [Symbol names in object files produced by C compiler have trailing underscores.])
63fi
64])# AX_C_UNDERSCORES_TRAILING
65
66# AX_WIN32
67# --------
68# Combined check for several flavors of Microsoft Windows so
69 # their "issues" can be dealt with
70AC_DEFUN([AX_WIN32],
71[AC_MSG_CHECKING([for Microsoft Windows])
72AC_REQUIRE([AC_CANONICAL_HOST]) []dnl
73case $host_os in
74     *cygwin*) MINGW32=no;  WIN32=yes;;
75
76      *mingw*) MINGW32=yes; WIN32=yes;;
77
78            *) MINGW32=no;  WIN32=no;;
79esac
80AC_SUBST(MINGW32)
81AC_SUBST(WIN32)
82AC_MSG_RESULT($WIN32)
83if test $WIN32 = yes; then
84AC_MSG_CHECKING([for MinGW])
85AC_MSG_RESULT($MINGW32)
86fi
87])# AX_WIN32
88
89# AX_LD_EXTRALIBS
90# ---------------
91# mingw needs to link with libiberty.a, but cygwin alone can't tolerate it
92AC_DEFUN([AX_LD_EXTRALIBS],
93[AC_MSG_CHECKING([for extra libs needed])
94EXTRALIBS=
95case "${host}" in
96     *-*-cygwin* )
97        if test "$MINGW32" = "yes"; then
98            EXTRALIBS="-liberty"
99        fi
100        ;;
101esac
102AC_SUBST(EXTRALIBS)
103AC_MSG_RESULT($EXTRALIBS)
104])# AX_LD_EXTRALIBS
105
106# AX_LD_SHAREDLIB_OPTS
107# --------------------
108# linker options when building a shared library
109AC_DEFUN([AX_LD_SHAREDLIB_OPTS],
110[AC_MSG_CHECKING([for shared library link flag])
111shared=-shared
112case "${host}" in
113     *-*-cygwin*)
114        shared="-shared -Wl,--enable-auto-image-base"
115        ;;
116
117     *-*-mingw*)
118        shared="-shared -Wl,--enable-auto-image-base"
119        ;;
120
121     *-*-hpux*)
122        shared="-b"
123        ;;
124
125     *-*-darwin1.[0123])
126        shared="-bundle -undefined suppress"
127        ;;
128
129     *-*-darwin*)
130        shared="-bundle -undefined suppress -flat_namespace"
131        ;;
132
133     *-*-solaris*)
134        if test ${using_sunpro_c} = 1
135        then
136           shared="-G"
137        fi
138        ;;
139esac
140AC_SUBST(shared)
141AC_MSG_RESULT($shared)
142])# AX_LD_SHAREDLIB_OPTS
143
144# AX_C_PICFLAG
145# ------------
146# The -fPIC flag is used to tell the compiler to make position
147# independent code. It is needed when making shared objects.
148AC_DEFUN([AX_C_PICFLAG],
149[AC_MSG_CHECKING([for flag to make position independent code])
150PICFLAG=-fPIC
151case "${host}" in
152
153     *-*-cygwin*)
154        PICFLAG=
155        ;;
156
157     *-*-mingw*)
158        PICFLAG=
159        ;;
160
161     *-*-hpux*)
162        PICFLAG=+z
163        ;;
164
165     *-*-solaris*)
166        if test ${using_sunpro_c} = 1
167        then
168           PICFLAG=-G
169        fi
170        ;;
171esac
172AC_SUBST(PICFLAG)
173AC_MSG_RESULT($PICFLAG)
174])# AX_C_PICFLAG
175
176# AX_LD_RDYNAMIC
177# --------------
178# The -rdynamic flag is used by iverilog when compiling the target,
179# to know how to export symbols of the main program to loadable modules
180# that are brought in by -ldl
181AC_DEFUN([AX_LD_RDYNAMIC],
182[AC_MSG_CHECKING([for -rdynamic compiler flag])
183rdynamic=-rdynamic
184case "${host}" in
185
186    *-*-netbsd*)
187        rdynamic="-Wl,--export-dynamic"
188        ;;
189
190    *-*-openbsd*)
191        rdynamic="-Wl,--export-dynamic"
192        ;;
193
194    *-*-solaris*)
195        rdynamic=""
196        ;;
197
198    *-*-cygwin*)
199        rdynamic=""
200        ;;
201
202    *-*-mingw*)
203        rdynamic=""
204        ;;
205
206    *-*-hpux*)
207        rdynamic="-E"
208        ;;
209
210    *-*-darwin*)
211        rdynamic="-Wl,-all_load"
212        strip_dynamic="-SX"
213        ;;
214
215esac
216AC_SUBST(rdynamic)
217AC_MSG_RESULT($rdynamic)
218AC_SUBST(strip_dynamic)
219# since we didn't tell them we're "checking", no good place to tell the answer
220# AC_MSG_RESULT($strip_dynamic)
221])# AX_LD_RDYNAMIC
222
223
224# AX_C99_STRTOD
225# -------------
226AC_DEFUN([AX_C99_STRTOD],
227[# On MinGW we need to jump through hoops to get a C99 compliant strtod().
228 # mingw-w64 doesn't need this, and the 64-bit version doesn't support it.
229case "${host}" in
230    x86_64-w64-mingw32)
231        ;;
232    *-*-mingw32)
233        LDFLAGS+=" -Wl,--undefined=___strtod,--wrap,strtod,--defsym,___wrap_strtod=___strtod"
234        ;;
235esac
236])# AX_C99_STRTOD
237
238# When config.status generates a header, we must update the stamp-h file.
239# This file resides in the same directory as the config header
240# that is generated.  The stamp file name are based on the header name.
241
242# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
243# loop where config.status creates the headers, so we can generate
244# our stamp files there.
245AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
246[
247_config_header=$1
248_stamp_name=stamp-`expr //$_config_header : '.*/\([[^./]]*\)\.[[^./]]*$'`-h
249echo "timestamp for $_config_header" > `AS_DIRNAME(["$_config_header"])`/[]$_stamp_name
250]) #_AC_AM_CONFIG_HEADER_HOOK
251
252# ===========================================================================
253#   http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
254# ===========================================================================
255#
256# SYNOPSIS
257#
258#   AX_PROG_CC_FOR_BUILD
259#
260# DESCRIPTION
261#
262#   This macro searches for a C compiler that generates native executables,
263#   that is a C compiler that surely is not a cross-compiler. This can be
264#   useful if you have to generate source code at compile-time like for
265#   example GCC does.
266#
267#   The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
268#   needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
269#   The value of these variables can be overridden by the user by specifying
270#   a compiler with an environment variable (like you do for standard CC).
271#
272#   It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
273#   file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
274#   the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
275#   substituted in the Makefile.
276#
277# LICENSE
278#
279#   Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
280#
281#   Copying and distribution of this file, with or without modification, are
282#   permitted in any medium without royalty provided the copyright notice
283#   and this notice are preserved. This file is offered as-is, without any
284#   warranty.
285
286#serial 8
287
288AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
289AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
290AC_REQUIRE([AC_PROG_CC])dnl
291AC_REQUIRE([AC_PROG_CPP])dnl
292AC_REQUIRE([AC_EXEEXT])dnl
293AC_REQUIRE([AC_CANONICAL_HOST])dnl
294
295dnl Use the standard macros, but make them use other variable names
296dnl
297pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
298pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
299pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
300pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
301pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
302pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
303pushdef([ac_cv_objext], ac_cv_build_objext)dnl
304pushdef([ac_exeext], ac_build_exeext)dnl
305pushdef([ac_objext], ac_build_objext)dnl
306pushdef([CC], CC_FOR_BUILD)dnl
307pushdef([CPP], CPP_FOR_BUILD)dnl
308pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
309pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
310pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
311pushdef([host], build)dnl
312pushdef([host_alias], build_alias)dnl
313pushdef([host_cpu], build_cpu)dnl
314pushdef([host_vendor], build_vendor)dnl
315pushdef([host_os], build_os)dnl
316pushdef([ac_cv_host], ac_cv_build)dnl
317pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
318pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
319pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
320pushdef([ac_cv_host_os], ac_cv_build_os)dnl
321pushdef([ac_cpp], ac_build_cpp)dnl
322pushdef([ac_compile], ac_build_compile)dnl
323pushdef([ac_link], ac_build_link)dnl
324
325save_cross_compiling=$cross_compiling
326save_ac_tool_prefix=$ac_tool_prefix
327cross_compiling=no
328ac_tool_prefix=
329
330AC_PROG_CC
331AC_PROG_CPP
332AC_EXEEXT
333
334ac_tool_prefix=$save_ac_tool_prefix
335cross_compiling=$save_cross_compiling
336
337dnl Restore the old definitions
338dnl
339popdef([ac_link])dnl
340popdef([ac_compile])dnl
341popdef([ac_cpp])dnl
342popdef([ac_cv_host_os])dnl
343popdef([ac_cv_host_vendor])dnl
344popdef([ac_cv_host_cpu])dnl
345popdef([ac_cv_host_alias])dnl
346popdef([ac_cv_host])dnl
347popdef([host_os])dnl
348popdef([host_vendor])dnl
349popdef([host_cpu])dnl
350popdef([host_alias])dnl
351popdef([host])dnl
352popdef([LDFLAGS])dnl
353popdef([CPPFLAGS])dnl
354popdef([CFLAGS])dnl
355popdef([CPP])dnl
356popdef([CC])dnl
357popdef([ac_objext])dnl
358popdef([ac_exeext])dnl
359popdef([ac_cv_objext])dnl
360popdef([ac_cv_exeext])dnl
361popdef([ac_cv_prog_cc_g])dnl
362popdef([ac_cv_prog_cc_cross])dnl
363popdef([ac_cv_prog_cc_works])dnl
364popdef([ac_cv_prog_gcc])dnl
365popdef([ac_cv_prog_CPP])dnl
366
367dnl Finally, set Makefile variables
368dnl
369BUILD_EXEEXT=$ac_build_exeext
370BUILD_OBJEXT=$ac_build_objext
371AC_SUBST(BUILD_EXEEXT)dnl
372AC_SUBST(BUILD_OBJEXT)dnl
373AC_SUBST([CFLAGS_FOR_BUILD])dnl
374AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
375AC_SUBST([LDFLAGS_FOR_BUILD])dnl
376])
377
378