Updated MediaGoblin config stuff to latest pyconfigure release
[mediagoblin.git] / configure.ac
CommitLineData
e342891a
BI
1dnl configure.ac
2dnl
3dnl Copyright 2012, 2013 Brandon Invergo <brandon@invergo.net>
4dnl
5dnl Copying and distribution of this file, with or without modification,
6dnl are permitted in any medium without royalty provided the copyright
7dnl notice and this notice are preserved. This file is offered as-is,
8dnl without any warranty.
9
10dnl#########
11dnl README #
12dnl#########
13dnl
14dnl This is a basic Autoconf configure.ac file for Python-based
15dnl projects. It is not intended to be used as-is, but rather to be
16dnl modified to the specific needs of the project.
17dnl
18dnl Lines prefixed with "dnl" are comments that are automatically
19dnl removed by Autoconf/M4, thus they will not appear in the generated
20dnl configure script (see the M4 documentation for more information).
21dnl Such comments are used in this file to communicate information to
22dnl you, the developer. In some cases, the comments contain extra
23dnl macros that you might consider including in your configure script.
24dnl If you wish to include them, simply remove the "dnl" from the
25dnl beginning of the line.
26dnl
27dnl Lines prefixed with "#" are comments that will appear in the
28dnl generated configure script. These comments are thus used to clarify
29dnl to the user what is happening in that script
30dnl
31dnl Wherever pyconfigure-specific macros are used, extra comments are
32dnl included to describe the macros.
33
34dnl######################
35dnl Package Information #
36dnl######################
37
38dnl----
39dnl Initialize Autoconf with the package metadata
40dnl The arguments have been set via the project's PKG-INFO file
41dnl and correspond to:
42dnl
43dnl 1) package name (i.e. foo)
44dnl 2) package version (i.e. 1.2)
45dnl 3) bug/info/project email address (i.e. bug-foo@gnu.org)
46dnl----
47dnl
48AC_INIT([mediagoblin], [0.4.0.dev], [cwebber@gnu.org])
49
a9dc855a 50
e342891a
BI
51dnl----
52dnl Load macros from the m4/ directory. If you plan to write new
53dnl macros, put them in files in this directory.
54dnl----
55dnl
56AC_CONFIG_MACRO_DIR([m4])
57
58
dc85ee8c
BI
59# The default prefix should be changed from /usr/local. Set it, as in
60# the documentation, to /srv/mediagoblin.example.org/mediagoblin/
e56b493a 61AC_PREFIX_DEFAULT([`pwd`])
dc85ee8c
BI
62
63
e342891a
BI
64dnl###########################
65dnl Program/command support #
66dnl###########################
67dnl
68dnl In this section, we check for the presence of important commands
69dnl and programs.
70
71dnl--PC_INIT----------------------------------------------------------
72dnl This is the only required macro. Its primary function is to find
73dnl a Python interpreter that is compatible with the package and set
74dnl the PYTHON variable to hold its path. It can optionally take
a9dc855a
CAW
75dnl arguments to specify minimum and/or maximum versions. This is a
76dnl convenience macro that combines the functionality of the macros
77dnl PC_PROG_PYTHON and PC_PYTHON_VERIFY_VERSION
e342891a
BI
78dnl PC_INIT: find an interpreter with a version between 2.0 and 3.3.99
79dnl (in other words, up to and including any possible release
80dnl in the 3.3 series)
81dnl PC_INIT([MIN_VER], [MAX_VER]): Find an interpreter that is between
82dnl the minimum and maximum version. If the min is in the 2.0
83dnl series and the max is in the 3.0 series, non-existent
84dnl releases (2.8 & 2.9) will be correctly skipped.
85dnl----
86dnl
a9dc855a
CAW
87PC_INIT([2.7], [3.3.1])
88
89
90dnl--PC_PROG_PYTHON---------------------------------------------------
91dnl This macro provides a means of finding a Python interpreter.
92dnl You may optionally pass it argument to pass a path to a binary to
93dnl check for first. You may also pass a second and third argument to
94dnl specify the minimum and maximum versions to check for. This works
95dnl in a naive way by appending the major and minor release numbers to
96dnl the binary name. By default, this will first check for a binary
97dnl called "python" and then from there it will check for version-
98dnl specific binaries (ie "python3", "python2.7") in decending version
99dnl order. Thus, the highest version binary will be found first.
100dnl----
101dnl
102dnl PC_PROG_PYTHON
103
e342891a
BI
104
105dnl--PC_PYTHON_PROG_PYTHON_CONFIG-------------------------------------
106dnl In order to use some of the other macros, you also need the
107dnl python-config command, which will fall subject to the same problem
108dnl of python3-config being preferred to python2-config. This macro
109dnl will be automatically included if you use on of the macros that
110dnl depends on it, so you normally don't have to call it. However, if
111dnl you require a specific version, you can do something like the
112dnl following example.
113dnl----
114dnl
115PC_PYTHON_PROG_PYTHON_CONFIG([python2-config])
116if [[ "x$PYTHON_CONFIG" == "x" ]]; then
117 PC_PYTHON_PROG_PYTHON_CONFIG([$PYTHON-config])
118fi
119
120dnl----
121dnl With the following set of macros, we implement an option
122dnl "--with-virtualenv", which the user can pass to the configure
123dnl script in order to install to a Virtualenv (AC_ARG_WITH). If the
124dnl option is specified by the user, then we check if the program is
125dnl available, checking both for "virtualenv" and "virtualenv2"
126dnl (AC_CHECK_PROGS)
127dnl----
128dnl
129# Support installing to a virtualenv via the --with-virtualenv
130# configure flag
131AC_ARG_WITH([virtualenv],
a9dc855a 132 [AS_HELP_STRING([--with-virtualenv], [install to a Python virtualenv])],
e342891a 133 [],
a9dc855a 134 [with_virtualenv=no])
e342891a
BI
135AS_IF([test "x$with_virtualenv" != xno],
136 AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
137 AS_IF([test "x$VIRTUALENV" = xno],
138 [AC_MSG_FAILURE(
139 [--with-virtualenv given but virtualenv could not be found])]),
140 AC_SUBST([VIRTUALENV], [no]))
141AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])
142
143dnl----
144dnl If the program uses sphinx-build to build documentation, uncomment
145dnl this to create a SPHINXBUILD variable in the Makefile pointing to
146dnl the program. Thus, the user would specify
147dnl SPHINXBUILD=/path/to/sphinx-build as an argument to the configure
148dnl script. Since building the documentation should be optional, just
149dnl print a warning. If the program uses some other documentation
150dnl system, you can do something similar with it.
151dnl----
152dnl
153# Check for sphinx-build
154AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [no])
155AS_IF([test "x$SPHINXBUILD" = xno],
156 AC_MSG_WARN(sphinx-build is required to build documentation))
157
158
159dnl----
160dnl These two are standard Autoconf macros which check for the
161dnl presence of some programs that we will use in the Makefile.
162dnl----
163dnl
164AC_PROG_MKDIR_P
165AC_PROG_INSTALL
166
167# Check for a supported database program
c62d1744 168AC_PATH_PROG([SQLITE], [sqlite3])
d57dd89e 169AC_PATH_PROG([POSTGRES], [psql])
c62d1744 170AS_IF([test "x$SQLITE" = x -a "x$POSTGRES" = "x"],
26da3271 171 [AC_MSG_ERROR([SQLite or PostgreSQL is required])])
e342891a 172
c62d1744 173
a9dc855a
CAW
174dnl#################################
175dnl Python installation properties #
176dnl#################################
177dnl
178dnl In this section, we test for various aspects of the Python
179dnl installation on the user's computer.
180
181dnl--PC_PYTHON_VERIFY_VERSION & PC_PYTHON_CHECK_VERSION----------------
182dnl PC_PYTHON_VERIFY_VERSION is used to check if the version of the
183dnl discovered Python binary meets some requirement. The first argument
184dnl should be a Python-compatible numerical comparison operator (i.e.
185dnl "==", "<", ">=", etc.). The second argument should be the version to
186dnl test against. Finally, you may optionally provide actions to take if
187dnl it does (3rd argument) or if it does not (4th argument) meet the
188dnl requirement.
189dnl
190dnl PC_PYTHON_CHECK_VERSION simply fetches the version number of the
191dnl Python interpreter stored in the PYTHON variable
192dnl----
193dnl
194dnl PC_PYTHON_VERIFY_VERSION([>=], [2.7.1], [AC_MSG_RESULT([yes])],
195dnl AC_MSG_FAILURE(Python 2 (python_min_ver+) is required))
196
197
198dnl--PC_PYTHON_CHECK_PREFIX--------------------------------------------
199dnl This macro finds out what Python thinks is the PREFIX
200dnl (i.e. /usr) and stores it in PYTHON_PREFIX. You probably shouldn't
201dnl use this and you should just stick to $prefix, but here it is
202dnl anyway.
203dnl----
204dnl
205dnl PC_PYTHON_CHECK_PREFIX
206
207
208dnl--PC_PYTHON_CHECK_EXEC_PREFIX---------------------------------------
209dnl The same as above but for $exec-prefix
210dnl----
211dnl
212dnl PC_PYTHON_CHECK_EXEC_PREFIX
213
214
215dnl--PC_PYTHON_CHECK_PLATFORM------------------------------------------
216dnl This macro checks what platform Python thinks this is (ie
217dnl "linux2") and stores it in PYTHON_PLATFORM
218dnl----
219dnl
220dnl PC_PYTHON_CHECK_PLATFORM
221
222
223dnl--PC_PYTHON_CHECK_SITE_DIR------------------------------------------
224dnl This checks where Python packages are installed (usually
225dnl /usr/lib/pythonX.Y/site-packages) and stores it in the variable
226dnl pythondir.
227dnl----
228dnl
229dnl PC_PYTHON_CHECK_SITE_DIR
230
231
e342891a
BI
232dnl--PC_PYTHON_SITE_PACKAGE_DIR---------------------------------------
233dnl This uses PYTHON_SITE_DIR to construct a directory for this
234dnl project (ie $PYTHON_SITE_DIR/project_name) and stores it in
235dnl pkgpythondir. This value is used by Automake for installing Python
236dnl scripts. By default, this begins with $pythondir, unexpanded, to
237dnl provide compatibility with GNU Makefile specifications, allowing
238dnl the user to change the prefix from the commandline.
239dnl----
240dnl
241PC_PYTHON_SITE_PACKAGE_DIR
242
a9dc855a
CAW
243
244dnl--PC_PYTHON_CHECK_EXEC_DIR------------------------------------------
245dnl Same as PC_PYTHON_CHECK_SITE_DIR but for $exec-prefix. Stored in
246dnl pyexecdir
247dnl----
248dnl
249dnl PC_PYTHON_CHECK_EXEC_DIR
250
e342891a
BI
251dnl--PC_PYTHON_EXEC_PACKAGE_DIR----------------------------------------
252dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
253dnl pkgpyexecdir
254dnl----
255dnl
256PC_PYTHON_EXEC_PACKAGE_DIR
257
258
259dnl###############################
260dnl Checking Python capabilities #
261dnl###############################
262
263dnl--PC_PYTHON_CHECK_MODULE([PYTHON-MODULE], [ACTION-IF-PRESENT],
264dnl [ACTION-IF-ABSENT])
265dnl This macro lets you check if a given Python module exists on the
266dnl system.
267dnl----
268dnl
269dnl PC_PYTHON_CHECK_MODULE([foo])
270
a9dc855a 271
e342891a
BI
272# Check for python-lxml module
273PC_PYTHON_CHECK_MODULE([lxml], [],
274 [AC_MSG_ERROR([python-lxml is required])])
275
276# Check for the Python Imaging Library
277PC_PYTHON_CHECK_MODULE([Image], [],
278 [AC_MSG_ERROR([Python Imaging Library is required])])
279
280
a9dc855a
CAW
281dnl--PC_PYTHON_CHECK_FUNC([PYTHON-MODULE], [FUNCTION], [ARGS],
282dnl [ACTION-IF-SUCCESSFUL], [ACTION-IF-FAIL])
283dnl
284dnl This macro lets you test if a given function, possibly contained
285dnl in a given module, exists. If any exception is encountered when
286dnl calling this function, the check will fail.
287dnl----
288dnl
289dnl # test if Python library foo can do bar()
290dnl PC_PYTHON_CHECK_FUNC([foo], [bar])
291
292
293dnl Advanced notes:
294dnl m4/python.m4 implements Python as a language in Autoconf. This
295dnl means that you can use all the usual AC_LANG_* macros with Python
296dnl and it will behave as expected. In particular, this means that you
297dnl can run arbitrary Python code. For example:
298dnl
299dnl AC_LANG_PUSH(Python)[]
300dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([dnl
301dnl # some code here
302dnl import foo
303dnl ], [dnl
304dnl # some more code here
305dnl foo.bar()
306dnl ])], [ACTION-IF-SUCCESSFUL], [ACTION-IF-FAILED])
307dnl AC_LANG_POP(Python)[]
308dnl
309dnl As usual, AC_LANG_PROGRAM takes two arguments, PROLOG code and
310dnl MAIN code. The PROLOG code goes verbatim at the top of the file,
311dnl while the MAIN code is embedded in an if __name__ == "__main__":
312dnl block. Python's indentation rules complicate things, however. In
313dnl particular, you must be sure that all of the code in MAIN is
314dnl indented once by default. PROLOG code does not require this.
315
316
317dnl##################################
318dnl Python module build environment #
319dnl##################################
320dnl
321dnl Here we check for necessary information for building Python modules
322dnl written in C
323
324dnl--PC_PYTHON_CHECK_INCLUDES------------------------------------------
325dnl This macro figures out the include flags necessary for loading the
326dnl Python headers (ie -I/usr/lib/python). The results are stored in
327dnl PYTHON_INCLUDES
328dnl----
329dnl
330dnl PC_PYTHON_CHECK_INCLUDES
331
332
333dnl--PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])--
334dnl Using the information found from PC_PYTHON_CHECK_INCLUDES, check
335dnl to make sure that Python.h can be loaded. Note that if you use
336dnl this, you don't strictly need to also include
337dnl PC_PYTHON_CHECK_INCLUDES.
338dnl----
339dnl
340dnl PC_PYTHON_CHECK_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
341
342
343dnl--PC_PYTHON_CHECK_LIBS----------------------------------------------
344dnl This checks what LIBS flags are necessary to use the Python
345dnl libraries (ie -lpython). The results are stored in PYTHON_LIBS
346dnl----
347dnl
348dnl PC_PYTHON_CHECK_LIBS
349
350
351dnl--PC_PYTHON_TEST_LIBS([FUNCTION-TO-TEST], [ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
352dnl This checks whether the LIBS flag for libpython discovered with
353dnl PC_PYTHON_CHECK_LIBS is loadable and if a given function can be
354dnl found in the library. You may use this to test for the presence of
355dnl features in the library.
356dnl----
357dnl
358dnl PC_PYTHON_TEST_LIBS([PyObject_Print],,
359dnl [AC_MSG_ERROR(The Python library could not be loaded)])
360dnl # Add PYTHON_LIBS to LIBS
361dnl LIBS="$LIBS $PYTHON_LIBS"
362
363
364dnl--PC_PYTHON_CHECK_CFLAGS--------------------------------------------
365dnl This macro checks what Python thinks are the proper CFLAGS to
366dnl use and stores them in PYTHON_CFLAGS. Note that this info is only
367dnl available for Python versions which include a python-config tool
368dnl (2.5+).
369dnl----
370dnl
371dnl PC_PYTHON_CHECK_CFLAGS
372dnl # Add PYTHON_CFLAGS to CFLAGS
373dnl CFLAGS="$CFLAGS $PYTHON_CFLAGS"
374
375
376dnl--PC_PYTHON_CHECK_LDFLAGS-------------------------------------------
377dnl The same as above but for LDFLAGS
378dnl----
379dnl
380dnl PC_PYTHON_CHECK_LDFLAGS
381dnl # Add PYTHON_LDFLAGS to LDFLAGS
382dnl LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
383
384
385dnl--PC_PYTHON_CHECK_EXTENSION_SUFFIX----------------------------------
386dnl This checks for what Python expects the suffix of extension
387dnl modules to be (i.e. .cpython-32mu.so) and stores it in
388dnl PYTHON_EXTENSION SUFFIX. This information is only available for
389dnl Python 3+
390dnl----
391dnl
392dnl PC_PYTHON_CHECK_EXTENSION_SUFFIX
393
394
395dnl--PC_PYTHON_CHECK_ABI_FLAGS----------------------------------------
396dnl This checks for the ABI flags used by Python (i.e. "mu") and
397dnl stores it in PYTHON_ABI_FLAGS. This information is only available
398dnl for Python 3+
399dnl----
400dnl
401dnl PC_PYTHON_CHECK_ABI_FLAGS
402
403
e342891a
BI
404dnl#########
405dnl Finish #
406dnl#########
407
408dnl Define the files to be configured
00ed01b7 409AC_CONFIG_FILES([Makefile])
e342891a
BI
410dnl Generate config.status
411AC_OUTPUT