Makefile.am 19.3 KB
Newer Older
Kenton Varda's avatar
Kenton Varda committed
1 2
## Process this file with automake to produce Makefile.in

3 4
ACLOCAL_AMFLAGS = -I m4

Kenton Varda's avatar
Kenton Varda committed
5
AUTOMAKE_OPTIONS = foreign subdir-objects
Kenton Varda's avatar
Kenton Varda committed
6

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# Always include gtest in distributions.
DIST_SUBDIRS = $(subdirs)

# Build gtest before we build Cap'n Proto tests.  We don't add gtest to SUBDIRS
# because then "make check" would also build and run all of gtest's own tests,
# which takes a lot of time and is generally not useful to us.  Also, we don't
# want "make install" to recurse into gtest since we don't want to overwrite
# the installed version of gtest if there is one (and, actually, gtest doesn't
# even support "make install" anyway).  So we define a rule such that it will
# only be built when needed.
gtest/lib/libgtest.la:
	@echo "Making lib/libgtest.a lib/libgtest_main.a in gtest"
	@cd gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la

gtest/lib/libgtest_main.la: gtest/lib/libgtest.la
	@:

# We would like to clean gtest when "make clean" is invoked.  But we have to
# be careful because clean-local is also invoked during "make distclean", but
# "make distclean" already recurses into gtest because it's listed among the
# DIST_SUBDIRS.  distclean will delete gtest/Makefile, so if we then try to
# cd to the directory again and "make clean" it will fail.  So, check that the
# Makefile exists before recursing.
clean-local:
	@if test -e gtest/Makefile; then \
	  echo "Making clean in gtest"; \
	  cd gtest && $(MAKE) $(AM_MAKEFLAGS) clean; \
	fi

36 37 38
AM_CXXFLAGS = -I$(srcdir)/src -I$(builddir)/src $(PTHREAD_CFLAGS)

AM_LDFLAGS = $(PTHREAD_CFLAGS)
Kenton Varda's avatar
Kenton Varda committed
39 40 41

EXTRA_DIST =                                                                 \
  README.txt                                                                 \
42
  LICENSE.txt                                                                \
Kenton Varda's avatar
Kenton Varda committed
43 44 45 46 47 48 49 50 51 52 53
  $(test_capnpc_inputs)                                                      \
  src/capnp/compiler/capnp-test.sh                                           \
  src/capnp/testdata/segmented-packed                                        \
  src/capnp/testdata/errors.capnp.nobuild                                    \
  src/capnp/testdata/short.txt                                               \
  src/capnp/testdata/flat                                                    \
  src/capnp/testdata/binary                                                  \
  src/capnp/testdata/errors.txt                                              \
  src/capnp/testdata/segmented                                               \
  src/capnp/testdata/packed                                                  \
  src/capnp/testdata/pretty.txt
Kenton Varda's avatar
Kenton Varda committed
54

55
CLEANFILES = $(test_capnpc_outputs) test_capnpc_middleman
Kenton Varda's avatar
Kenton Varda committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

# Deletes all the files generated by autoreconf.
MAINTAINERCLEANFILES =   \
  aclocal.m4             \
  config.guess           \
  config.sub             \
  configure              \
  depcomp                \
  install-sh             \
  ltmain.sh              \
  Makefile.in            \
  missing                \
  mkinstalldirs          \
  config.h.in            \
  stamp.h.in             \
  m4/ltsugar.m4          \
  m4/libtool.m4          \
  m4/ltversion.m4        \
  m4/lt~obsolete.m4      \
  m4/ltoptions.m4

77 78 79
maintainer-clean-local:
	-rm -rf build-aux

80 81 82 83 84 85
# gmake defines an implicit rule building n from n.o.  Unfortunately, this triggers on our .capnp
# files because they generate .capnp.c++ which is compiled to .capnp.o.  In addition to being
# nonsense, this leads to cyclic dependency issues and could even cause the .capnp files to be
# unexpectedly overwritten!  We need to cancel the implicit rule by declaring an explicit one.
#
# I want the hours of my life back that I spent figuring this out.
86 87
%.capnp:
	@:
88

89
public_capnpc_inputs =                                         \
90 91
  src/capnp/c++.capnp                                          \
  src/capnp/schema.capnp
Kenton Varda's avatar
Kenton Varda committed
92

93 94
capnpc_inputs =                                                \
  $(public_capnpc_inputs)                                      \
95
  src/capnp/rpc.capnp                                          \
96
  src/capnp/rpc-twoparty.capnp                                 \
