From 92e5026146483d8483e79400967b73ddabe361bf Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 14 Jun 2017 10:26:07 +0200 Subject: [PATCH] build: fix some cross-compilation issues Signed-off-by: David Lamparter --- configure.ac | 31 +++++++++++++++++++++++++++---- lib/command_parse.y | 2 ++ zebra/Makefile.am | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 65ba26d5f8..29bff56a5e 100755 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,28 @@ AC_DEFUN([AC_C_FLAG], [{ AC_LANG_POP(C) }]) +AC_DEFUN([AC_LINK_IFELSE_FLAGS], [{ + AC_LANG_PUSH(C) + ac_cflags_save="$CFLAGS" + ac_libs_save="$LIBS" + CFLAGS="$CFLAGS $1" + LIBS="$LIBS $2" + AC_LINK_IFELSE( + [$3], + [ + AC_MSG_RESULT([yes]) + CFLAGS="$ac_cflags_save" + LIBS="$ac_libs_save" + $5 + ], [ + AC_MSG_RESULT([no]) + CFLAGS="$ac_cflags_save" + LIBS="$ac_libs_save" + $4 + ]) + AC_LANG_POP(C) + }]) + dnl ICC won't bail on unknown options without -diag-error 10006 dnl need to do this first so we get useful results for the other options AC_C_FLAG([-diag-error 10006]) @@ -1430,7 +1452,9 @@ dnl ------------------ dnl check C-Ares library dnl ------------------ if test "${NHRPD}" != ""; then - PKG_CHECK_MODULES([CARES], [libcares]) + PKG_CHECK_MODULES([CARES], [libcares], , [ + AC_MSG_ERROR([trying to build nhrpd, but libcares not found. install c-ares and its -dev headers.]) + ]) fi @@ -1445,15 +1469,14 @@ if test "${enable_snmp}" != ""; then SNMP_LIBS="`${NETSNMP_CONFIG} --agent-libs`" SNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags`" AC_MSG_CHECKING([whether we can link to Net-SNMP]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([ + AC_LINK_IFELSE_FLAGS([$SNMP_CFLAGS], [$SNMP_LIBS], [AC_LANG_PROGRAM([ int main(void); ], [ { return 0; } -])],[AC_MSG_RESULT(yes)],[ - AC_MSG_RESULT(no) +])], [ AC_MSG_ERROR([--enable-snmp given but not usable])]) case "${enable_snmp}" in yes) diff --git a/lib/command_parse.y b/lib/command_parse.y index 466e3d3f1f..77e4e543aa 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -44,6 +44,8 @@ * struct parser_ctx is needed for the bison forward decls. */ %code requires { + #include "config.h" + #include #include #include diff --git a/zebra/Makefile.am b/zebra/Makefile.am index 3e0de3b463..45fc2680dc 100644 --- a/zebra/Makefile.am +++ b/zebra/Makefile.am @@ -76,10 +76,10 @@ zebra_fpm_la_SOURCES += zebra_fpm_netlink.c endif if HAVE_PROTOBUF zebra_fpm_la_SOURCES += zebra_fpm_protobuf.c -endif if DEV_BUILD zebra_fpm_la_SOURCES += zebra_fpm_dt.c endif +endif EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_netlink.c \ -- 2.39.5