aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: 01b61097ffcd7e5f9e37444d0bf3f56c6feb60e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# Process this file with autoconf to produce a configure script.

#
# autoconf setup
#
AC_PREREQ(2.53)
AC_INIT([yasm],
       	m4_esyscmd([./YASM-VERSION-GEN.sh && tr -d '\n' <YASM-VERSION-FILE]),
        [bug-yasm@tortall.net])
#AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_HEADER([config.h])

AM_INIT_AUTOMAKE([1.9.6 foreign subdir-objects])
AM_MAINTAINER_MODE

#
# autoconf command-line options
#
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],
	       [Turn on debugging and compile time warnings]),
[case "${enableval}" in
  yes) debugging="yes" ;;
  no)  debugging="no" ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac])

AC_ARG_ENABLE(warnerror,
AC_HELP_STRING([--enable-warnerror],[Treat GCC warnings as errors]),
[case "${enableval}" in
  yes) warnerror="yes" ;;
  no)  warnerror="no" ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-warnerror]) ;;
esac])

AC_ARG_ENABLE(profiling,
AC_HELP_STRING([--enable-profiling],[Enable profiling (requires GCC)]),
[case "${enableval}" in
  yes) profiling="yes" ;;
  no)  profiling="no" ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-profiling]) ;;
esac])

AC_ARG_ENABLE(gcov,
AC_HELP_STRING([--enable-gcov],[Enable gcov code coverage (requires GCC)]),
[case "${enableval}" in
  yes) gcov="yes" ;;
  no)  gcov="no" ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-gcov]) ;;
esac])

AC_ARG_ENABLE(python,
AC_HELP_STRING([--enable-python],[Enable Python-requiring portions of build]),
[case "${enableval}" in
  yes) enable_python="yes" ;;
  no)  enable_python="no" ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-python]) ;;
esac], enable_python="auto")

AC_ARG_ENABLE(python-bindings,
AC_HELP_STRING([--enable-python-bindings],[Build Python bindings]),
[case "${enableval}" in
  yes) enable_python_bindings="yes" ;;
  no)  enable_python_bindings="no" ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-python-bindings]) ;;
esac], enable_python_bindings="no")

#
# Checks for programs.
#
AC_PROG_CPP
AC_PROG_CC_STDC
AC_PROG_INSTALL
AC_PROG_LN_S
#automake default ARFLAGS to "cru"
AC_CHECK_TOOLS(AR,[$AR ar],[ar])
AC_PROG_RANLIB

# REQUIRE a standard (ANSI/ISO) C compiler
if test "$ac_cv_prog_cc_stdc" = no; then
	AC_MSG_ERROR([A standard (ANSI/ISO C89) C compiler is required.])
fi

# Check for xmlto (for rendering manpages, needed only for development)
AC_CHECK_PROGS([XMLTO], [$XMLTO xmlto], [:])
if test "$XMLTO" = ":"; then
  AC_MSG_WARN([xmlto not found, manpages will not be rebuilt.])
fi
AM_CONDITIONAL(BUILD_MAN, test "$XMLTO" != ":")

# Check for compiler output filename suffixes.
AC_OBJEXT
AC_EXEEXT

#
# Checks for libraries.
#
AM_WITH_DMALLOC

#
# Checks for header files.
#
AC_HEADER_STDC
AC_CHECK_HEADERS([strings.h libgen.h unistd.h direct.h sys/stat.h])

# REQUIRE standard C headers
if test "$ac_cv_header_stdc" != yes; then
	AC_MSG_ERROR([Standard (ANSI/ISO C89) header files are required.])
fi

#
# Checks for typedefs, structures, and compiler characteristics.
#
AC_C_CONST
AC_C_INLINE
AC_C_PROTOTYPES
AC_TYPE_SIZE_T
AX_CREATE_STDINT_H([libyasm-stdint.h])