97 98
  src/capnp/compiler/lexer.capnp                               \
  src/capnp/compiler/grammar.capnp
99

Kenton Varda's avatar
Kenton Varda committed
100
capnpc_outputs =                                               \
101 102 103
  src/capnp/c++.capnp.c++                                      \
  src/capnp/c++.capnp.h                                        \
  src/capnp/schema.capnp.c++                                   \
104
  src/capnp/schema.capnp.h                                     \
105 106
  src/capnp/rpc.capnp.c++                                      \
  src/capnp/rpc.capnp.h                                        \
107 108
  src/capnp/rpc-twoparty.capnp.c++                             \
  src/capnp/rpc-twoparty.capnp.h                               \
109 110 111 112
  src/capnp/compiler/lexer.capnp.c++                           \
  src/capnp/compiler/lexer.capnp.h                             \
  src/capnp/compiler/grammar.capnp.c++                         \
  src/capnp/compiler/grammar.capnp.h
Kenton Varda's avatar
Kenton Varda committed
113

114
includecapnpdir = $(includedir)/capnp
Kenton Varda's avatar
Kenton Varda committed
115
includekjdir = $(includedir)/kj
Kenton Varda's avatar
Kenton Varda committed
116
includekjparsedir = $(includekjdir)/parse
Kenton Varda's avatar
Kenton Varda committed
117

118
dist_includecapnp_DATA = $(public_capnpc_inputs)
119

Kenton Varda's avatar
Kenton Varda committed
120 121
includekj_HEADERS =                                            \
  src/kj/common.h                                              \
Kenton Varda's avatar
Kenton Varda committed
122
  src/kj/units.h                                               \
Kenton Varda's avatar
Kenton Varda committed
123
  src/kj/memory.h                                              \
Kenton Varda's avatar
Kenton Varda committed
124
  src/kj/refcount.h                                            \
Kenton Varda's avatar
Kenton Varda committed
125
  src/kj/array.h                                               \
126
  src/kj/vector.h                                              \
Kenton Varda's avatar
Kenton Varda committed
127
  src/kj/string.h                                              \
128
  src/kj/string-tree.h                                         \
Kenton Varda's avatar
Kenton Varda committed
129
  src/kj/exception.h                                           \
Kenton Varda's avatar
Kenton Varda committed
130
  src/kj/debug.h                                               \
131
  src/kj/arena.h                                               \
132
  src/kj/io.h                                                  \
133
  src/kj/tuple.h                                               \
Kenton Varda's avatar
Kenton Varda committed
134
  src/kj/one-of.h                                              \
135
  src/kj/function.h                                            \
Kenton Varda's avatar
Kenton Varda committed
136
  src/kj/mutex.h                                               \
137
  src/kj/thread.h                                              \
138
  src/kj/async-prelude.h                                       \
Kenton Varda's avatar
Kenton Varda committed
139
  src/kj/async.h                                               \
Kenton Varda's avatar
Kenton Varda committed
140
  src/kj/async-inl.h                                           \
Kenton Varda's avatar
Kenton Varda committed
141
  src/kj/async-unix.h                                          \
142
  src/kj/async-io.h                                            \
143
  src/kj/main.h
Kenton Varda's avatar
Kenton Varda committed
144 145 146 147

includekjparse_HEADERS =                                       \
  src/kj/parse/common.h                                        \
  src/kj/parse/char.h
Kenton Varda's avatar
Kenton Varda committed
148

149
includecapnp_HEADERS =                                         \
Kenton Varda's avatar
Kenton Varda committed
150
  src/capnp/c++.capnp.h                                        \
151 152 153 154
  src/capnp/common.h                                           \
  src/capnp/blob.h                                             \
  src/capnp/endian.h                                           \
  src/capnp/layout.h                                           \
155
  src/capnp/orphan.h                                           \
156
  src/capnp/list.h                                             \
Kenton Varda's avatar
Kenton Varda committed
157
  src/capnp/object.h                                           \
158
  src/capnp/message.h                                          \
Kenton Varda's avatar
Kenton Varda committed
159 160
  src/capnp/capability.h                                       \
  src/capnp/capability-context.h                               \
Kenton Varda's avatar
Kenton Varda committed
161
  src/capnp/schema.capnp.h                                     \
162 163
  src/capnp/schema.h                                           \
  src/capnp/schema-loader.h                                    \
164
  src/capnp/schema-parser.h                                    \
165
  src/capnp/dynamic.h                                          \
166
  src/capnp/pretty-print.h                                     \
