Skip to content

Commit

Permalink
Merge pull request #418 from kernelkit/kkit
Browse files Browse the repository at this point in the history
Misc. build fixes encountered when cross-compiling
  • Loading branch information
olofhagsand authored Feb 17, 2023
2 parents 204c704 + 058d3f7 commit ecd60fb
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
# 1) checkout and compile natively
- name: install cligen
run: (git clone https://github.com/clicon/cligen.git && cd cligen && ./configure && make && sudo make install)
- name: install ssl and nghttp2
run: sudo apt install -y libssl-dev libnghttp2-dev
- name: install dependencies
run: sudo apt install -y libssl-dev libnghttp2-dev curl-dev
- name: configure
run: ./configure
# 2) Use docker for tests
- name: make test # this is docker test
run: make test
run: make test
3 changes: 3 additions & 0 deletions apps/restconf/restconf_main_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ restconf_accept_client(int fd,
addr = &(in6->sin6_addr);
break;
}
default:
errno = EAFNOSUPPORT;
goto done;
}
if (rsock->rs_from_addr != NULL){
free(rsock->rs_from_addr);
Expand Down
92 changes: 67 additions & 25 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -633,16 +633,21 @@ ac_ct_CXX
CXXFLAGS
CXX
CPP
LOCALSTATEDIR
LIBDIR
SYSCONFDIR
MIB_GENERATED_YANG_DIR
YANG_STANDARD_DIR
YANG_INSTALLDIR
CLIXON_YANG_SCHEMA_MOUNT
CLIXON_YANG_PATCH
LIBXML2_CFLAGS
with_libxml2
HAVE_HTTP1
HAVE_LIBNGHTTP2
enable_netsnmp
with_restconf
with_libcurl
LINKAGE
LIBSTATIC_SUFFIX
SH_SUFFIX
Expand Down Expand Up @@ -723,6 +728,7 @@ enable_debug
with_cligen
enable_yang_patch
enable_yang_schema_mount
with_libcurl
enable_publish
with_restconf
enable_http1
Expand Down Expand Up @@ -1390,6 +1396,8 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-cligen=dir Use CLIGEN installation in this dir
--without-libcurl Disable use of libcurl, affects publish
notification, including clixon_util_stream
--with-restconf=native Integration with embedded web server (DEFAULT)
--with-restconf=fcgi FCGI interface for stand-alone web rev-proxy eg
nginx
Expand All @@ -1398,7 +1406,8 @@ Optional Packages:
Directory of generated YANG specs (default:
$prefix/share/mib-yangs)
--with-configfile=FILE Set default path to config file
--with-libxml2 Use gnome/libxml2 regex engine
--with-libxml2[=/path/to/xml2-config]
Use libxml2 regex engine
--without-sigaction Don't use sigaction
--with-yang-installdir=DIR
Install Clixon yang files here (default:
Expand Down Expand Up @@ -3413,6 +3422,7 @@ HAVE_HTTP1=false

# SNMP tests require generated YANGs from MIBs

# Used in expansion in, e.g., example/main/example.xml.in

#
ac_ext=c
Expand Down Expand Up @@ -4697,25 +4707,16 @@ $as_echo "#define CLIXON_YANG_SCHEMA_MOUNT 1" >>confdefs.h

fi

# Experimental: Curl publish notification stream to eg Nginx nchan.
# Check whether --enable-publish was given.
if test "${enable_publish+set}" = set; then :
enableval=$enable_publish;
if test "$enableval" = no; then
ac_enable_publish=no
else
ac_enable_publish=yes
fi
# publish streams uses libcurl

# Check whether --with-libcurl was given.
if test "${with_libcurl+set}" = set; then :
withval=$with_libcurl; with_libcurl=$withval
else
ac_enable_publish=no
with_libcurl=yes
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: publish is $ac_enable_publish" >&5
$as_echo "publish is $ac_enable_publish" >&6; }

if test "$ac_enable_publish" = "yes"; then
# publish streams uses libcurl
if test "x${with_libcurl}" != "xno"; then

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
Expand Down Expand Up @@ -4976,16 +4977,16 @@ fi
done


for ac_header in curl.h
for ac_header in curl/curl.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "curl.h" "ac_cv_header_curl_h" "$ac_includes_default"
if test "x$ac_cv_header_curl_h" = xyes; then :
ac_fn_c_check_header_mongrel "$LINENO" "curl/curl.h" "ac_cv_header_curl_curl_h" "$ac_includes_default"
if test "x$ac_cv_header_curl_curl_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_CURL_H 1
#define HAVE_CURL_CURL_H 1
_ACEOF

else
as_fn_error $? "curl missing" "$LINENO" 5
as_fn_error $? "curl header(s) missing" "$LINENO" 5
fi

done
Expand Down Expand Up @@ -5037,10 +5038,32 @@ else
as_fn_error $? "libcurl missing" "$LINENO" 5
fi

fi

# Experimental: Curl publish notification stream to eg Nginx nchan.
# Check whether --enable-publish was given.
if test "${enable_publish+set}" = set; then :
enableval=$enable_publish;
if test "$enableval" = no; then
ac_enable_publish=no
else
ac_enable_publish=yes
fi

else
ac_enable_publish=no
fi

if test "$ac_enable_publish" = "yes"; then
if test "x${with_libcurl}" = "xno"; then
as_fn_error $? "--enable-publish conflicts with --without-libcurl" "$LINENO" 5
fi

$as_echo "#define CLIXON_PUBLISH_STREAMS 1" >>confdefs.h

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: publish is $ac_enable_publish" >&5
$as_echo "publish is $ac_enable_publish" >&6; }

