summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 97d7607863d0705cf22c8a06df2e3ed7fd6e441e (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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])

# FIXME Temporary hack until the next release (we'll switch to plain numeric tags then)
# TBD need to quote sed expression
AC_INIT(
    [crosstool-NG],
    [m4_esyscmd_s([git describe --always --dirty])],
    [crossgcc@sourceware.org],
    [crosstool-ng],
    [http://crosstool-ng.org])
AC_CONFIG_AUX_DIR([scripts])
AC_CONFIG_MACRO_DIR([m4])

# Check if install(1) supports --strip-program=...
AC_DEFUN(
    [ACX_INSTALL_STRIP_PROGRAM],
    [touch conftest
     mkdir conftest.dir
     AC_MSG_CHECKING([if install takes --strip-program option])
     AS_IF([$INSTALL --strip-program=true -s conftest conftest.dir/conftest 2>/dev/null],
        [install_with_strip_program=y
         AC_MSG_RESULT([yes])],
        [AC_MSG_RESULT([no])])
     ACX_SET_KCONFIG_OPTION([install_with_strip_program])
     rm -rf conftest.dir
     rm -f conftest
    ])
     

#--------------------------------------------------------------------
# Allow dummy --{en,dis}able-{static,shared}
AC_ARG_ENABLE(
    [local],
    [AS_HELP_STRING(
        [--enable-local],
        [do not install, and use current directory])])
AC_SUBST([enable_local], [${enable_local:-no}])

# FIXME: I don't know why we have this. Will remove after the 1.24 release.
AC_ARG_ENABLE(
    [shared],
    [AS_HELP_STRING(
        [--enable-shared],
        [build shared libraries (deprecated, ignored)])])
AC_ARG_ENABLE(
    [static],
    [AS_HELP_STRING(
        [--enable-static],
        [build static libraries (deprecated, ignored)])])

# Check for --build and --host...
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# ... but refuse --target
AS_IF([test -n "$target_alias"],
      AC_MSG_ERROR([--target is not allowed]))

# Allow program name tranformation (--program-{prefix,suffix,transform-name})
AC_ARG_PROGRAM

AC_PROG_MKDIR_P

CTNG_WITH_DEPRECATED([install], [INSTALL])
AC_ARG_VAR([INSTALL], [Specify the full path to a BSD-compatible install])
AC_PROG_INSTALL
ACX_INSTALL_STRIP_PROGRAM

CTNG_WITH_DEPRECATED([grep], [GREP])
AC_ARG_VAR([GREP], [Specify the full path to GNU grep])

# This is not a typo! Prefer GNU grep on macOS if it is installed.
CTNG_PATH_TOOL_REQ([GREP], [ggrep grep], [grep])
CTNG_PATH_TOOL_REQ([EGREP], [gegrep egrep], [egrep])
AC_PROG_GREP
AC_PROG_EGREP

# FIXME: ct-ng assumes this in many places...
AS_IF([test "$EGREP" != "$GREP -E"],
    [AC_MSG_ERROR([egrep is not $GREP -E])])

CTNG_PROG_VERSION_REQ_STRICT([SED],
    [GNU sed >= 4.0],
    [sed],
    [gsed sed],
    ['GNU sed[^0-9]* [4-9]\.'])
AC_ARG_VAR([SED], [Specify the full path to GNU sed])

AC_PROG_LN_S

#--------------------------------------------------------------------
# A bunch of boring tests...
#--------------------------------------------------------------------
# Modern GCC/GDB releases require C++ support in the compiler
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LEX
AC_PROG_YACC
AS_IF([test -z "$CC" -o -z "$CXX"],
      [AC_MSG_ERROR([no suitable compiler found])])

#---------------------------------------------------------------------
# Check to see if the compiler can link statically
AC_MSG_CHECKING([if $CC can static link])
echo "int main() {}" | ${CC} -static -o /dev/null -xc - > /dev/null 2>&1
static_test=$?
AS_IF([test $static_test -eq 0],
          [static_link=y
           AC_MSG_RESULT([yes])],
      [test $static_test -ne 0],
          [static_link=
           AC_MSG_RESULT([no])])
CTNG_SET_KCONFIG_OPTION([static_link])

AC_PROG_RANLIB
CTNG_PATH_TOOL_REQ([OBJCOPY], [gobjcopy objcopy], [objcopy])
CTNG_PATH_TOOL_REQ([OBJDUMP], [gobjdump objdump], [objdump])
CTNG_PATH_TOOL_REQ([READELF], [greadelf readelf], [readelf])
CTNG_PATH_TOOL_REQ([GPERF], [gperf], [gperf])

CTNG_CHECK_PROGS_REQ([bison], [bison])
CTNG_CHECK_PROGS_REQ([flex], [flex])
CTNG_CHECK_PROGS_REQ([makeinfo], [makeinfo])
CTNG_CHECK_PROGS_REQ([cut], [cut])
CTNG_CHECK_PROGS_REQ([readlink], [readlink])
CTNG_CHECK_PROGS_REQ([tar], [tar])
CTNG_CHECK_PROGS_REQ([gzip], [gzip])
CTNG_CHECK_PROGS_REQ([bzip2], [bzip2])
CTNG_CHECK_PROGS_REQ([xz], [xz])
CTNG_CHECK_PROGS_REQ([help2man], [help2man])

# Not a fatal failure even if we have neither - the tarballs may
# be provided in a local directory.
AC_CHECK_PROGS([wget], [wget])
CTNG_SET_KCONFIG_OPTION([wget])
AC_SUBST([wget])

AC_CHECK_PROGS([curl], [curl])
CTNG_SET_KCONFIG_OPTION([curl])
AC_SUBST([curl])

# TBD move the checks/setting kconfig into [IF-BSD] and [IF-GNU] arguments to CTNG_PROG_STAT
# TBD modify CTNG_SET_KCONFIG_OPTION to take an optional argument to which it should be set
CTNG_PROG_STAT
# FIXME: support SET_KCONFIG_OPTION with string values? But then
# again, these checks may be moved into ct-ng script.
test "$acx_cv_stat_flavor" = "BSD" && stat_flavor_BSD=y
CTNG_SET_KCONFIG_OPTION([stat_flavor_BSD])
test "$acx_cv_stat_flavor" = "GNU" && stat_flavor_GNU=y
CTNG_SET_KCONFIG_OPTION([stat_flavor_GNU])

CTNG_CPU_COUNT

CTNG_PATH_TOOL_REQ([PATCH], [gpatch patch], [patch])

# We need a bash that is >= 3.1
CTNG_PROG_VERSION_REQ_STRICT([BASH_SHELL],
    [GNU bash >= 3.1],
    [bash],
    [bash],
    ['^GNU bash, version (3\.[1-9]|4)'])

# We need a awk that *is* GNU awk
CTNG_PROG_VERSION_REQ_STRICT([AWK],
    [GNU awk],
    [awk],
    [gawk awk],
    ['^GNU Awk '])

# FIXME This checks for tools at the time configure runs. If a tool is later updated
# to satisfy our version requirement, we still won't be able to see that. Or worse,
# downgraded/removed. We should check this and update configure.in options right
# before running kconfig. Our configure should only check for stuff needed to
# build/install crosstool-ng itself.
#----------------------------------------
# Check for GNU make (want 3.81 or above, but will accept as long as any make is found)
CTNG_PROG_VERSION_REQ_ANY([MAKE],
    [GNU make >= 3.81],
    [make],
    [gmake make],
    ['^GNU Make (3\.8[1-9]|3\.9[0-9]|[4-9]\.)'],
    [make_3_81_or_newer])

# Check other companion tools that we may or may not build
CTNG_PROG_VERSION([LIBTOOL],
    [GNU libtool >= 2.4],
    [libtool],
    [glibtool libtool],
    ['\(GNU libtool\) ([3-9]\.|2.[4-9]|2.[1-3][0-9])'],
    [libtool_2_4_or_newer])

CTNG_PROG_VERSION([LIBTOOLIZE],
    [GNU libtoolize >= 2.4],
    [libtoolize],
    [glibtoolize libtoolize],
    ['\(GNU libtool\) ([3-9]\.|2.[4-9]|2.[1-3][0-9])'],
    [libtoolize_2_4_or_newer])

CTNG_PROG_VERSION([AUTOCONF],
    [GNU autoconf >= 2.65],
    [autoconf],
    [autoconf],
    ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[5-9])'],
    [autoconf_2_63_or_newer])

CTNG_PROG_VERSION([AUTORECONF],
    [GNU autoreconf >= 2.63],
    [autoreconf],
    [autoreconf],
    ['\(GNU Autoconf\) ([3-9]\.|2\.[7-9][0-9]|2\.6[3-9])'],
    [autoreconf_2_63_or_newer])

CTNG_PROG_VERSION([AUTOMAKE],
    [GNU automake >= 1.15],
    [automake],
    [automake],
    ['\(GNU automake\) ([2-9]\.|1\.[2-9][0-9]|1\.1[5-9])'],
    [automake_1_15_or_newer])

CTNG_PROG_VERSION([M4],
    [GNU m4 >= 1.4.12],
    [m4],
    [gm4 m4],
    ['\(GNU M4\) ([2-9]\.|1\.[5-9]|1\.[1-4][0-9]|1\.4\.[2-9][0-9]|1\.4\.1[2-9])'],
    [gnu_m4_1_4_12_or_newer])

CTNG_PROG_GPERF

AC_SUBST([kconfig_options])

AC_CHECK_PROGS([cvs], [cvs])
CTNG_SET_KCONFIG_OPTION([cvs])

AC_CHECK_PROGS([svn], [svn])
CTNG_SET_KCONFIG_OPTION([svn])

AC_CHECK_PROGS([git], [git])
CTNG_SET_KCONFIG_OPTION([git])

AC_CHECK_PROGS([DPKG_BUILDFLAGS], [dpkg-buildflags])

# FIXME why checking if not using the result? We don't provide replacemant malloc/alloca/...
AC_C_INLINE
AC_HEADER_STDC
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_ALLOCA

#----------------------------------------
# Check for gettext and libintl for the kconfig frontends
AC_SUBST([gettext])
AC_CHECK_HEADERS(
    [libintl.h],
    [ac_ct_gettext_hdr=$ac_header; break])
AS_IF(
    [test -n "$ac_ct_gettext_hdr"],
    [AC_CHECK_DECL(
        [gettext],
        [gettext=y],,
        [AC_INCLUDES_DEFAULT()
         #include <$ac_ct_gettext_hdr>])])
SAVE_LIBS=$LIBS
AC_SEARCH_LIBS(bindtextdomain, intl, [test "$ac_res" = "none required" || INTL_LIBS="${ac_res}"])
LIBS=$SAVE_LIBS
AC_SUBST([INTL_LIBS])

# Check for ncurses, for the kconfig frontends
AC_SUBST([ac_ct_curses_hdr])
AC_CHECK_HEADERS(
    [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
    [ac_ct_curses_hdr=$ac_header; break])
AS_IF(
    [test -z "$ac_ct_curses_hdr"],
    [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])])
AC_SEARCH_LIBS(
    [initscr],
    [ncursesw ncurses curses],
    [ac_ct_curses_lib_found=yes; break])
AS_IF(
    [test -z "$ac_ct_curses_lib_found"],
    [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])])
AC_SEARCH_LIBS(
    [tgetent],
    [termcap tinfo ncursesw ncurses curses])

# Hey! We need the date! :-)
DATE_FMT="%Y%m%d"
if test "x$SOURCE_DATE_EPOCH" = "x"; then
    DATE=$(date "+$DATE_FMT")
else
    DATE="$(date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || date -u "+$DATE_FMT")"
fi
AC_SUBST([DATE])

# Decorate the version string per user-supplied version.sh, if any
AS_IF(
    [test -f version.sh -a -x version.sh],
    [PACKAGE_VERSION=$(./version.sh "${PACKAGE_VERSION}")])

# Handle the local case
AC_SUBST([sublibdir])
AC_SUBST([subdocdir])
AS_IF(
    [test "x$enable_local" = "xyes"],
    [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set])
     prefix=$(pwd)
     exec_prefix="$prefix"
     bindir="$prefix"
     libdir="$prefix"
     sublibdir=""
     docdir="$prefix""/docs"
     subdocdir=""
     datarootdir="$prefix"
     mandir="$docdir"],
    [sublibdir="/\${VERSION}"
     subdocdir="/\${VERSION}"])

AC_CONFIG_FILES([
    Makefile
    kconfig/Makefile
    config/configure.in
])

AC_OUTPUT