diff options
author | Alan Antonuk <alan.antonuk@gmail.com> | 2012-05-24 12:16:55 -0700 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2012-05-24 12:16:55 -0700 |
commit | 7a74c3574afb32ab31dc5f946afbf89f3022a36d (patch) | |
tree | 905ce64fbee48f720b553cda46cee272ea064b17 /configure.ac | |
parent | 50a298e6c0df1ef8f2ec19da5949adef392e5131 (diff) | |
parent | e567f9eb8918d35db4ebc78e9a512d3e838afe00 (diff) | |
download | rabbitmq-c-github-ask-7a74c3574afb32ab31dc5f946afbf89f3022a36d.tar.gz |
Merge pull request #16 from msteinert/autotools
Cleanup autoconf/automake build
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 300 |
1 files changed, 141 insertions, 159 deletions
diff --git a/configure.ac b/configure.ac index e6aac32..211858e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,166 +1,148 @@ -AC_INIT([librabbitmq],[0.0.1],[support@rabbitmq.com]) -AC_CONFIG_SRCDIR(librabbitmq/codegen.py) -AM_INIT_AUTOMAKE - -AC_CONFIG_HEADER([config.h]) - -dnl Program checks +AC_PREREQ([2.59]) + +# Library versioning +# Making releases: +# micro_version += 1 +# interface_age += 1 +# If functions have been added or backward-compatibility has been broken: +# interface_age = 0 +m4_define([major_version], [0]) +m4_define([minor_version], [2]) +m4_define([micro_version], [0]) +m4_define([interface_age], [0]) + +AC_INIT([rabbitmq-c], [major_version.minor_version.micro_version], + [https://github.com/alanxz/rabbitmq-c/issues], [librabbitmq], + [http://www.rabbitmq.com/]) +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([1.9 subdir-objects foreign -Wno-portability]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +AC_CONFIG_SRCDIR([librabbitmq/amqp.h]) AC_GNU_SOURCE -AC_PROG_CC - -dnl Library checks -AC_LIBTOOL_WIN32_DLL -AM_PROG_LIBTOOL -dnl Header-file checks -AC_HEADER_STDC +# Initialize Libtool +LT_PREREQ([2.2]) +LT_INIT([disable-static win32-dll]) -if test "x$GCC" = "xyes"; then - dnl Only use -Wall if we have gcc - if ! echo "$CFLAGS" | grep "\-Wall" 2> /dev/null ; then - CFLAGS="$CFLAGS -Wall" - fi -fi +# Program checks +m4_ifdef([AC_PROG_CC_C99], [AC_PROG_CC_C99], + [AC_MSG_WARN([Attempt c99 workaround for old versions of autoconf]) + AC_PROG_CC + AX_TRY_CFLAGS([-std=c99], [AX_CFLAGS([-std=c99])])]) -dnl Detect the kind of host we're building for +# Environment setup AC_CANONICAL_HOST -windows=no -case "${host}" in -*-*-mingw*) - windows=yes - ;; -esac -AM_CONDITIONAL(WINDOWS, test "x$windows" = xyes) -AS_IF([test "x$windows" = xyes], - [AC_DEFINE([WINDOWS], [1], [Define to 1 if on Windows.])] -) - -AM_CONDITIONAL(GCC, test "x$GCC" = xyes) - -# Detect how to declare inline functions. Because we will sometimes -# use "-ansi -pedantic" with gcc, we need to make sure the result will -# work in that context. -orig_cflags="$CFLAGS" -AS_IF([test "x$GCC" = "xyes"], [CFLAGS="$CFLAGS -ansi -pedantic"]) -AC_C_INLINE -CFLAGS="$orig_cflags" - AC_C_BIGENDIAN +AC_C_INLINE -dnl Decide which API abstraction layer to use -PLATFORM_DIR=unix -if test "x$windows" = xyes ; then - PLATFORM_DIR=windows -fi -AC_SUBST(PLATFORM_DIR) - -dnl Enable -m64 if we were asked to do so -AC_ARG_ENABLE(64-bit, -[ --enable-64-bit produce 64-bit library], -[CFLAGS="$CFLAGS -m64"; LDFLAGS="$LDFLAGS -m64"], -) - -AC_MSG_CHECKING(location of AMQP codegen directory) -for d in ../rabbitmq-codegen codegen ; do - AMQP_CODEGEN_DIR="$d" - test -d "$srcdir/$AMQP_CODEGEN_DIR" && break -done -AMQP_SPEC_JSON_PATH="$AMQP_CODEGEN_DIR/amqp-rabbitmq-0.9.1.json" - -if test -f "$srcdir/$AMQP_SPEC_JSON_PATH" -then - AC_MSG_RESULT($AMQP_CODEGEN_DIR) -else - AC_MSG_ERROR(could not find AMQP spec file at "'$AMQP_SPEC_JSON_PATH'") -fi - -AC_MSG_CHECKING(finding a python with simplejson installed) -found_python=no -checkPython() { - if test "$found_python" = "yes" - then - return - fi - PYTHON=$1 - if $PYTHON -c 'import json' 2>/dev/null \ - || $PYTHON -c 'import simplejson' 2>/dev/null - then - found_python=yes - AC_MSG_RESULT($PYTHON) - fi -} -checkPython python -checkPython python2.6 -checkPython python2.5 -if test "$found_python" = "no" -then - AC_MSG_ERROR(could not find a python that can 'import simplejson') -fi - -AC_SUBST(AMQP_CODEGEN_DIR) -AC_SUBST(AMQP_SPEC_JSON_PATH) -AC_SUBST(PYTHON) - -dnl Decide which extra win32 libs we need, and handle other special -dnl cases when building with the Microsoft compiler -EXTRA_LIBS= -USE_MISINTTYPES= -AS_IF([test "x$windows" = xyes], - [ - AS_IF([test "x$GCC" = xyes], - [EXTRA_LIBS="-lws2_32 $EXTRA_LIBS"], - [ - EXTRA_LIBS="ws2_32.lib $EXTRA_LIBS" - USE_MSINTTYPES=yes - ]) - ]) - -AC_SUBST(EXTRA_LIBS) -AM_CONDITIONAL(USE_MSINTTYPES, test "x$USE_MSINTTYPES" != "x") - -dnl Check for libpopt, which we need to build the tools -AC_ARG_WITH([popt], - [AS_HELP_STRING([--with-popt], [use the popt library. Needed for tools.])], - [], - [with_popt=check]) - -LIBPOPT= -AS_IF([test "x$with_popt" != xno], - [AC_CHECK_LIB([popt], [poptGetContext], - [AC_SUBST([LIBPOPT], ["-lpopt"]) - AC_DEFINE([HAVE_LIBPOPT], [1], [Define if you have libpopt]) - ], - [if test "x$with_popt" != xcheck; then - AC_MSG_FAILURE([--with-popt was given, but test for libpopt failed]) - fi - ])]) - -AS_IF([test "x$LIBPOPT" != "x"], - [AC_CHECK_HEADER([popt.h], [], - [AC_MSG_FAILURE([You have libpopt, but could not find the popt.h header])]) - ]) - -AM_CONDITIONAL(TOOLS, test "x$LIBPOPT" != "x") - -AC_ARG_WITH([xmlto], - [AS_HELP_STRING([--with-xmlto], [use the xmlto toolchain. Needed for tools man pages.])], - [], - [with_xmlto=check]) - -XMLTO= -AS_IF([test "x$with_xmlto" != xno], - [AC_CHECK_PROG([XMLTO], [xmlto], [xmlto]) - if test "x$with_xmlto" != xcheck; then - AC_MSG_FAILURE([--with-xmlto was given, but xmlto not found]) - fi]) - -AM_CONDITIONAL(TOOLS_DOC, test "x$XMLTO" != "x") - -AC_OUTPUT( -Makefile -librabbitmq/Makefile -tests/Makefile -examples/Makefile -tools/Makefile -tools/doc/Makefile -) +# Set compiler flags +AX_TRY_CFLAGS([-Wall], [AX_CFLAGS([-Wall])]) +AX_TRY_CFLAGS([-Wextra], [AX_CFLAGS([-Wextra])]) +AX_TRY_CFLAGS([-pedantic], [AX_CFLAGS([-pedantic])]) +AX_TRY_CFLAGS([-Wstrict-prototypes], [AX_CFLAGS([-Wstrict-prototypes])]) +AX_TRY_CFLAGS([-Wcast-align], [AX_CFLAGS([-Wcast-align])]) +AX_TRY_CFLAGS([-fno-common], [AX_CFLAGS([-fno-common])]) +AX_TRY_CFLAGS([-fvisibility=hidden], [AX_CFLAGS([-fvisibility=hidden])]) +AX_TRY_LDFLAGS([-no-undefined], [NO_UNDEFINED=-no-undefined]) +AC_SUBST([NO_UNDEFINED]) + +# Libtool versioning +LT_CURRENT=m4_eval(minor_version + micro_version - interface_age) +LT_REVISION=interface_age +LT_AGE=m4_eval(m4_eval(minor_version + micro_version) - interface_age) +AC_SUBST([LT_CURRENT]) +AC_SUBST([LT_REVISION]) +AC_SUBST([LT_AGE]) + +# OS setup +os_unix=no +os_win32=no +AS_CASE([$host], + [*-*-mingw*], + [os_win32=yes], + [*], + [os_unix=yes]) +AM_CONDITIONAL([OS_UNIX], [test "x$os_unix" = xyes]) +AM_CONDITIONAL([OS_WIN32], [test "x$os_win32" = xyes]) + +# Extra Win32 setup +AS_IF([test "x$os_win32" = xyes], + [AC_DEFINE([OS_WIN32], [1], [Define to 1 for Win32.]) + AC_DEFINE([AMQP_BUILD], [1], [Define to 1 for a Win32 build.]) + AS_IF([test "x$GCC" = xyes], + [AX_LDFLAGS([-lws2_32])], + [AX_LDFLAGS([ws2_32.lib])]) + AS_IF([test "x$enable_static" = "xyes"], + [AS_IF([test "x$enable_shared" = "xyes"], + [AC_MSG_ERROR([select one of shared @<:@--enable-shared@:>@ or static @<:@--enable-static@:>@.])], + [AC_DEFINE([AMQP_STATIC], [1], + [Define to 1 for a static Win32 build.])])])]) + +# 64-bit option +AC_ARG_ENABLE([64-bit], + [AS_HELP_STRING([--enable-64-bit], + [produce 64-bit library @<:@no@:>@])], + [AX_TRY_CFLAGS([-m64], AX_CFLAGS([-m64])) + AX_TRY_LDFLAGS([-m64], [AX_LDFLAGS([-m64])])], + [enable_64_bit=no]) + +# Configure python +pythons="python python2.6 python2.5" +AC_CACHE_CHECK([for Python with 'json'], [ac_cv_path_PYTHON], + [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [$pythons], + [$ac_path_PYTHON -c 'import json' 2>/dev/null + AS_IF([test "x$?" = "x0"], + [ac_cv_path_PYTHON=$ac_path_PYTHON + ac_path_PYTHON_found=:])], + [AC_MSG_RESULT([not found])])]) +AC_CACHE_CHECK([for Python with 'simplejson'], [ac_cv_path_PYTHON], + [AC_PATH_PROGS_FEATURE_CHECK([PYTHON], [$pythons], + [$ac_path_PYTHON -c 'import simplejson' 2>/dev/null + AS_IF([test "x$?" = "x0"], + [ac_cv_path_PYTHON=$ac_path_PYTHON + ac_path_PYTHON_found=:])], + [AC_MSG_RESULT([not found])])]) +AS_IF([test "x$ac_cv_path_PYTHON" = "x"], + [ac_cv_path_PYTHON=: + AC_MSG_WARN([unable to rebuild AMQP framing])]) +AC_SUBST([PYTHON], [$ac_cv_path_PYTHON]) + +# Configure AMQP command-line tools +AC_ARG_ENABLE([tools], + [AS_HELP_STRING([--enable-tools], + [build AMQP command-line tools @<:@auto@:>@])],, + [enable_tools=auto]) +AS_IF([test "x$enable_tools" != "xno"], + [AX_LIB_POPT([enable_tools=yes], [enable_tools=no])]) +AM_CONDITIONAL([TOOLS], [test "x$enable_tools" = "xyes"]) + +# Configure command-line tool documentation +AC_ARG_ENABLE([docs], + [AS_HELP_STRING([--enable-docs], + [build command-line tool documentation @<:@auto@:>@])],, + [AS_IF([test "x$enable_tools" = "xno"], + [enable_docs=no], + [enable_docs=auto])]) +AC_ARG_VAR([XMLTO], [xmlto command]) +AS_IF([test "x$enable_docs" != "xno"], + [AS_IF([test "x$XMLTO" = "x"], + [AC_CHECK_PROGS([XMLTO], [xmlto])]) + AS_IF([test "x$XMLTO" != "x"], + [enable_docs=yes], + [enable_docs=no])]) +AM_CONDITIONAL([DOCS], [test "x$enable_docs" = "xyes"]) + +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([ + librabbitmq.pc + Makefile +]) +AC_OUTPUT +AC_MSG_RESULT([ +$PACKAGE_NAME build options: + Host: $host + Version: $VERSION + 64-bit: $enable_64_bit + Tools: $enable_tools + Documentation: $enable_docs +]) |