summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 8981e10eaca68467db1c9c8cdc55a3c35c31d241 (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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# Configure template for GNU m4.           -*-Autoconf-*-
# Copyright (C) 1991-1994, 2000-2002, 2004-2014 Free Software
# Foundation, Inc.
#
# This file is part of GNU M4.
#
# GNU M4 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNU M4 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

dnl We depend on autotest's ./testsuite -C.
AC_PREREQ([2.62])

## ------------------------ ##
## Autoconf initialization. ##
## ------------------------ ##
m4_define([M4_VERSION],
          m4_esyscmd([build-aux/git-version-gen .tarball-version]))
m4_bmatch(m4_defn([M4_VERSION]), [^[0-9]], [],
          [m4_define([M4_VERSION], [1.9a])])
AC_INIT([GNU M4], m4_defn([M4_VERSION]), [bug-m4@gnu.org])

AC_CONFIG_SRCDIR([src/m4.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
AC_CONFIG_LIBOBJ_DIR([m4/gnu])
AC_CONFIG_TESTDIR([tests])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([tests/m4], [chmod +x tests/m4])


## -------------------------- ##
## M4 specific configuration. ##
## -------------------------- ##
dnl Autoconf recommends that packages use lowercase for their package-specific
dnl prefix for cache variables.  But in the case of m4, that collides with
dnl the m4_ namespace provided by m4sugar, so we prefer M4_ as our
dnl package-specific prefix.
m4_pattern_forbid([^M4_[A-Z]])

AC_DEFUN([M4_DEFAULT_PRELOAD], [])
M4_default_preload="M4_DEFAULT_PRELOAD"


## ------------------------ ##
## Automake Initialization. ##
## ------------------------ ##
AM_INIT_AUTOMAKE([1.10b subdir-objects dist-bzip2 dist-xz
color-tests parallel-tests silent-rules]
m4_if(m4_index(m4_defn([M4_VERSION]), [-]), [-1], [gnits], [gnu]))
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])


## ------------------ ##
## C compiler checks. ##
## ------------------ ##
AC_PROG_CC
AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO])
M4_EARLY

# Maintainer note - comment this line out if you plan to rerun
# GNULIB_POSIXCHECK testing to see if M4 should be using more modules.
# Leave it uncommented for normal releases, for faster ./configure.
gl_ASSERT_NO_GNULIB_POSIXCHECK

AC_SYS_LARGEFILE
AC_PROG_CPP
AM_PROG_CC_C_O
M4_CHECK_DEBUGGING


## --------------------------- ##
## C compiler characteristics. ##
## --------------------------- ##
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF([long long int])

AS_CASE([$host], [*-*-os2*], [OS2_LDFLAGS=-Zargs-resp])
AC_SUBST([OS2_LDFLAGS])


## ----------------------- ##
## Libtool initialization. ##
## ----------------------- ##
LT_PREREQ([2.2])
LT_INIT([shared dlopen win32-dll])

AC_ARG_ENABLE([gcc-warnings],
  [AS_HELP_STRING([--enable-gcc-warnings],
                  [turn on lots of GCC warnings (for developers)])],
  [case $enableval in
     yes|no) ;;
     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
   esac
   gl_gcc_warnings=$enableval],
  [gl_gcc_warnings=no]
)

