VPPAPIGEN: Run tool directly from source tree.
[vpp.git] / src / configure.ac
1 AC_INIT([vpp], [18.04], [vpp-dev@fd.io])
2 LT_INIT
3 AC_CONFIG_AUX_DIR([.])
4 AM_INIT_AUTOMAKE([subdir-objects])
5 AM_SILENT_RULES([yes])
6 AC_CONFIG_FILES([Makefile plugins/Makefile vpp-api/python/Makefile vpp-api/java/Makefile vpp-api/vapi/Makefile vpp-api/vom/Makefile])
7 AC_CONFIG_MACRO_DIR([m4])
8
9 AC_PROG_CC
10 AC_PROG_CXX
11 AC_PROG_CPP
12 AM_PROG_AS
13 AM_PROG_LIBTOOL
14 AC_PROG_YACC
15 AM_PATH_PYTHON
16
17 AM_CONDITIONAL([CROSSCOMPILE], [test "$cross_compiling" == "yes"])
18
19 ###############################################################################
20 # Macros
21 ###############################################################################
22
23 AC_DEFUN([ENABLE_ARG],
24 [
25   AC_ARG_ENABLE($1,
26     AC_HELP_STRING(patsubst([--enable-$1],[_],[-]), $2),
27     [enable_$1=yes n_enable_$1=1],
28     [enable_$1=no n_enable_$1=0])
29   AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes")
30   m4_append([list_of_enabled], [$1], [, ])
31 ])
32
33 AC_DEFUN([DISABLE_ARG],
34 [
35   AC_ARG_ENABLE($1,
36     AC_HELP_STRING(patsubst([--disable-$1],[_],[-]), $2),
37     [enable_$1=no n_enable_$1=0],
38     [enable_$1=yes n_enable_$1=1])
39   AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes")
40   m4_append([list_of_enabled], [$1], [, ])
41 ])
42
43 AC_DEFUN([WITH_ARG],
44 [
45   AC_ARG_WITH($1,
46     AC_HELP_STRING(patsubst([--with-$1],[_],[-]), $2),
47     [with_$1=yes n_with_$1=1],
48     [with_$1=no n_with_$1=0])
49   AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes")
50   m4_append([list_of_with], [$1], [, ])
51 ])
52
53 AC_DEFUN([WITHOUT_ARG],
54 [
55   AC_ARG_WITH($1,
56     AC_HELP_STRING(patsubst([--without-$1],[_],[-]), $2),
57     [with_$1=no n_with_$1=0],
58     [with_$1=yes n_with_$1=1])
59   AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes")
60   m4_append([list_of_with], [$1], [, ])
61 ])
62
63 AC_DEFUN([PLUGIN_ENABLED],
64 [
65    AC_ARG_ENABLE($1_plugin,
66      AC_HELP_STRING([--disable-$1-plugin], [Do not build $1 plugin]),
67        [enable_$1_plugin=no],
68        [enable_$1_plugin=yes ])
69   AM_CONDITIONAL(m4_toupper(ENABLE_$1_PLUGIN), test "$enable_$1_plugin" = "yes")
70   m4_append([list_of_plugins], [$1], [, ])
71 ])
72
73 AC_DEFUN([PLUGIN_DISABLED],
74 [
75    AC_ARG_ENABLE($1_plugin,
76      AC_HELP_STRING([--enable-$1-plugin], [Build $1 plugin]),
77        [enable_$1_plugin=yes ],
78        [enable_$1_plugin=no])
79   AM_CONDITIONAL(m4_toupper(ENABLE_$1_PLUGIN), test "$enable_$1_plugin" = "yes")
80   m4_append([list_of_plugins], [$1], [, ])
81 ])
82
83 AC_DEFUN([PRINT_VAL], [ AC_MSG_RESULT(AC_HELP_STRING($1,$2)) ])
84
85 AC_DEFUN([DPDK_IS_PMD_ENABLED],
86 [
87   AC_MSG_CHECKING([for $1 in rte_config.h])
88   AC_COMPILE_IFELSE(
89     [AC_LANG_PROGRAM(
90       [[#include <rte_config.h>]],
91       [[return RTE_$1;]],
92     )],
93     [with_$2=yes]
94     [AC_MSG_RESULT([yes])],
95     [with_$2=no]
96     [AC_MSG_RESULT([no])]
97   )
98   AM_CONDITIONAL(m4_toupper(WITH_$2), test "$with_$2" = "yes")
99   m4_append_uniq([list_of_with], [$2], [, ])
100 ])
101
102 # Check if compiler supports specific flag
103 AC_DEFUN([CC_CHECK_FLAG],
104 [
105   AC_MSG_CHECKING([if $CC supports $1])
106   AC_LANG_PUSH([C])
107   ac_saved_cflags="$CFLAGS"
108   CFLAGS="-Werror $1"
109   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
110   [cc_flag_check=yes],
111   [cc_flag_check=no]
112 )
113   AC_MSG_RESULT([$cc_flag_check])
114   CFLAGS="$ac_saved_cflags"
115   AC_LANG_POP([C])
116 ])
117
118 ###############################################################################
119 # configure arguments
120 ###############################################################################
121
122 # --enable-X
123 ENABLE_ARG(tests,       [Enable unit tests])
124 ENABLE_ARG(dpdk_shared, [Enable unit tests])
125 ENABLE_ARG(perftool,    [Enable perftool])
126 ENABLE_ARG(g2,          [Enable g2])
127
128 # --disable-X
129 DISABLE_ARG(vlib,       [Disable vlib and dependant libs and binaries])
130 DISABLE_ARG(svm,        [Disable svm and dependant libs and binaries])
131 DISABLE_ARG(papi,       [Disable Python API bindings])
132 DISABLE_ARG(japi,       [Disable Java API bindings])
133 DISABLE_ARG(vom,        [Disable VPP object model bindings])
134
135 # --with-X
136
137 # --without-X
138 WITHOUT_ARG(libssl,     [Disable libssl])
139 WITHOUT_ARG(apicli,     [Disable binary api CLI])
140 WITHOUT_ARG(mbedtls,    [Disable mbedtls])
141
142 AC_ARG_WITH(unix,
143             AC_HELP_STRING([--with-unix],[Compile unix version of clib]),
144             [],
145             [case $host_os in
146               darwin* | linux*) with_unix=yes;;
147               *) with_unix=no;;
148               esac])
149
150 AM_CONDITIONAL(WITH_UNIX, test "$with_unix" = "yes")
151
152 AC_ARG_WITH(pre-data,
153             AC_HELP_STRING([--with-pre-data],[Set buffer rewrite space]),
154             [case $with_pre_data in
155                128) ;;
156                256) ;;
157                *) with_pre_data="pre-data-not-set" ;;
158              esac], [with_pre_data=128])
159
160 ###############################################################################
161 # Target CPU flags
162 ###############################################################################
163
164 # Check if compiler supports march=core-avx2
165 CC_CHECK_FLAG("-march=core-avx2")
166 AS_IF([test "$cc_flag_check" = yes],
167       [march_core_avx2=yes],
168       [march_core_avx2=no])
169 AM_CONDITIONAL([CC_SUPPORTS_AVX2], [test "$march_core_avx2" = "yes"])
170
171 # Check if compiler supports march=skylake-avx512
172 CC_CHECK_FLAG("-march=skylake-avx512")
173 AS_IF([test "$cc_flag_check" = yes],
174   [march_skylake_avx512=yes],
175   [march_skylake_avx512=no])
176 AM_CONDITIONAL([CC_SUPPORTS_AVX512], [test "$march_skylake_avx512" = "yes"])
177
178 AS_CASE([$build_cpu],
179         [x86_64], [CPU_FLAGS="-march=corei7 -mtune=corei7-avx"],
180         [aarch64], [CPU_FLAGS="-march=armv8-a+crc"],
181         [CPU_FLAGS=""],
182 )
183 AC_SUBST([CPU_FLAGS])
184
185 AC_SUBST([CPU_AVX2_FLAGS],"-march=core-avx2 -mtune=core-avx2")
186 AC_SUBST([CPU_AVX512_FLAGS],"-march=skylake-avx512 -mtune=skylake-avx512")
187
188 AM_CONDITIONAL([CPU_X86_64], [test "$build_cpu" = "x86_64"])
189 AM_CONDITIONAL([CPU_AARCH64], [test "$build_cpu" = "aarch64"])
190
191 ###############################################################################
192 # Substitutions and defines
193 ###############################################################################
194
195 AC_SUBST(PRE_DATA_SIZE,         [$with_pre_data])
196 AC_SUBST(APICLI,                [-DVPP_API_TEST_BUILTIN=${n_with_apicli}])
197
198 AC_DEFINE_UNQUOTED(DPDK_SHARED_LIB,     [${n_enable_dpdk_shared}])
199 AC_DEFINE_UNQUOTED(WITH_LIBSSL,         [${n_with_libssl}])
200 AC_DEFINE_UNQUOTED(WITH_MBEDTLS,        [${n_with_mbedtls}])
201
202
203 # Silence following noise:
204 # ar: `u' modifier ignored since `D' is the default (see `U')
205 AR_FLAGS=cr
206 AC_SUBST(AR_FLAGS)
207
208 ###############################################################################
209 # Plugins
210 ###############################################################################
211
212 # Please keep alphabetical order
213 PLUGIN_ENABLED(acl)
214 PLUGIN_ENABLED(dpdk)
215 PLUGIN_ENABLED(flowprobe)
216 PLUGIN_ENABLED(gbp)
217 PLUGIN_ENABLED(gtpu)
218 PLUGIN_ENABLED(ila)
219 PLUGIN_ENABLED(ioam)
220 PLUGIN_ENABLED(ixge)
221 PLUGIN_ENABLED(kubeproxy)
222 PLUGIN_ENABLED(l2e)
223 PLUGIN_ENABLED(lb)
224 PLUGIN_ENABLED(marvell)
225 PLUGIN_ENABLED(memif)
226 PLUGIN_ENABLED(pppoe)
227 PLUGIN_ENABLED(nat)
228 PLUGIN_ENABLED(sixrd)
229 PLUGIN_ENABLED(srv6ad)
230 PLUGIN_ENABLED(srv6am)
231 PLUGIN_ENABLED(srv6as)
232 PLUGIN_ENABLED(stn)
233
234 ###############################################################################
235 # Dependency checks
236 ###############################################################################
237 AC_CHECK_FUNC([memfd_create], [AC_DEFINE([HAVE_MEMFD_CREATE], [1], [Define if memfd exists])])
238
239 AM_COND_IF([ENABLE_DPDK_SHARED],
240 [
241   AC_CHECK_HEADERS([rte_config.h],
242     [],
243     [AC_MSG_ERROR([DPDK header files not found])],)
244   AC_CHECK_LIB( [dpdk], [rte_eal_init],
245     [],
246     [AC_MSG_ERROR([DPDK shared library not found])],)
247 ])
248
249 with_aesni_mb_lib=no
250 with_isa_l_crypto_lib=no
251
252 DPDK_IS_PMD_ENABLED(LIBRTE_PMD_AESNI_MB, dpdk_aesni_mb_pmd)
253 DPDK_IS_PMD_ENABLED(LIBRTE_PMD_AESNI_GCM, dpdk_aesni_gcm_pmd)
254
255 AM_COND_IF([WITH_DPDK_AESNI_MB_PMD],
256 [
257   AC_CHECK_LIB([IPSec_MB], [submit_job_sse],
258                [with_aesni_mb_lib=yes],
259                [AC_MSG_ERROR([IPSec_MB library not found])])
260 ])
261
262 AM_COND_IF([WITH_DPDK_AESNI_GCM_PMD],
263 [
264   AC_CHECK_LIB([IPSec_MB], [submit_job_sse],
265     [with_aesni_mb_lib=yes],
266     [AC_MSG_ERROR([IPSec_MB library not found])])
267 ])
268
269 m4_append([list_of_with], [aesni_mb_lib], [, ])
270 AM_CONDITIONAL(WITH_AESNI_MB_LIB, test "$with_aesni_mb_lib" = "yes")
271
272 m4_append([list_of_with], [isa_l_crypto_lib], [, ])
273 AM_CONDITIONAL(WITH_ISA_L_CRYPTO_LIB, test "$with_isa_l_crypto_lib" = "yes")
274
275 AM_COND_IF([ENABLE_G2],
276 [
277   PKG_CHECK_MODULES(g2, gtk+-2.0)
278 ])
279
280 AM_COND_IF([ENABLE_MARVELL_PLUGIN],
281 [
282   AC_CHECK_LIB( [musdk], [pp2_init],
283     [],
284     [
285       AC_MSG_WARN([Marvell MUSDK library with PP2 support not found. Plugin disabled.])
286       enable_marvell_plugin=no
287       AM_CONDITIONAL(ENABLE_MARVELL_PLUGIN, false)
288     ])
289 ])
290
291 AM_COND_IF([WITH_MBEDTLS],
292 [
293   AC_CHECK_HEADERS([mbedtls/ssl.h], [],
294     [
295       AC_MSG_WARN([mbedtls headers not found. TLS app disabled])
296       AM_CONDITIONAL(WITH_MBEDTLS, false)
297     ], [])
298 ])
299
300 ###############################################################################
301 # JAVA
302 ###############################################################################
303
304 AM_COND_IF([ENABLE_JAPI],
305 [
306   AX_VPP_FIND_JDK8
307   AC_SUBST(JAVA_HOME)
308   AC_SUBST(JAVAC)
309   AC_SUBST(JAVAH)
310   AC_SUBST(JAR)
311 ])
312
313 ###############################################################################
314 # PYTHON
315 ###############################################################################
316
317 AM_COND_IF([ENABLE_PAPI],
318 [
319   AM_PATH_PYTHON
320 ])
321
322 ###############################################################################
323 # Output
324 ###############################################################################
325
326 AC_OUTPUT
327
328 AC_MSG_RESULT([==============================================================================])
329 PRINT_VAL([version], $PACKAGE $VERSION)
330 PRINT_VAL([prefix], ${prefix})
331 PRINT_VAL([libdir], ${libdir})
332 PRINT_VAL([includedir], ${includedir})
333 PRINT_VAL([CFLAGS], ${CFLAGS})
334 PRINT_VAL([CPPFLAGS], ${CPPFLAGS})
335 PRINT_VAL([LDFLAGS], ${LDFLAGS})
336 AM_COND_IF([ENABLE_JAPI],
337 [
338   PRINT_VAL([JAVA_VERSION], ${JAVA_VERSION})
339   PRINT_VAL([JAVA_HOME], ${JAVA_HOME})
340 ])
341
342 AC_MSG_RESULT([])
343 AC_MSG_RESULT([with:])
344 m4_foreach([x], m4_dquote(list_of_with), [
345   AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${with_], x, [}])))
346 ])
347
348 AC_MSG_RESULT([])
349 AC_MSG_RESULT([enabled:])
350 m4_foreach([x], m4_dquote(list_of_enabled), [
351   AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${enable_], x, [}])))
352 ])
353
354 AC_MSG_RESULT([])
355 AC_MSG_RESULT([plugins:])
356 m4_foreach([x], m4_dquote(list_of_plugins), [
357   AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${enable_], x, [_plugin}])))
358 ])
359 AC_MSG_RESULT([==============================================================================])
360
361