Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@
AUTOMAKE_OPTIONS = foreign 1.4
ACLOCAL_AMFLAGS = -I m4

SUBDIRS = src test
DIST_SUBDIRS = src test
SUBDIRS = src
DIST_SUBDIRS = src

if !COND_CROSS_COMPILE
SUBDIRS += test
DIST_SUBDIRS += test

if BUILD_EXAMPLES
SUBDIRS += examples
DIST_SUBDIRS += examples
endif

endif

EXTRA_DIST = libhttpserver.pc.in $(DX_CONFIG)

MOSTLYCLEANFILES = $(DX_CLEANFILES) *.gcda *.gcno *.gcov
Expand Down
74 changes: 41 additions & 33 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AX_VALGRIND_CHECK
OLD_CXXFLAGS=$CXXFLAGS
LT_INIT
AC_PROG_CC
AC_PROG_CXX([clang++])
AC_PROG_CXX()
AC_PROG_LN_S
CXXFLAGS=$OLD_CXXFLAGS
AC_LANG([C++])
Expand Down Expand Up @@ -93,28 +93,48 @@ AC_CHECK_HEADER([signal.h],[],[AC_MSG_ERROR("signal.h not found")])
AC_CHECK_HEADER([gnutls/gnutls.h],[have_gnutls="yes"],[AC_MSG_WARN("gnutls/gnutls.h not found. TLS will be disabled"); have_gnutls="no"])

# Checks for libmicrohttpd
AC_CHECK_HEADER([microhttpd.h],
AC_CHECK_LIB([microhttpd], [MHD_get_fdset2],
[AC_MSG_CHECKING([for libmicrohttpd >= 0.9.52])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
#include <microhttpd.h>
#if (MHD_VERSION < 0x00095102)
#error needs at least version 0.9.52
#endif
int main () { return 0; }
])],
if test x"$host" = x"$build"; then
AC_CHECK_HEADER([microhttpd.h],
AC_CHECK_LIB([microhttpd], [MHD_get_fdset2],
[AC_MSG_CHECKING([for libmicrohttpd >= 0.9.52])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([
#include <microhttpd.h>
#if (MHD_VERSION < 0x00095102)
#error needs at least version 0.9.52
#endif
int main () { return 0; }
])],
[],
[AC_MSG_ERROR("libmicrohttpd is too old - install libmicrohttpd >= 0.9.52")]
)
],
[AC_MSG_ERROR(["libmicrohttpd not found"])]
),
[AC_MSG_ERROR(["microhttpd.h not found"])]
)

CXXFLAGS="-std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT $LIBMICROHTTPD_CFLAGS $CXXFLAGS"
LDFLAGS="$LIBMICROHTTPD_LIBS $REGEX_LIBS $LDFLAGS"

cond_cross_compile="no"
else
AC_CHECK_HEADER([microhttpd.h],
AC_CHECK_LIB([microhttpd], [MHD_get_fdset2],
[],
[AC_MSG_ERROR("libmicrohttpd is too old - install libmicrohttpd >= 0.9.52")]
)
],
[AC_MSG_ERROR(["libmicrohttpd not found"])]
),
[AC_MSG_ERROR(["microhttpd.h not found"])]
)
[AC_MSG_ERROR(["libmicrohttpd not found"])]
),
[AC_MSG_ERROR(["microhttpd.h not found"])]
)

CXXFLAGS="-std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT $CXXFLAGS"
LDFLAGS="$REGEX_LIBS $LDFLAGS"

cond_cross_compile="yes"
fi

CXXFLAGS="-std=c++11 -DHTTPSERVER_COMPILATION -D_REENTRANT $LIBMICROHTTPD_CFLAGS $CXXFLAGS"
LDFLAGS="$LIBMICROHTTPD_LIBS $REGEX_LIBS $LDFLAGS"
AM_CONDITIONAL([COND_CROSS_COMPILE],[test x"$cond_cross_compile" = x"yes"])
AC_SUBST(COND_CROSS_COMPILE)

AC_MSG_CHECKING([whether to build with TCP_FASTOPEN support])
AC_ARG_ENABLE([fastopen],
Expand Down Expand Up @@ -292,18 +312,6 @@ AC_ARG_ENABLE([[examples]],
test "x$enable_examples" = "xno" || enable_examples=yes
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])

if test "$CROSS_COMPILE" == "1"; then
if test "$ARM_ARCH_DIR" == "aarch64-linux-gnu"; then
AM_CXXFLAGS="$AM_CXXFLAGS --prefix=${ARM_LD_PATH}/"
AM_CFLAGS="$AM_CFLAGS --prefix=${ARM_LD_PATH}/"
PATH="${ARM_LD_PATH}/:$PATH"
CXXLINK="${ARM_LD_PATH}/ld"
LINK="${ARM_LD_PATH}/ld"
LD="${ARM_LD_PATH}/ld"
LDFLAGS="$LDFLAGS -Wl,-rpath -Wl,/usr/lib -Wl,-rpath-link -Wl,${ARM_LD_PATH}/usr/lib -L${ARM_LD_PATH}/lib -L${ARM_LD_PATH}/usr/lib"
fi
fi

AM_CONDITIONAL([COND_GCOV],[test x"$cond_gcov" = x"yes"])
AC_SUBST(COND_GCOV)

Expand Down
2 changes: 1 addition & 1 deletion libhttpserver.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ includedir=@includedir@
Name: libhttpserver
Description: A C++ library for creating an embedded Rest HTTP server
Version: @VERSION@
Requires: libmicrohttpd >= 0.9.37
Requires: libmicrohttpd >= 0.9.52
Conflicts:
Libs: -L${libdir} -lhttpserver
Libs.private: @LHT_LIBDEPS@
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ AM_CXXFLAGS += -O0 --coverage --no-inline
AM_LDFLAGS += -O0 --coverage -lgcov --no-inline
endif

if !COND_CROSS_COMPILE
libhttpserver_la_LIBADD = -lmicrohttpd
endif

libhttpserver_la_CFLAGS = $(AM_CFLAGS)
libhttpserver_la_CXXFLAGS = $(AM_CXXFLAGS)
libhttpserver_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined
Expand Down