if test "$gl_gcc_warnings" = yes; then
  gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
  AC_SUBST([WERROR_CFLAGS])

  # This, $nw, is the list of warnings we disable.
  nw=
  nw="$nw -Waggregate-return"       # K&R is anachronistic
  nw="$nw -Wtraditional-conversion" # K&R is anachronistic
  nw="$nw -Wundef"                  # K&R is anachronistic
  nw="$nw -Wlong-long"              # C90 is anachronistic
  nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
  nw="$nw -Wpadded"                 # Our structs are not packed
  nw="$nw -Wformat-nonliteral"      # Needed in builtin.c
  nw="$nw -Wconversion"             # Too many warnings for now
  nw="$nw -Wsign-conversion"        # Too many warnings for now
  nw="$nw -Wcast-qual"              # Too many warnings for now
  nw="$nw -Wswitch-enum"            # Too many warnings for now
  # gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
  nw="$nw -Wenum-compare"

  # Gnulib uses '#pragma GCC diagnostic push' to silence some
  # warnings, but older gcc doesn't support this.
  AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
    [M4_cv_gcc_pragma_push_works], [
    save_CFLAGS=$CFLAGS
    CFLAGS='-Wunknown-pragmas -Werror'
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #pragma GCC diagnostic push
      #pragma GCC diagnostic pop
    ]])],
    [M4_cv_gcc_pragma_push_works=yes],
    [M4_cv_gcc_pragma_push_works=no])
    CFLAGS=$save_CFLAGS])
  if test $M4_cv_gcc_pragma_push_works = no; then
    nw="$nw -Wmissing-prototypes"
    nw="$nw -Wmissing-declarations"
    nw="$nw -Wunreachable-code"
  fi

  gl_MANYWARN_ALL_GCC([ws])
  gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
  for w in $ws; do
    gl_WARN_ADD([$w])
  done

  gl_WARN_ADD([-fdiagnostics-show-option])
  gl_WARN_ADD([-funit-at-a-time])

  AC_SUBST([WARN_CFLAGS])

  AH_VERBATIM([FORTIFY_SOURCE],
  [/* Enable compile-time and run-time bounds-checking, and some warnings,
      without upsetting newer glibc. */
   #if defined __OPTIMIZE__ && __OPTIMIZE__
   # define _FORTIFY_SOURCE 2
   #endif
  ])
fi

# Use gcc's -pipe option if available: for faster compilation.
case "$CFLAGS" in
  *-pipe* ) ;;
        * ) _LT_COMPILER_OPTION([if $compiler supports -pipe],
                [M4_cv_prog_compiler_pipe],
                [-pipe -c conftest.$ac_ext], [],
                [CFLAGS="$CFLAGS -pipe"])
              ;;
esac


## ------------------------------- ##
## Dynamic Loader Characteristics. ##
## ------------------------------- ##

LT_LIB_DLLOAD
LT_SYS_SYMBOL_USCORE

if test yes = "$sys_symbol_underscore"; then
  AC_MSG_CHECKING([whether dlsym requires underscore prefixed symbols])
  AC_CACHE_VAL([mfour_cv_sys_dlsym_uscore], [dnl
    # Use Libtool to make a loadable module
    cat >conftest_loadme.$ac_ext <<_M4_EOF
[#line $LINENO "configure"
#include "confdefs.h"
/* When -fvisibility=hidden is used, assume the code has been annotated
   correspondingly for the symbols needed.  */
#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
int fnord () __attribute__((visibility("default")));
#endif
int fnord () { return 42; }]
_M4_EOF
    save_module=$module; module=yes
    mfour_shrext=`eval printf '%s' \"$shrext_cmds\"`
    module=$save_module

    libobjs=conftest_loadme.$ac_objext; lib=conftest_loadme$mfour_shrext
    save_module_cmds=$module_cmds; module_cmds=`eval echo $module_cmds`
    test -n "$module_cmds" || module_cmds=`eval echo $archive_cmds`
    $CC $pic_flag -c conftest_loadme.$ac_ext
    eval "wl=\"$lt_prog_compiler_wl\"; major=; versuffix=; verstring=; deplibs=; \
	  rpath=/not-exists/conftest_loadme$mfour_shrext; $module_cmds"
    module_cmds=$save_module_cmds

    # Try to fetch fnord with dlsym().
    mfour_dlunknown=0; mfour_dlnouscore=1; mfour_dluscore=2
    cat >conftest.$ac_ext <<_M4_EOF
[#line $LINENO "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#include <stdio.h>
#ifndef RTLD_GLOBAL
#  ifdef DL_GLOBAL
#    define RTLD_GLOBAL DL_GLOBAL
#  else
#    define RTLD_GLOBAL 0
#  endif
#endif
#ifndef RTLD_NOW
#  ifdef DL_NOW
#    define RTLD_NOW DL_NOW
#  else
#    define RTLD_NOW 0
#  endif
#endif
int main () {
  void *handle = dlopen ("`pwd`/$objdir/conftest_loadme$mfour_shrext", RTLD_GLOBAL|RTLD_NOW);
  int status = $mfour_dlunknown;
  if (handle) {
    if (dlsym (handle, "fnord"))
      status = $mfour_dlnouscore;
    else {
      if (dlsym (handle, "_fnord"))
        status = $mfour_dluscore;
      else
	puts (dlerror ());
    }
    dlclose (handle);
  } else
    puts (dlerror ());
  return status;
}]
_M4_EOF
    if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
      (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
      mfour_status=$?
      case x$mfour_status in
        x$mfour_dlnouscore) mfour_cv_sys_dlsym_uscore=no ;;
	x$mfour_dluscore) mfour_cv_sys_dlsym_uscore=yes ;;
	x*) mfour_cv_sys_dlsym_uscore=unknown ;;
      esac
    fi
    rm -rf conftest*
  ])
  sys_dlsym_uscore=$mfour_cv_sys_dlsym_uscore
  AC_MSG_RESULT($sys_dlsym_uscore)
  if test yes = "$sys_dlsym_uscore"; then
    AC_DEFINE([DLSYM_USCORE], [1],
      [Define if dlsym() requires a leading underscore in symbol names.])
  fi
