speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Construct Makefiles for the Python library with automake.


From: Christopher Brannon
Subject: [PATCH] Construct Makefiles for the Python library with automake.
Date: Fri, 30 Jul 2010 23:21:20 -0500

automake provides support for building and installing Python packages.
As of this commit, we use it, instead of calling setup.py in
src/python/Makefile.in.

This change comes from OpenTTS.  Several of us were responsible:
Chris Brannon, William Hubbs, and Rui Batista.
---
 configure.in                          |   17 ++++++++++-
 src/Makefile.am                       |    5 +--
 src/python/Makefile.am                |    2 +
 src/python/Makefile.in                |   50 ---------------------------------
 src/python/setup.py                   |   12 --------
 src/python/speechd/Makefile.am        |   21 ++++++++++++++
 src/python/speechd/paths.py.in        |    1 +
 src/python/speechd_config/Makefile.am |   27 +++++++++++++++++
 src/python/speechd_config/paths.py.in |    4 ++
 9 files changed, 71 insertions(+), 68 deletions(-)
 create mode 100644 src/python/Makefile.am
 delete mode 100644 src/python/Makefile.in
 delete mode 100755 src/python/setup.py
 create mode 100644 src/python/speechd/Makefile.am
 create mode 100644 src/python/speechd/paths.py.in
 create mode 100644 src/python/speechd_config/Makefile.am
 create mode 100644 src/python/speechd_config/paths.py.in

