Makefile.am 13.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
  $(test_capnpc_inputs)
Kenton Varda's avatar
Kenton Varda committed
44

45
CLEANFILES = $(test_capnpc_outputs) test_capnpc_middleman
Kenton Varda's avatar
Kenton Varda committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

# 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

67 68 69
maintainer-clean-local:
	-rm -rf build-aux

70 71 72 73 74 75
# 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.
76 77
%.capnp:
	@:
78

79
public_capnpc_inputs =                                         \
80 81
  src/capnp/c++.capnp                                          \
  src/capnp/schema.capnp
Kenton Varda's avatar
Kenton Varda committed
82

83 84 85 86
capnpc_inputs =                                                \
  $(public_capnpc_inputs)                                      \
  src/capnp/compiler/lexer.capnp                               \
  src/capnp/compiler/grammar.capnp
87

Kenton Varda's avatar
Kenton Varda committed
88
capnpc_outputs =                                               \
89 90 91
  src/capnp/c++.capnp.c++                                      \
  src/capnp/c++.capnp.h                                        \
  src/capnp/schema.capnp.c++                                   \
92 93 94 95 96
  src/capnp/schema.capnp.h                                     \
  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
97

98
includecapnpdir = $(includedir)/capnp
Kenton Varda's avatar
Kenton Varda committed
99
includekjdir = $(includedir)/kj
Kenton Varda's avatar
Kenton Varda committed
100
includekjparsedir = $(includekjdir)/parse
Kenton Varda's avatar
Kenton Varda committed
101

102
dist_includecapnp_DATA = $(public_capnpc_inputs)
103

Kenton Varda's avatar
Kenton Varda committed
104 105
includekj_HEADERS =                                            \
  src/kj/common.h                                              \
Kenton Varda's avatar
Kenton Varda committed
106
  src/kj/units.h                                               \
Kenton Varda's avatar
Kenton Varda committed
107 108
  src/kj/memory.h                                              \
  src/kj/array.h                                               \
109
  src/kj/vector.h                                              \
Kenton Varda's avatar
Kenton Varda committed
110
  src/kj/string.h                                              \
111
  src/kj/string-tree.h                                         \
Kenton Varda's avatar
Kenton Varda committed
112
  src/kj/exception.h                                           \
Kenton Varda's avatar
Kenton Varda committed
113
  src/kj/debug.h                                               \
114
  src/kj/arena.h                                               \
115
  src/kj/io.h                                                  \
116
  src/kj/tuple.h                                               \
117
  src/kj/function.h                                            \
Kenton Varda's avatar
Kenton Varda committed
118
  src/kj/mutex.h                                               \
119 120
  src/kj/thread.h                                              \
  src/kj/main.h
Kenton Varda's avatar
Kenton Varda committed
121 122 123 124

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

126
includecapnp_HEADERS =                                         \
Kenton Varda's avatar
Kenton Varda committed
127
  src/capnp/c++.capnp.h                                        \
128 129 130 131
  src/capnp/common.h                                           \
  src/capnp/blob.h                                             \
  src/capnp/endian.h                                           \
  src/capnp/layout.h                                           \
132
  src/capnp/orphan.h                                           \
133 134
  src/capnp/list.h                                             \
  src/capnp/message.h                                          \
Kenton Varda's avatar
Kenton Varda committed
135
  src/capnp/schema.capnp.h                                     \
136 137 138
  src/capnp/schema.h                                           \
  src/capnp/schema-loader.h                                    \
  src/capnp/dynamic.h                                          \
139
  src/capnp/pretty-print.h                                     \
140 141 142
  src/capnp/serialize.h                                        \
  src/capnp/serialize-packed.h                                 \
  src/capnp/generated-header-support.h
Kenton Varda's avatar
Kenton Varda committed
143

144
lib_LTLIBRARIES = libcapnp.la
Kenton Varda's avatar
Kenton Varda committed
145

146
libcapnp_la_LIBADD = $(PTHREAD_LIBS)
147 148
libcapnp_la_LDFLAGS = -release $(VERSION) -export-dynamic -no-undefined
libcapnp_la_SOURCES=                                           \
Kenton Varda's avatar
Kenton Varda committed
149
  src/kj/common.c++                                            \
Kenton Varda's avatar
Kenton Varda committed
150
  src/kj/units.c++                                             \
Kenton Varda's avatar
Kenton Varda committed
151 152 153
  src/kj/memory.c++                                            \
  src/kj/array.c++                                             \
  src/kj/string.c++                                            \
154
  src/kj/string-tree.c++                                       \
Kenton Varda's avatar
Kenton Varda committed
155
  src/kj/exception.c++                                         \
Kenton Varda's avatar
Kenton Varda committed
156
  src/kj/debug.c++                                             \
157
  src/kj/arena.c++                                             \
Kenton Varda's avatar
Kenton Varda committed
158
  src/kj/io.c++                                                \
