-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathconfigure.ac
224 lines (165 loc) · 5.99 KB
/
configure.ac
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Needed for autoconf 2.64
#m4_pattern_allow([AC_CHECK_HEADER_STDBOOL])
AC_PREREQ([2.64])
AC_INIT([epiphany-libs: Epiphany Libraries], [0.1],
[https://github.com/adapteva/epiphany-sdk/issues], [epiphany-libs],
[https://github.com/adapteva/epiphany-libs])
AC_CONFIG_SRCDIR([README])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
# Support cross compilation
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# Don't use autoconf machinery for configuring e-lib target.
# See --with-target
# AC_CANONICAL_TARGET
# Initialize automake
AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror])
# Support silent build rules. Disable by either passing --disable-silent-rules
# to configure or passing V=1 to make.
AM_SILENT_RULES([yes])
# Checks for programs.
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC_C99
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# AC_PROG_RANLIB # No: is rendered obsolete by `LT_INIT'
AM_PROG_CC_C_O
AM_PROG_AR
AX_CXX_COMPILE_STDCXX_11
# Initialize libtool
LT_INIT
# Checks for libraries.
# (none needed)
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
AC_FUNC_ALLOCA
#AC_FUNC_MALLOC # Don't do it. Assume GNU libc compatible malloc.
AC_FUNC_MMAP
AC_CHECK_FUNCS([gettimeofday inet_ntoa memchr memmove memset munmap pow realpath socket strcasecmp strchr strerror strstr strtol strtoul])
AC_CONFIG_FILES([Makefile])
# Make it possible to disable components
# N.B: If e-hal is disabled, components that require it will also be disabled
# in Automake files.
AC_ARG_ENABLE([ehal],
AS_HELP_STRING([--disable-ehal],
[Disable building e-hal]))
AM_CONDITIONAL([ENABLE_EHAL],
[test "x$enable_ehal" != "xno"])
AC_ARG_ENABLE([elib],
AS_HELP_STRING([--disable-elib],
[Disable building e-lib]))
AM_CONDITIONAL([ENABLE_ELIB],
[test "x$enable_elib" != "xno"])
# Define the --enable-assert command-line option
AC_ARG_ENABLE(assert,
[AS_HELP_STRING([--enable-assert], [Build with assertions enabled])],
[enable_assert=yes], [enable_assert=no])
# Set any CPPFLAGS specific to debugging
AS_IF([test "x$enable_assert" = "xyes"],
[AC_SUBST(assert_CPPFLAGS, [''])],
[AC_SUBST(assert_CPPFLAGS, ['-DNDEBUG'])])
AC_ARG_WITH(target,
[AS_HELP_STRING([--with-target=ARCH],
[target architecture (used for e-lib)])],
[], [with_target="epiphany-elf"])
# Verify target
AS_CASE([$with_target],
[epiphany-elf], [],
[AC_MSG_ERROR(["Invalid target ${with_target}, must be epiphany-elf."])])
AC_ARG_WITH(target-prefix,
[AS_HELP_STRING([--with-target-prefix=PREFIX],
[install target files in PREFIX (e-lib)])],
[target_prefix="$withval"])
AC_ARG_WITH(bsps-dir,
[AS_HELP_STRING([--with-bsps-dir=DIR],
[install BSPs in DIR])],
[bspsdir="$withval"], [bspsdir='${datadir}/epiphany/bsps'])
AC_SUBST(BSPSDIR, [$bspsdir])
AC_SUBST(bspsdir, [$bspsdir])
AC_ARG_ENABLE(esim,
[AS_HELP_STRING([--enable-esim], [Enable building e-hal with ESIM target.])])
AS_IF([test "x$enable_esim" = xyes],
[AC_CHECK_HEADERS([esim.h], break;, enable_esim=no)])
AS_IF([test "x$enable_esim" = xyes],
[AC_CHECK_LIB(esim, es_init, break;, enable_esim=no)])
AM_CONDITIONAL(ENABLE_ESIM, [test "x$enable_esim" = xyes])
AC_ARG_ENABLE(pal-target,
[AS_HELP_STRING([--enable-pal-target],
[Enable building e-hal with PAL target.])])
AS_IF([test "x$enable_pal_target" = xyes],
[AC_CHECK_HEADERS([pal/pal.h], break;, enable_pal_target=no)])
AS_IF([test "x$enable_pal_target" = xyes],
[AC_CHECK_LIB(pal, p_init, break;, enable_pal_target=no)])
AM_CONDITIONAL(ENABLE_PAL_TARGET, [test "x$enable_pal_target" = xyes])
# Easiest way to include header files globally
AC_SUBST([AM_CPPFLAGS],
['-I$(top_srcdir) -I$(top_srcdir)/e-hal/src -I$(top_srcdir)/e-xml/src -I$(top_srcdir)/e-trace/include -I$(top_builddir) $(assert_CPPFLAGS)'])
AC_SUBST([AM_LDFLAGS])
# This is the messy part. We need to set the host to epiphany-elf and adjust
# the prefix for e-lib.
save_prefix=$prefix
save_exec_prefix=$exec_prefix
save_ac_configure_args=$ac_configure_args
save_CFLAGS=$CFLAGS
save_CPPFLAGS=$CPPFLAGS
save_CXXFLAGS=$CXXFLAGS
save_LDFLAGS=$LDFLAGS
host_ac_configure_args=$ac_configure_args
ac_configure_args=
CFLAGS=${CFLAGS_FOR_TARGET:-"-g -O2"}
CXXFLAGS=${CXXFLAGS_FOR_TARGET:-"-g -O2"}
CPPFLAGS=$CPPFLAGS_FOR_TARGET
LDFLAGS=$LDFLAGS_FOR_TARGET
# Whitelist arguments
for host_arg in $host_ac_configure_args
do
AS_CASE([$host_arg],
[*--enable-assert*], [ac_configure_args="$ac_configure_args $host_arg"],
[*--disable-assert*],[ac_configure_args="$ac_configure_args $host_arg"],
[])
done
# Insert target as host
ac_configure_args="--host=$with_target $ac_configure_args"
# Expand default prefix NOW.
test "x$prefix" = xNONE && host_prefix=$ac_default_prefix || host_prefix=$prefix
test "x$target_prefix" = x && target_prefix="${host_prefix}/${with_target}"
prefix=$target_prefix
exec_prefix=$prefix
# Insert target prefix
ac_configure_args="$ac_configure_args --prefix=${target_prefix}"
# Custom command that configures subdir NOW, so we can restore variables after.
AX_CONFIG_DIR([e-lib])
# Restore variables
prefix=$save_prefix
exec_prefix=$save_exec_prefix
ac_configure_args=$save_ac_configure_args
CFLAGS=$save_CFLAGS
CPPFLAGS=$save_CPPFLAGS
CXXFLAGS=$save_CXXFLAGS
LDFLAGS=$save_LDFLAGS
AC_SUBST(TARGET_PREFIX, [$target_prefix])
AC_SUBST(target_prefix, [$target_prefix])
AC_OUTPUT