|
|
1 |
# =========================================================================== |
|
|
2 |
# http://autoconf-archive.cryp.to/ax_with_prog.html |
|
|
3 |
# =========================================================================== |
|
|
4 |
# |
|
|
5 |
# SYNOPSIS |
|
|
6 |
# |
|
|
7 |
# AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH]) |
|
|
8 |
# |
|
|
9 |
# DESCRIPTION |
|
|
10 |
# |
|
|
11 |
# Locates an installed program binary, placing the result in the precious |
|
|
12 |
# variable VARIABLE. Accepts a present VARIABLE, then --with-program, and |
|
|
13 |
# failing that searches for program in the given path (which defaults to |
|
|
14 |
# the system path). If program is found, VARIABLE is set to the full path |
|
|
15 |
# of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND |
|
|
16 |
# if provided, unchanged otherwise. |
|
|
17 |
# |
|
|
18 |
# A typical example could be the following one: |
|
|
19 |
# |
|
|
20 |
# AX_WITH_PROG(PERL,perl) |
|
|
21 |
# |
|
|
22 |
# NOTE: This macro is based upon the original AX_WITH_PYTHON macro from |
|
|
23 |
# Dustin J. Mitchell <dustin@cs.uchicago.edu>. |
|
|
24 |
# |
|
|
25 |
# LAST MODIFICATION |
|
|
26 |
# |
|
|
27 |
# 2008-05-05 |
|
|
28 |
# |
|
|
29 |
# COPYLEFT |
|
|
30 |
# |
|
|
31 |
# Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net> |
|
|
32 |
# Copyright (c) 2008 Dustin J. Mitchell <dustin@cs.uchicago.edu> |
|
|
33 |
# |
|
|
34 |
# Copying and distribution of this file, with or without modification, are |
|
|
35 |
# permitted in any medium without royalty provided the copyright notice |
|
|
36 |
# and this notice are preserved. |
|
|
37 |
|
|
|
38 |
AC_DEFUN([AX_WITH_PROG],[ |
|
|
39 |
AC_PREREQ([2.61]) |
|
|
40 |
|
|
|
41 |
pushdef([VARIABLE],$1) |
|
|
42 |
pushdef([EXECUTABLE],$2) |
|
|
43 |
pushdef([VALUE_IF_NOT_FOUND],$3) |
|
|
44 |
pushdef([PATH_PROG],$4) |
|
|
45 |
|
|
|
46 |
AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable) |
|
|
47 |
|
|
|
48 |
AS_IF(test -z "$VARIABLE",[ |
|
|
49 |
AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided) |
|
|
50 |
AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[[PATH]]]]],absolute path to EXECUTABLE executable), [ |
|
|
51 |
AS_IF([test "$withval" != "yes"],[ |
|
|
52 |
VARIABLE="$withval" |
|
|
53 |
AC_MSG_RESULT($VARIABLE) |
|
|
54 |
],[ |
|
|
55 |
VARIABLE="" |
|
|
56 |
AC_MSG_RESULT([no]) |
|
|
57 |
]) |
|
|
58 |
],[ |
|
|
59 |
AC_MSG_RESULT([no]) |
|
|
60 |
]) |
|
|
61 |
|
|
|
62 |
AS_IF(test -z "$VARIABLE",[ |
|
|
63 |
AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) |
|
|
64 |
]) |
|
|
65 |
]) |
|
|
66 |
|
|
|
67 |
popdef([PATH_PROG]) |
|
|
68 |
popdef([VALUE_IF_NOT_FOUND]) |
|
|
69 |
popdef([EXECUTABLE]) |
|
|
70 |
popdef([VARIABLE]) |
|
|
71 |
]) |
|
|
72 |
|
|
|
73 |
# =========================================================================== |
|
|
74 |
# http://www.nongnu.org/autoconf-archive/ax_python_devel.html |
|
|
75 |
# =========================================================================== |
|
|
76 |
# |
|
|
77 |
# SYNOPSIS |
|
|
78 |
# |
|
|
79 |
# AX_PYTHON_DEVEL([version]) |
|
|
80 |
# |
|
|
81 |
# DESCRIPTION |
|
|
82 |
# |
|
|
83 |
# Note: Defines as a precious variable "PYTHON_VERSION". Don't override it |
|
|
84 |
# in your configure.ac. |
|
|
85 |
# |
|
|
86 |
# This macro checks for Python and tries to get the include path to |
|
|
87 |
# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) |
|
|
88 |
# output variables. It also exports $(PYTHON_EXTRA_LIBS) and |
|
|
89 |
# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. |
|
|
90 |
# |
|
|
91 |
# You can search for some particular version of Python by passing a |
|
|
92 |
# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please |
|
|
93 |
# note that you *have* to pass also an operator along with the version to |
|
|
94 |
# match, and pay special attention to the single quotes surrounding the |
|
|
95 |
# version number. Don't use "PYTHON_VERSION" for this: that environment |
|
|
96 |
# variable is declared as precious and thus reserved for the end-user. |
|
|
97 |
# |
|
|
98 |
# This macro should work for all versions of Python >= 2.1.0. As an end |
|
|
99 |
# user, you can disable the check for the python version by setting the |
|
|
100 |
# PYTHON_NOVERSIONCHECK environment variable to something else than the |
|
|
101 |
# empty string. |
|
|
102 |
# |
|
|
103 |
# If you need to use this macro for an older Python version, please |
|
|
104 |
# contact the authors. We're always open for feedback. |
|
|
105 |
# |
|
|
106 |
# LICENSE |
|
|
107 |
# |
|
|
108 |
# Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de> |
|
|
109 |
# Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca> |
|
|
110 |
# Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net> |
|
|
111 |
# Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za> |
|
|
112 |
# Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org> |
|
|
113 |
# Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org> |
|
|
114 |
# |
|
|
115 |
# This program is free software: you can redistribute it and/or modify it |
|
|
116 |
# under the terms of the GNU General Public License as published by the |
|
|
117 |
# Free Software Foundation, either version 3 of the License, or (at your |
|
|
118 |
# option) any later version. |
|
|
119 |
# |
|
|
120 |
# This program is distributed in the hope that it will be useful, but |
|
|
121 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
122 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
|
123 |
# Public License for more details. |
|
|
124 |
# |
|
|
125 |
# You should have received a copy of the GNU General Public License along |
|
|
126 |
# with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
127 |
# |
|
|
128 |
# As a special exception, the respective Autoconf Macro's copyright owner |
|
|
129 |
# gives unlimited permission to copy, distribute and modify the configure |
|
|
130 |
# scripts that are the output of Autoconf when processing the Macro. You |
|
|
131 |
# need not follow the terms of the GNU General Public License when using |
|
|
132 |
# or distributing such scripts, even though portions of the text of the |
|
|
133 |
# Macro appear in them. The GNU General Public License (GPL) does govern |
|
|
134 |
# all other use of the material that constitutes the Autoconf Macro. |
|
|
135 |
# |
|
|
136 |
# This special exception to the GPL applies to versions of the Autoconf |
|
|
137 |
# Macro released by the Autoconf Archive. When you make and distribute a |
|
|
138 |
# modified version of the Autoconf Macro, you may extend this special |
|
|
139 |
# exception to the GPL to apply to your modified version as well. |
|
|
140 |
|
|
|
141 |
AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) |
|
|
142 |
AC_DEFUN([AX_PYTHON_DEVEL],[ |
|
|
143 |
# |
|
|
144 |
# Allow the use of a (user set) custom python version |
|
|
145 |
# |
|
|
146 |
AC_ARG_VAR([PYTHON_VERSION],[The installed Python |
|
|
147 |
version to use, for example '2.3'. This string |
|
|
148 |
will be appended to the Python interpreter |
|
|
149 |
canonical name.]) |
|
|
150 |
|
|
|
151 |
AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) |
|
|
152 |
if test -z "$PYTHON"; then |
|
|
153 |
AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) |
|
|
154 |
PYTHON_VERSION="" |
|
|
155 |
fi |
|
|
156 |
|
|
|
157 |
# |
|
|
158 |
# Check for a version of Python >= 2.1.0 |
|
|
159 |
# |
|
|
160 |
AC_MSG_CHECKING([for a version of Python >= '2.1.0']) |
|
|
161 |
ac_supports_python_ver=`$PYTHON -c "import sys; \ |
|
|
162 |
ver = sys.version.split ()[[0]]; \ |
|
|
163 |
print (ver >= '2.1.0')"` |
|
|
164 |
if test "$ac_supports_python_ver" != "True"; then |
|
|
165 |
if test -z "$PYTHON_NOVERSIONCHECK"; then |
|
|
166 |
AC_MSG_RESULT([no]) |
|
|
167 |
AC_MSG_FAILURE([ |
|
|
168 |
This version of the AC@&t@_PYTHON_DEVEL macro |
|
|
169 |
doesn't work properly with versions of Python before |
|
|
170 |
2.1.0. You may need to re-run configure, setting the |
|
|
171 |
variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, |
|
|
172 |
PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. |
|
|
173 |
Moreover, to disable this check, set PYTHON_NOVERSIONCHECK |
|
|
174 |
to something else than an empty string. |
|
|
175 |
]) |
|
|
176 |
else |
|
|
177 |
AC_MSG_RESULT([skip at user request]) |
|
|
178 |
fi |
|
|
179 |
else |
|
|
180 |
AC_MSG_RESULT([yes]) |
|
|
181 |
fi |
|
|
182 |
|
|
|
183 |
# |
|
|
184 |
# if the macro parameter ``version'' is set, honour it |
|
|
185 |
# |
|
|
186 |
if test -n "$1"; then |
|
|
187 |
AC_MSG_CHECKING([for a version of Python $1]) |
|
|
188 |
ac_supports_python_ver=`$PYTHON -c "import sys; \ |
|
|
189 |
ver = sys.version.split ()[[0]]; \ |
|
|
190 |
print (ver $1)"` |
|
|
191 |
if test "$ac_supports_python_ver" = "True"; then |
|
|
192 |
AC_MSG_RESULT([yes]) |
|
|
193 |
else |
|
|
194 |
AC_MSG_RESULT([no]) |
|
|
195 |
AC_MSG_ERROR([this package requires Python $1. |
|
|
196 |
If you have it installed, but it isn't the default Python |
|
|
197 |
interpreter in your system path, please pass the PYTHON_VERSION |
|
|
198 |
variable to configure. See ``configure --help'' for reference. |
|
|
199 |
]) |
|
|
200 |
PYTHON_VERSION="" |
|
|
201 |
fi |
|
|
202 |
fi |
|
|
203 |
|
|
|
204 |
# |
|
|
205 |
# Check if you have distutils, else fail |
|
|
206 |
# |
|
|
207 |
AC_MSG_CHECKING([for the distutils Python package]) |
|
|
208 |
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` |
|
|
209 |
if test -z "$ac_distutils_result"; then |
|
|
210 |
AC_MSG_RESULT([yes]) |
|
|
211 |
else |
|
|
212 |
AC_MSG_RESULT([no]) |
|
|
213 |
AC_MSG_ERROR([cannot import Python module "distutils". |
|
|
214 |
Please check your Python installation. The error was: |
|
|
215 |
$ac_distutils_result]) |
|
|
216 |
PYTHON_VERSION="" |
|
|
217 |
fi |
|
|
218 |
|
|
|
219 |
# |
|
|
220 |
# Check for Python include path |
|
|
221 |
# |
|
|
222 |
AC_MSG_CHECKING([for Python include path]) |
|
|
223 |
if test -z "$PYTHON_CPPFLAGS"; then |
|
|
224 |
python_path=`$PYTHON -c "import distutils.sysconfig; \ |
|
|
225 |
print (distutils.sysconfig.get_python_inc ());"` |
|
|
226 |
if test -n "${python_path}"; then |
|
|
227 |
python_path="-I$python_path" |
|
|
228 |
fi |
|
|
229 |
PYTHON_CPPFLAGS=$ |