for ac_header in cligen/cligen.h
do :
Expand Down Expand Up @@ -5120,7 +5143,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: restconf mode ${with_restconf}" >&5
$as_echo "restconf mode ${with_restconf}" >&6; }
# Actions for each specific package
if test "x${with_restconf}" == xfcgi; then
if test "x${with_restconf}" = xfcgi; then
# Lives in libfcgi-dev
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FCGX_Init in -lfcgi" >&5
$as_echo_n "checking for FCGX_Init in -lfcgi... " >&6; }
Expand Down Expand Up @@ -5172,7 +5195,7 @@ fi

$as_echo "#define WITH_RESTCONF_FCGI 1" >>confdefs.h
# For c-code that cant use strings
elif test "x${with_restconf}" == xnative; then
elif test "x${with_restconf}" = xnative; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL_init_ssl in -lssl" >&5
$as_echo_n "checking for OPENSSL_init_ssl in -lssl... " >&6; }
if ${ac_cv_lib_ssl_OPENSSL_init_ssl_+:} false; then :
Expand Down Expand Up @@ -5374,7 +5397,7 @@ fi

$as_echo "#define WITH_RESTCONF_NATIVE 1" >>confdefs.h
# For c-code that cant use strings
elif test "x${with_restconf}" == xno; then
elif test "x${with_restconf}" = xno; then
# Cant get around "no" as an answer for --without-restconf that is reset here to undefined
with_restconf=
else
Expand Down Expand Up @@ -5657,6 +5680,16 @@ fi

if test "${with_libxml2}"; then
# Find libxml2 lib
if test -x "${with_libxml2}" 2>/dev/null; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libxml2 header files and libs" >&5
$as_echo_n "checking for libxml2 header files and libs... " >&6; }
LIBXML2_CFLAGS="`${with_libxml2} --cflags`"
LIBS="$LIBS `${with_libxml2} --libs`"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBXML2_CFLAGS" >&5
$as_echo "$LIBXML2_CFLAGS" >&6; }
else
LIBXML2_CFLAGS="-I/usr/include/libxml2"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlRegexpCompile in -lxml2" >&5
$as_echo_n "checking for xmlRegexpCompile in -lxml2... " >&6; }
if ${ac_cv_lib_xml2_xmlRegexpCompile+:} false; then :
Expand Down Expand Up @@ -5731,7 +5764,7 @@ else
fi


if test "x${with_sigaction}" == "xyes"; then
if test "x${with_sigaction}" = "xyes"; then
for ac_func in sigaction
do :
ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction"
Expand Down Expand Up @@ -5815,6 +5848,15 @@ fi



