Refactor configure options

--enable-src is renamed as --enable-app. Fix build failure if
libxml2 is not available.
This commit is contained in:
Tatsuhiro Tsujikawa 2014-01-10 23:19:36 +09:00
parent d1c109f59e
commit 9dcd6b003d
4 changed files with 74 additions and 44 deletions

View File

@ -53,25 +53,30 @@ AC_ARG_ENABLE([maintainer-mode],
[Turn on compile time warnings])],
[maintainer_mode=$enableval], [maintainer_mode=no])
AC_ARG_ENABLE([src],
[AS_HELP_STRING([--enable-src],
[Build installable SPDY client/server programs in src])],
[request_src=$enableval], [request_src=yes])
AC_ARG_ENABLE([app],
[AS_HELP_STRING([--enable-app],
[Build applications (nghttp, nghttpd and nghttpx) [default=check]])],
[request_app=$enableval], [request_app=check])
AC_ARG_ENABLE([hpack-tools],
[AS_HELP_STRING([--enable-hpack-tools],
[Build HPACK tools [default=check]])],
[request_hpack_tools=$enableval], [request_hpack_tools=check])
AC_ARG_ENABLE([examples],
[AS_HELP_STRING([--enable-examples],
[Build example programs])],
[request_examples=$enableval], [request_examples=yes])
[Build examples [default=check]])],
[request_examples=$enableval], [request_examples=check])
AC_ARG_ENABLE([failmalloc],
[AS_HELP_STRING([--enable-failmalloc],
[Build failmalloc test program])],
[Build failmalloc test program [default=no]])],
[request_failmalloc=$enableval], [request_failmalloc=no])
AC_ARG_WITH([libxml2],
[AS_HELP_STRING([--without-libxml2],
[disable support for libxml2])],
[], [with_libxml2=yes])
[AS_HELP_STRING([--with-libxml2],
[Use libxml2 [default=check]])],
[request_libxml2=$withval], [request_libxml2=check])
dnl Define variables
AC_ARG_VAR([CYTHON], [the Cython executable])
@ -205,12 +210,18 @@ fi
# libxml2 (for src/nghttp)
have_libxml2=no
if test "x$with_libxml2" != "xno"; then
if test "x${request_libxml2}" != "xno"; then
AM_PATH_XML2(2.7.7, [have_libxml2=yes], [have_libxml2=no])
if test "x${have_libxml2}" = "xyes"; then
AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
fi
fi
if test "x${request_libxml2}" = "xyes" &&
test "x${have_libxml2}" != "xyes"; then
AC_MSG_ERROR([libxml2 was requested (--with-libxml2) but not found])
fi
AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ])
# spdylay (for src/nghttpx)
@ -224,32 +235,50 @@ else
fi
AM_CONDITIONAL([HAVE_SPDYLAY], [ test "x${have_spdylay}" = "xyes" ])
# The programs under src depend on OpenSSL and libevent_openssl
enable_src=no
if test "x${request_src}" = "xyes" &&
# The nghttp, nghttpd and nghttpx under src depend on OpenSSL and
# libevent_openssl
enable_app=no
if test "x${request_app}" != "xno" &&
test "x${have_openssl}" = "xyes" &&
test "x${have_libevent_openssl}" = "xyes"; then
enable_src=yes
enable_app=yes
fi
AM_CONDITIONAL([ENABLE_SRC], [ test "x${enable_src}" = "xyes" ])
if test "x${request_app}" = "xyes" &&
test "x${enable_app}" != "xyes"; then
AC_MSG_ERROR([applications were requested (--enable-app) but dependencies are not met.])
fi
# The example programs depend on OpenSSL
AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
enable_hpack_tools=no
# HPACK tools requires jansson
if test "x${request_hpack_tools}" != "xno" &&
test "x${have_jansson}" = "xyes"; then
enable_hpack_tools=yes
fi
if test "x${request_hpack_tools}" = "xyes" &&
test "x${enable_hpack_tools}" != "xyes"; then
AC_MSG_ERROR([HPACK tools were requested (--enable-hpack-tools) but dependencies are not met.])
fi
AM_CONDITIONAL([ENABLE_HPACK_TOOLS], [ test "x${enable_hpack_tools}" = "xyes" ])
# The example programs depend on OpenSSL and libevent_openssl
enable_examples=no
if test "x${request_examples}" = "xyes" &&
if test "x${request_examples}" != "xno" &&
test "x${have_openssl}" = "xyes" &&
test "x${have_libevent_openssl}" = "xyes"; then
enable_examples=yes
fi
AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
# HPACK tools requires jansson
if test "x${have_jansson}" = "xyes"; then
enable_hpack_tools=yes
if test "x${request_examples}" = "xyes" &&
test "x${enable_examples}" != "xyes"; then
AC_MSG_ERROR([examples were requested (--enable-examples) but dependencies are not met.])
fi
AM_CONDITIONAL([ENABLE_HPACK_TOOLS], [ test "x${enable_hpack_tools}" = "xyes" ])
AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
# failmalloc tests
AM_CONDITIONAL([ENABLE_FAILMALLOC], [ test "x${enable_failmalloc}" = "xyes" ])
@ -349,16 +378,16 @@ AC_MSG_NOTICE([summary of build options:
CXXFLAGS: ${CXXFLAGS}
CXXCPP: ${CXXCPP}
Library types: Shared=${enable_shared}, Static=${enable_static}
Python: ${PYTHON} ${PYTHON_VERSION}
Cython: ${CYTHON}
CUnit: ${have_cunit}
OpenSSL: ${have_openssl}
Libxml2: ${have_libxml2}
Libevent(SSL): ${have_libevent_openssl}
Spdylay: ${have_spdylay}
Jansson: ${have_jansson}
Src: ${enable_src}
Examples: ${enable_examples}
Applications: ${enable_app}
HPACK tools: ${enable_hpack_tools}
Examples: ${enable_examples}
Failmalloc: ${request_failmalloc}
Python: ${PYTHON} ${PYTHON_VERSION}
Cython: ${CYTHON}
])

