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