more autotools work

This commit is contained in:
Zach Tibbitts 2007-06-12 20:35:59 +00:00
parent e0e502aaa9
commit cc2c6d94d4
4 changed files with 275 additions and 1 deletions

View File

@ -1,2 +1,18 @@
SUBDIRS = src
dist_doc_DATA = README
dist_doc_DATA = README README.Packagers
CLEANFILES =
bin_SCRIPTS = deluge
CLEANFILES += deluge
EXTRA_DIST =
deluge: deluge.in
sed -e s!\@PYTHON\@!@PYTHON@! \
-e s!\@PYOPTIONS\@!-OOt! \
-e s!\@VERSION\@!${VERSION}! \
< $< > $@
EXTRA_DIST += deluge.in

132
acinclude.m4 Normal file
View File

@ -0,0 +1,132 @@
# Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# AM_PATH_PYTHON_VERSION(ABI-VERSION1, [MINIMUM-VERSION1 [, ABI-VERSION2, [MINIMUM-VERSION2 ...]]])
#
# An alternative to AM_PATH_PYTHON that checks for specific python ABI/version pairs.
# Example:
# AM_PATH_PYTHON_VERSION(2.3, 2.3.5, 2.4, 2.4.0)
# checks for a python2.3 binary returning python version >= 2.3.5, and
# if that fails it looks for python2.4 containing version >= 2.4.0
# It aborts configure with an error if no statisfying version is found.
# Env. var. PYTHON can be used to point a specific/laternate version to configure.
AC_DEFUN([AM_PATH_PYTHON_VERSION],
[
m4_pattern_allow([m4_shift])
_python_save="$PYTHON"
dnl Find a Python interpreter with corresponding ABI version.
m4_define(PYTHON_var, PYTHON[]m4_translit($1,[.],[_]))
if test -z "$PYTHON"; then
AC_PATH_PROG(PYTHON_var, python$1, [])
else
PYTHON_var="$PYTHON"
fi
PYTHON="$PYTHON_var"
AC_SUBST(PYTHON)
if test -n "$PYTHON"; then
m4_if([$2],[],[
], [
dnl A version check is needed.
AC_MSG_CHECKING([whether $PYTHON version is >= $2])
AM_PYTHON_CHECK_VERSION([$PYTHON], [$2],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT([no]); PYTHON=""])
])
fi
if test -z "$PYTHON"; then
dnl if more arguments, shift/recurse, else fail
m4_if([$3],[],[
AC_MSG_ERROR([no suitable Python interpreter found])
], [
PYTHON="$_python_save"
AM_PATH_PYTHON_VERSION(m4_shift(m4_shift($@)))
])
else
dnl Query Python for its version number. Getting [:3] seems to be
dnl the best way to do this; it's what "site.py" does in the standard
dnl library.
AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
[am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
dnl Use the values of $prefix and $exec_prefix for the corresponding
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
dnl distinct variables so they can be overridden if need be. However,
dnl general consensus is that you shouldn't need this ability.
AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
dnl At times (like when building shared libraries) you may want
dnl to know which OS platform Python thinks this is.
AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
[am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
dnl Set up 4 directories:
dnl pythondir -- where to install python scripts. This is the
dnl site-packages directory, not the python standard library
dnl directory like in previous automake betas. This behavior
dnl is more consistent with lispdir.m4 for example.
dnl Query distutils for this directory. distutils does not exist in
dnl Python 1.5, so we fall back to the hardcoded directory if it
dnl doesn't work.
AC_CACHE_CHECK([for $am_display_PYTHON script directory],
[am_cv_python_pythondir],
[am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
AC_SUBST([pythondir], [$am_cv_python_pythondir])
dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
dnl more consistent with the rest of automake.
AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
dnl pyexecdir -- directory for installing python extension modules
dnl (shared libraries)
dnl Query distutils for this directory. distutils does not exist in
dnl Python 1.5, so we fall back to the hardcoded directory if it
dnl doesn't work.
AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
[am_cv_python_pyexecdir],
[am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
fi
])

View File

@ -1,5 +1,25 @@
AC_INIT([deluge], [0.5.2], [zach@collegegeek.org])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
m4_define(required_pygtk_version, 2.8.0)
m4_define(required_python_abi, 2.4)
AM_PATH_PYTHON_VERSION(2.4, 2.4.0, 2.5, 2.5.0)
dnl Check for correctly installed pygtk
AC_MSG_CHECKING(for pygtk required_pygtk_version installed for python required_python_abi)
prog="
import pygtk; pygtk.require('2.0')
import gtk
assert gtk.pygtk_version >= tuple(map(int, 'required_pygtk_version'.split('.')))
"
if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC; then
AC_MSG_RESULT(found)
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR(required pygtk version not found)
fi
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([

106
deluge.in Normal file
View File

@ -0,0 +1,106 @@
#!@PYTHON@ @PYOPTIONS@
#
# deluge
# Copyright (C) Zach Tibbitts 2006 <zach@collegegeek.org>
# Copyright (C) Alon Zakai 2006 <kripkensteiner@gmail.com>
#
#
#
# Deluge is free software.
#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# deluge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with deluge. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# You must obey the GNU General Public License in all respects for all of
# the code used other than OpenSSL. If you modify file(s) with this
# exception, you may extend this exception to your version of the file(s),
# but you are not obligated to do so. If you do not wish to do so, delete
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
from optparse import OptionParser
import sys
import os, os.path
import gettext, locale
import deluge, deluge.common, deluge.interface
try:
import dbus
dbus_version = getattr(dbus, 'version', (0,0,0))
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
import dbus.glib
elif dbus_version >= (0,80,0):
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
else:
pass
except: dbus_imported = False
else: dbus_imported = True
parser = OptionParser(usage="%prog [options] [actions]", version="@VERSION@")
parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray",
metavar="TRAY", action="store_true")
parser.add_option("--url", dest="url", help="Load a torrent from a URL",
metavar="URL", action="store")
(options, args) = parser.parse_args()
def start_deluge():
print "Starting new Deluge session..."
interface = deluge.interface.DelugeGTK()
add_args(interface)
interface.start()
def add_args(interface):
if options.url:
interface.external_add_url(options.url)
else:
for arg in args:
apath = os.path.abspath(arg)
if apath.endswith(".torrent"):
interface.external_add_torrent(apath)
else:
print "Error,", arg, " does not seem to be a .torrent file"
if dbus_imported:
bus = dbus.SessionBus()
dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames()
interface = None
if not "org.deluge_torrent.Deluge" in dbus_objects:
print "no existing Deluge session"
start_deluge()
else:
## This connects to the deluge interface
print "create proxy object"
proxy = bus.get_object('org.deluge_torrent.Deluge', '/org/deluge_torrent/DelugeObject')
print "create iface"
deluge_iface = dbus.Interface(proxy, 'org.deluge_torrent.Deluge')
print "send to iface"
add_args(deluge_iface)
else:
print "no existing Deluge session"
start_deluge()