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