1## Process this file with automake to produce Makefile.in
2
3include ../generic/generic.mk
4
5abs_builddir = @abs_builddir@
6
7## Test programs to be run
8TESTS = smoketest.php
9LOG_COMPILER = \
10    $(LIBTOOL) -dlopen xapian.la --mode=execute $(OSX_SIP_HACK_ENV) $(PHP)
11# Use -n to disable use of the system php.ini to avoid custom configuration
12# settings there which might interfere with our tests.
13AM_LOG_FLAGS = -n -d extension_dir='$(abs_builddir)/.libs' -d extension=xapian \
14	-d include_path='php5$(PHP_PATH_SEPARATOR)$(srcdir)/php5'
15
16installcheck-local:
17	$(MAKE) check AM_LOG_FLAGS=
18
19SWIG_GENERATED =\
20	php5/xapian_wrap.cc\
21	php5/xapian_wrap.h\
22	php5/php_xapian.h\
23	php5/xapian.php
24
25EXTRA_DIST = php.i except.i \
26	generate-php-exceptions \
27	add-php-ref-handling \
28	add-php-type-hints \
29	docs/index.rst \
30	$(TESTS) $(SWIG_GENERATED)
31
32BUILT_SOURCES = $(SWIG_GENERATED)
33
34phpextdir = $(PHP_EXTENSION_DIR)
35
36phpext_LTLIBRARIES = xapian.la
37
38# This location is correct for Debian, but in general there doesn't seem
39# to be a suitable location which is guaranteed to be in the include_path
40# by default.
41phpincdir = $(datadir)/php$(PHP_MAJOR_VERSION)
42phpinc_DATA = php5/xapian.php
43
44# Remove the .la file - xapian.la is never linked against (it's a module)
45# and PHP doesn't use libltdl.  Note that the library gets installed by
46# install-data, so that's where we need to hook.
47install-data-hook:
48	rm -f $(DESTDIR)$(phpextdir)/xapian.la
49
50# Because we don't install the .la file, "make uninstall" doesn't work and
51# we need to remove the file ourselves.
52uninstall-local:
53	eval `grep '^dlname=' $(phpext_LTLIBRARIES)` ; \
54	  rm -f $(DESTDIR)$(phpextdir)/"$$dlname"
55
56AM_CPPFLAGS = $(PHP_INC)
57AM_CXXFLAGS = $(SWIG_CXXFLAGS) $(XAPIAN_CXXFLAGS)
58xapian_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)
59xapian_la_SOURCES = php5/xapian_wrap.cc php5/xapian_wrap.h
60xapian_la_LIBADD = $(XAPIAN_LIBS) $(PHP_LIBS)
61
62if MAINTAINER_MODE
63BUILT_SOURCES += except.i
64except.i: $(srcdir)/generate-php-exceptions ../../xapian-core/exception_data.pm
65	$(PERL) -w -I$(srcdir)/../../xapian-core $(srcdir)/generate-php-exceptions
66
67# We need to explicitly set -outdir because on Windows, SWIG splits paths at
68# "\" when extracting the output directory from the value passed to the -o
69# option.
70
71stamp = php5/xapian_wrap.stamp
72RUN_SWIG = stamp='$(stamp)' $(PERL) '$(top_srcdir)'/swig-depcomp $(SWIG)
73
74php5/xapian_wrap.cc php5/xapian_wrap.h php5/php_xapian.h php5/xapian.php: $(stamp)
75	$(make_many_locked)
76$(stamp): except.i add-php-ref-handling add-php-type-hints
77	$(MKDIR_P) php5
78	$(multitarget_begin)
79	$(RUN_SWIG) $(SWIG_WERROR) -I'$(srcdir)' $(SWIG_FLAGS) -c++ \
80	    -php5 -prefix Xapian -outdir php5 \
81	    -o php5/xapian_wrap.cc '$(srcdir)/'php.i
82	$(PERL) '$(srcdir)/'add-php-ref-handling php5/xapian.php | \
83	    $(PERL) '$(srcdir)/'add-php-type-hints > php5/xapian.tmp
84	mv php5/xapian.tmp php5/xapian.php
85	$(multitarget_end)
86
87-include php5/xapian_wrap.d
88
89CLEANFILES = $(stamp)
90endif
91MAINTAINERCLEANFILES = $(BUILT_SOURCES)
92
93exampledatadir = $(docdir)/php/examples
94dist_exampledata_DATA =\
95	docs/examples/simplesearch.php5\
96	docs/examples/simpleindex.php5\
97	docs/examples/simpleexpand.php5\
98	docs/examples/simplematchdecider.php5
99
100docdatadir = $(docdir)/php
101dist_docdata_DATA = docs/index.html
102
103if DOCUMENTATION_RULES
104BUILT_SOURCES += docs/index.html
105
106.rst.html:
107	-case "$@" in */*) d=`echo "$@"|sed 's,/[^/]*$$,,'`; $(MKDIR_P) "$$d" ;; esac
108	$(RST2HTML) --exit-status=warning $< $@
109endif
110