Merge remote-tracking branch 'refs/remotes/tsyesika/master'
[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 # 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`])
61
62
63 dnl###########################
64 dnl Program/command support #
65 dnl###########################
66 dnl
67 dnl In this section, we check for the presence of important commands
68 dnl and programs.
69
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.
82 dnl----
83 dnl
84 PC_INIT([2.6], [2.7.99])
85
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.
94 dnl----
95 dnl
96 PC_PYTHON_PROG_PYTHON_CONFIG([python2-config])
97 if [[ "x$PYTHON_CONFIG" == "x" ]]; then
98 PC_PYTHON_PROG_PYTHON_CONFIG([$PYTHON-config])
99 fi
100
101 dnl----
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"
107 dnl (AC_CHECK_PROGS)
108 dnl----
109 dnl
110 # Support installing to a virtualenv via the --with-virtualenv
111 # configure flag
112 AC_ARG_WITH([virtualenv],
113 [AS_HELP_STRING([--without-virtualenv], [install to a Python virtualenv])],
114 [],
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],
119 [AC_MSG_FAILURE(
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])
123
124 dnl----
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.
132 dnl----
133 dnl
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))
138
139
140 dnl----
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.
143 dnl----
144 dnl
145 AC_PROG_MKDIR_P
146 AC_PROG_INSTALL
147
148 # Check for a supported database program
149 AC_PATH_PROG([SQLITE], [sqlite3])
150 AC_PATH_PROG([POSTGRES], [postgres])
151 AS_IF([test "x$SQLITE" = x -a "x$POSTGRES" = "x"],
152 [AC_MSG_ERROR([SQLite or PostgreSQL is required])])
153
154
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.
162 dnl----
163 dnl
164 PC_PYTHON_SITE_PACKAGE_DIR
165
166 dnl--PC_PYTHON_EXEC_PACKAGE_DIR----------------------------------------
167 dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
168 dnl pkgpyexecdir
169 dnl----
170 dnl
171 PC_PYTHON_EXEC_PACKAGE_DIR
172
173
174 dnl###############################
175 dnl Checking Python capabilities #
176 dnl###############################
177
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
181 dnl system.
182 dnl----
183 dnl
184 dnl PC_PYTHON_CHECK_MODULE([foo])
185
186 # Check for python-lxml module
187 PC_PYTHON_CHECK_MODULE([lxml], [],
188 [AC_MSG_ERROR([python-lxml is required])])
189
190 # Check for the Python Imaging Library
191 PC_PYTHON_CHECK_MODULE([Image], [],
192 [AC_MSG_ERROR([Python Imaging Library is required])])
193
194
195 dnl#########
196 dnl Finish #
197 dnl#########
198
199 dnl Define the files to be configured
200 AC_CONFIG_FILES([Makefile])
201 dnl Generate config.status
202 AC_OUTPUT