Skip to content

Commit ce08812

Browse files
author
Sebastiano Merlino
committed
Adjusted installation path for python wrappers auto-generated files
1 parent 9c029ed commit ce08812

File tree

7 files changed

+222
-10
lines changed

7 files changed

+222
-10
lines changed

Makefile.am

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@
1818

1919
# not a GNU package. You can remove this line, if
2020
# have all needed files, that a GNU package needs
21+
22+
LIBTOOL_DEPS = @LIBTOOL_DEPS@
23+
2124
AUTOMAKE_OPTIONS = foreign 1.4
25+
ACLOCAL_AMFLAGS = -I m4
2226

2327
SUBDIRS = src $(PYTHON_DIR) $(JAVA_DIR) $(PHP_DIR) $(LUA_DIR) $(PERL_DIR) $(RUBY_DIR) $(GUILE_DIR)
2428
DIST_SUBDIRS = src $(PYTHON_DIR) $(JAVA_DIR) $(PHP_DIR) $(LUA_DIR) $(PERL_DIR) $(RUBY_DIR) $(GUILE_DIR)
25-
EXTRA_DIST = libhttpserver.pc.in $(DOXYFILE)
29+
EXTRA_DIST = libhttpserver.pc.in $(DOXYFILE) $(PYTHON_EXTRA) $(PHP_EXTRA) $(PERL_EXTRA)
2630

2731
pkgconfigdir = $(libdir)/pkgconfig
2832
pkgconfig_DATA = libhttpserver.pc
2933

3034
if PYTHON
3135
PYTHON_DIR = src/python
36+
PYTHON_EXTRA = src/python/libhttpserver_python.py
3237
endif
3338

3439
if JAVA
@@ -37,6 +42,7 @@ endif
3742

3843
if PHP
3944
PHP_DIR = src/php
45+
PHP_EXTRA = src/php/libhttpserver_php.php
4046
endif
4147

4248
if LUA
@@ -45,6 +51,7 @@ endif
4551

4652
if PERL
4753
PERL_DIR = src/perl
54+
PERL_EXTRA = src/php/libhttpserver_perl.pm
4855
endif
4956

5057
if RUBY
@@ -57,3 +64,12 @@ endif
5764

5865
include $(top_srcdir)/aminclude.am
5966
DOXYFILE = doxyconfig
67+
68+
# Update libtool, if needed.
69+
libtool: $(LIBTOOL_DEPS)
70+
$(SHELL) ./config.status --recheck
71+
72+
dist-hook:
73+
date >DIST_REVISION
74+
git branch -vv >>DIST_REVISION
75+
cp DIST_REVISION $(distdir)/

Makefile.cvs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
default: all
2020

2121
all:
22-
aclocal
22+
aclocal -I m4
2323
autoheader
2424
libtoolize --automake
2525
automake --add-missing

bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# License along with this library; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919

20-
aclocal
20+
aclocal -I m4
2121
autoheader
2222
libtoolize --automake
2323
automake --add-missing

configure.ac

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,38 @@ if test x$python = xtrue; then
171171
then
172172
AC_MSG_ERROR(python-config not found)
173173
fi
174+
AC_CHECK_PROG([PYTHONINT],[python],["yes"], ["no"])
175+
if test "$PYTHONINT" = "no"
176+
then
177+
AC_MSG_ERROR(python interpreter not found)
178+
fi
179+
180+
AM_PATH_PYTHON()
181+
if test -n "$PYTHON" ; then
182+
AC_MSG_CHECKING([$PYTHON include dir])
183+
if $PYTHON -c 'import distutils.sysconfig' 2>/dev/null ; then
184+
PYTHON_INC=`$PYTHON -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
185+
AC_SUBST(PYTHON_INC)
186+
else
187+
if test yes = "$with_python" ; then
188+
AC_MSG_ERROR([Could not import Python module distutils.sysconfig - you probably need to install a python-dev or python-devel package])
189+
else
190+
AC_MSG_WARN([Couldn not import Python module distutils.sysconfig - you probably do not have a python-dev or python-devel package installed])
191+
fi
192+
fi
193+
AC_MSG_RESULT([$PYTHON_INC])
194+
AC_MSG_CHECKING([for directory to install python bindings in])
195+
if test -z "$PYTHON_LIB" ; then
196+
PYTHON_LIB=`$PYTHON -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
197+
fi
198+
AC_MSG_RESULT([$PYTHON_LIB])
199+
AC_ARG_VAR(PYTHON_LIB, [Directory to install python bindings in])
200+
201+
AC_MSG_CHECKING([for python libraries to link against])
202+
PYTHON_LIBS=`$PYTHON -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'`
203+
AC_SUBST(PYTHON_LIBS)
204+
AC_MSG_RESULT([$PYTHON_LIBS])
205+
fi
174206
PYINCLUDES="`python-config --includes`"
175207
PYDEFINES="-DWITHPYTHON"
176208
PYLDFLAGS="$LDFLAGS -L`python-config --prefix`/lib"