# Expand for easy replacement in example/main/example.xml.in
# Special case is $libdir, which is composed from $exec_prefix
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
SYSCONFDIR=`eval echo $sysconfdir`
LIBDIR=`eval echo $libdir`
LIBDIR=`eval echo $LIBDIR`
LOCALSTATEDIR=`eval echo $localstatedir`

ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile apps/snmp/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/main/Makefile example/main/example.xml extras/rpm/Makefile docker/Makefile docker/clixon-dev/Makefile docker/example/Makefile docker/test/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/mandatory/Makefile doc/Makefile test/Makefile test/config.sh test/cicd/Makefile test/vagrant/Makefile"

cat >confcache <<\_ACEOF
Expand Down
57 changes: 45 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ AC_SUBST(LIBS)
AC_SUBST(SH_SUFFIX)
AC_SUBST(LIBSTATIC_SUFFIX)
AC_SUBST(LINKAGE)
AC_SUBST(with_libcurl)
AC_SUBST(with_restconf) # Set to native or fcgi -> compile apps/restconf
AC_SUBST(enable_netsnmp) # Enable build of apps/snmp
AC_SUBST(HAVE_LIBNGHTTP2,false) # consider using neutral constant such as with-http2
AC_SUBST(HAVE_HTTP1,false)
AC_SUBST(with_libxml2)
AC_SUBST(with_libxml2)
AC_SUBST(LIBXML2_CFLAGS)
AC_SUBST(CLIXON_YANG_PATCH)
AC_SUBST(CLIXON_YANG_SCHEMA_MOUNT)
# Where Clixon installs its YANG specs
Expand All @@ -127,6 +129,10 @@ AC_SUBST(YANG_INSTALLDIR)
AC_SUBST(YANG_STANDARD_DIR)
# SNMP tests require generated YANGs from MIBs
AC_SUBST(MIB_GENERATED_YANG_DIR)
# Used in expansion in, e.g., example/main/example.xml.in
AC_SUBST(SYSCONFDIR)
AC_SUBST(LIBDIR)
AC_SUBST(LOCALSTATEDIR)

#
AC_PROG_CC()
Expand Down Expand Up @@ -212,23 +218,33 @@ if test "${enable_yang_schema_mount}" = "yes"; then
AC_DEFINE(CLIXON_YANG_SCHEMA_MOUNT, 1, [Enable YANG schema mount, RFC 8528])
fi

# publish streams uses libcurl
AC_ARG_WITH([libcurl],
[AS_HELP_STRING([--without-libcurl],
[Disable use of libcurl, affects publish notification, including clixon_util_stream])],
[with_libcurl=$withval],[with_libcurl=yes])
if test "x${with_libcurl}" != "xno"; then
AC_CHECK_HEADERS(curl/curl.h,[], AC_MSG_ERROR([curl header(s) missing]))
AC_CHECK_LIB(curl, curl_global_init,, AC_MSG_ERROR([libcurl missing]))
fi