diff --git a/configure.in b/configure.in
index fa0ce93..351fa5f 100644
--- a/configure.in
+++ b/configure.in
@@ -12,6 +12,11 @@ AM_INIT_AUTOMAKE("speech-dispatcher", "`cat version.sh|grep 
'^VERSION'|awk -F= '
 
 AM_CONFIG_HEADER(config.h)
 
+# Command-line arguments.
+AC_ARG_ENABLE([python],
+       [AS_HELP_STRING([--disable-python], [do not install python bindings])],
+       [],
+       [enable_python=check])
 
 dnl Checks for header files.
 AC_HEADER_STDC
@@ -21,6 +26,15 @@ dnl Checks for typedefs, structures, and compiler 
characteristics.
 AC_C_CONST
 AC_HEADER_TIME
 
+# Python support
+# Python 2.4 or greater should be acceptable.
+AS_IF([test $enable_python != "no"],
+       [AM_PATH_PYTHON([2.4],
+               [enable_python=yes],
+               [AS_IF([test $enable_python = "yes"],
+               [AC_MSG_FAILURE([python is not available])])])])
+AM_CONDITIONAL([HAVE_PYTHON], [test "$enable_python" = 'yes'])
+
 dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
 AC_CHECK_FUNCS(select socket)
@@ -261,7 +275,6 @@ AC_CHECK_LIB(pulse,
        -lpulse)
 
 
-AC_PATH_PROG([PYTHON],[python])
 
 AC_ARG_WITH(pulse, AS_HELP_STRING(--with-pulse, Compile with PulseAudio 
support),
                 if test $withval = "no"; then 
@@ -344,5 +357,5 @@ AC_SUBST(ERROR_CFLAGS)
 AC_SUBST(RPATH)
 AC_SUBST(RDYNAMIC)
 
-AC_OUTPUT([Makefile src/Makefile src/server/Makefile src/modules/Makefile 
src/c/Makefile src/c/api/Makefile src/c/clients/Makefile 
src/c/clients/say/Makefile src/c/clients/spdsend/Makefile src/tests/Makefile 
src/audio/Makefile config/Makefile config/modules/Makefile 
config/clients/Makefile doc/Makefile src/python/Makefile])
+AC_OUTPUT([Makefile src/Makefile src/server/Makefile src/modules/Makefile 
src/c/Makefile src/c/api/Makefile src/c/clients/Makefile 
src/c/clients/say/Makefile src/c/clients/spdsend/Makefile src/tests/Makefile 
src/audio/Makefile config/Makefile config/modules/Makefile 
config/clients/Makefile doc/Makefile src/python/Makefile 
src/python/speechd/Makefile src/python/speechd_config/Makefile])
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 666b92a..4f9661d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,10 +5,7 @@
 # in SUBDIRS if they contain another Makefile)
 # otherwise they won't be included in distribution packages
 EXTRA_DIST = cl/ChangeLog cl/README cl/*.lisp cl/*.asd \
-guile/ChangeLog guile/Makefile guile/README guile/*.in guile/*.c guile/*.h \
-python/*.py python/speechd/*.py python/Makefile.in python/speechd_config/*.py \
-python/speechd_config/spd-conf python/speechd_config/test.wav \
-python/speechd_config/speechd.desktop
+guile/ChangeLog guile/Makefile guile/README guile/*.in guile/*.c guile/*.h
 
 SUBDIRS=server audio c modules tests python
 DIST_SUBDIRS=server audio c modules tests python
diff --git a/src/python/Makefile.am b/src/python/Makefile.am
new file mode 100644
index 0000000..d54489f
--- /dev/null
+++ b/src/python/Makefile.am
@@ -0,0 +1,2 @@
+## Process this file with automake to produce Makefile.in
+SUBDIRS = speechd speechd_config
diff --git a/src/python/Makefile.in b/src/python/Makefile.in
deleted file mode 100644
index 85d117b..0000000
--- a/src/python/Makefile.in
+++ /dev/null
@@ -1,50 +0,0 @@
-
-prefix = @prefix@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-spdconforigdir = @spdconforigdir@
-datarootdir = @datarootdir@
-
-SPD_CONF_PATH_PY="speechd_config/spd_conf_path.py"
-
-all:
-       echo "SPD_CONF_ORIG_PATH=\"@address@hidden"" > speechd_config/paths.py
-       echo "SPD_CONF_PATH=\"@address@hidden"" >> speechd_config/paths.py
-       echo "SPD_SOUND_DATA_PATH=\"@address@hidden"" >> speechd_config/paths.py
-       echo "SPD_DESKTOP_CONF_PATH=\"@address@hidden"" >> 
speechd_config/paths.py
-
-       echo "SPD_SPAWN_CMD=\"@prefix@/bin/speech-dispatcher\"" > 
speechd/paths.py
-
-install:
-       if test -x /usr/bin/python; then \
-               ./setup.py install --root="${DESTDIR}" --prefix=${prefix}; \
-       else \
-               echo "Python not found, not installing speechd module nor 
spd-conf"; \
-       fi
-       cp speechd_config/test.wav "address@hidden@"
-
-       if test ! -d "address@hidden@"; then \
-               mkdir -p "address@hidden@"; \
-       fi
-
-       cp speechd_config/speechd.desktop "address@hidden@/"
-
-uninstall:
-       rm -f "address@hidden@/test.wav"
-       rm -rf "address@hidden@"
-
-clean:
-       rm -f *.pyc
-       rm -rf build
-       rm -f speechd_config/paths.py
-       rm -f speechd/spawn.py
-
-distclean: clean
-
-maintainer-clean: clean
-
-distdir:
-
-
-check:
-
diff --git a/src/python/setup.py b/src/python/setup.py
deleted file mode 100755
index fec90a0..0000000
--- a/src/python/setup.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python
-from distutils.core import setup
-setup(name='speechd',
-      version='0.3',
-      packages=['speechd'],
-      )
-
-setup(name='speechd_config',
-      version='0.0',
-      packages=['speechd_config'],
-      scripts=['speechd_config/spd-conf']
-      )
diff --git a/src/python/speechd/Makefile.am b/src/python/speechd/Makefile.am
new file mode 100644
index 0000000..59a7afe
--- /dev/null
+++ b/src/python/speechd/Makefile.am
@@ -0,0 +1,21 @@
+## Process this file with automake to produce Makefile.in
+
+speechd_pythondir = $(pyexecdir)/speechd
+speechd_python_PYTHON = __init__.py _test.py client.py
+
+nodist_speechd_python_PYTHON = paths.py
+
+edit = sed  \
+       -e 's:@address@hidden:$(bindir):g'
+
+paths.py: Makefile
+       rm -f $@
+       srcdir=; \
+       test -f ./address@hidden || srcdir=$(srcdir)/; \
+       $(edit) address@hidden > $@
+
+paths.py: $(srcdir)/paths.py.in
+
+CLEANFILES = paths.py
+
+EXTRA_DIST = paths.py.in
diff --git a/src/python/speechd/paths.py.in b/src/python/speechd/paths.py.in
new file mode 100644
index 0000000..a2a9696
--- /dev/null
+++ b/src/python/speechd/paths.py.in
@@ -0,0 +1 @@
+SPD_SPAWN_CMD = "@bindir@/speech-dispatcher"
diff --git a/src/python/speechd_config/Makefile.am 
b/src/python/speechd_config/Makefile.am
new file mode 100644
index 0000000..8b57ad8
--- /dev/null
+++ b/src/python/speechd_config/Makefile.am
@@ -0,0 +1,27 @@
+## Process this file with automake to produce Makefile.in
+
+dist_snddata_DATA = test.wav
+
+dist_bin_SCRIPTS = spd-conf
+
+speechd_pythondir = $(pyexecdir)/speechd_config
+speechd_python_PYTHON = __init__.py config.py
+nodist_speechd_python_PYTHON = paths.py
+
+paths_edit = sed \
+       -e "s:address@hidden@]:$(spdconforigdir):" \
+       -e "s:address@hidden@]:$(spdconfdir):" \
+       -e "s:address@hidden@]:$(snddatadir):" \
+       -e "s:address@hidden@]:$(spddesktopconforigdir):"
+
+paths.py: Makefile
+       rm -f $@
+       srcdir=; \
+       test -f ./address@hidden || srcdir=$(srcdir)/; \
+       $(paths_edit) address@hidden > $@
+
+paths.py: $(srcdir)/paths.py.in
+
+CLEANFILES = paths.py
+
+EXTRA_DIST = paths.py.in
diff --git a/src/python/speechd_config/paths.py.in 
b/src/python/speechd_config/paths.py.in
new file mode 100644
index 0000000..326e954
--- /dev/null
+++ b/src/python/speechd_config/paths.py.in
@@ -0,0 +1,4 @@
+SPD_CONF_ORIG_PATH="@spdconforigdir@"
+SPD_CONF_PATH="@spdconfdir@"
+SPD_SOUND_DATA_PATH="@snddatadir@"
+SPD_DESKTOP_CONF_PATH="@spddesktopconforigdir@"
-- 
1.7.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]