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