# Experimental: Curl publish notification stream to eg Nginx nchan.
AC_ARG_ENABLE(publish, AS_HELP_STRING([--enable-publish],[Enable publish of notification streams using SSE and curl]),[
AC_ARG_ENABLE(publish, AS_HELP_STRING([--enable-publish],
[Enable publish of notification streams using SSE and curl]),[
if test "$enableval" = no; then
ac_enable_publish=no
else
ac_enable_publish=yes
fi
],
[ ac_enable_publish=no])
AC_MSG_RESULT(publish is $ac_enable_publish)

if test "$ac_enable_publish" = "yes"; then
# publish streams uses libcurl
AC_CHECK_HEADERS(curl.h,[], AC_MSG_ERROR([curl missing]))
AC_CHECK_LIB(curl, curl_global_init,, AC_MSG_ERROR([libcurl missing]))
if test "x${with_libcurl}" = "xno"; then
AC_MSG_ERROR([--enable-publish conflicts with --without-libcurl])
fi
AC_DEFINE(CLIXON_PUBLISH_STREAMS, 1, [Enable publish of notification streams using SSE and curl])
fi
AC_MSG_RESULT(publish is $ac_enable_publish)

AC_CHECK_HEADERS(cligen/cligen.h,, AC_MSG_ERROR([CLIgen missing. Try: git clone https://github.com/clicon/cligen.git]))

Expand All @@ -244,11 +260,11 @@ AC_ARG_WITH([restconf],
[with_restconf=native])
AC_MSG_RESULT(restconf mode ${with_restconf})
# Actions for each specific package
if test "x${with_restconf}" == xfcgi; then
if test "x${with_restconf}" = xfcgi; then
# Lives in libfcgi-dev
AC_CHECK_LIB(fcgi, FCGX_Init,, AC_MSG_ERROR([libfcgi-dev missing]))
AC_DEFINE(WITH_RESTCONF_FCGI, 1, [Use fcgi restconf mode]) # For c-code that cant use strings
elif test "x${with_restconf}" == xnative; then
elif test "x${with_restconf}" = xnative; then
AC_CHECK_LIB(ssl, OPENSSL_init_ssl ,, AC_MSG_ERROR([libssl missing]))
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, , AC_MSG_ERROR([libcrypto missing]))
# Check if http/1 enabled
Expand Down Expand Up @@ -283,7 +299,7 @@ elif test "x${with_restconf}" == xnative; then
HAVE_LIBNGHTTP2=true
fi
AC_DEFINE(WITH_RESTCONF_NATIVE, 1, [Use native restconf mode]) # For c-code that cant use strings
elif test "x${with_restconf}" == xno; then
elif test "x${with_restconf}" = xno; then
# Cant get around "no" as an answer for --without-restconf that is reset here to undefined
with_restconf=
else
Expand Down Expand Up @@ -344,9 +360,17 @@ AC_CHECK_LIB(dl, dlopen)
# Note this only enables the compiling of the code. In order to actually
# use it you need to set Clixon config option CLICON_YANG_REGEXP to libxml2
AC_ARG_WITH([libxml2],
[AS_HELP_STRING([--with-libxml2],[Use gnome/libxml2 regex engine])])
[AS_HELP_STRING([--with-libxml2[[=/path/to/xml2-config]]],[Use libxml2 regex engine])])
if test "${with_libxml2}"; then
# Find libxml2 lib
if test -x "${with_libxml2}" 2>/dev/null; then
AC_MSG_CHECKING([for libxml2 header files and libs])
LIBXML2_CFLAGS="`${with_libxml2} --cflags`"
LIBS="$LIBS `${with_libxml2} --libs`"
AC_MSG_RESULT([$LIBXML2_CFLAGS])
else
LIBXML2_CFLAGS="-I/usr/include/libxml2"
fi
AC_CHECK_LIB(xml2, xmlRegexpCompile,[], AC_MSG_ERROR([libxml2 not found]))
fi

Expand All @@ -361,7 +385,7 @@ AC_ARG_WITH(
[with_sigaction=yes]
)

if test "x${with_sigaction}" == "xyes"; then
if test "x${with_sigaction}" = "xyes"; then
AC_CHECK_FUNCS(sigaction)
fi

Expand Down Expand Up @@ -400,6 +424,15 @@ AC_ARG_ENABLE(nls)

AH_BOTTOM([#include <clixon_custom.h>])

# Expand for easy replacement in example/main/example.xml.in
# Special case is $libdir, which is composed from $exec_prefix
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
SYSCONFDIR=`eval echo $sysconfdir`
LIBDIR=`eval echo $libdir`
LIBDIR=`eval echo $LIBDIR`
LOCALSTATEDIR=`eval echo $localstatedir`

AC_OUTPUT(Makefile
lib/Makefile
lib/src/Makefile
Expand Down
2 changes: 1 addition & 1 deletion example/main/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ endif

with_restconf = @with_restconf@

INCLUDES = -I$(includedir) @INCLUDES@
INCLUDES = -I$(DESTDIR)$(includedir) @INCLUDES@
LINKAGE = @LINKAGE@
LDFLAGS = @LDFLAGS@
CPPFLAGS = @CPPFLAGS@
Expand Down
Loading

0 comments on commit ecd60fb

Please sign in to comment.