fi

AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['$PATH_SEPARATOR'],
		   [Define this to system search path delimiter])


## ------------------------------- ##
## Preloaded module configuration. ##
## ------------------------------- ##
AS_IF([test "x$enable_shared" != xno],
      [DYNAMIC_MODULES=yes], [DYNAMIC_MODULES=no])
AC_SUBST([DYNAMIC_MODULES], [$DYNAMIC_MODULES])

AC_MSG_CHECKING([for modules to preload])
  DLPREOPEN=

  AC_ARG_WITH([modules],
    [AS_HELP_STRING([--with-modules=MODULES],
                    [preload MODULES @<:@default: ]M4_DEFAULT_PRELOAD[@:>@])],
    [use_modules="$withval"],
    [use_modules="$M4_default_preload"])

  PREOPEN_DEPENDENCIES=
  DLPREOPEN="-dlpreopen force"
  if test -z "$use_modules"; then
    use_modules=none
  else
    if test "$use_modules" != yes; then
      for module in $use_modules; do
        case $module in
          no|none) break ;;
          m4|traditional|gnu|load|mpeval) dir=modules ;;
          import|modtest|shadow|stdlib|time) dir=tests ;;
          *) AC_MSG_ERROR([Unrecognized module `$module' in --with-modules])
            ;;
        esac
        DLPREOPEN="$DLPREOPEN -dlpreopen $dir/$module.la"
        PREOPEN_DEPENDENCIES="$PREOPEN_DEPENDENCIES $dir/$module.la"
      done
    fi
  fi
AC_MSG_RESULT([$use_modules])
AC_SUBST([DLPREOPEN])
AC_SUBST([PREOPEN_DEPENDENCIES])


## ---------------- ##
## Gettext support. ##
## ---------------- ##
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_NEED([need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.16])
M4_GNU_GETTEXT


## --------------- ##
## Gnulib support. ##
## --------------- ##
M4_INIT

gl_VERSION_ETC

# Gnulib doesn't always do things quite the way M4 would like...
M4_ERROR
M4_GETOPT
M4_OBSTACK
M4_REGEX
M4_RENAME


## ------------------------- ##
## C headers required by M4. ##
## ------------------------- ##
AC_CHECK_HEADERS_ONCE([limits.h])

if test $ac_cv_header_stdbool_h = yes; then
  INCLUDE_STDBOOL_H='#include <stdbool.h>'
else
  INCLUDE_STDBOOL_H='#include <gnu/stdbool.h>'
fi
AC_SUBST([INCLUDE_STDBOOL_H])


## --------------------------------- ##
## Library functions required by M4. ##
## --------------------------------- ##
AC_CHECK_FUNCS_ONCE([calloc strerror])

AM_WITH_DMALLOC

M4_SYS_STACKOVF

# This is for the modules
AC_STRUCT_TM
AC_FUNC_STRFTIME
AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])


## ------------------ ##
## Configure options. ##
## ------------------ ##

M4_LIB_GMP
AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
M4_SYSCMD


## -------- ##
## Outputs. ##
## -------- ##
AC_CONFIG_FILES([
Makefile
doc/Makefile
m4/gnu/Makefile
m4/system.h:m4/system_.h
tests/atlocal
tests/gnu/Makefile
])

AC_OUTPUT