Permalink
Browse files

Installation targets and python bindings

  • Loading branch information...
1 parent 2051831 commit b22fbad2e78ffb5e1ce0ee97eab2157f89526899 @wlach committed Feb 14, 2010
Showing with 171 additions and 4 deletions.
  1. +24 −4 Makefile
  2. +1 −0 configure.ac
  3. +119 −0 install-sh
  4. +18 −0 install.mk
  5. +9 −0 neocoder.i
  6. 0 python/neocoder/.gitignore
View
@@ -1,6 +1,9 @@
-include config.mk
-default: tests/geocode utils/creategeodb.py
+default: libneocoder.so tests/geocode utils/creategeodb.py \
+ python/neocoder/__init__.py python/neocoder/_geocoder.so
+
+include install.mk
# Always always compile with fPIC
CFLAGS += -fPIC
@@ -10,13 +13,21 @@ CXXFLAGS += -fPIC
CXXFLAGS+=-I./include
LDFLAGS+=-lsqlite3 -lboost_regex
+# libneocoder should be a shared library
+ifeq (${OS},MACOS)
+ LIBNEOCODER_LDFLAGS += -dynamiclib
+else
+ LIBNEOCODER_LDFLAGS += -shared
+endif
+
+
config.mk:
@echo "Please run ./configure. Stop."
@exit 1
%.o: %.cc
- g++ $< -c -o $@ $(CXXFLAGS) -D WVTEST_CONFIGURED -I./include -I./wvtest/cpp -g
- @g++ $< -MM $(CXXFLAGS) -D WVTEST_CONFIGURED -I./include -I./wvtest/cpp > $*.d
+ g++ $< -c -o $@ $(CXXFLAGS) $(PYTHON_CFLAGS) -D WVTEST_CONFIGURED -I./include -I./wvtest/cpp -g
+ @g++ $< -MM $(CXXFLAGS) $(PYTHON_CFLAGS) -D WVTEST_CONFIGURED -I./include -I./wvtest/cpp > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
@@ -39,6 +50,15 @@ GEOCODE_OBJS= $(GEOCODER_OBJS) tests/geocode.o
tests/geocode: $(GEOCODE_OBJS)
g++ $(GEOCODE_OBJS) $(LDFLAGS) -o $@
+libneocoder.so: $(GEOCODER_OBJS)
+ g++ $(GEOCODER_OBJS) $(LDFLAGS) $(LIBNEOCODER_LDFLAGS) -o $@ -fPIC -g
+
+python/neocoder/__init__.py python/neocoder/geocoder_wrap_py.cc: neocoder.i
+ swig -classic -c++ -python -I./include -outdir python/neocoder -o python/neocoder/geocoder_wrap_py.cc $<
+ mv python/neocoder/geocoder.py python/neocoder/__init__.py
+python/neocoder/_geocoder.so: libneocoder.so python/neocoder/geocoder_wrap_py.o
+ g++ -o $@ python/neocoder/geocoder_wrap_py.o libneocoder.so $(LDFLAGS) $(LIBNEOCODER_LDFLAGS) $(PYTHON_LDFLAGS) -fPIC
+
TEST_OBJS=t/geoparser.t.o
WVTEST_OBJS=$(patsubst %,wvtest/cpp/%, wvtest.o wvtestmain.o)
t/all.t: $(TEST_OBJS) $(WVTEST_OBJS) $(GEOCODER_OBJS)
@@ -50,7 +70,7 @@ test: t/all.t
clean:
rm -f *.so *.d lib/*.o lib/*.d lib/address.cc lib/geoparser.cc \
- utils/*.o utils/*.d utils/geocode
+ utils/*.o utils/*.d utils/geocode libneocoder.so
-include $(GEOPARSER_OBJS:.o=.d)
-include $(TEST_OBJS:.o=.d)
View
@@ -7,6 +7,7 @@ AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
+AC_PROG_INSTALL
# Detect target build environment
AC_CANONICAL_TARGET
View
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+#
+# install - install a program, script, or datafile
+# This comes from X11R5; it is not part of GNU.
+#
+# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+
+instcmd="$mvprog"
+chmodcmd=""
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+fi
+
+if [ x"$dst" = x ]
+then
+ echo "install: no destination specified"
+ exit 1
+fi
+
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+if [ -d $dst ]
+then
+ dst="$dst"/`basename $src`
+fi
+
+# Make a temp file name in the proper directory.
+
+dstdir=`dirname $dst`
+dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+$doit $instcmd $src $dsttmp
+
+# and set any options; do chmod last to preserve setuid bits
+
+if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
+if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
+if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
+if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
+
+# Now rename the file to the real destination.
+
+$doit $rmcmd $dst
+$doit $mvcmd $dsttmp $dst
+
+
+exit 0
View
@@ -0,0 +1,18 @@
+install-neocoder: libneocoder.so
+ $(INSTALL) -d $(DESTDIR)$(libdir)
+ $(INSTALL_PROGRAM) libneocoder.so $(DESTDIR)$(libdir)/ ;
+
+# note: this is very non-idiomatic way of installing a python library. it
+# probably doesn't handle edge cases well. but it works for me.
+install-python: python/neocoder/_geocoder.so python/neocoder/__init__.py
+ $(INSTALL) -d $(DESTDIR)$(libdir)/python/neocoder
+ $(INSTALL) python/neocoder/_geocoder.so $(DESTDIR)$(libdir)/python/neocoder
+ $(INSTALL) python/neocoder/__init__.py $(DESTDIR)$(libdir)/python/neocoder
+
+install-util: utils/creategeodb.py
+ $(INSTALL) -d $(DESTDIR)$(bindir)
+ $(INSTALL) utils/gml2py.py $(DESTDIR)$(bindir)
+ $(INSTALL) utils/creategeodb.py $(DESTDIR)$(bindir)
+
+
+install: install-neocoder install-python install-util
View
@@ -0,0 +1,9 @@
+%module geocoder
+
+%{
+#include "geocoder.h"
+%}
+
+%include "std_pair.i"
+%template(LatLng) std::pair<float, float>;
+%include "geocoder.h"
No changes.

0 comments on commit b22fbad

Please sign in to comment.