jni: Add all dependencies and their compilation scripts

Compilation has been verified for all target platforms using a slightly
modified version of CrystaX NDK 10.1.0 (the issue has been resolved with
not yet release 10.2.0)

Change-Id: I99f6c270ae8732adfa402d75ba04f42b179a1a9b
diff --git a/app/src/main/java/net/named_data/nfd/wrappers/Example.java b/app/src/main/java/net/named_data/nfd/wrappers/Example.java
index 0e70c0a..62f2109 100644
--- a/app/src/main/java/net/named_data/nfd/wrappers/Example.java
+++ b/app/src/main/java/net/named_data/nfd/wrappers/Example.java
@@ -6,7 +6,7 @@
 public class Example
 {
   static {
-    System.loadLibrary("nfd-example");
+    System.loadLibrary("nfd-wrapper");
   }
 
   public native static void main();
diff --git a/app/src/main/jni/Android.mk b/app/src/main/jni/Android.mk
index 67d22e0..925d790 100644
--- a/app/src/main/jni/Android.mk
+++ b/app/src/main/jni/Android.mk
@@ -1,8 +1,11 @@
 LOCAL_PATH := $(call my-dir)
+LOCAL_PATH_SAVED := $(LOCAL_PATH)
 
 include $(CLEAR_VARS)
-LOCAL_MODULE := nfd-example
+LOCAL_MODULE := nfd-wrapper
 LOCAL_SRC_FILES := android-logger-streambuf.cpp wrappers-example.cpp
-# LOCAL_SHARED_LIBRARIES :=
 LOCAL_LDLIBS := -llog
 include $(BUILD_SHARED_LIBRARY)
+
+include $(LOCAL_PATH_SAVED)/ndn-cxx.mk
+include $(LOCAL_PATH_SAVED)/nfd.mk
diff --git a/app/src/main/jni/Application.mk b/app/src/main/jni/Application.mk
index 980d621..121e000 100644
--- a/app/src/main/jni/Application.mk
+++ b/app/src/main/jni/Application.mk
@@ -1,4 +1,4 @@
-APP_ABI=all
+APP_ABI := all
 
 APP_STL := gnustl_shared
 APP_GNUSTL_FORCE_CPP_FEATURES := exceptions rtti
diff --git a/app/src/main/jni/NFD b/app/src/main/jni/NFD
new file mode 160000
index 0000000..e46279d
--- /dev/null
+++ b/app/src/main/jni/NFD
@@ -0,0 +1 @@
+Subproject commit e46279dc8382316fb933697346b66f22cad1ee5e
diff --git a/app/src/main/jni/cryptopp b/app/src/main/jni/cryptopp
new file mode 160000
index 0000000..dfa7453
--- /dev/null
+++ b/app/src/main/jni/cryptopp
@@ -0,0 +1 @@
+Subproject commit dfa7453a47f397bad10a662a4117ffed99638513
diff --git a/app/src/main/jni/ndn-cxx b/app/src/main/jni/ndn-cxx
new file mode 160000
index 0000000..cf3a667
--- /dev/null
+++ b/app/src/main/jni/ndn-cxx
@@ -0,0 +1 @@
+Subproject commit cf3a667634ef93c47c0ef3056a01c47112e49427
diff --git a/app/src/main/jni/ndn-cxx-android/ndn-cxx b/app/src/main/jni/ndn-cxx-android/ndn-cxx
new file mode 120000
index 0000000..cd44943
--- /dev/null
+++ b/app/src/main/jni/ndn-cxx-android/ndn-cxx
@@ -0,0 +1 @@
+../ndn-cxx/src
\ No newline at end of file
diff --git a/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp b/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp
new file mode 100644
index 0000000..fe8e99b
--- /dev/null
+++ b/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp
@@ -0,0 +1,14 @@
+#ifndef W_SRC_NDN_CXX_CONFIG_HPP_WAF
+#define W_SRC_NDN_CXX_CONFIG_HPP_WAF
+
+#define NDN_CXX_HAVE_IS_DEFAULT_CONSTRUCTIBLE 1
+#define NDN_CXX_HAVE_IS_MOVE_CONSTRUCTIBLE 1
+#define NDN_CXX_HAVE_IS_MOVE_ASSIGNABLE 1
+#define NDN_CXX_HAVE_CXX_FRIEND_TYPENAME 1
+#define NDN_CXX_HAVE_PTHREAD 1
+#define NDN_CXX_HAVE_RT
+#define NDN_CXX_HAVE_SQLITE3 1
+#define NDN_CXX_HAVE_CRYPTOPP_CONFIG_H 1
+#define NDN_CXX_SYSCONFDIR "./etc"
+
+#endif /* W_SRC_NDN_CXX_CONFIG_HPP_WAF */
diff --git a/app/src/main/jni/ndn-cxx.mk b/app/src/main/jni/ndn-cxx.mk
new file mode 100644
index 0000000..4ecb9be
--- /dev/null
+++ b/app/src/main/jni/ndn-cxx.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH := $(call my-dir)
+LOCAL_PATH_SAVED := $(LOCAL_PATH)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ndn-cxx
+NDN_CXX_BOOST_LIBS = system filesystem date_time iostreams regex program_options chrono random
+LOCAL_SHARED_LIBRARIES := cryptopp $(addsuffix _shared,$(addprefix boost_,$(NDN_CXX_BOOST_LIBS)))
+LOCAL_STATIC_LIBRARIES := sqlite3
+NDN_CXX_SRC_FILES := name.cpp util/dns.cpp util/time-unit-test-clock.cpp util/segment-fetcher.cpp util/config-file.cpp util/in-memory-storage.cpp util/in-memory-storage-lfu.cpp util/in-memory-storage-fifo.cpp util/ethernet.cpp util/crypto.cpp util/regex/regex-top-matcher.cpp util/signal-scoped-connection.cpp util/dummy-client-face.cpp util/scheduler.cpp util/indented-stream.cpp util/signal-connection.cpp util/in-memory-storage-persistent.cpp util/digest.cpp util/in-memory-storage-lru.cpp util/in-memory-storage-entry.cpp util/time.cpp util/random.cpp util/face-uri.cpp interest-filter.cpp signature.cpp transport/tcp-transport.cpp transport/unix-transport.cpp management/nfd-face-event-notification.cpp management/nfd-control-command.cpp management/nfd-command-options.cpp management/nfd-face-status.cpp management/nfd-control-response.cpp management/nfd-rib-entry.cpp management/nfd-controller.cpp management/nfd-forwarder-status.cpp management/nfd-channel-status.cpp management/nfd-fib-entry.cpp management/nfd-strategy-choice.cpp management/nfd-face-query-filter.cpp management/nfd-control-parameters.cpp exclude.cpp name-component.cpp face.cpp key-locator.cpp data.cpp interest.cpp selectors.cpp meta-info.cpp signature-info.cpp encoding/nfd-constants.cpp encoding/oid.cpp encoding/cryptopp/asn_ext.cpp encoding/block.cpp encoding/buffer.cpp security/sec-public-info-sqlite3.cpp security/signature-sha256-with-rsa.cpp security/public-key.cpp security/certificate-cache-ttl.cpp security/sec-rule-specific.cpp security/sec-tpm-file.cpp security/digest-sha256.cpp security/sec-public-info.cpp security/certificate.cpp security/identity-certificate.cpp security/certificate-subject-description.cpp security/certificate-extension.cpp security/sec-tpm.cpp security/validator.cpp security/sec-rule-relative.cpp security/key-params.cpp security/secured-bag.cpp security/key-chain.cpp security/signature-sha256-with-ecdsa.cpp security/validator-config.cpp security/validator-regex.cpp
+LOCAL_SRC_FILES := $(addprefix ndn-cxx/src/,$(NDN_CXX_SRC_FILES))
+LOCAL_CPPFLAGS := -I$(LOCAL_PATH)/ndn-cxx/src -I$(LOCAL_PATH)/ndn-cxx-android
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ndn-cxx-android
+include $(BUILD_SHARED_LIBRARY)
+
+include $(LOCAL_PATH_SAVED)/sqlite3/Android.mk
+include $(LOCAL_PATH_SAVED)/cryptopp/Android.mk
+
+$(call import-module,boost/1.57.0)
diff --git a/app/src/main/jni/nfd-android/config.hpp b/app/src/main/jni/nfd-android/config.hpp
new file mode 100644
index 0000000..78b3f8b
--- /dev/null
+++ b/app/src/main/jni/nfd-android/config.hpp
@@ -0,0 +1,12 @@
+#ifndef W_CONFIG_HPP_WAF
+#define W_CONFIG_HPP_WAF
+
+#define HAVE_IS_DEFAULT_CONSTRUCTIBLE 1
+#define HAVE_IS_MOVE_CONSTRUCTIBLE 1
+#define HAVE_CXX_OVERRIDE 1
+#define HAVE_LIBRT
+#define HAVE_LIBRESOLV
+/*#undef HAVE_UNIX_SOCKETS*/
+#define DEFAULT_CONFIG_FILE "./nfd.conf"
+
+#endif /* W_CONFIG_HPP_WAF */
diff --git a/app/src/main/jni/nfd-android/version.hpp b/app/src/main/jni/nfd-android/version.hpp
new file mode 100644
index 0000000..d9aa54a
--- /dev/null
+++ b/app/src/main/jni/nfd-android/version.hpp
@@ -0,0 +1,74 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014,  Regents of the University of California,
+ *                      Arizona Board of Regents,
+ *                      Colorado State University,
+ *                      University Pierre & Marie Curie, Sorbonne University,
+ *                      Washington University in St. Louis,
+ *                      Beijing Institute of Technology,
+ *                      The University of Memphis
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NFD_VERSION_HPP
+#define NFD_VERSION_HPP
+
+namespace nfd {
+
+/** NFD version follows Semantic Versioning 2.0.0 specification
+ *  http://semver.org/
+ */
+
+// To change version number, modify VERSION variable in top-level wscript.
+
+/** \brief NFD version represented as an integer
+ *
+ *  MAJOR*1000000 + MINOR*1000 + PATCH
+ */
+#define NFD_VERSION 2000
+
+/** \brief NFD version represented as a string
+ *
+ *  MAJOR.MINOR.PATCH
+ */
+#define NFD_VERSION_STRING "0.2.0"
+
+/** \brief NFD version string, including git commit information, if NFD is build from
+ *         specific git commit
+ *
+ * NFD_VERSION_BUILD_STRING is obtained using the following command (`NFD-` prefix is
+ * afterwards removed):
+ *
+ *    `git describe --match 'NFD-*'`
+ *
+ * When NFD is built not from git, NFD_VERSION_BUILD_STRING equals NFD_VERSION_STRING
+ *
+ * MAJOR.MINOR.PATCH(-release-candidate-tag)(-(number-of-commits-since-tag)-COMMIT-HASH)
+ *
+ * Example, 0.1.0-rc1-1-g5c86570
+ */
+#define NFD_VERSION_BUILD_STRING "0.2.0-134-gde88b46"
+
+/// MAJOR version
+#define NFD_VERSION_MAJOR 0
+/// MINOR version
+#define NFD_VERSION_MINOR 2
+/// PATCH version
+#define NFD_VERSION_PATCH 0
+
+} // namespace nfd
+
+#endif // NFD_VERSION_HPP
diff --git a/app/src/main/jni/nfd.mk b/app/src/main/jni/nfd.mk
new file mode 100644
index 0000000..04cf7e3
--- /dev/null
+++ b/app/src/main/jni/nfd.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH := $(call my-dir)
+LOCAL_PATH_SAVED := $(LOCAL_PATH)
+
+NFD_BOOST_LIBS = system filesystem chrono program_options random
+
+# core
+include $(CLEAR_VARS)
+LOCAL_MODULE := nfd-core
+LOCAL_SHARED_LIBRARIES := cryptopp ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
+NFD_CORE_SRC_FILES := core/network.cpp core/config-file.cpp core/network-interface.cpp core/logger-factory.cpp core/privilege-helper.cpp core/city-hash.cpp core/scheduler.cpp core/global-io.cpp core/logger.cpp core/random.cpp
+LOCAL_SRC_FILES := $(addprefix NFD/,$(NFD_CORE_SRC_FILES))
+LOCAL_CPPFLAGS := -I$(LOCAL_PATH)/nfd-android -I$(LOCAL_PATH)/NFD -I$(LOCAL_PATH)/NFD/core
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/nfd-android $(LOCAL_PATH)/NFD $(LOCAL_PATH)/NFD/core
+include $(BUILD_STATIC_LIBRARY)
+
+# nfd itself
+include $(CLEAR_VARS)
+LOCAL_MODULE := nfd-daemon
+LOCAL_SHARED_LIBRARIES := cryptopp ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
+LOCAL_STATIC_LIBRARIES := nfd-core
+NFD_DAEMON_SRC_FILES := daemon/face/ndnlp-sequence-generator.cpp daemon/face/udp-channel.cpp daemon/face/ndnlp-partial-message-store.cpp daemon/face/ndnlp-parse.cpp daemon/face/face.cpp daemon/face/null-face.cpp daemon/face/tcp-factory.cpp daemon/face/ndnlp-slicer.cpp daemon/face/udp-face.cpp daemon/face/multicast-udp-face.cpp daemon/face/channel.cpp daemon/face/tcp-channel.cpp daemon/face/tcp-face.cpp daemon/face/udp-factory.cpp daemon/main.cpp daemon/table/measurements-accessor.cpp daemon/table/pit-out-record.cpp daemon/table/fib-entry.cpp daemon/table/pit-in-record.cpp daemon/table/measurements-entry.cpp daemon/table/strategy-choice.cpp daemon/table/cs-entry.cpp daemon/table/pit.cpp daemon/table/measurements.cpp daemon/table/strategy-info-host.cpp daemon/table/pit-face-record.cpp daemon/table/fib.cpp daemon/table/cs-entry-impl.cpp daemon/table/fib-nexthop.cpp daemon/table/name-tree.cpp daemon/table/name-tree-entry.cpp daemon/table/cs.cpp daemon/table/pit-entry.cpp daemon/table/strategy-choice-entry.cpp daemon/table/cs-skip-list-entry.cpp daemon/table/dead-nonce-list.cpp daemon/fw/access-strategy.cpp daemon/fw/retransmission-suppression.cpp daemon/fw/strategy.cpp daemon/fw/rtt-estimator.cpp daemon/fw/broadcast-strategy.cpp daemon/fw/client-control-strategy.cpp daemon/fw/best-route-strategy.cpp daemon/fw/face-table.cpp daemon/fw/ncc-strategy.cpp daemon/fw/forwarder.cpp daemon/fw/best-route-strategy2.cpp daemon/fw/available-strategies.cpp daemon/mgmt/status-server.cpp daemon/mgmt/tables-config-section.cpp daemon/mgmt/channel-status-publisher.cpp daemon/mgmt/strategy-choice-publisher.cpp daemon/mgmt/general-config-section.cpp daemon/mgmt/command-validator.cpp daemon/mgmt/internal-face.cpp daemon/mgmt/fib-enumeration-publisher.cpp daemon/mgmt/face-manager.cpp daemon/mgmt/manager-base.cpp daemon/mgmt/face-status-publisher.cpp daemon/mgmt/strategy-choice-manager.cpp daemon/mgmt/face-query-status-publisher.cpp daemon/mgmt/fib-manager.cpp
+LOCAL_SRC_FILES := $(addprefix NFD/,$(NFD_DAEMON_SRC_FILES))
+LOCAL_CPPFLAGS := -I$(LOCAL_PATH)/NFD/daemon
+include $(BUILD_SHARED_LIBRARY)
+
+# rib manager
+include $(CLEAR_VARS)
+LOCAL_MODULE := nfd-rib
+LOCAL_SHARED_LIBRARIES := cryptopp ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
+LOCAL_STATIC_LIBRARIES := nfd-core
+NFD_DAEMON_SRC_FILES := rib/fib-update.cpp rib/main.cpp rib/remote-registrator.cpp rib/rib-entry.cpp rib/rib-manager.cpp rib/rib-status-publisher.cpp rib/rib.cpp
+LOCAL_SRC_FILES := $(addprefix NFD/,$(NFD_DAEMON_SRC_FILES))
+LOCAL_CPPFLAGS := -I$(LOCAL_PATH)/NFD/rib
+include $(BUILD_SHARED_LIBRARY)
diff --git a/app/src/main/jni/sqlite3 b/app/src/main/jni/sqlite3
new file mode 160000
index 0000000..b2b9ab5
--- /dev/null
+++ b/app/src/main/jni/sqlite3
@@ -0,0 +1 @@
+Subproject commit b2b9ab529987de81585ce6bf7bcfab91917f37af