167
  src/capnp/serialize.h                                        \
168
  src/capnp/serialize-async.h                                  \
169
  src/capnp/serialize-packed.h                                 \
170
  src/capnp/pointer-helpers.h                                  \
171
  src/capnp/generated-header-support.h                         \
172
  src/capnp/rpc-prelude.h                                      \
173
  src/capnp/rpc.h                                              \
174 175
  src/capnp/rpc-twoparty.h                                     \
  src/capnp/rpc.capnp.h                                        \
176 177
  src/capnp/rpc-twoparty.capnp.h                               \
  src/capnp/ez-rpc.h
Kenton Varda's avatar
Kenton Varda committed
178

179
lib_LTLIBRARIES = libkj.la libkj-async.la libcapnp.la libcapnp-rpc.la libcapnpc.la
Kenton Varda's avatar
Kenton Varda committed
180

181 182
# -lpthread is here to work around https://bugzilla.redhat.com/show_bug.cgi?id=661333
libkj_la_LIBADD = $(PTHREAD_LIBS) -lpthread
183
libkj_la_LDFLAGS = -release $(VERSION) -no-undefined
184
libkj_la_SOURCES=                                              \
Kenton Varda's avatar
Kenton Varda committed
185
  src/kj/common.c++                                            \
Kenton Varda's avatar
Kenton Varda committed
186
  src/kj/units.c++                                             \
Kenton Varda's avatar
Kenton Varda committed
187
  src/kj/memory.c++                                            \
Kenton Varda's avatar
Kenton Varda committed
188
  src/kj/refcount.c++                                          \
Kenton Varda's avatar
Kenton Varda committed
189 190
  src/kj/array.c++                                             \
  src/kj/string.c++                                            \
191
  src/kj/string-tree.c++                                       \
Kenton Varda's avatar
Kenton Varda committed
192
  src/kj/exception.c++                                         \
Kenton Varda's avatar
Kenton Varda committed
193
  src/kj/debug.c++                                             \
194
  src/kj/arena.c++                                             \
Kenton Varda's avatar
Kenton Varda committed
195
  src/kj/io.c++                                                \
196
  src/kj/mutex.c++                                             \
Kenton Varda's avatar
Kenton Varda committed
197
  src/kj/thread.c++                                            \
198
  src/kj/main.c++                                              \
199 200
  src/kj/parse/char.c++

201 202 203 204 205 206 207 208
# -lpthread is here to work around https://bugzilla.redhat.com/show_bug.cgi?id=661333
libkj_async_la_LIBADD = libkj.la $(PTHREAD_LIBS) -lpthread
libkj_async_la_LDFLAGS = -release $(VERSION) -no-undefined
libkj_async_la_SOURCES=                                        \
  src/kj/async.c++                                             \
  src/kj/async-unix.c++                                        \
  src/kj/async-io.c++

209 210
# -lpthread is here to work around https://bugzilla.redhat.com/show_bug.cgi?id=661333
libcapnp_la_LIBADD = libkj.la $(PTHREAD_LIBS) -lpthread
211
libcapnp_la_LDFLAGS = -release $(VERSION) -no-undefined
212
libcapnp_la_SOURCES=                                           \
Kenton Varda's avatar
Kenton Varda committed
213
  src/capnp/c++.capnp.c++                                      \
214 215 216 217 218
  src/capnp/blob.c++                                           \
  src/capnp/arena.h                                            \
  src/capnp/arena.c++                                          \
  src/capnp/layout.c++                                         \
  src/capnp/list.c++                                           \
Kenton Varda's avatar
Kenton Varda committed
219
  src/capnp/object.c++                                         \
220
  src/capnp/message.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
221
  src/capnp/schema.capnp.c++                                   \
222 223 224 225 226
  src/capnp/schema.c++                                         \
  src/capnp/schema-loader.c++                                  \
  src/capnp/dynamic.c++                                        \
  src/capnp/stringify.c++                                      \
  src/capnp/serialize.c++                                      \
227 228 229
  src/capnp/serialize-packed.c++

# -lpthread is here to work around https://bugzilla.redhat.com/show_bug.cgi?id=661333
230
libcapnp_rpc_la_LIBADD = libcapnp.la libkj-async.la libkj.la $(PTHREAD_LIBS) -lpthread
231 232
libcapnp_rpc_la_LDFLAGS = -release $(VERSION) -no-undefined
libcapnp_rpc_la_SOURCES=                                       \
233 234 235 236
  src/capnp/serialize-async.c++                                \
  src/capnp/capability.c++                                     \
  src/capnp/capability-context.c++                             \
  src/capnp/dynamic-capability.c++                             \
