Makefile.am 13.9 KB
## Process this file with automake to produce Makefile.in

ACLOCAL_AMFLAGS = -I m4

AUTOMAKE_OPTIONS = foreign subdir-objects

# 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

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

AM_LDFLAGS = $(PTHREAD_CFLAGS)

EXTRA_DIST =                                                                 \
  README.txt                                                                 \
  LICENSE.txt                                                                \
  $(test_capnpc_inputs)

CLEANFILES = $(test_capnpc_outputs) test_capnpc_middleman

# 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

maintainer-clean-local:
	-rm -rf build-aux

# 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.
%.capnp:
	@:

public_capnpc_inputs =                                         \
  src/capnp/c++.capnp                                          \
  src/capnp/schema.capnp

capnpc_inputs =                                                \
  $(public_capnpc_inputs)                                      \
  src/capnp/compiler/lexer.capnp                               \
  src/capnp/compiler/grammar.capnp

capnpc_outputs =                                               \
  src/capnp/c++.capnp.c++                                      \
  src/capnp/c++.capnp.h                                        \
  src/capnp/schema.capnp.c++                                   \
  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

includecapnpdir = $(includedir)/capnp
includekjdir = $(includedir)/kj
includekjparsedir = $(includekjdir)/parse

dist_includecapnp_DATA = $(public_capnpc_inputs)

includekj_HEADERS =                                            \
  src/kj/common.h                                              \
  src/kj/units.h                                               \
  src/kj/memory.h                                              \
  src/kj/array.h                                               \
  src/kj/vector.h                                              \
  src/kj/string.h                                              \
  src/kj/string-tree.h                                         \
  src/kj/exception.h                                           \
  src/kj/debug.h                                               \
  src/kj/arena.h                                               \
  src/kj/io.h                                                  \
  src/kj/tuple.h                                               \
  src/kj/function.h                                            \
  src/kj/mutex.h                                               \
  src/kj/thread.h                                              \
  src/kj/main.h

includekjparse_HEADERS =                                       \
  src/kj/parse/common.h                                        \
  src/kj/parse/char.h

includecapnp_HEADERS =                                         \
  src/capnp/c++.capnp.h                                        \
  src/capnp/common.h                                           \
  src/capnp/blob.h                                             \
  src/capnp/endian.h                                           \
  src/capnp/layout.h                                           \
  src/capnp/orphan.h                                           \
  src/capnp/list.h                                             \
  src/capnp/message.h                                          \
  src/capnp/schema.capnp.h                                     \
  src/capnp/schema.h                                           \
  src/capnp/schema-loader.h                                    \
  src/capnp/schema-parser.h                                    \
  src/capnp/dynamic.h                                          \
  src/capnp/pretty-print.h                                     \
  src/capnp/serialize.h                                        \
  src/capnp/serialize-packed.h                                 \
  src/capnp/generated-header-support.h

lib_LTLIBRARIES = libkj.la libcapnp.la libcapnpc.la

libkj_la_LIBADD = $(PTHREAD_LIBS)
libkj_la_LDFLAGS = -release $(VERSION) -export-dynamic -no-undefined
libkj_la_SOURCES=                                              \
  src/kj/common.c++                                            \
  src/kj/units.c++                                             \
  src/kj/memory.c++                                            \
  src/kj/array.c++                                             \
  src/kj/string.c++                                            \
  src/kj/string-tree.c++                                       \
  src/kj/exception.c++                                         \
  src/kj/debug.c++                                             \
  src/kj/arena.c++                                             \
  src/kj/io.c++                                                \
  src/kj/mutex.c++                                             \
  src/kj/thread.c++                                            \
  src/kj/main.c++                                              \
  src/kj/parse/char.c++

libcapnp_la_LIBADD = $(PTHREAD_LIBS) libkj.la
libcapnp_la_LDFLAGS = -release $(VERSION) -export-dynamic -no-undefined
libcapnp_la_SOURCES=                                           \
  src/capnp/c++.capnp.c++                                      \
  src/capnp/blob.c++                                           \
  src/capnp/arena.h                                            \
  src/capnp/arena.c++                                          \
  src/capnp/layout.c++                                         \
  src/capnp/list.c++                                           \
  src/capnp/message.c++                                        \
  src/capnp/schema.capnp.c++                                   \
  src/capnp/schema.c++                                         \
  src/capnp/schema-loader.c++                                  \
  src/capnp/dynamic.c++                                        \
  src/capnp/stringify.c++                                      \
  src/capnp/serialize.c++                                      \
  src/capnp/serialize-packed.c++

libcapnpc_la_LIBADD = $(PTHREAD_LIBS) libcapnp.la
libcapnpc_la_LDFLAGS = -release $(VERSION) -export-dynamic -no-undefined
libcapnpc_la_SOURCES=                                          \
  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/schema-parser.c++

bin_PROGRAMS = capnp capnpc-capnp capnpc-c++

capnp_LDADD = $(PTHREAD_LIBS) libcapnpc.la libcapnp.la libkj.la
capnp_SOURCES =                                                \
  src/capnp/compiler/module-loader.h                           \
  src/capnp/compiler/module-loader.c++                         \
  src/capnp/compiler/capnp.c++

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

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

# 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

# Source files intentionally not included in the dist at this time:
#  src/capnp/serialize-snappy*
#  src/capnp/benchmark/...
#  src/capnp/compiler/...

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

test_capnpc_inputs =                                           \
  src/capnp/test.capnp                                         \
  src/capnp/test-import.capnp

test_capnpc_outputs =                                          \
  src/capnp/test.capnp.c++                                     \
  src/capnp/test.capnp.h                                       \
  src/capnp/test-import.capnp.c++                              \
  src/capnp/test-import.capnp.h

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

BUILT_SOURCES = $(test_capnpc_outputs)

check_PROGRAMS = capnp-test
capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.la libcapnpc.la libcapnp.la libkj.la
capnp_test_CPPFLAGS = -Igtest/include -I$(srcdir)/gtest/include
capnp_test_SOURCES =                                           \
  src/kj/common-test.c++                                       \
  src/kj/memory-test.c++                                       \
  src/kj/array-test.c++                                        \
  src/kj/string-test.c++                                       \
  src/kj/string-tree-test.c++                                  \
  src/kj/exception-test.c++                                    \
  src/kj/debug-test.c++                                        \
  src/kj/arena-test.c++                                        \
  src/kj/units-test.c++                                        \
  src/kj/tuple-test.c++                                        \
  src/kj/function-test.c++                                     \
  src/kj/mutex-test.c++                                        \
  src/kj/parse/common-test.c++                                 \
  src/kj/parse/char-test.c++                                   \
  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++                                  \
  src/capnp/orphan-test.c++                                    \
  src/capnp/serialize-test.c++                                 \
  src/capnp/serialize-packed-test.c++                          \
  src/capnp/test-util.c++                                      \
  src/capnp/test-util.h                                        \
  src/capnp/compiler/lexer-test.c++                            \
  src/capnp/compiler/md5-test.c++
nodist_capnp_test_SOURCES = $(test_capnpc_outputs)

TESTS = capnp-test