build: Makefile.am corrections (separate Makefile.am for tests)

Change-Id: I69f442d5b7dee7fd7c20d10bd4229e692ee1193d
diff --git a/.gitignore b/.gitignore
index 0670a81..fed2661 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,8 +14,10 @@
 *~
 
 # Autoconf files
-/Makefile
-/include/Makefile
+Makefile
+Makefile.in
+.libs
+.deps
 /autom4te.cache
 config.log
 /config.status
@@ -47,7 +49,6 @@
 config.sub
 configure
 depcomp
-include/Makefile.in
 include/config.h.in
 install-sh
 ltmain.sh
diff --git a/Makefile.am b/Makefile.am
index 0f2c0b8..f191f26 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,105 +9,96 @@
 ## to provide a way for the user to supply additional arguments.
 ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
 
-# "make install" will also install the include headers.
-SUBDIRS = include
-
 lib_LTLIBRARIES = libndn-c.la libndn-cpp.la
 
-noinst_PROGRAMS = bin/test-encode-decode-benchmark bin/test-encode-decode-data bin/test-encode-decode-forwarding-entry \
-  bin/test-encode-decode-interest bin/test-get-async bin/test-publish-async
-
-# Public C headers.
-# NOTE: If a new directory is added, then add it to ndn_cpp_c_headers in include/Makefile.am.
-ndn_cpp_c_headers = \
-  include/ndn-cpp/ndn-cpp-config.h \
-  include/ndn-cpp/c/common.h \
-  include/ndn-cpp/c/data-types.h \
-  include/ndn-cpp/c/forwarding-flags.h \
-  include/ndn-cpp/c/interest-types.h \
-  include/ndn-cpp/c/key-types.h \
-  include/ndn-cpp/c/encoding/element-listener.h
-
-# Public C++ headers.
-# NOTE: If a new directory is added, then add it to ndn_cpp_cpp_headers in include/Makefile.am.
-ndn_cpp_cpp_headers = \
-  include/ndn-cpp/common.hpp \
-  include/ndn-cpp/data.hpp \
-  include/ndn-cpp/face.hpp \
-  include/ndn-cpp/forwarding-entry.hpp \
-  include/ndn-cpp/forwarding-flags.hpp \
-  include/ndn-cpp/interest.hpp \
-  include/ndn-cpp/key-locator.hpp \
-  include/ndn-cpp/name.hpp \
-  include/ndn-cpp/node.hpp \
-  include/ndn-cpp/publisher-public-key-digest.hpp \
-  include/ndn-cpp/sha256-with-rsa-signature.hpp \
-  include/ndn-cpp/encoding/binary-xml-wire-format.hpp \
-  include/ndn-cpp/encoding/element-listener.hpp \
-  include/ndn-cpp/encoding/oid.hpp \
-  include/ndn-cpp/encoding/wire-format.hpp \
-  include/ndn-cpp/security/security-common.hpp \
-  include/ndn-cpp/security/key-chain.hpp \
-  include/ndn-cpp/security/security-exception.hpp \
-  include/ndn-cpp/security/certificate/certificate-extension.hpp \
-  include/ndn-cpp/security/certificate/certificate-subject-description.hpp \
-  include/ndn-cpp/security/certificate/certificate.hpp \
-  include/ndn-cpp/security/certificate/identity-certificate.hpp \
-  include/ndn-cpp/security/certificate/public-key.hpp \
-  include/ndn-cpp/security/encryption/encryption-manager.hpp \
-  include/ndn-cpp/security/identity/basic-identity-storage.hpp \
-  include/ndn-cpp/security/identity/identity-manager.hpp \
-  include/ndn-cpp/security/identity/identity-storage.hpp \
-  include/ndn-cpp/security/identity/memory-identity-storage.hpp \
-  include/ndn-cpp/security/identity/memory-private-key-storage.hpp \
-  include/ndn-cpp/security/identity/osx-private-key-storage.hpp \
-  include/ndn-cpp/security/identity/private-key-storage.hpp \
-  include/ndn-cpp/security/policy/no-verify-policy-manager.hpp \
-  include/ndn-cpp/security/policy/policy-manager.hpp \
-  include/ndn-cpp/security/policy/self-verify-policy-manager.hpp \
-  include/ndn-cpp/security/policy/validation-request.hpp \
-  include/ndn-cpp/security/signature/sha256-with-rsa-handler.hpp \
-  include/ndn-cpp/transport/tcp-transport.hpp \
-  include/ndn-cpp/transport/transport.hpp \
-  include/ndn-cpp/transport/udp-transport.hpp \
-  include/ndn-cpp/util/blob.hpp \
-  include/ndn-cpp/util/signed-blob.hpp
+# "make install" will also install the include headers.
+SUBDIRS = include . tests
 
 # Just the C code.