#
# Checks for library functions.
#
AC_CHECK_FUNCS([abort toascii vsnprintf])
AC_CHECK_FUNCS([strsep mergesort getcwd])
AC_CHECK_FUNCS([popen ftruncate])
# Look for the case-insensitive comparison functions
AC_CHECK_FUNCS([strcasecmp strncasecmp stricmp _stricmp strcmpi])

#
# Check for gettext() and other i18n/l10n things.
#
ALL_LINGUAS=""
AM_GNU_GETTEXT([external])
# autoheader templates for AM_GNU_GETTEXT checks.
AH_TEMPLATE([ENABLE_NLS], [])
AH_TEMPLATE([HAVE_CATGETS], [])
AH_TEMPLATE([HAVE_GETTEXT], [])
AH_TEMPLATE([HAVE_LC_MESSAGES], [])
AH_TEMPLATE([HAVE_STPCPY], [])

# Check for GNU C Library
AH_TEMPLATE([HAVE_GNU_C_LIBRARY], [Define to 1 if you have the GNU C Library])
AC_CACHE_CHECK([for GNU C Library], yasm_cv_header_gnulib,
	AC_EGREP_CPP(gnulib,
	[#include <features.h>
	#ifdef __GNU_LIBRARY__
	  gnulib
	#endif
	], yasm_cv_header_gnulib=yes, yasm_cv_header_gnulib=no))
if test "$yasm_cv_header_gnulib" = yes; then
	AC_DEFINE([HAVE_GNU_C_LIBRARY])
fi

# Force x86 architecture only for now.
ARCH=x86
AC_SUBST([ARCH])
AC_SUBST([GCC])

# Require things for --enable-maintainer-mode option.
if test "$USE_MAINTAINER_MODE" = "yes"; then
  # Enable debugging
  if test "$debugging" != "no"; then
    debugging=yes
  fi

  # Enable more warnings
  if test "$GCC" = "yes"; then
    MORE_CFLAGS="$MORE_CFLAGS -W"
    MORE_CFLAGS="$MORE_CFLAGS -Waggregate-return"
    MORE_CFLAGS="$MORE_CFLAGS -Wbad-function-cast"
    MORE_CFLAGS="$MORE_CFLAGS -Wcast-align"
    MORE_CFLAGS="$MORE_CFLAGS -Wcast-qual"
    MORE_CFLAGS="$MORE_CFLAGS -Wchar-subscripts"
#    MORE_CFLAGS="$MORE_CFLAGS -Wconversion"
#    MORE_CFLAGS="$MORE_CFLAGS -Wdeclaration-after-statement"
#    MORE_CFLAGS="$MORE_CFLAGS -Wendif-labels"
    MORE_CFLAGS="$MORE_CFLAGS -Winline"
    MORE_CFLAGS="$MORE_CFLAGS -Wmissing-declarations"
    MORE_CFLAGS="$MORE_CFLAGS -Wmissing-prototypes"
    MORE_CFLAGS="$MORE_CFLAGS -Wnested-externs"
    MORE_CFLAGS="$MORE_CFLAGS -Wpointer-arith"
    MORE_CFLAGS="$MORE_CFLAGS -Wreturn-type"
    MORE_CFLAGS="$MORE_CFLAGS -Wshadow"
    MORE_CFLAGS="$MORE_CFLAGS -Wsign-compare"
    MORE_CFLAGS="$MORE_CFLAGS -Wstrict-prototypes"
    MORE_CFLAGS="$MORE_CFLAGS -Wswitch"
    MORE_CFLAGS="$MORE_CFLAGS -Wwrite-strings"
    MORE_CFLAGS="$MORE_CFLAGS -Wno-undef"
#    MORE_CFLAGS="$MORE_CFLAGS -Wno-unused"
    MORE_CFLAGS="$MORE_CFLAGS -Wno-unused-parameter"
  fi
fi

#
# Add some more CFLAGS for various options.
#

if test "$debugging" = "no" ; then
  changequote(,)
  CFLAGS="`echo $CFLAGS' ' | sed -e 's/-g[0-9] //g' | sed -e 's/-g//g'`"
  changequote([,])