237 238
  src/capnp/rpc.c++                                            \
  src/capnp/rpc.capnp.c++                                      \
239
  src/capnp/rpc-twoparty.c++                                   \
240 241
  src/capnp/rpc-twoparty.capnp.c++                             \
  src/capnp/ez-rpc.c++
242

243 244
# -lpthread is here to work around https://bugzilla.redhat.com/show_bug.cgi?id=661333
libcapnpc_la_LIBADD = libcapnp.la libkj.la $(PTHREAD_LIBS) -lpthread
245
libcapnpc_la_LDFLAGS = -release $(VERSION) -no-undefined
246
libcapnpc_la_SOURCES=                                          \
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
  src/capnp/compiler/md5.h                                     \
  src/capnp/compiler/md5.c++                                   \
  src/capnp/compiler/error-reporter.h                          \
  src/capnp/compiler/error-reporter.c++                        \
  src/capnp/compiler/lexer.capnp.h                             \
  src/capnp/compiler/lexer.capnp.c++                           \
  src/capnp/compiler/lexer.h                                   \
  src/capnp/compiler/lexer.c++                                 \
  src/capnp/compiler/grammar.capnp.h                           \
  src/capnp/compiler/grammar.capnp.c++                         \
  src/capnp/compiler/parser.h                                  \
  src/capnp/compiler/parser.c++                                \
  src/capnp/compiler/node-translator.h                         \
  src/capnp/compiler/node-translator.c++                       \
  src/capnp/compiler/compiler.h                                \
  src/capnp/compiler/compiler.c++                              \
263
  src/capnp/schema-parser.c++
Kenton Varda's avatar
Kenton Varda committed
264

265
bin_PROGRAMS = capnp capnpc-capnp capnpc-c++
266

267
capnp_LDADD = libcapnpc.la libcapnp.la libkj.la $(PTHREAD_LIBS)
268 269 270 271
capnp_SOURCES =                                                \
  src/capnp/compiler/module-loader.h                           \
  src/capnp/compiler/module-loader.c++                         \
  src/capnp/compiler/capnp.c++
272

273
capnpc_capnp_LDADD = libcapnp.la libkj.la $(PTHREAD_LIBS)
274 275
capnpc_capnp_SOURCES = src/capnp/compiler/capnpc-capnp.c++

276
capnpc_c___LDADD = libcapnp.la libkj.la $(PTHREAD_LIBS)
277 278
capnpc_c___SOURCES = src/capnp/compiler/capnpc-c++.c++

Kenton Varda's avatar
Kenton Varda committed
279 280
# Symlink capnpc -> capnp.  The capnp binary will behave like the old capnpc
# binary (i.e. like "capnp compile") when invoked via this symlink.
281 282 283 284
#
# Also attempt to run ldconfig, because otherwise users get confused.  If
# it fails (e.g. because the platform doesn't have it, or because the
# user doesn't have root privileges), don't worry about it.
Kenton Varda's avatar
Kenton Varda committed
285
install-exec-hook:
286
	ln -sf capnp $(DESTDIR)$(bindir)/capnpc
287
	ldconfig < /dev/null > /dev/null 2>&1 || true
Kenton Varda's avatar
Kenton Varda committed
288 289

uninstall-hook:
290
	rm -f $(DESTDIR)$(bindir)/capnpc
Kenton Varda's avatar
Kenton Varda committed
291

Kenton Varda's avatar
Kenton Varda committed
292
# Source files intentionally not included in the dist at this time:
293 294 295
#  src/capnp/serialize-snappy*
#  src/capnp/benchmark/...
#  src/capnp/compiler/...
Kenton Varda's avatar
Kenton Varda committed
296 297 298

# Tests ==============================================================

Kenton Varda's avatar
Kenton Varda committed
299
test_capnpc_inputs =                                           \
300
  src/capnp/test.capnp                                         \
301 302
  src/capnp/test-import.capnp                                  \
  src/capnp/test-import2.capnp
Kenton Varda's avatar
Kenton Varda committed
303

Kenton Varda's avatar
Kenton Varda committed
304
test_capnpc_outputs =                                          \
305 306 307
  src/capnp/test.capnp.c++                                     \
  src/capnp/test.capnp.h                                       \
  src/capnp/test-import.capnp.c++                              \
