[Pkg-crosswire-devel] Packaging SWIG bindings for Ubuntu

Matthew Talbert ransom1982 at gmail.com
Sat Oct 24 02:57:33 BST 2009


I have an initial patch which cleans things up a bit. I've only tested
with python, but I think it shouldn't affect the other bindings
negatively. I'll test later. This basically removes the sword.m4 and
replaces it with two lines in configure.ac using pkg-config. Similar
things could be done to remove the other m4 files. Because of this
change, it no longer matters what the name of libsword.so* is, because
it just gets the linker flags from pkg-config. I've also updated the
version names and remove README.cvs, which seems to be out of date,
and not as informative as ../README.

Patch is at http://chaqar.com/static/xiphos/pythonswig.patch and included below.

Matthew

Index: configure.ac
===================================================================
--- configure.ac	(revision 2451)
+++ configure.ac	(working copy)
@@ -1,11 +1,11 @@
 # ---------------------------------------------------------------------
 # Initialisation
 # ---------------------------------------------------------------------
-AC_INIT([swordbindings],[1.5.11],[sword-bugs at crosswire.org])
+AC_INIT([swordbindings],[1.6.0],[sword-bugs at crosswire.org])
 AC_CONFIG_SRCDIR(sword.i)
 AC_PREREQ(2.59)
 AC_REVISION($Revision: 1.2 $)
-AM_INIT_AUTOMAKE(swordbindings,1.5.11)
+AM_INIT_AUTOMAKE(swordbindings,1.6.0)

 # ---------------------------------------------------------------------
 # Check Programs
@@ -20,7 +20,8 @@
 # ---------------------------------------------------------------------
 # Check libraries
 # ---------------------------------------------------------------------
-SW_CHECK_SWORD(1.5.7)
+PKG_CHECK_MODULES(SWORD, "sword")
+AC_SUBST([SWORD_INCLUDE_DIR], [`pkg-config --variable=includedir sword`/sword])

 # ---------------------------------------------------------------------
 # Misc
Index: README.cvs
===================================================================
--- README.cvs	(revision 2451)
+++ README.cvs	(working copy)
@@ -1,10 +0,0 @@
-README
-------
-
-To build the sword bindings for Sword you require
-
-SWIG 1.3 (see http://www.swig.org)
-one of perl, python, tcl, php
-Sword 1.5.8
-
-First run ./autogen.sh to generate this directory
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 2451)
+++ Makefile.am	(working copy)
@@ -1,4 +1,4 @@
-INCLUDES = $(SWORD_INCLUDES)
+INCLUDES = $(SWORD_CFLAGS)
 lib_LTLIBRARIES = libsword_csharpsword.la
 libsword_csharpsword_la_LIBADD = $(SWORD_LIBS)
 libsword_csharpsword_la_SOURCES = csharp/Sword.cxx
@@ -42,7 +42,7 @@
 	@echo "		'VERSION'	=> '$(VERSION)'," >> perl/Makefile.PL
 	@echo "		'INC'		=> '$(SWORD_INCLUDES) -I..'," >> perl/Makefile.PL
 	@echo "		'DEFINE'	=> '-DSWIG'," >> perl/Makefile.PL
-	@echo "		'LIBS'		=> '$(LIB_SWORD) -lz'," >> perl/Makefile.PL
+	@echo "		'LIBS'		=> '$(SWORD_LIBS) -lz'," >> perl/Makefile.PL
 	@echo "		'PREREQ_PM'	=> {}, # e.g., Module::Name => 1.1" >> perl/Makefile.PL
 	@echo "			($$] >= 5.005 ?		## Add these new keywords supported since
5.005" >> perl/Makefile.PL
 	@echo "			(ABSTRACT => 'Sword Project perl bindings', # retrieve
abstract from module" >> perl/Makefile.PL
@@ -69,14 +69,14 @@

 tclswig: sword.i
 	mkdir -p tcl
-	$(SWIG) -tcl -c++ -namespace -pkgversion $(VERSION) -o tcl/Sword.cxx
-I$(top_srcdir) $(SWORD_INCLUDES) $(top_srcdir)/sword.i
+	$(SWIG) -tcl -c++ -namespace -pkgversion $(VERSION) -o tcl/Sword.cxx
-I$(top_srcdir) $(SWORD_CFLAGS) $(top_srcdir)/sword.i

 python_make: python_makebuild
-	cd python && $(PYTHON) setup.py build_ext $(LIB_SWORD)
+	cd python && $(PYTHON) setup.py build_ext $(SWORD_LIBS)

 pythonswig: sword.i
 	mkdir -p python
