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
35include include/Makefile.am.inc
36
37LUTOK_CFLAGS = -I$(srcdir)/include $(LUA_CFLAGS)
38LUTOK_LIBS = liblutok.la $(LUA_LIBS)
39
40pkginclude_HEADERS  = c_gate.hpp
41pkginclude_HEADERS += debug.hpp
42pkginclude_HEADERS += exceptions.hpp
43pkginclude_HEADERS += operations.hpp
44pkginclude_HEADERS += stack_cleaner.hpp
45pkginclude_HEADERS += state.hpp
46pkginclude_HEADERS += state.ipp
47pkginclude_HEADERS += test_utils.hpp
48
49lib_LTLIBRARIES = liblutok.la
50liblutok_la_SOURCES  = c_gate.cpp
51liblutok_la_SOURCES += c_gate.hpp
52liblutok_la_SOURCES += debug.cpp
53liblutok_la_SOURCES += debug.hpp
54liblutok_la_SOURCES += exceptions.cpp
55liblutok_la_SOURCES += exceptions.hpp
56liblutok_la_SOURCES += operations.cpp
57liblutok_la_SOURCES += operations.hpp
58liblutok_la_SOURCES += stack_cleaner.cpp
59liblutok_la_SOURCES += stack_cleaner.hpp
60liblutok_la_SOURCES += state.cpp
61liblutok_la_SOURCES += state.hpp
62liblutok_la_SOURCES += state.ipp
63liblutok_la_SOURCES += test_utils.hpp
64liblutok_la_CPPFLAGS = $(LUTOK_CFLAGS)
65liblutok_la_LDFLAGS = -version-info 3:0:0
66liblutok_la_LIBADD = $(LUA_LIBS)
67
68pkgconfig_DATA = lutok.pc
69CLEANFILES = lutok.pc
70EXTRA_DIST += lutok.pc.in
71lutok.pc: $(srcdir)/lutok.pc.in Makefile
72	sed -e 's#__INCLUDEDIR__#$(includedir)#g' \
73	    -e 's#__LIBDIR__#$(libdir)#g' \
74	    -e 's#__LUA_CFLAGS__#$(LUA_CFLAGS)#g' \
75	    -e 's#__LUA_LIBS__#$(LUA_LIBS)#g' \
76	    -e 's#__VERSION__#$(PACKAGE_VERSION)#g' \
77	    <$(srcdir)/lutok.pc.in >lutok.pc.tmp
78	mv lutok.pc.tmp lutok.pc
79
80CLEAN_TARGETS =
81PHONY_TARGETS =
82
83examplesdir = $(docdir)/examples
84examples_DATA  = examples/Makefile
85examples_DATA += examples/bindings.cpp
86examples_DATA += examples/hello.cpp
87examples_DATA += examples/interpreter.cpp
88examples_DATA += examples/raii.cpp
89EXTRA_DIST += $(examples_DATA)
90
91if WITH_ATF
92tests_DATA = Kyuafile
93EXTRA_DIST += $(tests_DATA)
94
95tests_PROGRAMS = c_gate_test
96c_gate_test_SOURCES = c_gate_test.cpp test_utils.hpp
97c_gate_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
98c_gate_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
99
100tests_PROGRAMS += debug_test
101debug_test_SOURCES = debug_test.cpp test_utils.hpp
102debug_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
103debug_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
104
105tests_SCRIPTS = examples_test
106CLEANFILES += examples_test
107EXTRA_DIST += examples_test.sh
108examples_test: $(srcdir)/examples_test.sh
109	sed -e 's,__ATF_SH__,$(ATF_SH),g' \
110	    -e 's,__EXAMPLESDIR__,$(examplesdir),g' \
111	    -e 's,__LIBDIR__,$(libdir),g' \
112	    <$(srcdir)/examples_test.sh >examples_test.tmp
113	chmod +x examples_test.tmp
114	rm -f examples_test
115	mv examples_test.tmp examples_test
116
117tests_PROGRAMS += exceptions_test
118exceptions_test_SOURCES = exceptions_test.cpp
119exceptions_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
120exceptions_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
121
122tests_PROGRAMS += operations_test
123operations_test_SOURCES = operations_test.cpp test_utils.hpp
124operations_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
125operations_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
126
127tests_PROGRAMS += stack_cleaner_test
128stack_cleaner_test_SOURCES = stack_cleaner_test.cpp test_utils.hpp
129stack_cleaner_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
130stack_cleaner_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
131
132tests_PROGRAMS += state_test
133state_test_SOURCES = state_test.cpp test_utils.hpp
134state_test_CXXFLAGS = $(LUTOK_CFLAGS) $(ATF_CXX_CFLAGS)
135state_test_LDADD = $(LUTOK_LIBS) $(ATF_CXX_LIBS)
136
137check-local: check-kyua
138PHONY_TARGETS += check-kyua
139check-kyua:
140	$(TESTS_ENVIRONMENT) kyua test \
141	    --kyuafile='$(top_srcdir)/Kyuafile' --build-root='$(top_builddir)'
142
143installcheck-local: installcheck-kyua
144PHONY_TARGETS += installcheck-kyua
145installcheck-kyua:
146	cd $(testsdir) && $(TESTS_ENVIRONMENT) kyua test
147else
148dist-hook: dist-no-atf
149PHONY_TARGETS += dist-no-atf
150dist-no-atf:
151	@echo "Sorry; cannot build a distfile without atf"
152	@false
153endif
154
155if WITH_DOXYGEN
156# This should probably be html-local, but it seems better to generate the
157# documentation in all cases to get warnings about missing documentation every
158# time the code is modified.  (And, after all, the documentation is not
159# installed so generating it unconditionally is not a big problem.)
160all-local: api-docs/api-docs.tag
161
162api-docs/api-docs.tag: $(builddir)/Doxyfile $(SOURCES)
163	rm -rf api-docs
164	mkdir -p api-docs
165	${DOXYGEN} $(builddir)/Doxyfile 2>&1 | tee api-docs/warnings
166	rm -f api-docs/html/installdox
167api-docs/html: api-docs/api-docs.tag
168
169CLEAN_TARGETS += clean-api-docs
170clean-api-docs:
171	rm -rf api-docs
172endif
173EXTRA_DIST += api-docs/html
174
175install-data-local: install-api-docs
176install-api-docs: install-docDATA
177	@echo "Installing HTML documentation into $(DESTDIR)$(htmldir)"
178	@if [ -d api-docs/html ]; then \
179	    test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"; \
180	    ( cd api-docs/html && tar cf - . ) | \
181                ( cd "$(DESTDIR)$(htmldir)" && tar xf - ); \
182	elif [ -d "$(srcdir)/api-docs/html" ]; then \
183	    test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"; \
184	    ( cd "$(srcdir)/api-docs/html" && tar cf - . ) | \
185                ( cd "$(DESTDIR)$(htmldir)" && tar xf - ); \
186	else \
187	    echo "Doxygen not installed and prebuilt documents not found"; \
188	fi
189
190uninstall-local: uninstall-api-docs
191uninstall-api-docs:
192	find "$(DESTDIR)$(htmldir)" -type d -exec chmod 755 {} \;
193	rm -rf "$(DESTDIR)$(htmldir)"
194
195clean-local: $(CLEAN_TARGETS)
196
197PHONY_TARGETS += clean-all
198clean-all:
199	GIT="$(GIT)" $(SH) $(srcdir)/admin/clean-all.sh
200
201.PHONY: ${PHONY_TARGETS}
202