1## Process this file with automake to produce Makefile.in
2
3# Make sure that when we re-make ./configure, we get the macros we need
4ACLOCAL_AMFLAGS = -I m4
5
6# This is so we can #include <ctemplate/foo>
7AM_CPPFLAGS = -I$(top_srcdir)/src
8
9# These are good warnings to turn on by default
10if GCC
11AM_CXXFLAGS = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
12endif
13
14dist_doc_DATA = AUTHORS ChangeLog NEWS README
15
16# mingw does weird directory munging on /tmp, which causes some of our
17# tests to fail, so use a different tmpdir there.
18if MINGW
19TMPDIR = ./
20dist_doc_DATA += README_windows.txt
21else
22TMPDIR = /tmp
23endif
24
25ctemplateincludedir = $(includedir)/ctemplate
26## The .h files you want to install (that is, .h files that people
27## who install this package can include in their own applications.)
28## We have to include both the .h and .h.in forms.  The latter we
29## put in noinst_HEADERS.
30## NOTE: If you add a file here, also add it to the end of configure.ac
31nodist_ctemplateinclude_HEADERS = \
32	src/ctemplate/template.h \
33	src/ctemplate/template_cache.h \
34	src/ctemplate/template_string.h \
35	src/ctemplate/template_enums.h \
36	src/ctemplate/template_pathops.h \
37	src/ctemplate/template_modifiers.h \
38	src/ctemplate/template_dictionary.h \
39	src/ctemplate/template_dictionary_interface.h \
40	src/ctemplate/template_annotator.h \
41	src/ctemplate/template_emitter.h \
42	src/ctemplate/template_namelist.h \
43	src/ctemplate/per_expand_data.h \
44	src/ctemplate/str_ref.h
45noinst_HEADERS = \
46	src/ctemplate/template.h.in \
47	src/ctemplate/template_cache.h.in \
48	src/ctemplate/template_string.h.in \
49	src/ctemplate/template_enums.h.in \
50	src/ctemplate/template_pathops.h.in \
51	src/ctemplate/template_modifiers.h.in \
52	src/ctemplate/template_dictionary.h.in \
53	src/ctemplate/template_dictionary_interface.h.in \
54	src/ctemplate/template_annotator.h.in \
55	src/ctemplate/template_emitter.h.in \
56	src/ctemplate/template_namelist.h.in \
57	src/ctemplate/per_expand_data.h.in \
58	src/ctemplate/str_ref.h.in
59
60## This is for HTML and other documentation you want to install.
61## Add your documentation files (in doc/) in addition to these
62## top-level boilerplate files.  Also add a TODO file if you have one.
63dist_html_DATA = doc/designstyle.css doc/index.html \
64	doc/howto.html doc/guide.html doc/reference.html \
65	doc/tips.html doc/example.html doc/auto_escape.html \
66	doc/xss_resources.html
67
68## The libraries (.so's) you want to install
69lib_LTLIBRARIES =
70## Libraries that we want to use only internally (for our unittest binaries)
71noinst_LTLIBRARIES =
72## The binaries you want to install
73bin_PROGRAMS =
74bin_SCRIPTS =
75## The location of the windows project file for each binary we make
76WINDOWS_PROJECTS = ctemplate.sln
77
78
79## unittests you want to run when people type 'make check'.
80## TESTS is for binary unittests, check_SCRIPTS for script-based unittests.
81## TESTS_ENVIRONMENT sets environment variables for when you run unittest,
82## but it only seems to take effect for *binary* unittests (argh!)
83TESTS =
84check_SCRIPTS =
85TESTS_ENVIRONMENT = TEMPLATE_ROOTDIR=$(top_srcdir)
86# Every time you add a unittest to check_SCRIPTS, add it here too
87noinst_SCRIPTS =
88# Add to this for tests that use data
89TESTDATA =
90
91## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
92
93# These files are auto-generated via generate_fsm.py.  Since we don't want
94# to require python to build ctemplate, we include these in the dist
95src/htmlparser/htmlparser_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/htmlparser/htmlparser_fsm.config
96	$(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/htmlparser/htmlparser_fsm.config > $@
97
98src/htmlparser/jsparser_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/htmlparser/jsparser_fsm.config
99	$(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/htmlparser/jsparser_fsm.config > $@
100
101src/tests/statemachine_test_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/tests/statemachine_test_fsm.config
102	$(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/tests/statemachine_test_fsm.config > $@
103
104# This is a required hack for auto-generated .h files: cf the automake info pages
105# NOTE: since we put these .h files in BUILT_SOURCES, we don't need to put
106# them in as deps for the binaries that use them.  In fact, it's important
107# that we don't; instead we put them in EXTRA_DIST.  This mean, in practice,
108# they'll go at the end of the distribution tarfile, which means they'll
109# have a later timestamp than the .config files that generate them, which
110# means users won't try to rebuild them.  Ah, the joys of automake.
111BUILT_SOURCES = src/htmlparser/htmlparser_fsm.h \
112                src/htmlparser/jsparser_fsm.h \
113                src/tests/statemachine_test_fsm.h
114
115
116# These are the symbols (classes, mostly) we want to export from our library.
117# Note this regexp applies to the *mangled* name, which is why we have to
118# be careful where we want to assert [^A-Za-z].  (Particularly bad on Darwin.)
119# template_modifiers and BaseArena and UnsafeArena perhaps shouldn't be
120# exported, but they're needed -- at least -- for some unittests.
121CTEMPLATE_SYMBOLS = '(ctemplate|template_modifiers|BaseArena|UnsafeArena|[^A-Za-z]Template[^A-Za-z]|TemplateDictionary|TemplateNamelist|TemplateFromString|TemplateString|TemplateState|[^A-Za-z]Strip[^A-Za-z])'
122
123lib_LTLIBRARIES += libctemplate.la
124WINDOWS_PROJECTS += vsprojects/libctemplate/libctemplate.vcxproj
125libctemplate_la_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
126	src/base/arena-inl.h \
127	src/base/arena.cc \
128	src/base/arena.h \
129	src/base/fileutil.h \
130	src/base/macros.h \
131	src/base/manual_constructor.h \
132	src/base/mutex.h \
133	src/base/small_map.h \
134	src/base/thread_annotations.h \
135	src/base/util.h \
136	src/indented_writer.h \
137	src/per_expand_data.cc \
138	src/template.cc \
139	src/template_annotator.cc \
140	src/template_cache.cc \
141	src/template_dictionary.cc \
142	src/template_modifiers.cc \
143	src/template_modifiers_internal.h \
144	src/template_namelist.cc \
145	src/template_pathops.cc \
146	src/template_string.cc \
147	src/htmlparser/htmlparser.cc \
148	src/htmlparser/htmlparser.h \
149	src/htmlparser/htmlparser_cpp.h \
150	src/htmlparser/jsparser.cc \
151	src/htmlparser/jsparser.h \
152	src/htmlparser/statemachine.cc \
153	src/htmlparser/statemachine.h
154libctemplate_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS)
155# -version-info gets passed to libtool
156libctemplate_la_LDFLAGS = $(PTHREAD_CFLAGS) \
157                          -export-symbols-regex $(CTEMPLATE_SYMBOLS) \
158                          -no-undefined \
159                          -version-info @SO_VERSION@
160libctemplate_la_LIBADD = $(PTHREAD_LIBS)
161
162# For MinGW, we need to bring in the windows port files
163if MINGW
164libctemplate_la_SOURCES += src/windows/port.h src/windows/port.cc
165endif MINGW
166
167# automake will make different .o files for this library, which is good,
168# because we use an extra compiler flag.
169lib_LTLIBRARIES += libctemplate_nothreads.la
170libctemplate_nothreads_la_SOURCES = $(libctemplate_la_SOURCES)
171libctemplate_nothreads_la_DEPENDENCIES = $(libctemplate_la_DEPENDENCIES)
172libctemplate_nothreads_la_CXXFLAGS = -DNDEBUG -DNO_THREADS $(AM_CXXFLAGS)
173libctemplate_nothreads_la_LDFLAGS = -export-symbols-regex $(CTEMPLATE_SYMBOLS) \
174                                    -no-undefined \
175                                    -version-info @SO_VERSION@
176
177# For our tests, we want versions of these libraries that include asserts.
178noinst_LTLIBRARIES += libctemplate_debug.la
179libctemplate_debug_la_SOURCES = $(libctemplate_la_SOURCES)
180libctemplate_debug_la_DEPENDENCIES = $(libctemplate_la_DEPENDENCIES)
181libctemplate_debug_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
182libctemplate_debug_la_LDFLAGS = $(libctemplate_la_LDFLAGS)
183libctemplate_debug_la_LIBADD = $(libctemplate_la_LIBADD)
184noinst_LTLIBRARIES += libctemplate_nothreads_debug.la
185libctemplate_nothreads_debug_la_SOURCES = $(libctemplate_nothreads_la_SOURCES)
186libctemplate_nothreads_debug_la_DEPENDENCIES = $(libctemplate_nothreads_la_DEPENDENCIES)
187libctemplate_nothreads_debug_la_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
188libctemplate_nothreads_debug_la_LDFLAGS = $(libctemplate_nothreads_la_LDFLAGS)
189
190# We could also make a library that has the TemplateDictionaryPeer
191# class.  This class is useful for testing (it provides introspection
192# on the TemplateDictionary hierarchy that's easier to use than the
193# default debugging method, TemplateDictionary::Dump()) but by the
194# same token also violates abstraction in ways that might be fragile.
195# We don't expose the library for now, until the demonstrated need
196# outweighs the costs.  If you'd like to use this library, please send
197# mail to google-ctemplate@googlegroups.com!
198##lib_LTLIBRARIES += libctemplate_testing.la
199noinst_LTLIBRARIES += libctemplate_testing.la libctemplate_testing_nothreads.la
200libctemplate_testing_la_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
201                                  src/tests/template_test_util.h \
202                                  src/tests/template_test_util.cc
203libctemplate_testing_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
204CTEMPLATE_TESTING_SYMBOLS = 'TemporaryRegisterTemplate|TemplateDictionaryPeer'
205libctemplate_testing_la_LDFLAGS = $(PTHREAD_CFLAGS) \
206                                  -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) \
207                                  -no-undefined \
208                                  -version-info @SO_VERSION@
209libctemplate_testing_la_LIBADD = $(PTHREAD_LIBS)
210libctemplate_testing_nothreads_la_SOURCES = $(libctemplate_testing_la_SOURCES)
211libctemplate_testing_nothreads_la_CXXFLAGS = $(AM_CXXFLAGS) -DNO_THREADS
212libctemplate_testing_nothreads_la_LDFLAGS = -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) \
213                                            -no-undefined \
214                                            -version-info @SO_VERSION@
215
216# This library depends on libctemplate, but it can use either libctemplate
217# or libctemplate_nothreads.  Rather than have two versions of this
218# library, I just leave out the deps entirely: you must be sure to specify
219# one of the two whenever you link this library into your code.
220#libctemplate_testing_la_LIBADD = libctemplate.la # or libctemplate_nothreads.la
221
222
223# Helper apps
224bin_PROGRAMS += make_tpl_varnames_h
225WINDOWS_PROJECTS += vsprojects/make_tpl_varname_h/make_tpl_varname_h.vcxproj
226make_tpl_varnames_h_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
227	src/make_tpl_varnames_h.cc
228make_tpl_varnames_h_LDADD = libctemplate_nothreads.la
229
230bin_PROGRAMS += diff_tpl_auto_escape
231WINDOWS_PROJECTS += vsprojects/diff_tpl_auto_escape/diff_tpl_auto_escape.vcxproj
232diff_tpl_auto_escape_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
233	src/diff_tpl_auto_escape.cc
234diff_tpl_auto_escape_LDADD = libctemplate_nothreads.la
235
236bin_SCRIPTS += src/template-converter
237
238# For each of the tests, we test with and without threads
239
240TESTS += compile_test compile_nothreads_test
241WINDOWS_PROJECTS += vsprojects/compile_test/compile_test.vcxproj
242compile_test_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
243                       src/tests/compile_test.cc
244compile_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
245compile_test_LDFLAGS = $(PTHREAD_CFLAGS)
246compile_test_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
247compile_nothreads_test_SOURCES = $(compile_test_SOURCES)
248compile_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
249compile_nothreads_test_LDADD = libctemplate_nothreads_debug.la
250
251# With compile_test, we are making sure that the code compiles without
252# needing config.h/etc.  The best test is to make sure we can compile
253# with just the installed header files.  The best way to do this is at
254# installcheck time.  When this rule is run (via 'make distcheck'),
255# 'includedir' is the installed include-dir.
256installcheck-local:
257	$(CXX) -I $(includedir) -c $(top_srcdir)/src/tests/compile_test.cc \
258	       -o installcheck_compile_test.o
259
260TESTS += template_test_util_test template_test_util_nothreads_test
261WINDOWS_PROJECTS += vsprojects/template_test_util_test/template_test_util_test.vcxproj
262template_test_util_test_SOURCES = src/tests/config_for_unittests.h \
263                                   src/template_dictionary.cc \
264                                   src/tests/template_test_util_test.cc
265template_test_util_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
266template_test_util_test_LDFLAGS = $(PTHREAD_CFLAGS)
267template_test_util_test_LDADD = libctemplate_testing.la libctemplate_debug.la \
268                                 $(PTHREAD_LIBS)
269template_test_util_nothreads_test_SOURCES = $(template_test_util_test_SOURCES)
270template_test_util_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
271template_test_util_nothreads_test_LDADD = libctemplate_testing_nothreads.la \
272                                          libctemplate_nothreads_debug.la
273
274TESTS += template_dictionary_unittest template_dictionary_nothreads_unittest
275WINDOWS_PROJECTS += vsprojects/template_dictionary_unittest/template_dictionary_unittest.vcxproj
276template_dictionary_unittest_SOURCES = src/tests/config_for_unittests.h \
277                                       src/base/arena.h \
278                                       src/tests/template_dictionary_unittest.cc
279template_dictionary_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
280template_dictionary_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
281template_dictionary_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
282                                     $(PTHREAD_LIBS)
283template_dictionary_nothreads_unittest_SOURCES = $(template_dictionary_unittest_SOURCES)
284template_dictionary_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
285template_dictionary_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
286                                               libctemplate_nothreads_debug.la
287
288TESTS += template_modifiers_unittest template_modifiers_nothreads_unittest
289WINDOWS_PROJECTS += vsprojects/template_modifiers_unittest/template_modifiers_unittest.vcxproj
290template_modifiers_unittest_SOURCES = src/tests/config_for_unittests.h \
291                                      src/tests/template_modifiers_unittest.cc
292template_modifiers_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
293template_modifiers_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
294template_modifiers_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
295                                    $(PTHREAD_LIBS)
296template_modifiers_nothreads_unittest_SOURCES = $(template_modifiers_unittest_SOURCES)
297template_modifiers_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
298template_modifiers_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
299                                              libctemplate_nothreads_debug.la
300
301TESTS += template_setglobals_unittest template_setglobals_nothreads_unittest
302WINDOWS_PROJECTS += vsprojects/template_setglobals_unittest/template_setglobals_unittest.vcxproj
303template_setglobals_unittest_SOURCES = src/tests/config_for_unittests.h \
304                                       src/tests/template_setglobals_unittest.cc
305template_setglobals_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
306template_setglobals_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
307template_setglobals_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
308                                     $(PTHREAD_LIBS)
309template_setglobals_nothreads_unittest_SOURCES = $(template_setglobals_unittest_SOURCES)
310template_setglobals_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
311template_setglobals_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
312                                               libctemplate_nothreads_debug.la
313
314TESTS += template_cache_test template_cache_nothreads_test
315WINDOWS_PROJECTS += vsprojects/template_cache_test/template_cache_test.vcxproj
316template_cache_test_SOURCES = src/tests/config_for_unittests.h \
317                              src/template_modifiers_internal.h \
318                              src/tests/template_cache_test.cc
319template_cache_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
320template_cache_test_LDFLAGS = $(PTHREAD_CFLAGS)
321template_cache_test_LDADD = libctemplate_testing.la libctemplate_debug.la \
322                            $(PTHREAD_LIBS)
323template_cache_nothreads_test_SOURCES = $(template_cache_test_SOURCES)
324template_cache_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
325template_cache_nothreads_test_LDADD = libctemplate_testing_nothreads.la \
326                                      libctemplate_nothreads_debug.la
327
328TESTS += template_unittest template_nothreads_unittest
329WINDOWS_PROJECTS += vsprojects/template_unittest/template_unittest.vcxproj
330WINDOWS_PROJECTS += vsprojects/template_unittest_static/template_unittest_static.vcxproj
331template_unittest_SOURCES = src/tests/config_for_unittests.h \
332                            src/template_modifiers_internal.h \
333                            src/tests/template_unittest.cc
334template_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
335template_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
336template_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
337                          $(PTHREAD_LIBS)
338template_nothreads_unittest_SOURCES = $(template_unittest_SOURCES)
339template_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
340template_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
341                                    libctemplate_nothreads_debug.la
342
343TESTS += template_regtest template_nothreads_regtest
344WINDOWS_PROJECTS += vsprojects/template_regtest/template_regtest.vcxproj
345template_regtest_SOURCES = src/tests/template_regtest.cc
346template_regtest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
347template_regtest_LDFLAGS = $(PTHREAD_CFLAGS)
348template_regtest_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
349template_nothreads_regtest_SOURCES = $(template_regtest_SOURCES)
350template_nothreads_regtest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
351template_nothreads_regtest_LDADD = libctemplate_nothreads_debug.la
352TESTDATA += \
353   src/tests/template_unittest_test_footer.in \
354   src/tests/template_unittest_test_html.in \
355   src/tests/template_unittest_test_invalid1.in \
356   src/tests/template_unittest_test_invalid2.in \
357   src/tests/template_unittest_test_markerdelim.in \
358   src/tests/template_unittest_test_modifiers.in \
359   src/tests/template_unittest_test_nul.in \
360   src/tests/template_unittest_test_selective_css.in \
361   src/tests/template_unittest_test_selective_html.in \
362   src/tests/template_unittest_test_selective_js.in \
363   src/tests/template_unittest_test_simple.in \
364   src/tests/template_unittest_test_valid1.in \
365   src/tests/template_unittest_test_footer_dict01.out \
366   src/tests/template_unittest_test_footer_dict02.out \
367   src/tests/template_unittest_test_html_dict01.out \
368   src/tests/template_unittest_test_html_dict02.out \
369   src/tests/template_unittest_test_markerdelim_dict01.out \
370   src/tests/template_unittest_test_markerdelim_dict02.out \
371   src/tests/template_unittest_test_modifiers_dict01.out \
372   src/tests/template_unittest_test_nul_dict01.out \
373   src/tests/template_unittest_test_selective_css_dict01.out \
374   src/tests/template_unittest_test_selective_css_dict02.out \
375   src/tests/template_unittest_test_selective_html_dict01.out \
376   src/tests/template_unittest_test_selective_html_dict02.out \
377   src/tests/template_unittest_test_selective_js_dict01.out \
378   src/tests/template_unittest_test_selective_js_dict02.out \
379   src/tests/template_unittest_test_simple_dict01.out \
380   src/tests/template_unittest_test_simple_dict02.out \
381   src/tests/template_unittest_test_simple_dict03.out \
382   src/tests/template_unittest_test_valid1_dict01.out
383
384TESTS += htmlparser_test htmlparser_nothreads_test
385WINDOWS_PROJECTS += vsprojects/htmlparser_test/htmlparser_test.vcxproj
386htmlparser_test_SOURCES = src/tests/htmlparser_cpp_test.cc
387htmlparser_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
388htmlparser_test_LDFLAGS = $(PTHREAD_CFLAGS)
389htmlparser_test_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
390htmlparser_nothreads_test_SOURCES = $(htmlparser_test_SOURCES)
391htmlparser_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
392htmlparser_nothreads_test_LDADD = libctemplate_nothreads_debug.la
393TESTDATA += \
394   src/tests/htmlparser_testdata/cdata.html \
395   src/tests/htmlparser_testdata/comments.html \
396   src/tests/htmlparser_testdata/context.html \
397   src/tests/htmlparser_testdata/google.html \
398   src/tests/htmlparser_testdata/javascript_attribute.html \
399   src/tests/htmlparser_testdata/javascript_block.html \
400   src/tests/htmlparser_testdata/javascript_regexp.html \
401   src/tests/htmlparser_testdata/position.html \
402   src/tests/htmlparser_testdata/reset.html \
403   src/tests/htmlparser_testdata/simple.html \
404   src/tests/htmlparser_testdata/tags.html
405
406# We want to compile statemachine.cc as a c file as well as a c++ file
407statemachine.c: $(top_srcdir)/src/htmlparser/statemachine.cc
408	cp $< $@
409
410BUILT_SOURCES += statemachine.c
411CLEANFILES = statemachine.c
412
413TESTS += statemachine_test
414WINDOWS_PROJECTS += vsprojects/statemachine_test/statemachine_test.vcxproj
415statemachine_test_SOURCES = src/tests/statemachine_test.c \
416                            statemachine.c
417statemachine_test_CFLAGS = -I$(top_srcdir)/src/htmlparser
418
419TESTS += generate_fsm_c_test
420WINDOWS_PROJECTS += vsprojects/generate_fsm_c_test/generate_fsm_c_test.vcxproj
421generate_fsm_c_test_SOURCES = src/tests/generate_fsm_c_test.c
422generate_fsm_c_test_DEPENDENCIES = src/tests/htmlparser_testdata/sample_fsm.c
423
424# This is something only maintainers need (since they're the only ones
425# who generate .h or .c files from .config files).
426check_SCRIPTS += generate_fsm_test_sh
427noinst_SCRIPTS += src/tests/generate_fsm_test.sh
428generate_fsm_test_sh: src/tests/generate_fsm_test.sh \
429                      src/tests/htmlparser_testdata/sample_fsm.config \
430                      src/tests/htmlparser_testdata/sample_fsm.c \
431                      src/htmlparser/generate_fsm.py
432	sh $(top_srcdir)/src/tests/generate_fsm_test.sh $(top_srcdir)
433TESTDATA += \
434   src/tests/htmlparser_testdata/sample_fsm.config \
435   src/tests/htmlparser_testdata/sample_fsm.c
436
437check_SCRIPTS += make_tpl_varnames_h_unittest_sh
438noinst_SCRIPTS += src/tests/make_tpl_varnames_h_unittest.sh
439make_tpl_varnames_h_unittest_sh: src/tests/make_tpl_varnames_h_unittest.sh \
440                                 make_tpl_varnames_h
441	sh $(top_srcdir)/src/tests/make_tpl_varnames_h_unittest.sh \
442	   $(top_builddir)/make_tpl_varnames_h $(TMPDIR)/$@_dir
443
444check_SCRIPTS += diff_tpl_auto_escape_unittest_sh
445noinst_SCRIPTS += src/tests/diff_tpl_auto_escape_unittest.sh
446diff_tpl_auto_escape_unittest_sh: src/tests/diff_tpl_auto_escape_unittest.sh \
447                                  diff_tpl_auto_escape
448	sh $(top_srcdir)/src/tests/diff_tpl_auto_escape_unittest.sh \
449	   $(top_builddir)/diff_tpl_auto_escape $(TMPDIR)/$@_dir
450
451## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
452
453## This should always include $(TESTS), but may also include other
454## binaries that you compile but don't want automatically installed.
455check_PROGRAMS = $(TESTS)
456
457rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
458	@cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
459
460deb: dist-gzip packages/deb.sh packages/deb/*
461	@cd packages && ./deb.sh ${PACKAGE} ${VERSION}
462
463# http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
464pkgconfigdir = $(prefix)/libdata/pkgconfig
465pkgconfig_DATA = lib${PACKAGE}.pc lib${PACKAGE}_nothreads.pc
466CLEANFILES += $(pkgconfig_DATA)
467
468# I get the description and URL lines from the rpm spec. I use sed to
469# try to rewrite exec_prefix, libdir, and includedir in terms of
470# prefix, if possible.
471lib${PACKAGE}.pc: Makefile packages/rpm/rpm.spec
472	echo 'prefix=$(prefix)' > "$@".tmp
473	echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
474	echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
475	echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
476	echo '' >> "$@".tmp
477	echo 'Name: $(PACKAGE)' >> "$@".tmp
478	echo 'Version: $(VERSION)' >> "$@".tmp
479	-grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
480	-grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
481	echo 'Requires:' >> "$@".tmp
482	echo 'Libs: -L$${libdir} -l$(PACKAGE)' >> "$@".tmp
483	echo 'Libs.private: $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)' >> "$@".tmp
484	echo 'Cflags: -I$${includedir}' >> "$@".tmp
485	mv -f "$@".tmp "$@"
486
487# The nothreads version is mostly the same
488lib${PACKAGE}_nothreads.pc: lib${PACKAGE}.pc
489	grep -v Libs.private lib${PACKAGE}.pc | sed s/-l$(PACKAGE)/-l$(PACKAGE)_nothreads/ > "$@"
490
491# Windows wants write permission to .vcxproj files and maybe even sln files.
492dist-hook:
493	test -e "$(distdir)/vsprojects" \
494	   && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
495
496## If you're using libtool, add 'libtool' here.  Also add this rule:
497libtool: $(LIBTOOL_DEPS)
498	$(SHELL) ./config.status --recheck
499
500# In addition to the normal stuff, we include all the windows-specific
501# code, and also the code used to generate the html-parser fsm files.
502# NOTE: BUILT_SOURCES should come after the .config files, so they
503# come later (and thus end up with a later timestamp) when we tar/untar.
504EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
505	$(SCRIPTS) $(TESTDATA) libtool autogen.sh \
506	src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py \
507	src/tests/statemachine_test_fsm.config \
508	src/htmlparser/htmlparser_fsm.config \
509	src/htmlparser/jsparser_fsm.config \
510	$(BUILT_SOURCES) \
511	src/windows/config.h src/windows/preprocess.sh \
512	src/windows/ctemplate $(WINDOWS_PROJECTS) \
513	src/solaris/libstdc++.la contrib
514