308 309 310
  src/capnp/test-import.capnp.h                                \
  src/capnp/test-import2.capnp.c++                             \
  src/capnp/test-import2.capnp.h
Kenton Varda's avatar
Kenton Varda committed
311

312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
if USE_EXTERNAL_CAPNP

test_capnpc_middleman: $(test_capnpc_inputs)
	$(CAPNP) compile --src-prefix=$(srcdir)/src -o$(CAPNPC_CXX):src -I$(srcdir)/src $^
	touch test_capnpc_middleman

else

test_capnpc_middleman: capnp$(EXEEXT) capnpc-c++$(EXEEXT) $(test_capnpc_inputs)
	echo $^ | (read CAPNP CAPNPC_CXX SOURCES && ./$$CAPNP compile --src-prefix=$(srcdir)/src -o./$$CAPNPC_CXX:src -I$(srcdir)/src $$SOURCES)
	touch test_capnpc_middleman

endif

$(test_capnpc_outputs): test_capnpc_middleman

328
BUILT_SOURCES = $(test_capnpc_outputs)
329

330
check_PROGRAMS = capnp-test capnp-evolution-test
331
capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.la \
332
                   libcapnpc.la libcapnp-rpc.la libcapnp.la libkj-async.la libkj.la
333
capnp_test_CPPFLAGS = -Igtest/include -I$(srcdir)/gtest/include
334
capnp_test_SOURCES =                                           \
Kenton Varda's avatar
Kenton Varda committed
335
  src/kj/common-test.c++                                       \
Kenton Varda's avatar
Kenton Varda committed
336
  src/kj/memory-test.c++                                       \
Kenton Varda's avatar
Kenton Varda committed
337
  src/kj/refcount-test.c++                                     \
Kenton Varda's avatar
Kenton Varda committed
338
  src/kj/array-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
339
  src/kj/string-test.c++                                       \
340
  src/kj/string-tree-test.c++                                  \
341
  src/kj/exception-test.c++                                    \
Kenton Varda's avatar
Kenton Varda committed
342
  src/kj/debug-test.c++                                        \
343
  src/kj/arena-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
344
  src/kj/units-test.c++                                        \
345
  src/kj/tuple-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
346
  src/kj/one-of-test.c++                                       \
347
  src/kj/function-test.c++                                     \
348
  src/kj/mutex-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
349
  src/kj/async-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
350
  src/kj/async-unix-test.c++                                   \
351
  src/kj/async-io-test.c++                                     \
Kenton Varda's avatar
Kenton Varda committed
352 353
  src/kj/parse/common-test.c++                                 \
  src/kj/parse/char-test.c++                                   \
354
  src/capnp/common-test.c++                                    \
355 356 357 358 359
  src/capnp/blob-test.c++                                      \
  src/capnp/endian-test.c++                                    \
  src/capnp/endian-fallback-test.c++                           \
  src/capnp/endian-reverse-test.c++                            \
  src/capnp/layout-test.c++                                    \
Kenton Varda's avatar
Kenton Varda committed
360
  src/capnp/object-test.c++                                    \
361
  src/capnp/message-test.c++                                   \
Kenton Varda's avatar
Kenton Varda committed
362
  src/capnp/capability-test.c++                                \
363 364 365 366 367
  src/capnp/schema-test.c++                                    \
  src/capnp/schema-loader-test.c++                             \
  src/capnp/dynamic-test.c++                                   \
  src/capnp/stringify-test.c++                                 \
  src/capnp/encoding-test.c++                                  \
368
  src/capnp/orphan-test.c++                                    \
369
  src/capnp/serialize-test.c++                                 \
370
  src/capnp/serialize-async-test.c++                           \
371
  src/capnp/serialize-packed-test.c++                          \
372
  src/capnp/rpc-test.c++                                       \
373
  src/capnp/rpc-twoparty-test.c++                              \
374
  src/capnp/ez-rpc-test.c++                                    \
375
  src/capnp/test-util.c++                                      \
376 377 378
  src/capnp/test-util.h                                        \
  src/capnp/compiler/lexer-test.c++                            \
  src/capnp/compiler/md5-test.c++
379
nodist_capnp_test_SOURCES = $(test_capnpc_outputs)
Kenton Varda's avatar
Kenton Varda committed
380

381 382 383
capnp_evolution_test_LDADD = libcapnpc.la libcapnp.la libkj.la
capnp_evolution_test_SOURCES = src/capnp/compiler/evolution-test.c++

384
TESTS = capnp-test capnp-evolution-test src/capnp/compiler/capnp-test.sh