m4/python.m4

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
## ------------------------ -*- Autoconf -*-
2+
## Python file handling
3+
## From Andrew Dalke
4+
## Updated by James Henstridge
5+
## ------------------------
6+
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
7+
# Free Software Foundation, Inc.
8+
#
9+
# This file is free software; the Free Software Foundation
10+
# gives unlimited permission to copy and/or distribute it,
11+
# with or without modifications, as long as this notice is preserved.
12+
13+
# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
14+
# ---------------------------------------------------------------------------
15+
# Adds support for distributing Python modules and packages. To
16+
# install modules, copy them to $(pythondir), using the python_PYTHON
17+
# automake variable. To install a package with the same name as the
18+
# automake package, install to $(pkgpythondir), or use the
19+
# pkgpython_PYTHON automake variable.
20+
#
21+
# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
22+
# locations to install python extension modules (shared libraries).
23+
# Another macro is required to find the appropriate flags to compile
24+
# extension modules.
25+
#
26+
# If your package is configured with a different prefix to python,
27+
# users will have to add the install directory to the PYTHONPATH
28+
# environment variable, or create a .pth file (see the python
29+
# documentation for details).
30+
#
31+
# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
32+
# cause an error if the version of python installed on the system
33+
# doesn't meet the requirement. MINIMUM-VERSION should consist of
34+
# numbers and dots only.
35+
AC_DEFUN([AM_PATH_PYTHON],
36+
[
37+
dnl Find a Python interpreter. Python versions prior to 1.5 are not
38+
dnl supported because the default installation locations changed from
39+
dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
40+
dnl in 1.5.
41+
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
42+
[python python2 python2.5 python2.4 python2.3 python2.2 dnl
43+
python2.1 python2.0 python1.6 python1.5])
44+
45+
m4_if([$1],[],[
46+
dnl No version check is needed.
47+
# Find any Python interpreter.
48+
if test -z "$PYTHON"; then
49+
AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
50+
fi
51+
am_display_PYTHON=python
52+
], [
53+
dnl A version check is needed.
54+
if test -n "$PYTHON"; then
55+
# If the user set $PYTHON, use it and don't search something else.
56+
AC_MSG_CHECKING([whether $PYTHON version >= $1])
57+
AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
58+
[AC_MSG_RESULT(yes)],
59+
[AC_MSG_ERROR(too old)])
60+
am_display_PYTHON=$PYTHON
61+
else
62+
# Otherwise, try each interpreter until we find one that satisfies
63+
# VERSION.
64+
AC_CACHE_CHECK([for a Python interpreter with version >= $1],
65+
[am_cv_pathless_PYTHON],[
66+
for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
67+
test "$am_cv_pathless_PYTHON" = none && break
68+
AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
69+
done])
70+
# Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
71+
if test "$am_cv_pathless_PYTHON" = none; then
72+
PYTHON=:
73+
else
74+
AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
75+
fi
76+
am_display_PYTHON=$am_cv_pathless_PYTHON
77+
fi
78+
])
79+
80+
if test "$PYTHON" = :; then
81+
dnl Run any user-specified action, or abort.
82+
m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
83+
else
84+
85+
dnl Query Python for its version number. Getting [:3] seems to be
86+
dnl the best way to do this; it's what "site.py" does in the standard
87+
dnl library.
88+
89+
AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
90+
[am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
91+
AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
92+
93+
dnl Use the values of $prefix and $exec_prefix for the corresponding
94+
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
95+
dnl distinct variables so they can be overridden if need be. However,
96+
dnl general consensus is that you shouldn't need this ability.
97+
98+
AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
99+
AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
100+
101+
dnl At times (like when building shared libraries) you may want
102+
dnl to know which OS platform Python thinks this is.
103+
104+
AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
105+
[am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
106+
AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
107+
108+
109+
dnl Set up 4 directories:
110+
111+
dnl pythondir -- where to install python scripts. This is the
112+
dnl site-packages directory, not the python standard library
113+
dnl directory like in previous automake betas. This behavior
114+
dnl is more consistent with lispdir.m4 for example.
115+
dnl Query distutils for this directory. distutils does not exist in
116+
dnl Python 1.5, so we fall back to the hardcoded directory if it
117+
dnl doesn't work.
118+
AC_CACHE_CHECK([for $am_display_PYTHON script directory],
119+
[am_cv_python_pythondir],
120+
[am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
121+
echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
122+
AC_SUBST([pythondir], [$am_cv_python_pythondir])
123+
124+
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
125+
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
126+
dnl more consistent with the rest of automake.
127+
128+
AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
129+
130+
dnl pyexecdir -- directory for installing python extension modules
131+
dnl (shared libraries)
132+
dnl Query distutils for this directory. distutils does not exist in
133+
dnl Python 1.5, so we fall back to the hardcoded directory if it
134+
dnl doesn't work.
135+
AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
136+
[am_cv_python_pyexecdir],
137+
[am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
138+
echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
139+
AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
140+
141+
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
142+
143+
AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
144+
145+
dnl Run any user-specified action.
146+
$2
147+
fi
148+
149+
])
150+
151+
152+
# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
153+
# ---------------------------------------------------------------------------
154+
# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
155+
# Run ACTION-IF-FALSE otherwise.
156+
# This test uses sys.hexversion instead of the string equivalent (first
157+
# word of sys.version), in order to cope with versions such as 2.2c1.
158+
# hexversion has been introduced in Python 1.5.2; it's probably not
159+
# worth to support older versions (1.5.1 was released on October 31, 1998).
160+
AC_DEFUN([AM_PYTHON_CHECK_VERSION],
161+
[prog="import sys, string
162+
# split strings by '.' and convert to numeric. Append some zeros
163+
# because we need at least 4 digits for the hex conversion.
164+
minver = map(int, string.split('$2', '.')) + [[0, 0, 0]]
165+
minverhex = 0
166+
for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]]
167+
sys.exit(sys.hexversion < minverhex)"
168+
AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])

src/Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ nobase_include_HEADERS = httpserver.h httpserver/Webserver.hpp httpserver/HttpUt
2525
AM_CXXFLAGS += -fPIC -Wall
2626
libhttpserver_la_LIBADD = -lmicrohttpd
2727
libhttpserver_la_LDFLAGS =
28-
29-

src/python/Makefile.am

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818

1919
INCLUDES = -I../ -I$(top_srcdir)/src -I$(top_srcdir)/src/httpserver $(PYINCLUDES)
2020
AM_CPPFLAGS=$(PYDEFINES)
21+
pythonSitePackagesdirdir = $(pythondir)
2122
METASOURCES = AUTO
22-
lib_LTLIBRARIES = _libhttpserver_python.la
23+
pythonSitePackagesdir_LTLIBRARIES = _libhttpserver_python.la
24+
pythonSitePackagesdir_SCRIPTS = libhttpserver_python.py
2325
_libhttpserver_python_la_LDFLAGS = -module $(PYLDFLAGS)
2426
_libhttpserver_python_la_LIBADD = -lmicrohttpd $(PYLIBS)
2527
_libhttpserver_python_la_SOURCES = WebserverWrap.cpp $(top_srcdir)/src/Webserver.cpp $(top_srcdir)/src/HttpUtils.cpp $(top_srcdir)/src/HttpEndpoint.cpp $(top_srcdir)/src/HttpResource.cpp $(top_srcdir)/src/HttpRequest.cpp $(top_srcdir)/src/HttpResponse.cpp $(top_srcdir)/src/string_utilities.cpp
2628

27-
pydir=$(datadir)/python
28-
29-
py_DATA=libhttpserver_python.py
30-
3129
language=python
3230
swigoptions=-Wall
3331
@PYTHON_AUTOGENERATION@

0 commit comments

Comments
 (0)