-	$(SWIG) -python -c++ -shadow -o python/Sword.cxx -I$(top_srcdir)
$(SWORD_INCLUDES) $(top_srcdir)/sword.i
+	$(SWIG) -python -c++ -shadow -o python/Sword.cxx -I$(top_srcdir)
$(SWORD_CFLAGS) $(top_srcdir)/sword.i

 python_makebuild: $(PYTHONSWIG)
 	mkdir -p python
@@ -100,14 +100,14 @@

 phpswig: sword.i
 	mkdir -p php
-	$(SWIG) -php4 -c++ -phpfull -o php/Sword.cxx -I$(top_srcdir)
$(SWORD_INCLUDES) $(top_srcdir)/sword.i
+	$(SWIG) -php4 -c++ -phpfull -o php/Sword.cxx -I$(top_srcdir)
$(SWORD_CFLAGS) $(top_srcdir)/sword.i


 csharp/Sword.cxx: csharpswig

 csharpswig: sword.i
 	        mkdir -p csharp
-		        $(SWIG) -csharp -c++ -nodefaultctor -dllimport
libsword_csharpwrap.dll -o csharp/Sword.cxx -I$(top_srcdir)
$(SWORD_INCLUDES)  $(top_srcdir)/sword.i
+		        $(SWIG) -csharp -c++ -nodefaultctor -dllimport
libsword_csharpwrap.dll -o csharp/Sword.cxx -I$(top_srcdir)
$(SWORD_CFLAGS)  $(top_srcdir)/sword.i

 csharpmake:
 	        mcs -out:csharp/Sword.dll -target:library csharp/*.cs
Index: sword.m4
===================================================================
--- sword.m4	(revision 2451)
+++ sword.m4	(working copy)
@@ -1,174 +0,0 @@
-##	-*- autoconf -*-
-dnl This file was created by Joachim Ansorg <jansorg at gmx.de>
-dnl It provides macord for the autoconf package to find the Sword
library on your system.
-
-dnl ----------------------------------------------------------------------
-dnl		Check wheter to use static linking
-dnl		first parameter is the required version
-dnl		second is whether to use static sword library
-dnl ----------------------------------------------------------------------
-AC_DEFUN(SW_CHECK_SWORD,
-[
-dnl AC_MSG_CHECKING([for a Sword installation])
-
-dnl The option for the configure script
-AC_ARG_WITH(sword-dir,
-[  --with-sword-dir=DIR     Path where Sword is being installed
(default=/usr) ],
-[
-  ac_sword_dir=$withval
-],ac_sword_dir=/usr
-)
-
-AC_ARG_ENABLE(static-sword,
-[  --enable-static-sword    Link to the static Sword library],
- 	ac_static_sword="YES",
- 	[ ac_static_sword="$2" ]
-)
-
-dnl try to find Sword library files
-AC_MSG_CHECKING([for Sword library files])
-AC_REQUIRE([AC_FIND_ZLIB])
-ac_sword_library_dirs="$ac_sword_dir/lib /usr/lib /usr/lib/sword
/usr/local/lib /usr/local/lib/sword /usr/local/sword/lib"
-
-if test "$ac_static_sword" = "YES"; then
-	SEARCH_LIBS="libsword.a";
-else
-	SEARCH_LIBS="libsword.a libsword.so";
-fi
-
-
-AC_CACHE_VAL(ac_cv_sword_libdir, AC_FIND_FILE($SEARCH_LIBS,
$ac_sword_library_dirs, ac_cv_sword_libdir))
-
-if test "$ac_cv_sword_libdir" = "NO"; then
-  AC_MSG_ERROR(SWORD library not found. Try to use configure with
--with-sword-dir=/your/SWORD/path!);
-fi
-
-if test "$ac_static_sword" = "YES"; then
-	LIB_SWORD="$ac_cv_sword_libdir/libsword.a";
-else
-	LIB_SWORD="-L$ac_cv_sword_libdir -lsword";
-fi
-
-#AC_SUBST(SWORD_LIBRARY_PATH)
-AC_SUBST(LIB_SWORD)
-all_libraries="$all_libraries -L$ac_cv_sword_libdir"
-
-if test "$ac_static_sword" = "YES"; then
-	MESSAGE="static library $ac_cv_sword_libdir/libsword.a";
-else
-	MESSAGE="$ac_cv_sword_libdir";
-fi
-AC_MSG_RESULT([$MESSAGE])
-
-
-
-dnl -- try to find Swords include files --
-AC_MSG_CHECKING([for Sword include files])
-ac_sword_include_dirs="$ac_sword_dir/include/sword
$ac_sword_dir/include /usr/include/sword /usr/include
/usr/local/include/sword /usr/local/include /usr/local/sword/include
/usr/local/sword/include/sword"
-
-AC_CACHE_VAL(ac_cv_sword_incdir, AC_FIND_FILE(swmgr.h,
$ac_sword_include_dirs, ac_cv_sword_incdir))
-
-if test "$ac_cv_sword_incdir" = "NO"; then
-	AC_MSG_ERROR([The Sword include file files were not found.
-Please try to use configure with --with-sword-dir=/your/SWORD/path !
-])
-fi
-
-SWORD_INCLUDES="-I$ac_cv_sword_incdir"
-SWORD_INCLUDE_DIR="$ac_cv_sword_incdir"
-AC_SUBST(SWORD_INCLUDES)
-AC_SUBST(SWORD_INCLUDE_DIR)
-all_includes="$all_includes -I$ac_cv_sword_incdir"
-
-AC_MSG_RESULT([$ac_cv_sword_incdir])
-
-
-
-dnl -- check if Sword matches the minimum version --
-AC_MSG_CHECKING([if you have Sword $1 or later])
-
-AC_CACHE_VAL(ac_cv_installed_sword_version,
-[
-AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
-ac_LIBRARY_PATH="$LIBRARY_PATH"
-ac_cxxflags_safe="$CXXFLAGS"
-ac_ldflags_safe="$LDFLAGS"
-ac_libs_safe="$LIBS"
-
-CXXFLAGS="$CXXFLAGS -I$"
-LDFLAGS="$LDFLAGS -L$ac_cv_sword_libdir"
-LIBS="$LIB_SWORD -lz"
-LD_LIBRARY_PATH="$ac_cv_sword_libdir"
-export LD_LIBRARY_PATH
-LIBRARY_PATH=
-export LIBRARY_PATH
-
-cat > conftest.$ac_ext <<EOF
-#include <iostream.h>
-#include <swversion.h>
-using std::cout;
-using std::endl;
-using sword::SWVersion;
-
-int main(int argc, char* argv[]) {
-	if (argc != 2) {
-		cout << SWVersion::currentVersion << endl;
-	}
-	else if (argc == 2)
-	{
-		if (SWVersion(&argv[[1]]) < SWVersion::currentVersion ||
SWVersion(&argv[[1]]) == SWVersion::currentVersion)
-		{
-			cout << 0 << endl;
-			return 0;
-		}
-		else	
-		{
-			cout << 1 << endl;
-			return 1; //version not recent enough
-		}
-	}
-	return 0;
-}
-EOF
-
-ac_link='${CXX-g++} -o conftest $CXXFLAGS $all_includes $CPPFLAGS
$LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-if AC_TRY_EVAL(ac_link) && test -s conftest; then
-	if test -x conftest; then
-		eval ac_cv_installed_sword_version=`./conftest 2>&5`
-		echo "configure:
ac_cv_installed_sword_version=$ac_cv_installed_sword_version"
>&AC_FD_CC
-		eval sword_test_returncode=`./conftest $1 2>&5`;
-		echo "configure: sword_test_returncode=$sword_test_returncode" >&AC_FD_CC
-	fi
-else
-  echo "configure: failed program was:" >&AC_FD_CC
-  cat conftest.$ac_ext >&AC_FD_CC
-fi
-
-rm -f conftest*
-CXXFLAGS="$ac_cxxflags_safe"
-LDFLAGS="$ac_ldflags_safe"
-LIBS="$ac_libs_safe"
-
-LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
-export LD_LIBRARY_PATH
-LIBRARY_PATH="$ac_LIBRARY_PATH"
-export LIBRARY_PATH
-AC_LANG_RESTORE
-])
-
-right_version="ok";
-if test "x$sword_test_returncode" = "x1"; then
-	echo "configure: changing right_version" >&AC_FD_CC
-	right_version="wrong version";
-fi;
-	
-AC_MSG_RESULT([$ac_cv_installed_sword_version])
-echo "configure: right_version=$right_version" >&AC_FD_CC
-if test "x$right_version" != "xok"; then
-        AC_MSG_ERROR([Your Sword installation is not recent enough!
$sword_test_returncode Please
-upgrade to version $1!]);
-fi;
-
-])




More information about the Pkg-crosswire-devel mailing list