1# Copyright 2010 Google Inc.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8# * Redistributions of source code must retain the above copyright
9#   notice, this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above copyright
11#   notice, this list of conditions and the following disclaimer in the
12#   documentation and/or other materials provided with the distribution.
13# * Neither the name of Google Inc. nor the names of its contributors
14#   may be used to endorse or promote products derived from this software
15#   without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29ACLOCAL_AMFLAGS = -I m4
30
31doc_DATA = AUTHORS COPYING NEWS README
32noinst_DATA = INSTALL README
33EXTRA_DIST = $(doc_DATA) INSTALL README
34
35LUTOK_CFLAGS = -I$(srcdir)/include $(LUA_CFLAGS)
36LUTOK_LIBS = liblutok.la $(LUA_LIBS)
37
38pkginclude_HEADERS  = c_gate.hpp
39pkginclude_HEADERS += debug.hpp
40pkginclude_HEADERS += exceptions.hpp
41pkginclude_HEADERS += operations.hpp
42pkginclude_HEADERS += stack_cleaner.hpp
43pkginclude_HEADERS += state.hpp
44pkginclude_HEADERS += state.ipp
45pkginclude_HEADERS += test_utils.hpp
46
47EXTRA_DIST += include/lutok/README
48EXTRA_DIST += include/lutok/c_gate.hpp
49EXTRA_DIST += include/lutok/debug.hpp
50EXTRA_DIST += include/lutok/exceptions.hpp
51EXTRA_DIST += include/lutok/operations.hpp
52EXTRA_DIST += include/lutok/stack_cleaner.hpp
53EXTRA_DIST += include/lutok/state.hpp
54EXTRA_DIST += include/lutok/state.ipp
55
56lib_LTLIBRARIES = liblutok.la
57liblutok_la_SOURCES  = c_gate.cpp
58liblutok_la_SOURCES += c_gate.hpp
59liblutok_la_SOURCES += debug.cpp
60liblutok_la_SOURCES += debug.hpp
61liblutok_la_SOURCES += exceptions.cpp
62liblutok_la_SOURCES += exceptions.hpp
63liblutok_la_SOURCES += operations.cpp
64liblutok_la_SOURCES += operations.hpp
65liblutok_la_SOURCES += stack_cleaner.cpp
66liblutok_la_SOURCES += stack_cleaner.hpp
67liblutok_la_SOURCES += state.cpp
68liblutok_la_SOURCES += state.hpp
69liblutok_la_SOURCES += state.ipp
70liblutok_la_SOURCES += test_utils.hpp
71liblutok_la_CPPFLAGS = $(LUTOK_CFLAGS)
72liblutok_la_LDFLAGS = -version-info 3:0:0
73liblutok_la_LIBADD = $(LUA_LIBS)
74
75pkgconfig_DATA = lutok.pc
76CLEANFILES = lutok.pc
77EXTRA_DIST += lutok.pc.in
78lutok.pc: $(srcdir)/lutok.pc.in Makefile
79	$(AM_V_GEN)sed -e 's#__INCLUDEDIR__#$(includedir)#g' \
80	    -e 's#__LIBDIR__#$(libdir)#g' \
81	    -e 's#__LUA_CFLAGS__#$(LUA_CFLAGS)#g' \
82	    -e 's#__LUA_LIBS__#$(LUA_LIBS)#g' \
83	    -e 's#__VERSION__#$(PACKAGE_VERSION)#g' \
84	    <$(srcdir)/lutok.pc.in >lutok.pc.tmp; \
85	mv lutok.pc.tmp lutok.pc
86
87CLEAN_TARGETS =
88DIST_HOOKS =
89PHONY_TARGETS =
90
91examplesdir = $(docdir)/examples
92examples_DATA  = examples/Makefile
93examples_DATA += examples/bindings.cpp
94examples_DATA += examples/hello.cpp
95examples_DATA += examples/interpreter.cpp
96examples_DATA += examples/raii.cpp
97EXTRA_DIST += $(examples_DATA)
98
99if WITH_ATF
100tests_DATA = Kyuafile
101EXTRA_DIST += $(tests_DATA)
102
103tests_PROGRAMS = c_gate_test
104c_gate_test_SOURCES = c_gate_test.cpp test_utils.hpp
105c_gate_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
106c_gate_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
107
108tests_PROGRAMS += debug_test
109debug_test_SOURCES = debug_test.cpp test_utils.hpp
110debug_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
111debug_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
112
113tests_SCRIPTS = examples_test
114CLEANFILES += examples_test
115EXTRA_DIST += examples_test.sh
116examples_test: $(srcdir)/examples_test.sh
117	$(AM_V_GEN)sed -e 's,__ATF_SH__,$(ATF_SH),g' \
118	    -e 's,__CXX__,$(CXX),g' \
119	    -e 's,__EXAMPLESDIR__,$(examplesdir),g' \
120	    -e 's,__LIBDIR__,$(libdir),g' \
121	    <$(srcdir)/examples_test.sh >examples_test.tmp; \
122	chmod +x examples_test.tmp; \
123	rm -f examples_test; \
124	mv examples_test.tmp examples_test
125
126tests_PROGRAMS += exceptions_test
127exceptions_test_SOURCES = exceptions_test.cpp
128exceptions_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
129exceptions_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
130
131tests_PROGRAMS += operations_test
132operations_test_SOURCES = operations_test.cpp test_utils.hpp
133operations_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
134operations_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
135
136tests_PROGRAMS += stack_cleaner_test
137stack_cleaner_test_SOURCES = stack_cleaner_test.cpp test_utils.hpp
138stack_cleaner_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
139stack_cleaner_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
140
141tests_PROGRAMS += state_test
142state_test_SOURCES = state_test.cpp test_utils.hpp
143state_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
144state_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
145
146if HAVE_KYUA
147check-local: check-kyua
148PHONY_TARGETS += check-kyua
149check-kyua:
150	$(TESTS_ENVIRONMENT) kyua test \
151	    --kyuafile='$(top_srcdir)/Kyuafile' --build-root='$(top_builddir)'
152
153installcheck-local: installcheck-kyua
154PHONY_TARGETS += installcheck-kyua
155installcheck-kyua:
156	cd $(testsdir) && $(TESTS_ENVIRONMENT) kyua test
157endif
158else
159DIST_HOOKS += dist-no-atf
160PHONY_TARGETS += dist-no-atf
161dist-no-atf:
162	@echo "Sorry; cannot build a distfile without atf"
163	@false
164endif
165
166if WITH_DOXYGEN
167# This should probably be html-local, but it seems better to generate the
168# documentation in all cases to get warnings about missing documentation every
169# time the code is modified.  (And, after all, the documentation is not
170# installed so generating it unconditionally is not a big problem.)
171all-local: api-docs/api-docs.tag
172
173api-docs/api-docs.tag: $(builddir)/Doxyfile $(SOURCES)
174	$(AM_V_GEN)rm -rf api-docs; \
175	mkdir -p api-docs; \
176	${DOXYGEN} $(builddir)/Doxyfile 2>&1 | tee api-docs/warnings; \
177	rm -f api-docs/html/installdox
178api-docs/html: api-docs/api-docs.tag
179
180CLEAN_TARGETS += clean-api-docs
181clean-api-docs:
182	rm -rf api-docs
183
184EXTRA_DIST += api-docs/html
185else
186DIST_HOOKS += dist-no-doxygen
187PHONY_TARGETS += dist-no-doxygen
188dist-no-doxygen:
189	@echo "Sorry; cannot build a distfile without Doxygen"
190	@false
191endif
192
193install-data-local: install-api-docs
194install-api-docs: install-docDATA
195	@echo "Installing HTML documentation into $(DESTDIR)$(htmldir)"
196	@if [ -d api-docs/html ]; then \
197	    test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"; \
198	    ( cd api-docs/html && tar cf - . ) | \
199                ( cd "$(DESTDIR)$(htmldir)" && tar xf - ); \
200	elif [ -d "$(srcdir)/api-docs/html" ]; then \
201	    test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"; \
202	    ( cd "$(srcdir)/api-docs/html" && tar cf - . ) | \
203                ( cd "$(DESTDIR)$(htmldir)" && tar xf - ); \
204	else \
205	    echo "Doxygen not installed and prebuilt documents not found"; \
206	fi
207
208uninstall-local: uninstall-api-docs
209uninstall-api-docs:
210	find "$(DESTDIR)$(htmldir)" -type d -exec chmod 755 {} \;
211	rm -rf "$(DESTDIR)$(htmldir)"
212
213clean-local: $(CLEAN_TARGETS)
214
215PHONY_TARGETS += clean-all
216clean-all:
217	GIT="$(GIT)" $(SH) $(srcdir)/admin/clean-all.sh
218
219dist-hook: $(DIST_HOOKS)
220
221.PHONY: ${PHONY_TARGETS}
222