3 dnl Copyright 2012, 2013 Brandon Invergo <brandon@invergo.net>
5 dnl Copying and distribution of this file, with or without modification,
6 dnl are permitted in any medium without royalty provided the copyright
7 dnl notice and this notice are preserved. This file is offered as-is,
8 dnl without any warranty.
14 dnl This is a basic Autoconf configure.ac file for Python-based
15 dnl projects. It is not intended to be used as-is, but rather to be
16 dnl modified to the specific needs of the project.
18 dnl Lines prefixed with "dnl" are comments that are automatically
19 dnl removed by Autoconf/M4, thus they will not appear in the generated
20 dnl configure script (see the M4 documentation for more information).
21 dnl Such comments are used in this file to communicate information to
22 dnl you, the developer. In some cases, the comments contain extra
23 dnl macros that you might consider including in your configure script.
24 dnl If you wish to include them, simply remove the "dnl" from the
25 dnl beginning of the line.
27 dnl Lines prefixed with "#" are comments that will appear in the
28 dnl generated configure script. These comments are thus used to clarify
29 dnl to the user what is happening in that script
31 dnl Wherever pyconfigure-specific macros are used, extra comments are
32 dnl included to describe the macros.
34 dnl######################
35 dnl Package Information #
36 dnl######################
39 dnl Initialize Autoconf with the package metadata
40 dnl The arguments have been set via the project's PKG-INFO file
41 dnl and correspond to:
43 dnl 1) package name (i.e. foo)
44 dnl 2) package version (i.e. 1.2)
45 dnl 3) bug/info/project email address (i.e. bug-foo@gnu.org)
48 AC_INIT([mediagoblin], [0.4.0.dev], [cwebber@gnu.org])
51 dnl Load macros from the m4/ directory. If you plan to write new
52 dnl macros, put them in files in this directory.
55 AC_CONFIG_MACRO_DIR([m4])
58 # The default prefix should be changed from /usr/local. Set it, as in
59 # the documentation, to /srv/mediagoblin.example.org/mediagoblin/
60 AC_PREFIX_DEFAULT([`pwd`])
63 dnl###########################
64 dnl Program/command support #
65 dnl###########################
67 dnl In this section, we check for the presence of important commands
70 dnl--PC_INIT----------------------------------------------------------
71 dnl This is the only required macro. Its primary function is to find
72 dnl a Python interpreter that is compatible with the package and set
73 dnl the PYTHON variable to hold its path. It can optionally take
74 dnl arguments to specify minimum and/or maximum versions:
75 dnl PC_INIT: find an interpreter with a version between 2.0 and 3.3.99
76 dnl (in other words, up to and including any possible release
77 dnl in the 3.3 series)
78 dnl PC_INIT([MIN_VER], [MAX_VER]): Find an interpreter that is between
79 dnl the minimum and maximum version. If the min is in the 2.0
80 dnl series and the max is in the 3.0 series, non-existent
81 dnl releases (2.8 & 2.9) will be correctly skipped.
84 PC_INIT([2.6], [2.7.99])
86 dnl--PC_PYTHON_PROG_PYTHON_CONFIG-------------------------------------
87 dnl In order to use some of the other macros, you also need the
88 dnl python-config command, which will fall subject to the same problem
89 dnl of python3-config being preferred to python2-config. This macro
90 dnl will be automatically included if you use on of the macros that
91 dnl depends on it, so you normally don't have to call it. However, if
92 dnl you require a specific version, you can do something like the
93 dnl following example.
96 PC_PYTHON_PROG_PYTHON_CONFIG([python2-config])
97 if [[ "x$PYTHON_CONFIG" == "x" ]]; then
98 PC_PYTHON_PROG_PYTHON_CONFIG([$PYTHON-config])
102 dnl With the following set of macros, we implement an option
103 dnl "--with-virtualenv", which the user can pass to the configure
104 dnl script in order to install to a Virtualenv (AC_ARG_WITH). If the
105 dnl option is specified by the user, then we check if the program is
106 dnl available, checking both for "virtualenv" and "virtualenv2"
110 # Support installing to a virtualenv via the --with-virtualenv
112 AC_ARG_WITH([virtualenv],
113 [AS_HELP_STRING([--without-virtualenv], [install to a Python virtualenv])],
115 [with_virtualenv=yes])
116 AS_IF([test "x$with_virtualenv" != xno],
117 AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
118 AS_IF([test "x$VIRTUALENV" = xno],
120 [--with-virtualenv given but virtualenv could not be found])]),
121 AC_SUBST([VIRTUALENV], [no]))
122 AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])
125 dnl If the program uses sphinx-build to build documentation, uncomment
126 dnl this to create a SPHINXBUILD variable in the Makefile pointing to
127 dnl the program. Thus, the user would specify
128 dnl SPHINXBUILD=/path/to/sphinx-build as an argument to the configure
129 dnl script. Since building the documentation should be optional, just
130 dnl print a warning. If the program uses some other documentation
131 dnl system, you can do something similar with it.
134 # Check for sphinx-build
135 AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [no])
136 AS_IF([test "x$SPHINXBUILD" = xno],
137 AC_MSG_WARN(sphinx-build is required to build documentation))
141 dnl These two are standard Autoconf macros which check for the
142 dnl presence of some programs that we will use in the Makefile.
148 # Check for a supported database program
149 AC_PATH_PROG([SQLITE], [sqlite3])
150 AC_PATH_PROG([POSTGRES], [psql])
151 AS_IF([test "x$SQLITE" = x -a "x$POSTGRES" = "x"],
152 [AC_MSG_ERROR([SQLite or PostgreSQL is required])])
155 dnl--PC_PYTHON_SITE_PACKAGE_DIR---------------------------------------
156 dnl This uses PYTHON_SITE_DIR to construct a directory for this
157 dnl project (ie $PYTHON_SITE_DIR/project_name) and stores it in
158 dnl pkgpythondir. This value is used by Automake for installing Python
159 dnl scripts. By default, this begins with $pythondir, unexpanded, to
160 dnl provide compatibility with GNU Makefile specifications, allowing
161 dnl the user to change the prefix from the commandline.
164 PC_PYTHON_SITE_PACKAGE_DIR
166 dnl--PC_PYTHON_EXEC_PACKAGE_DIR----------------------------------------
167 dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
171 PC_PYTHON_EXEC_PACKAGE_DIR
174 dnl###############################
175 dnl Checking Python capabilities #
176 dnl###############################
178 dnl--PC_PYTHON_CHECK_MODULE([PYTHON-MODULE], [ACTION-IF-PRESENT],
179 dnl [ACTION-IF-ABSENT])
180 dnl This macro lets you check if a given Python module exists on the
184 dnl PC_PYTHON_CHECK_MODULE([foo])
186 # Check for python-lxml module
187 PC_PYTHON_CHECK_MODULE([lxml], [],
188 [AC_MSG_ERROR([python-lxml is required])])
190 # Check for the Python Imaging Library
191 PC_PYTHON_CHECK_MODULE([Image], [],
192 [AC_MSG_ERROR([Python Imaging Library is required])])
199 dnl Define the files to be configured
200 AC_CONFIG_FILES([Makefile])
201 dnl Generate config.status