add configure.ac
[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
50dnl----
51dnl Load macros from the m4/ directory. If you plan to write new
52dnl macros, put them in files in this directory.
53dnl----
54dnl
55AC_CONFIG_MACRO_DIR([m4])
56
57
58dnl###########################
59dnl Program/command support #
60dnl###########################
61dnl
62dnl In this section, we check for the presence of important commands
63dnl and programs.
64
65dnl--PC_INIT----------------------------------------------------------
66dnl This is the only required macro. Its primary function is to find
67dnl a Python interpreter that is compatible with the package and set
68dnl the PYTHON variable to hold its path. It can optionally take
69dnl arguments to specify minimum and/or maximum versions:
70dnl PC_INIT: find an interpreter with a version between 2.0 and 3.3.99
71dnl (in other words, up to and including any possible release
72dnl in the 3.3 series)
73dnl PC_INIT([MIN_VER], [MAX_VER]): Find an interpreter that is between
74dnl the minimum and maximum version. If the min is in the 2.0
75dnl series and the max is in the 3.0 series, non-existent
76dnl releases (2.8 & 2.9) will be correctly skipped.
77dnl----
78dnl
79PC_INIT([2.6], [2.7.99])
80
81dnl--PC_PYTHON_PROG_PYTHON_CONFIG-------------------------------------
82dnl In order to use some of the other macros, you also need the
83dnl python-config command, which will fall subject to the same problem
84dnl of python3-config being preferred to python2-config. This macro
85dnl will be automatically included if you use on of the macros that
86dnl depends on it, so you normally don't have to call it. However, if
87dnl you require a specific version, you can do something like the
88dnl following example.
89dnl----
90dnl
91PC_PYTHON_PROG_PYTHON_CONFIG([python2-config])
92if [[ "x$PYTHON_CONFIG" == "x" ]]; then
93 PC_PYTHON_PROG_PYTHON_CONFIG([$PYTHON-config])
94fi
95
96dnl----
97dnl With the following set of macros, we implement an option
98dnl "--with-virtualenv", which the user can pass to the configure
99dnl script in order to install to a Virtualenv (AC_ARG_WITH). If the
100dnl option is specified by the user, then we check if the program is
101dnl available, checking both for "virtualenv" and "virtualenv2"
102dnl (AC_CHECK_PROGS)
103dnl----
104dnl
105# Support installing to a virtualenv via the --with-virtualenv
106# configure flag
107AC_ARG_WITH([virtualenv],
108 [AS_HELP_STRING([--with-virtualenv], [install to a Python virtualenv])],
109 [],
110 [with_virtualenv=no])
111AS_IF([test "x$with_virtualenv" != xno],
112 AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
113 AS_IF([test "x$VIRTUALENV" = xno],
114 [AC_MSG_FAILURE(
115 [--with-virtualenv given but virtualenv could not be found])]),
116 AC_SUBST([VIRTUALENV], [no]))
117AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])
118
119dnl----
120dnl If the program uses sphinx-build to build documentation, uncomment
121dnl this to create a SPHINXBUILD variable in the Makefile pointing to
122dnl the program. Thus, the user would specify
123dnl SPHINXBUILD=/path/to/sphinx-build as an argument to the configure
124dnl script. Since building the documentation should be optional, just
125dnl print a warning. If the program uses some other documentation
126dnl system, you can do something similar with it.
127dnl----
128dnl
129# Check for sphinx-build
130AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [no])
131AS_IF([test "x$SPHINXBUILD" = xno],
132 AC_MSG_WARN(sphinx-build is required to build documentation))
133
134
135dnl----
136dnl These two are standard Autoconf macros which check for the
137dnl presence of some programs that we will use in the Makefile.
138dnl----
139dnl
140AC_PROG_MKDIR_P
141AC_PROG_INSTALL
142
143# Check for a supported database program
144AC_PATH_PROG([SQLITE], [sqlite3])
145AC_PATH_PROG([POSTGRES], [postgres])
146if [[ "x$SQLITE" = "x" && "x$POSTGRES" = "x" ]]; then
147 AC_MSG_ERROR([SQLite or PostgreSQL is required])
148fi
149
150dnl--PC_PYTHON_SITE_PACKAGE_DIR---------------------------------------
151dnl This uses PYTHON_SITE_DIR to construct a directory for this
152dnl project (ie $PYTHON_SITE_DIR/project_name) and stores it in
153dnl pkgpythondir. This value is used by Automake for installing Python
154dnl scripts. By default, this begins with $pythondir, unexpanded, to
155dnl provide compatibility with GNU Makefile specifications, allowing
156dnl the user to change the prefix from the commandline.
157dnl----
158dnl
159PC_PYTHON_SITE_PACKAGE_DIR
160
161dnl--PC_PYTHON_EXEC_PACKAGE_DIR----------------------------------------
162dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
163dnl pkgpyexecdir
164dnl----
165dnl
166PC_PYTHON_EXEC_PACKAGE_DIR
167
168
169dnl###############################
170dnl Checking Python capabilities #
171dnl###############################
172
173dnl--PC_PYTHON_CHECK_MODULE([PYTHON-MODULE], [ACTION-IF-PRESENT],
174dnl [ACTION-IF-ABSENT])
175dnl This macro lets you check if a given Python module exists on the
176dnl system.
177dnl----
178dnl
179dnl PC_PYTHON_CHECK_MODULE([foo])
180
181# Check for python-lxml module
182PC_PYTHON_CHECK_MODULE([lxml], [],
183 [AC_MSG_ERROR([python-lxml is required])])
184
185# Check for the Python Imaging Library
186PC_PYTHON_CHECK_MODULE([Image], [],
187 [AC_MSG_ERROR([Python Imaging Library is required])])
188
189
190dnl#########
191dnl Finish #
192dnl#########
193
194dnl Define the files to be configured
195AC_CONFIG_FILES([Makefile setup.py])
196dnl Generate config.status
197AC_OUTPUT