1## Process this file with automake to produce Makefile.in
2
3include ../generic/generic.mk
4
5## Test programs to be run
6TESTS = smoketest.rb
7LOG_COMPILER = $(OSX_SIP_HACK_ENV) $(RUBY)
8AM_LOG_FLAGS = -I.libs -I'$(srcdir)'
9
10installcheck-local:
11	$(MAKE) check AM_LOG_FLAGS=
12
13SWIG_GENERATED = xapian_wrap.cc xapian_wrap.h
14
15EXTRA_DIST = ruby.i extra.i docs/index.rst $(TESTS) \
16	$(SWIG_GENERATED)
17
18BUILT_SOURCES = $(SWIG_GENERATED)
19
20rubylibdir = $(RUBY_LIB)
21dist_rubylib_DATA = xapian.rb
22
23rubylibarchdir = $(RUBY_LIB_ARCH)
24rubylibarch_LTLIBRARIES = _xapian.la
25
26# Remove the .la file - _xapian.la is never linked against (it's a module)
27# and Ruby doesn't use libltdl.  Note that the library gets installed by
28# install-data, so that's where we need to hook.
29install-data-hook:
30	rm -f $(DESTDIR)$(rubylibarchdir)/_xapian.la
31
32AM_CPPFLAGS = -I$(RUBY_INC) -I$(RUBY_INC_ARCH)
33AM_CXXFLAGS = @SWIG_CXXFLAGS@ $(XAPIAN_CXXFLAGS)
34_xapian_la_LDFLAGS = -avoid-version -module -shrext ".$(RUBY_DLEXT)" $(NO_UNDEFINED)
35_xapian_la_SOURCES = xapian_wrap.cc xapian_wrap.h
36_xapian_la_LIBADD = $(XAPIAN_LIBS) $(RUBY_LIBS)
37
38CLEANFILES =
39if MAINTAINER_MODE
40stamp = xapian_wrap.stamp
41RUN_SWIG = stamp='$(stamp)' $(PERL) '$(top_srcdir)'/swig-depcomp $(SWIG)
42
43xapian_wrap.cc xapian_wrap.h: $(stamp)
44	$(make_many_locked)
45$(stamp):
46	$(multitarget_begin)
47	$(RUN_SWIG) $(SWIG_WERROR) -I'$(srcdir)' $(SWIG_FLAGS) -c++ \
48	    -initname _xapian -ruby \
49	    -o xapian_wrap.cc '$(srcdir)/'ruby.i
50	## Fix code to avoid GCC -Wconversion-null warnings.  This was fixed
51	## in SWIG git master after SWIG 3.0.12.
52	##
53	## Also support Ruby 2.7 - fixed in SWIG git master after SWIG 4.0.1.
54	$(PERL) -pi -e 's/\b(rb_funcall\(.*, )NULL(\);)/$$1Qnil$$2/; s!^(#include <ruby)(\.h>\n)!$$1$$2$$1/version$$2!; if (/SWIG_TRACKINGS/) {$$_.="#endif\n"; print "#if RUBY_API_VERSION_CODE >= 20700\n  rb_define_virtual_variable(\"SWIG_TRACKINGS_COUNT\", swig_ruby_trackings_count, (rb_gvar_setter_t*)NULL);\n#else\n"}' \
55	    xapian_wrap.cc
56	$(multitarget_end)
57
58-include xapian_wrap.d
59
60CLEANFILES += $(stamp)
61endif
62MAINTAINERCLEANFILES = $(BUILT_SOURCES)
63
64# Compatibility wrapper which configure creates when required.
65DISTCLEANFILES = rubyio.h
66
67exampledatadir = $(docdir)/ruby/examples
68dist_exampledata_DATA = \
69	docs/examples/simpleexpand.rb \
70	docs/examples/simpleindex.rb \
71	docs/examples/simplematchdecider.rb \
72	docs/examples/simplesearch.rb
73
74install-data-local:
75	$(mkinstalldirs) $(DESTDIR)$(docdatadir)
76	## In a VPATH build, install files from srcdir first.  Use
77	## $(abs_builddir) because we need to cd there having already
78	## changed directory.
79	@paths=docs ; \
80	  test '$(abs_srcdir)' = '$(abs_builddir)' || paths='$(srcdir)/docs $(abs_builddir)/docs' ; \
81	  for docs in $$paths ; do \
82	    cd "$$docs" && for dir in `find rdocs -type d -print` ; do \
83	      echo " $(mkinstalldirs) '$(DESTDIR)$(docdatadir)/$$dir'"; \
84	      $(mkinstalldirs) "$(DESTDIR)$(docdatadir)/$$dir"; \
85	    done && for f in `find rdocs -type f -print` ; do \
86	      echo " $(INSTALL_DATA) '$$f' '$(DESTDIR)$(docdatadir)/$$f'"; \
87	      $(INSTALL_DATA) "$$f" "$(DESTDIR)$(docdatadir)/$$f"; \
88	    done ; \
89	  done
90
91uninstall-local:
92	## Because we don't install the .la file, "make uninstall" doesn't work
93	## and we need to remove the file ourselves.
94	rm -f $(DESTDIR)$(rubylibarchdir)/_xapian.$(RUBY_DLEXT)
95	@paths=docs ; \
96	  test '$(abs_srcdir)' = '$(abs_builddir)' || paths='$(srcdir)/docs $(abs_builddir)/docs' ; \
97	  for docs in $$paths ; do \
98	    cd "$$docs" && for f in `find rdocs -type f -print` ; do \
99	      echo " rm -f '$(DESTDIR)$(docdatadir)/$$f'"; \
100	      rm -f "$(DESTDIR)$(docdatadir)/$$f"; \
101	    done; \
102	  done
103
104docdatadir = $(docdir)/ruby
105dist_docdata_DATA = docs/index.html
106
107EXTRA_DIST += generate-rdoc-stubs docs/xapian.rb
108
109BUILT_SOURCES += docs/rdocs/index.html
110
111docs/rdocs/index.html: docs/xapian.rb
112	rm -rf docs/rdocs
113	$(MKDIR_P) docs
114	cd docs && $(RDOC) --op rdocs `test -f xapian.rb||echo '$(abs_srcdir)/docs/'`xapian.rb
115
116if DOCUMENTATION_RULES
117docs/xapian.rb: generate-rdoc-stubs xapian.rb ../doxygen-xml/index.xml
118	$(PERL) $(srcdir)/generate-rdoc-stubs
119
120BUILT_SOURCES += docs/index.html
121
122.rst.html:
123	-case "$@" in */*) d=`echo "$@"|sed 's,/[^/]*$$,,'`; $(MKDIR_P) "$$d" ;; esac
124	$(RST2HTML) --exit-status=warning $< $@
125
126CLEANFILES += docs/xapian.rb
127endif
128