-libndn_c_la_SOURCES = $(ndn_cpp_c_headers) \
+## To regenerate:
+## for i in `find src/c -name '*.c' -or -name '*.h'`; do echo "  $i \\"; done
+##
+## Note that public header files do not need to be included here (handled by include/Makefile.am)
+libndn_c_la_SOURCES = \
   src/c/data.h \
-  src/c/errors.c src/c/errors.h \
+  src/c/encoding/binary-xml-data.c \
+  src/c/encoding/binary-xml-data.h \
+  src/c/encoding/binary-xml-decoder.c \
+  src/c/encoding/binary-xml-decoder.h \
+  src/c/encoding/binary-xml-element-reader.c \
+  src/c/encoding/binary-xml-element-reader.h \
+  src/c/encoding/binary-xml-encoder.c \
+  src/c/encoding/binary-xml-encoder.h \
+  src/c/encoding/binary-xml-forwarding-entry.c \
+  src/c/encoding/binary-xml-forwarding-entry.h \
+  src/c/encoding/binary-xml-interest.c \
+  src/c/encoding/binary-xml-interest.h \
+  src/c/encoding/binary-xml-key.c \
+  src/c/encoding/binary-xml-key.h \
+  src/c/encoding/binary-xml-name.c \
+  src/c/encoding/binary-xml-name.h \
+  src/c/encoding/binary-xml-publisher-public-key-digest.c \
+  src/c/encoding/binary-xml-publisher-public-key-digest.h \
+  src/c/encoding/binary-xml-structure-decoder.c \
+  src/c/encoding/binary-xml-structure-decoder.h \
+  src/c/encoding/binary-xml.h \
+  src/c/errors.c \
+  src/c/errors.h \
   src/c/forwarding-entry.h \
   src/c/forwarding-flags.c \
-  src/c/interest.c src/c/interest.h \
+  src/c/interest.c \
+  src/c/interest.h \
   src/c/key-locator.h \
-  src/c/name.c src/c/name.h \
+  src/c/name.c \
+  src/c/name.h \
   src/c/publisher-public-key-digest.h \
-  src/c/encoding/binary-xml.h \
-  src/c/encoding/binary-xml-data.c src/c/encoding/binary-xml-data.h \
-  src/c/encoding/binary-xml-decoder.c src/c/encoding/binary-xml-decoder.h \
-  src/c/encoding/binary-xml-element-reader.c src/c/encoding/binary-xml-element-reader.h \
-  src/c/encoding/binary-xml-encoder.c src/c/encoding/binary-xml-encoder.h \
-  src/c/encoding/binary-xml-forwarding-entry.c src/c/encoding/binary-xml-forwarding-entry.h \
-  src/c/encoding/binary-xml-interest.c src/c/encoding/binary-xml-interest.h \
-  src/c/encoding/binary-xml-key.c src/c/encoding/binary-xml-key.h \
-  src/c/encoding/binary-xml-name.c src/c/encoding/binary-xml-name.h \
-  src/c/encoding/binary-xml-publisher-public-key-digest.c src/c/encoding/binary-xml-publisher-public-key-digest.h \
-  src/c/encoding/binary-xml-structure-decoder.c src/c/encoding/binary-xml-structure-decoder.h \
-  src/c/transport/socket-transport.c src/c/transport/socket-transport.h \
+  src/c/transport/socket-transport.c \
+  src/c/transport/socket-transport.h \
   src/c/transport/tcp-transport.h \
   src/c/transport/udp-transport.h \
   src/c/util/blob.h \
