summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 593b3093281b14e0f435a8f4d5f0d15130905329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
AC_INIT([librabbitmq],[0.0.1],[tonyg@rabbitmq.com])
AC_CONFIG_SRCDIR(librabbitmq/codegen.py)
AM_INIT_AUTOMAKE

AC_CONFIG_HEADER([config.h])

dnl Program checks
AC_GNU_SOURCE
AC_PROG_CC

dnl Library checks
AM_PROG_LIBTOOL

dnl Header-file checks
AC_HEADER_STDC

dnl Only use -Wall if we have gcc
if test "x$GCC" = "xyes"; then
  if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
    CFLAGS="$CFLAGS -Wall"
  fi
fi

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)
sibling_codegen_dir="$ac_abs_confdir/../rabbitmq-codegen"
AMQP_CODEGEN_DIR=$(test -d "$sibling_codegen_dir" && echo "$sibling_codegen_dir" || echo "$ac_abs_confdir/codegen")
AMQP_SPEC_JSON_PATH="$AMQP_CODEGEN_DIR/amqp-rabbitmq-0.9.1.json"

if test -f "$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 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)

# 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
)