1ACLOCAL_AMFLAGS=-I m4
2
3bin_PROGRAMS = watchman
4# ensure that we have a reasonable default for the python install
5DESTDIR ?= /
6
7doc_DATA = README.markdown
8docdir = ${prefix}/share/doc/watchman-$(VERSION)
9
10THIRDPARTY_CPPFLAGS = -I$(top_srcdir)/thirdparty/jansson -I$(top_builddir)/thirdparty/jansson
11JSON_LIB = -L. libwmanjson.a
12
13watchman_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
14watchman_LDADD = $(JSON_LIB) libwildmatch.a
15watchman_SOURCES = \
16	ChildProcess.cpp \
17	ContentHash.cpp \
18	CookieSync.cpp \
19	FileDescriptor.cpp \
20	FileInformation.cpp \
21	InMemoryView.cpp \
22	Pipe.cpp \
23	PubSub.cpp \
24	ThreadPool.cpp \
25	QueryableView.cpp \
26	spawn.cpp       \
27	opt.cpp        \
28	cfg.cpp        \
29	clockspec.cpp  \
30	checksock.cpp  \
31	error_category.cpp  \
32	fstype.cpp     \
33	log.cpp        \
34	ignore.cpp     \
35	json.cpp       \
36	bser.cpp       \
37	expflags.cpp   \
38	hash.cpp       \
39	ioprio.cpp        \
40	opendir.cpp       \
41	pending.cpp       \
42	perf.cpp          \
43	stream.cpp        \
44	stream_stdout.cpp \
45	stream_unix.cpp   \
46	timedlock.cpp     \
47	cmds/find.cpp     \
48	cmds/info.cpp     \
49	cmds/log.cpp      \
50	cmds/query.cpp    \
51	cmds/since.cpp    \
52	cmds/reg.cpp      \
53	cmds/state.cpp    \
54	cmds/subscribe.cpp    \
55	cmds/trigger.cpp  \
56	cmds/watch.cpp    \
57	cmds/debug.cpp    \
58	query/base.cpp       \
59	query/dirname.cpp    \
60	query/parse.cpp      \
61	query/eval.cpp       \
62	query/glob.cpp       \
63	query/intcompare.cpp \
64	query/type.cpp       \
65	query/suffix.cpp     \
66	query/match.cpp      \
67	query/pcre.cpp       \
68	query/name.cpp       \
69	query/fieldlist.cpp  \
70	query/since.cpp      \
71	query/empty.cpp      \
72	watcher/auto.cpp     \
73	watcher/fsevents.cpp \
74	watcher/inotify.cpp  \
75	watcher/kqueue.cpp   \
76	launchd.cpp    \
77	listener.cpp   \
78	listener-user.cpp   \
79	clientmode.cpp \
80	main.cpp       \
81	root/ageout.cpp       \
82	root/crawler.cpp       \
83	root/dir.cpp       \
84	root/file.cpp       \
85	root/init.cpp       \
86	root/iothread.cpp       \
87	root/notifythread.cpp       \
88	root/poison.cpp       \
89	root/reap.cpp       \
90	root/resolve.cpp       \
91	root/stat.cpp       \
92	root/symlink.cpp       \
93	root/sync.cpp       \
94	root/threading.cpp       \
95	root/vcs.cpp       \
96	root/warnerr.cpp       \
97	root/watchlist.cpp       \
98	scm/Mercurial.cpp \
99	scm/SCM.cpp \
100	state.cpp      \
101	string.cpp     \
102	time.cpp
103
104noinst_HEADERS =   \
105	watchman.h       \
106	watchman_hash.h
107
108noinst_LIBRARIES = \
109	libtap.a \
110	libwildmatch.a \
111	libwmanjson.a
112
113# bundled json library
114libwmanjson_a_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
115libwmanjson_a_SOURCES = \
116	thirdparty/jansson/dump.cpp \
117	thirdparty/jansson/error.cpp \
118	thirdparty/jansson/jansson_private.h \
119	thirdparty/jansson/load.cpp \
120	thirdparty/jansson/memory.cpp \
121	thirdparty/jansson/pack_unpack.cpp \
122	thirdparty/jansson/strbuffer.cpp \
123	thirdparty/jansson/strbuffer.h \
124	thirdparty/jansson/strconv.cpp \
125	thirdparty/jansson/utf.cpp \
126	thirdparty/jansson/utf.h \
127	thirdparty/jansson/value.cpp
128
129# bundled testing library
130libtap_a_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
131libtap_a_SOURCES = thirdparty/tap.cpp
132TAP_LIB = libtap.a
133
134# pattern matching library
135libwildmatch_a_SOURCES = thirdparty/wildmatch/wildmatch.c
136WILDMATCH_LIB = libwildmatch.a
137
138# unit tests
139TESTS = \
140		tests/art.t \
141		tests/bser.t \
142		tests/cache.t \
143		tests/childproc.t \
144		tests/future.t \
145		tests/ignore.t \
146		tests/pending.t \
147		tests/result.t \
148		tests/string.t \
149		tests/log.t \
150		tests/wildmatch.t
151
152if ENABLE_CPPCLIENT
153lib_LTLIBRARIES = libwatchmanclient.la
154libwatchmanclient_ladir = $(includedir)/watchman/
155libwatchmanclient_la_HEADERS = \
156	cppclient/WatchmanClient.h \
157	cppclient/WatchmanConnection.h
158
159TESTS += tests/integration/cppclient.t
160
161# No IRONMANCFLAGS as this is incompatible with Folly
162libwatchmanclient_la_SOURCES = \
163	cppclient/WatchmanClient.cpp \
164	cppclient/WatchmanConnection.cpp \
165	cppclient/WatchmanResponseError.cpp
166libwatchmanclient_la_CPPFLAGS = $(FOLLY_CFLAGS)
167libwatchmanclient_la_LDFLAGS = -version-info 0:0:0 $(FOLLY_LDFLAGS)
168CPPCLIENT_LIB=libwatchmanclient.la
169
170# No IRONMANCFLAGS as this is incompatible with Folly
171tests_integration_cppclient_t_CPPFLAGS = $(FOLLY_CFLAGS) -I cppclient/
172tests_integration_cppclient_t_LDADD = $(CPPCLIENT_LIB) $(FOLLY_LIBS)
173tests_integration_cppclient_t_LDFLAGS = $(FOLLY_LDFLAGS)
174tests_integration_cppclient_t_SOURCES = \
175	tests/integration/cppclient.cpp
176
177# install pkg-config metadata file
178pkgconfigdir = $(libdir)/pkgconfig
179nodist_pkgconfig_DATA = cppclient/watchmanclient.pc
180endif
181
182noinst_PROGRAMS = $(TESTS)
183
184export ARCHFLAGS=@ARCHFLAGS@
185if HAVE_PYTHON
186py-build:
187	cd python && $(PYTHON) ./setup.py clean build_py -c -d . build_ext -i
188
189py-install:
190	cd python && $(PYTHON) ./setup.py install --prefix ${prefix} --root $(DESTDIR)
191
192# This is invoked via WatchmanIntegrationEngine
193py-tests:
194	$(PYTHON) $(TESTNAME)
195
196py-integration:
197	$(PYTHON) runtests.py --keep-if-fail
198
199py-clean:
200	-cd python && $(PYTHON) ./setup.py clean --all
201
202else
203py-build:
204py-tests:
205py-clean:
206py-install:
207py-integration:
208	@echo You need python to run the tests
209	false
210endif
211
212if HAVE_RUBY
213rb-build:
214	cd ruby/ruby-watchman && bundle && bundle exec rake make
215
216rb-tests:
217	cd ruby/ruby-watchman && bundle && bundle exec rake spec
218
219rb-clean:
220	cd ruby/ruby-watchman && bundle && bundle exec rake clean
221else
222rb-build:
223rb-tests:
224rb-clean:
225endif
226
227all-local: py-build rb-build
228
229install-exec-local: py-install
230if WATCHMAN_STATE_DIR
231	${INSTALL} -d -m 777 ${DESTDIR}${WATCHMAN_STATE_DIR}
232	chmod g+s ${DESTDIR}${WATCHMAN_STATE_DIR}
233	touch ${DESTDIR}${WATCHMAN_STATE_DIR}/.not-empty
234endif
235
236clean-local: py-clean rb-clean
237	-find python \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
238	-rm -rf python/build
239
240# generate a rule that we can use to ensure that
241# the test programs are built
242build-tests: $(TESTS)
243.PHONY: build-tests integration py-tests
244# run integration AND unit tests
245integration: all py-integration check
246
247tests_art_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
248tests_art_t_LDADD = $(TAP_LIB) $(JSON_LIB)
249tests_art_t_SOURCES = \
250	tests/art_test.cpp \
251	tests/log_stub.cpp \
252	PubSub.cpp \
253	string.cpp \
254	hash.cpp \
255	log.cpp
256
257tests_childproc_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
258tests_childproc_t_LDADD = $(TAP_LIB) $(JSON_LIB)
259tests_childproc_t_SOURCES = \
260	tests/childproc.cpp \
261	tests/log_stub.cpp \
262	ChildProcess.cpp \
263	Pipe.cpp \
264	FileDescriptor.cpp \
265	FileInformation.cpp \
266	PubSub.cpp \
267	string.cpp \
268	hash.cpp \
269	log.cpp
270
271tests_cache_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
272tests_cache_t_LDADD = $(TAP_LIB) $(JSON_LIB)
273tests_cache_t_SOURCES = \
274	tests/CacheTest.cpp \
275	tests/log_stub.cpp \
276	PubSub.cpp \
277	ThreadPool.cpp \
278	string.cpp \
279	hash.cpp \
280	log.cpp
281
282tests_future_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
283tests_future_t_LDADD = $(TAP_LIB) $(JSON_LIB)
284tests_future_t_SOURCES = \
285	tests/FutureTest.cpp \
286	tests/log_stub.cpp \
287	PubSub.cpp \
288	ThreadPool.cpp \
289	string.cpp \
290	hash.cpp \
291	log.cpp
292
293tests_result_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
294tests_result_t_LDADD = $(TAP_LIB) $(JSON_LIB)
295tests_result_t_SOURCES = \
296	tests/ResultTest.cpp \
297	tests/log_stub.cpp \
298	PubSub.cpp \
299	string.cpp \
300	hash.cpp \
301	log.cpp
302
303tests_ignore_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
304tests_ignore_t_LDADD = $(TAP_LIB) $(JSON_LIB)
305tests_ignore_t_SOURCES = \
306	tests/ignore_test.cpp \
307	tests/log_stub.cpp \
308	hash.cpp \
309	ignore.cpp \
310	string.cpp \
311	PubSub.cpp \
312	log.cpp
313
314tests_string_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
315tests_string_t_LDADD = $(TAP_LIB) $(JSON_LIB)
316tests_string_t_SOURCES = \
317	tests/string_test.cpp \
318	tests/log_stub.cpp \
319	PubSub.cpp \
320	hash.cpp \
321	log.cpp \
322	string.cpp
323
324tests_pending_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
325tests_pending_t_LDADD = $(TAP_LIB) $(JSON_LIB)
326tests_pending_t_SOURCES = \
327	tests/pending_test.cpp \
328	tests/log_stub.cpp \
329	FileDescriptor.cpp \
330	FileInformation.cpp \
331	PubSub.cpp \
332	hash.cpp \
333	ignore.cpp \
334	pending.cpp \
335	expflags.cpp \
336	opendir.cpp \
337	cfg.cpp \
338	time.cpp \
339	string.cpp \
340	log.cpp
341
342tests_log_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
343tests_log_t_LDADD = $(JSON_LIB) $(TAP_LIB)
344tests_log_t_SOURCES = \
345	tests/log.cpp \
346	PubSub.cpp \
347	string.cpp \
348	hash.cpp \
349	log.cpp
350
351tests_bser_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
352tests_bser_t_LDADD = $(JSON_LIB) $(TAP_LIB)
353tests_bser_t_SOURCES = \
354	tests/bser.cpp \
355	tests/log_stub.cpp \
356	PubSub.cpp \
357	bser.cpp \
358	string.cpp \
359	hash.cpp \
360	log.cpp
361
362tests_wildmatch_t_CPPFLAGS = $(THIRDPARTY_CPPFLAGS) @IRONMANCFLAGS@
363tests_wildmatch_t_LDADD = $(JSON_LIB) $(TAP_LIB) $(WILDMATCH_LIB)
364tests_wildmatch_t_SOURCES = \
365	tests/wildmatch_test.cpp \
366	tests/log_stub.cpp \
367	PubSub.cpp \
368	string.cpp \
369	hash.cpp \
370	log.cpp
371
372watch:
373	PYTHONPATH=python python/bin/watchman-make \
374			-p '**/*.[ch]' 'Makefile*' '**/*.py' '**/*.php' \
375			-t integration
376