-  src/c/util/crypto.c src/c/util/crypto.h \
-  src/c/util/dynamic-uint8-array.c src/c/util/dynamic-uint8-array.h \
-  src/c/util/ndn_memory.c src/c/util/ndn_memory.h \
-  src/c/util/ndn_realloc.c src/c/util/ndn_realloc.h \
-  src/c/util/time.c src/c/util/time.h
+  src/c/util/crypto.c \
+  src/c/util/crypto.h \
+  src/c/util/dynamic-uint8-array.c \
+  src/c/util/dynamic-uint8-array.h \
+  src/c/util/ndn_memory.c \
+  src/c/util/ndn_memory.h \
+  src/c/util/ndn_realloc.c \
+  src/c/util/ndn_realloc.h \
+  src/c/util/time.c \
+  src/c/util/time.h
 
 # C++ code and also the C code.
-libndn_cpp_la_SOURCES = $(libndn_c_la_SOURCES) $(ndn_cpp_cpp_headers) \
+## To regenerate:
+## for i in `find src -name '*.cpp' -or -name '*.hpp' -or -name '*.h' -and -not -path 'src/c/*'`; do echo "  $i \\"; done
+libndn_cpp_la_SOURCES = $(libndn_c_la_SOURCES) \
   src/common.cpp \
   src/data.cpp \
+  src/encoding/binary-xml-decoder.hpp \
+  src/encoding/binary-xml-encoder.hpp \
+  src/encoding/binary-xml-structure-decoder.hpp \
+  src/encoding/binary-xml-wire-format.cpp \
+  src/encoding/der/der-exception.cpp \
+  src/encoding/der/der-exception.hpp \
+  src/encoding/der/der.cpp \
+  src/encoding/der/der.hpp \
+  src/encoding/der/visitor/certificate-data-visitor.cpp \
+  src/encoding/der/visitor/certificate-data-visitor.hpp \
+  src/encoding/der/visitor/no-arguments-visitor.cpp \
+  src/encoding/der/visitor/no-arguments-visitor.hpp \
+  src/encoding/der/visitor/print-visitor.cpp \
+  src/encoding/der/visitor/print-visitor.hpp \
+  src/encoding/der/visitor/public-key-visitor.cpp \
+  src/encoding/der/visitor/public-key-visitor.hpp \
+  src/encoding/der/visitor/simple-visitor.cpp \
+  src/encoding/der/visitor/simple-visitor.hpp \
+  src/encoding/der/visitor/visitor.hpp \
+  src/encoding/der/visitor/void-no-arguments-visitor.hpp \
+  src/encoding/der/visitor/void-visitor.cpp \
+  src/encoding/der/visitor/void-visitor.hpp \
+  src/encoding/element-listener.cpp \
+  src/encoding/oid.cpp \
+  src/encoding/wire-format.cpp \
   src/face.cpp \
   src/forwarding-entry.cpp \
   src/interest.cpp \
@@ -115,26 +106,6 @@
   src/name.cpp \
   src/node.cpp \
   src/publisher-public-key-digest.cpp \
-  src/sha256-with-rsa-signature.cpp \
-  src/encoding/binary-xml-decoder.hpp \
-  src/encoding/binary-xml-encoder.hpp \
-  src/encoding/binary-xml-structure-decoder.hpp \
-  src/encoding/binary-xml-wire-format.cpp \
-  src/encoding/element-listener.cpp \
-  src/encoding/oid.cpp \
-  src/encoding/wire-format.cpp \
-  src/encoding/der/der-exception.cpp src/encoding/der/der-exception.hpp \
-  src/encoding/der/der.cpp src/encoding/der/der.hpp \
-  src/encoding/der/visitor/certificate-data-visitor.cpp src/encoding/der/visitor/certificate-data-visitor.hpp \
-  src/encoding/der/visitor/no-arguments-visitor.cpp src/encoding/der/visitor/no-arguments-visitor.hpp \
-  src/encoding/der/visitor/print-visitor.cpp src/encoding/der/visitor/print-visitor.hpp \
-  src/encoding/der/visitor/public-key-visitor.cpp src/encoding/der/visitor/public-key-visitor.hpp \
-  src/encoding/der/visitor/simple-visitor.cpp src/encoding/der/visitor/simple-visitor.hpp \
-  src/encoding/der/visitor/visitor.hpp \
-  src/encoding/der/visitor/void-no-arguments-visitor.hpp \
-  src/encoding/der/visitor/void-visitor.cpp src/encoding/der/visitor/void-visitor.hpp \
-  src/security/key-chain.cpp \
-  src/security/security-exception.cpp \
   src/security/certificate/certificate-extension.cpp \
   src/security/certificate/certificate-subject-description.cpp \
   src/security/certificate/certificate.cpp \