fi

# Turn warnings into errors
if test "$warnerror" = "yes"; then
  if test "$GCC" = "yes"; then
    MORE_CFLAGS="$MORE_CFLAGS -Werror"
  fi
fi

# Enable output of profiling information
if test "$profiling" = "yes"; then
  if test "$GCC" = "yes"; then
    MORE_CFLAGS="$MORE_CFLAGS -pg"
  fi
fi

# Enable output of gcov information
if test "$gcov" = "yes"; then
  if test "$GCC" = "yes"; then
    MORE_CFLAGS="$MORE_CFLAGS -fprofile-arcs -ftest-coverage"
  fi
fi

# If we're using GCC, then we can turn on -ansi -pedantic -Wall too.
if test "$USE_MAINTAINER_MODE" = "yes"; then
  if test "$GCC" = yes; then
    MORE_CFLAGS="-ansi -pedantic -Wall $MORE_CFLAGS"
  fi
fi
AC_SUBST(MORE_CFLAGS)

AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
AC_ARG_VAR(CCLD_FOR_BUILD,[build system C linker frontend])
if test "${build}" != "${host}" ; then
  CC_FOR_BUILD=${CC_FOR_BUILD-cc}
  CCLD_FOR_BUILD=${CCLD_FOR_BUILD-cc}
else
  CC_FOR_BUILD="\$(CC)"
  CCLD_FOR_BUILD="\$(CC)"
fi
AC_SUBST(CC_FOR_BUILD)
AC_SUBST(CCLD_FOR_BUILD)

AC_ARG_VAR(CPP_FOR_HOST,[host system C preprocessor])
if test "$build" != "$target" || test "$build" != "$host"; then
  CPP_PROG="${CPP_FOR_HOST-cc -E}"
else
  CPP_PROG="${CPP}"
fi
AC_DEFINE_UNQUOTED([CPP_PROG], "${CPP_PROG}", [Command name to run C preprocessor])

# Detect if we have Python
if test x$enable_python = xno; then
    have_python=no
else
    AC_MSG_NOTICE([Checking for Python])
    have_python=no
    AM_PATH_PYTHON(2.4,[],[AC_MSG_WARN([Python not found])])

    if test -z "$PYTHON" || test "$PYTHON" = : ; then
        have_python=no
    else
        have_python=yes
    fi

    if test x$have_python = xno ; then
        if test x$enable_python = xyes ; then
            AC_MSG_ERROR([Python explicitly requested, but a suitable Python version was not found])
        else
            AC_MSG_WARN([Could not find a suitable version of Python])
        fi
    fi
fi

# Detect if we can build Python bindings
# (needs Python, Python headers, and Cython)
if test x$enable_python_bindings = xno; then
    have_python_bindings=no
else
    AC_MSG_NOTICE([Checking to see if we can build Python bindings])
    have_python_bindings=no
    if test x$have_python = xyes; then
        AC_MSG_CHECKING([for Cython >= 0.11.3])
        CYTHON_CHECK_VERSION(0.11.3, [AC_MSG_RESULT(yes)
                                      have_cython=yes],
                                     [AC_MSG_RESULT(no)
                                      have_cython=no])

        AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)

        if test x$have_cython = xyes -a x$have_python_headers = xyes ; then
            have_python_bindings=yes
        fi
    fi

    if test x$have_python_bindings = xno ; then
        if test x$enable_python_bindings = xyes ; then
            AC_MSG_ERROR([Building Python bindings explicitly requested, but can't build Python bindings because either Cython, Python headers or a suitable Python version was not found])
        else
            AC_MSG_WARN([Couldn't find either Cython, the Python headers or a suitable version of Python, not building Python bindings])
        fi
    fi
fi

AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes)
AM_CONDITIONAL(HAVE_PYTHON_BINDINGS, test x$have_python_bindings = xyes)

AC_CONFIG_FILES([Makefile
	po/Makefile.in
])
AC_OUTPUT