| 1 |
# |
| 2 |
# Makefile for generating python bindings |
| 3 |
# |
| 4 |
# Created by Linas Vepstas February 2014 |
| 5 |
# |
| 6 |
# |
| 7 |
SWIG_SOURCES = $(top_srcdir)/bindings/swig/link_grammar.i |
| 8 |
SWIG_INCLUDES = \ |
| 9 |
$(top_srcdir)/link-grammar/link-includes.h \ |
| 10 |
$(top_srcdir)/link-grammar/dict-common/dict-defines.h \ |
| 11 |
$(top_srcdir)/link-grammar/dict-common/dict-api.h \ |
| 12 |
$(top_srcdir)/link-grammar/dict-common/dict-structures.h |
| 13 |
|
| 14 |
built_c_sources = lg_python_wrap.cc |
| 15 |
built_py_sources = $(top_builddir)/bindings/python/clinkgrammar.py |
| 16 |
|
| 17 |
# Over-ride the install location, so as to remove the dash in the |
| 18 |
# directory "link-grammar". Turns out python cannot tolerate dashes. |
| 19 |
# Thus, typically, it will install into |
| 20 |
# /usr/local/lib/python3.x/dist-packages/linkgrammar (without the dash) |
| 21 |
pkgpythondir=$(pythondir)/linkgrammar |
| 22 |
pkgpyexecdir=$(pyexecdir)/linkgrammar |
| 23 |
|
| 24 |
# Files that get installed in $pkgpythondir |
| 25 |
pkgpython_PYTHON = \ |
| 26 |
$(srcdir)/linkgrammar.py \ |
| 27 |
$(top_builddir)/bindings/python/__init__.py \ |
| 28 |
$(built_py_sources) |
| 29 |
|
| 30 |
# Apparently, anaconda does not work without this!? |
| 31 |
# This seems wrong and lame to me, but see issue #298 |
| 32 |
# https://github.com/opencog/link-grammar/issues/298 |
| 33 |
pkgpypathdir=$(pythondir) |
| 34 |
pkgpypath_PYTHON = \ |
| 35 |
$(srcdir)/linkgrammar.pth |
| 36 |
|
| 37 |
# The make uninstall target should remove directories we created. |
| 38 |
uninstall-hook: |
| 39 |
-rmdir $(pkgpythondir) |
| 40 |
|
| 41 |
# These are packaged in the tarball; make clean should not remove them. |
| 42 |
maintainer-clean-local: |
| 43 |
-rm -f $(built_c_sources) |
| 44 |
-rm -f $(built_py_sources) |
| 45 |
|
| 46 |
# Don't remove __init__.py; it is built by configure! |
| 47 |
DISTCLEANFILES = \ |
| 48 |
$(top_builddir)/bindings/python/__init__.py |
| 49 |
|
| 50 |
if HAVE_SWIG |
| 51 |
# Swig builds these .... |
| 52 |
$(built_c_sources) $(built_py_sources): $(SWIG_INCLUDES) |
| 53 |
$(built_c_sources) $(built_py_sources): $(SWIG_SOURCES) |
| 54 |
$(AM_V_GEN) $(SWIG) -python -module clinkgrammar -I$(top_srcdir)/link-grammar -o $@ $< |
| 55 |
else |
| 56 |
$(built_c_sources) $(built_py_sources): |
| 57 |
touch $(built_c_sources) $(built_py_sources) |
| 58 |
endif |
| 59 |
|
| 60 |
# The la MUST have the same name as the pm, |
| 61 |
# which MUST be the swig -module name! |
| 62 |
# We're calling this clinkgrammar, since its a direct map of the C |
| 63 |
# interfaces. |
| 64 |
pkgpyexec_LTLIBRARIES = _clinkgrammar.la |
| 65 |
|
| 66 |
_clinkgrammar_la_SOURCES = $(built_c_sources) $(SWIG_SOURCES) |
| 67 |
|
| 68 |
# $(top_builddir) to pick up autogen'ed link-grammar/link-features.h |
| 69 |
_clinkgrammar_la_CPPFLAGS = \ |
| 70 |
$(SWIG_PYTHON_CPPFLAGS) \ |
| 71 |
$(PYTHON_CPPFLAGS) \ |
| 72 |
-I$(top_srcdir) \ |
| 73 |
-I$(top_srcdir)/link-grammar \ |
| 74 |
-I$(top_builddir) |
| 75 |
|
| 76 |
# On Cygwin and MinGW, a DLL with version is named name-major.EXT with no |
| 77 |
# symlink to it of an unversioned name (at least up and including libtool |
| 78 |
# 2.4.6). This is bad for Python modules, as they must have an identifier |
| 79 |
# name. |
| 80 |
# On MinGW, Python DLLs end with ".pyd". But Cygwin needs them with ".dll". |
| 81 |
if OS_WIN32 |
| 82 |
AVOID_VERSION = -avoid-version |
| 83 |
if !OS_CYGWIN |
| 84 |
PYMODULE_EXT = -shrext .pyd |
| 85 |
endif |
| 86 |
endif |
| 87 |
if OS_NETBSD |
| 88 |
AVOID_VERSION = -avoid-version |
| 89 |
endif |
| 90 |
_clinkgrammar_la_LDFLAGS = \ |
| 91 |
-version-info @VERSION_INFO@ $(AVOID_VERSION) \ |
| 92 |
$(PYTHON_LDFLAGS) -module -no-undefined $(PYMODULE_EXT) |
| 93 |
_clinkgrammar_la_LIBADD = \ |
| 94 |
$(top_builddir)/link-grammar/liblink-grammar.la $(PYTHON_LIBS) |
| 95 |
|
| 96 |
|
| 97 |
EXTRA_DIST = \ |
| 98 |
AUTHORS \ |
| 99 |
LICENSE \ |
| 100 |
README.md \ |
| 101 |
__init__.py.in \ |
| 102 |
linkgrammar.py |