View File

@ -34,6 +34,8 @@
#include <libxml/HTMLparser.h>
#endif // HAVE_LIBXML2
namespace nghttp2 {
enum RequestPriority {
@ -49,6 +51,8 @@ struct ParserData {
ParserData(const std::string& base_uri);
};
#ifdef HAVE_LIBXML2
class HtmlParser {
public:
HtmlParser(const std::string& base_uri);
@ -65,24 +69,21 @@ private:
ParserData parser_data_;
};
} // namespace nghttp2
#else // !HAVE_LIBXML2
namespace nghttp2 {
class HtmlParser {
public:
HtmlParser(const std::string& base_uri) {}
int parse_chunk(const char *chunk, size_t size, int fin) { return 0; }
const std::vector<std::string>& get_links() const { return links_; }
const std::vector<std::pair<std::string, RequestPriority>>&
get_links() const { return links_; }
void clear_links() {}
private:
std::vector<std::string> links_;
std::vector<std::pair<std::string, RequestPriority>> links_;
};
} // namespace nghttp2
#endif // !HAVE_LIBXML2
} // namespace nghttp2
#endif // HTML_PARSER_H

View File

@ -25,8 +25,6 @@ bin_PROGRAMS =
check_PROGRAMS =
TESTS =
if ENABLE_SRC
AM_CPPFLAGS = \
-Wall \
-I$(top_srcdir)/lib/includes \
@ -48,6 +46,8 @@ AM_LDFLAGS = \
LDADD = $(top_builddir)/lib/libnghttp2.la
if ENABLE_APP
bin_PROGRAMS += nghttp nghttpd nghttpx
HELPER_OBJECTS = util.cc http2.cc timegm.c app_helper.cc
@ -119,6 +119,8 @@ nghttpx_unittest_LDADD = libnghttpx.a ${LDADD} ${AM_LDFLAGS} \
TESTS += nghttpx-unittest
endif # HAVE_CUNIT
endif # ENABLE_APP
if ENABLE_HPACK_TOOLS
bin_PROGRAMS += inflatehd deflatehd
@ -130,5 +132,3 @@ inflatehd_SOURCES = inflatehd.c $(HPACK_TOOLS_COMMON_SRCS)
deflatehd_SOURCES = deflatehd.c $(HPACK_TOOLS_COMMON_SRCS)
endif # ENABLE_HPACK_TOOLS
endif # ENABLE_SRC

View File

@ -69,11 +69,11 @@ if ENABLE_FAILMALLOC
TESTS += failmalloc
endif # ENABLE_FAILMALLOC
if ENABLE_SRC
if ENABLE_APP
# EXTRA_DIST = end_to_end.py
# TESTS += end_to_end.py
endif # ENABLE_SRC
endif # ENABLE_APP
endif # HAVE_CUNIT