159
  src/kj/mutex.c++                                             \
Kenton Varda's avatar
Kenton Varda committed
160
  src/kj/thread.c++                                            \
161
  src/kj/main.c++                                              \
Kenton Varda's avatar
Kenton Varda committed
162
  src/kj/parse/char.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
163
  src/capnp/c++.capnp.c++                                      \
164 165 166 167 168 169
  src/capnp/blob.c++                                           \
  src/capnp/arena.h                                            \
  src/capnp/arena.c++                                          \
  src/capnp/layout.c++                                         \
  src/capnp/list.c++                                           \
  src/capnp/message.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
170
  src/capnp/schema.capnp.c++                                   \
171 172 173 174 175
  src/capnp/schema.c++                                         \
  src/capnp/schema-loader.c++                                  \
  src/capnp/dynamic.c++                                        \
  src/capnp/stringify.c++                                      \
  src/capnp/serialize.c++                                      \
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
  src/capnp/serialize-packed.c++                               \
  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++                              \
  src/capnp/compiler/module-loader.h                           \
  src/capnp/compiler/module-loader.c++
Kenton Varda's avatar
Kenton Varda committed
195

196
bin_PROGRAMS = capnp capnpc-capnp capnpc-c++
197 198 199 200 201 202 203

capnp_LDADD = $(PTHREAD_LIBS) libcapnp.la
capnp_SOURCES = src/capnp/compiler/capnp.c++

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

204 205 206
capnpc_c___LDADD = $(PTHREAD_LIBS) libcapnp.la
capnpc_c___SOURCES = src/capnp/compiler/capnpc-c++.c++

Kenton Varda's avatar
Kenton Varda committed
207 208 209 210 211 212 213 214
# Symlink capnpc -> capnp.  The capnp binary will behave like the old capnpc
# binary (i.e. like "capnp compile") when invoked via this symlink.
install-exec-hook:
	ln -s capnp $(DESTDIR)$(bindir)/capnpc

uninstall-hook:
	rm $(DESTDIR)$(bindir)/capnpc

Kenton Varda's avatar
Kenton Varda committed
215
# Source files intentionally not included in the dist at this time:
216 217 218
#  src/capnp/serialize-snappy*
#  src/capnp/benchmark/...
#  src/capnp/compiler/...
Kenton Varda's avatar
Kenton Varda committed
219 220 221

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

Kenton Varda's avatar
Kenton Varda committed
222
test_capnpc_inputs =                                           \
223 224
  src/capnp/test.capnp                                         \
  src/capnp/test-import.capnp
Kenton Varda's avatar
Kenton Varda committed
225

Kenton Varda's avatar
Kenton Varda committed
226
test_capnpc_outputs =                                          \
227 228 229 230
  src/capnp/test.capnp.c++                                     \
  src/capnp/test.capnp.h                                       \
  src/capnp/test-import.capnp.c++                              \
  src/capnp/test-import.capnp.h
Kenton Varda's avatar
Kenton Varda committed
231

232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
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

248
BUILT_SOURCES = $(test_capnpc_outputs)
249

250
check_PROGRAMS = capnp-test
251 252
capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.la libcapnp.la
capnp_test_CPPFLAGS = -Igtest/include -I$(srcdir)/gtest/include
253
capnp_test_SOURCES =                                           \
Kenton Varda's avatar
Kenton Varda committed
254
  src/kj/common-test.c++                                       \
Kenton Varda's avatar
Kenton Varda committed
255 256
  src/kj/memory-test.c++                                       \
  src/kj/array-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
257
  src/kj/string-test.c++                                       \
258
  src/kj/string-tree-test.c++                                  \
259
  src/kj/exception-test.c++                                    \
Kenton Varda's avatar
Kenton Varda committed
260
  src/kj/debug-test.c++                                        \
261
  src/kj/arena-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
262
  src/kj/units-test.c++                                        \
263
  src/kj/tuple-test.c++                                        \
264
  src/kj/function-test.c++                                     \
265
  src/kj/mutex-test.c++                                        \
Kenton Varda's avatar
Kenton Varda committed
266 267
  src/kj/parse/common-test.c++                                 \
  src/kj/parse/char-test.c++                                   \
268 269 270 271 272 273 274 275 276 277 278
  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++                                    \
  src/capnp/message-test.c++                                   \
  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++                                  \
279
  src/capnp/orphan-test.c++                                    \
280 281 282
  src/capnp/serialize-test.c++                                 \
  src/capnp/serialize-packed-test.c++                          \
  src/capnp/test-util.c++                                      \
283 284 285
  src/capnp/test-util.h                                        \
  src/capnp/compiler/lexer-test.c++                            \
  src/capnp/compiler/md5-test.c++
286
nodist_capnp_test_SOURCES = $(test_capnpc_outputs)
Kenton Varda's avatar
Kenton Varda committed
287

288
TESTS = capnp-test