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