Initial import package dbus-python: D-Bus Python Bindings
[external/dbus-python.git] / configure.ac
1 -*- mode: m4 -*-
2 AC_PREREQ(2.59c)
3
4 dnl If not 1, append datestamp to the version number
5 m4_define(dbus_python_released, 1)
6 dnl The dbus-python version number (must actually be numeric at the moment)
7 m4_define(dbus_python_major_version, 0)
8 m4_define(dbus_python_minor_version, 83)
9 m4_define(dbus_python_micro_version, 1)
10
11 m4_define(dbus_python_maybe_datestamp,
12           m4_esyscmd([if test x]dbus_python_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
13
14 m4_define(dbus_python_version, dbus_python_major_version.dbus_python_minor_version.dbus_python_micro_version[]dbus_python_maybe_datestamp)
15
16 dnl versions of packages we require ...
17 dnl m4_define(glib_required_version, 2.8.0)
18
19 AC_INIT(dbus-python, dbus_python_version,
20         [http://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=python])
21 AC_CONFIG_MACRO_DIR([m4])
22 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
23
24 AC_DEFINE(DBUS_PYTHON_MAJOR_VERSION, dbus_python_major_version, [dbus-python major version])
25 AC_SUBST(DBUS_PYTHON_MAJOR_VERSION, dbus_python_major_version)
26 AC_DEFINE(DBUS_PYTHON_MINOR_VERSION, dbus_python_minor_version, [dbus-python minor version])
27 AC_SUBST(DBUS_PYTHON_MINOR_VERSION, dbus_python_minor_version)
28 AC_DEFINE(DBUS_PYTHON_MICRO_VERSION, dbus_python_micro_version, [dbus-python micro version])
29 AC_SUBST(DBUS_PYTHON_MICRO_VERSION, dbus_python_micro_version)
30
31 AC_CONFIG_SRCDIR([_dbus_bindings/module.c])
32 AM_CONFIG_HEADER(config.h)
33
34 AM_INIT_AUTOMAKE([1.9])
35
36 AC_CANONICAL_BUILD
37 AC_CANONICAL_HOST
38
39 AC_DISABLE_STATIC
40
41 dnl XXXX hack to kill off all the libtool tags ...
42 dnl it isn't like we are using C++ or Fortran.
43 dnl (copied from libglade/configure.in)
44 m4_define([_LT_AC_TAGCONFIG],[])
45
46 AC_PROG_LIBTOOL
47
48 AM_PATH_PYTHON(2.4.0)
49
50 AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
51
52 PLATFORM=`$PYTHON -c "from distutils import util; print util.get_platform()"`
53 AC_SUBST(PLATFORM)
54
55 dnl Building documentation
56
57 AC_MSG_CHECKING([whether you want to build HTML docs])
58 AC_ARG_ENABLE(html-docs,
59 AC_HELP_STRING([--enable-html-docs], [Enable HTML documentation building (requires docutils, default: auto-detect)]), enable_html_docs=$enableval, enable_html_docs="if possible")
60 AC_MSG_RESULT([$enable_html_docs])
61
62 AC_MSG_CHECKING([whether you want to build API docs])
63 AC_ARG_ENABLE(api-docs,
64 AC_HELP_STRING([--enable-api-docs], [Enable API documentation building (requires epydoc 3 and docutils)]), enable_api_docs=$enableval, enable_api_docs="if possible")
65 AC_MSG_RESULT([$enable_api_docs])
66
67
68 if test "$enable_api_docs" != no || test "$enable_html_docs" != no; then
69   AM_CHECK_PYMOD([docutils], [__version__], [have_docutils=yes], [have_docutils=no])
70   if test "$have_docutils" = no; then
71     if test "$enable_api_docs" = "if possible"; then
72        enable_api_docs=no
73     fi
74     if test "$enable_html_docs" = "if possible"; then
75        enable_html_docs=no
76     fi
77     if test "$enable_api_docs" != no || test "$enable_html_docs" != no; then
78       AC_MSG_ERROR([cannot compile HTML documentation or API documentation without python-docutils installed])
79     fi
80   fi
81 fi
82
83 if test "${enable_api_docs}" != no; then
84   AC_PATH_PROG([EPYDOC], [epydoc])
85   AC_MSG_CHECKING([epydoc 3])
86   if test -n "$EPYDOC"; then
87     EPYDOC_VERSION=`$EPYDOC --version`
88     case "$EPYDOC_VERSION" in
89       *ersion?3*)
90         AC_MSG_RESULT([yes, $EPYDOC_VERSION])
91         ;;
92       *)
93         AC_MSG_RESULT([no, $EPYDOC_VERSION])
94         EPYDOC=
95         ;;
96     esac
97   fi
98   if test -z "$EPYDOC"; then
99     case "$enable_api_docs" in
100       if*possible)
101         enable_api_docs=no
102         ;;
103       *)
104         AC_MSG_ERROR([cannot compile API documentation without epydoc 3.0beta1 or newer installed])
105         ;;
106     esac
107   fi
108 fi
109
110 RST2HTMLFLAGS=
111 if test "${enable_html_docs}" != no; then
112   AC_CHECK_PROGS([RST2HTML], [rst2html rst2html.py], [])
113   if test -z "$RST2HTML"; then
114     case "$enable_html_docs" in
115       if*possible)
116         enable_html_docs=no
117       ;;
118       *)
119         AC_MSG_ERROR([cannot compile HTML documentation without rst2html installed])
120       ;;
121     esac
122   else
123     DBUS_PY_ADD_RST2HTMLFLAG([--generator])
124     DBUS_PY_ADD_RST2HTMLFLAG([--date])
125     DBUS_PY_ADD_RST2HTMLFLAG([--time])
126     DBUS_PY_ADD_RST2HTMLFLAG([--exit-status=2])
127     DBUS_PY_ADD_RST2HTMLFLAG([--no-raw])
128     DBUS_PY_ADD_RST2HTMLFLAG([--no-file-insertion])
129     DBUS_PY_ADD_RST2HTMLFLAG([--cloak-email-addresses])
130   fi
131 fi
132 AC_SUBST([RST2HTML])
133 AC_SUBST([RST2HTMLFLAGS])
134
135 AM_CONDITIONAL([ENABLE_API_DOCS], [test "$enable_api_docs" != no])
136 AM_CONDITIONAL([ENABLE_DOCS], [test "$enable_html_docs" != no])
137
138 PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.0])
139 PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.70])
140
141 dnl avoid deprecated stuff if possible
142 AC_CHECK_LIB([dbus-1], [dbus_watch_get_unix_fd],
143              [AC_DEFINE([HAVE_DBUS_WATCH_GET_UNIX_FD], [],
144                         [Define if libdbus-1 has dbus_watch_get_unix_fd])],
145              [:], [$DBUS_LIBS])
146
147 TP_COMPILER_WARNINGS([CFLAGS], [test] dbus_python_released [= 0],
148   [all \
149    extra \
150    declaration-after-statement \
151    deprecated-declarations \
152    shadow \
153    strict-prototypes \
154    missing-prototypes \
155    missing-declarations \
156    sign-compare \
157    nested-externs \
158    pointer-arith \
159    format-security \
160    init-self],
161   [missing-field-initializers])
162
163 JH_ADD_CFLAG([-std=c9x])
164 JH_ADD_CFLAG([-fno-strict-aliasing])
165
166 AC_ARG_ENABLE(Werror,
167 AC_HELP_STRING([--enable-Werror],
168                [Treat warnings as errors, if the compiler supports it]),
169 enable_Werror=$enableval, enable_Werror=no)
170 if test "x$enable_Werror" = xyes; then
171   JH_ADD_CFLAG([-Werror])
172 fi
173
174 ifelse(dbus_python_released, 1,
175     [ # version x.y.z - disable coding style checks by default
176 AC_ARG_ENABLE(coding-style-checks,
177   AC_HELP_STRING([--enable-coding-style-checks],
178                  [check coding style using grep]),
179     [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=no] )
180     ],
181     [ # version x.y.z.200xyyzz - enable coding style checks by default
182 AC_ARG_ENABLE(coding-style-checks,
183   AC_HELP_STRING([--disable-coding-style-checks],
184                  [don't check coding style using grep]),
185     [ENABLE_CODING_STYLE_CHECKS=$enableval], [ENABLE_CODING_STYLE_CHECKS=yes])
186     ])
187
188 AC_CONFIG_FILES(
189   Makefile
190   _dbus_bindings/Makefile
191   _dbus_glib_bindings/Makefile
192   dbus-python.pc
193   dbus/_version.py
194   examples/Makefile
195   m4/Makefile
196   test/Makefile
197   test/tmp-session-bus.conf
198   test/TestSuitePythonService.service
199   tools/Makefile)
200 AC_OUTPUT