@@ -146,34 +117,22 @@
   src/security/identity/memory-identity-storage.cpp \
   src/security/identity/memory-private-key-storage.cpp \
   src/security/identity/osx-private-key-storage.cpp \
+  src/security/key-chain.cpp \
   src/security/policy/no-verify-policy-manager.cpp \
   src/security/policy/self-verify-policy-manager.cpp \
+  src/security/security-exception.cpp \
   src/security/signature/sha256-with-rsa-handler.cpp \
+  src/sha256-with-rsa-signature.cpp \
   src/transport/tcp-transport.cpp \
   src/transport/transport.cpp \
   src/transport/udp-transport.cpp \
   src/util/blob-stream.hpp \
   src/util/blob.cpp \
-  src/util/changed-event.cpp src/util/changed-event.hpp \
-  src/util/dynamic-uint8-vector.cpp src/util/dynamic-uint8-vector.hpp \
-  src/util/logging.cpp src/util/logging.hpp
-
-bin_test_encode_decode_benchmark_SOURCES = tests/test-encode-decode-benchmark.cpp
-bin_test_encode_decode_benchmark_LDADD = libndn-cpp.la
-
-bin_test_encode_decode_data_SOURCES = tests/test-encode-decode-data.cpp
-bin_test_encode_decode_data_LDADD = libndn-cpp.la
-
-bin_test_encode_decode_forwarding_entry_SOURCES = tests/test-encode-decode-forwarding-entry.cpp
-bin_test_encode_decode_forwarding_entry_LDADD = libndn-cpp.la
-
-bin_test_encode_decode_interest_SOURCES = tests/test-encode-decode-interest.cpp
-bin_test_encode_decode_interest_LDADD = libndn-cpp.la
-
-bin_test_get_async_SOURCES = tests/test-get-async.cpp
-bin_test_get_async_LDADD = libndn-cpp.la
-
-bin_test_publish_async_SOURCES = tests/test-publish-async.cpp
-bin_test_publish_async_LDADD = libndn-cpp.la
+  src/util/changed-event.cpp \
+  src/util/changed-event.hpp \
+  src/util/dynamic-uint8-vector.cpp \
+  src/util/dynamic-uint8-vector.hpp \
+  src/util/logging.cpp \
+  src/util/logging.hpp
 
 dist_noinst_SCRIPTS = autogen.sh
diff --git a/configure.ac b/configure.ac
index 485a6ce..f04b30b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,5 +159,6 @@
 DX_INIT_DOXYGEN([$PACKAGE_NAME],[Doxyfile])
 
 AC_CONFIG_FILES([Makefile
-                 include/Makefile])
+                 include/Makefile
+                 tests/Makefile])
 AC_OUTPUT
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..8ab0c81
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,21 @@
+
+LDADD = ../libndn-cpp.la
+
+noinst_PROGRAMS = test-encode-decode-benchmark \
+	test-encode-decode-data \
+	test-encode-decode-forwarding-entry \
+	test-encode-decode-interest \
+	test-get-async \
+	test-publish-async
+
+test_encode_decode_benchmark_SOURCES = test-encode-decode-benchmark.cpp
+
+test_encode_decode_data_SOURCES = test-encode-decode-data.cpp
+
+test_encode_decode_forwarding_entry_SOURCES = test-encode-decode-forwarding-entry.cpp
+
+test_encode_decode_interest_SOURCES = test-encode-decode-interest.cpp
+
+test_get_async_SOURCES = test-get-async.cpp
+
+test_publish_async_SOURCES = test-publish-async.cpp