Commit bb41be7e authored by George Nash's avatar George Nash

Update readme file due to updates in Makefiles

This updates the documentation now that the Makefile
has been updated to build the SWIG and Java.

This also removes the make files that are no longer
needed now that the top level make file can do the
same build with just a change in build options.

Change-Id: Ic81c5656f6f7f68983f0ed2caa6682591ac7dbc4
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parent d1932b60
# Download NDK: https://developer.android.com/ndk/downloads/index.html
# Unzip downloaded package.
# Choose architecture and API level.
# cd <NDK>/build/tools
# ./make_standalone_toolchain.py --arch <architecture> --api <level> --install-dir <path>
# For example: ./make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
# This makefile uses then the NDK in <install-dir>.
# For further setup see: https://developer.android.com/ndk/guides/standalone_toolchain.html
#
# Either set ANDROID_API and ANDROID_BASE in this makefile
# or invoke like this: make NDK_HOME=/opt/android-ndk ANDROID_API=24
# Example Usage: make -f Makefile-swig DYNAMIC=1 TCP=1 IPV4=1 SECURE=1 DEBUG=1
#
# Copy the *.so to the appropriate jniLibs sub-directories, ie
# cp *.so ../../swig/apps/android_simple_client/SimpleClient/app/src/main/jniLibs/armeabi/.
# Location of the installation directory and the API level.
ANDROID_API := 23
ifeq (${NDK_HOME},)
ANDROID_BASE := "${HOME}/android-arm-${ANDROID_API}"
else
ANDROID_BASE := "${NDK_HOME}"
endif
# Compiler prefix
ANDROID_HOST := arm-linux-androideabi-
BIN_BASE := ${ANDROID_BASE}/bin/${ANDROID_HOST}
ifeq ($(origin CC),default)
CC := ${BIN_BASE}gcc
endif
ifeq ($(origin AR),default)
AR := ${BIN_BASE}ar
endif
RM ?= rm
MKDIR ?= mkdir
DYNAMIC ?= 1
SECURE ?= 1
PKI ?= 1
ROOT_DIR = ../..
SWIG_DIR := ../../swig/iotivity-lite-java/jni/
OBJDIR ?= ./${ANDROID_HOST}obj
MBEDTLS_DIR := $(ROOT_DIR)/deps/mbedtls
DTLS= aes.c aesni.c arc4.c asn1parse.c asn1write.c base64.c \
bignum.c blowfish.c camellia.c ccm.c cipher.c cipher_wrap.c \
cmac.c ctr_drbg.c des.c dhm.c ecdh.c ecdsa.c \
ecjpake.c ecp.c ecp_curves.c entropy.c entropy_poll.c error.c \
gcm.c havege.c hmac_drbg.c md.c md2.c md4.c \
md5.c md_wrap.c oid.c padlock.c \
pem.c pk.c pk_wrap.c pkcs12.c pkcs5.c pkparse.c \
pkwrite.c platform.c ripemd160.c rsa.c sha1.c sha256.c \
sha512.c threading.c timing.c version.c version_features.c \
xtea.c pkcs11.c x509.c x509_crt.c debug.c net_sockets.c \
ssl_cache.c ssl_ciphersuites.c ssl_cli.c ssl_cookie.c \
ssl_srv.c ssl_ticket.c ssl_tls.c rsa_internal.c x509write_csr.c\
x509write_crt.c x509_create.c
DTLSFLAGS=-I../../deps/mbedtls/include -D__OC_RANDOM
CBOR=../../deps/tinycbor/src/cborencoder.c ../../deps/tinycbor/src/cborencoder_close_container_checked.c ../../deps/tinycbor/src/cborparser.c# ../../deps/tinycbor/src/cbortojson.c ../../deps/tinycbor/src/cborpretty.c ../../deps/tinycbor/src/cborparser_dup_string.c
CTIMESTAMP=../../api/c-timestamp/timestamp_format.c ../../api/c-timestamp/timestamp_valid.c ../../api/c-timestamp/timestamp_parse.c
SRC_COMMON:=$(wildcard ../../util/*.c) ${CBOR} ${CTIMESTAMP}
SRC:=$(wildcard ../../messaging/coap/*.c ../../api/*.c ../../port/android/*.c)
SWIG_SRC_C:=$(wildcard ${SWIG_DIR}/*.c)
# From API level 24 on Android supports getifaddrs itself.
ifeq ($(shell if [ ${ANDROID_API} -gt 23 ]; then echo gt; fi),gt)
SRC:=$(filter-out ../../port/android/ifaddrs-android.c,${SRC})
endif
HEADERS = $(wildcard ../../include/*.h)
HEADERS += ../../port/android/oc_config.h
HEADERS_COAP = $(wildcard ../../messaging/coap/*.h)
HEADERS_UTIL = $(wildcard ../../util/*.h)
HEADERS_UTIL_PT = $(wildcard ../../util/pt/*.h)
HEADERS_PORT = $(wildcard ../../port/*.h)
HEADERS_TINYCBOR = $(wildcard ../../deps/tinycbor/src/*.h)
CFLAGS?=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-strict-overflow -I./ -I../../include/ -I../../ -std=gnu99 -Wall -D__ANDROID_API__=${ANDROID_API}
OBJ_COMMON=$(addprefix ${OBJDIR}/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix ${OBJDIR}/client/,$(notdir $(SRC:.c=.o)))
OBJ_SERVER=$(addprefix ${OBJDIR}/server/,$(filter-out oc_obt.o oc_obt.o oc_obt_otm_justworks.o oc_obt_otm_randompin.o,$(notdir $(SRC:.c=.o))))
OBJ_CLIENT_SERVER=$(addprefix ${OBJDIR}/client_server/,$(notdir $(SRC:.c=.o)))
OBJ_SWIG=$(addprefix ${OBJDIR}/swig/,$(notdir $(SWIG_SRC_C:.c=.o)))
VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../../deps/mbedtls/library:../../api/c-timestamp:
LIBS?= -lm
ifeq ($(DEBUG),1)
CFLAGS += -DOC_DEBUG -g -O0
ifeq ($(DEBUG_TLS),1)
CFLAGS += -DOC_DEBUG_TLS
endif
else
CFLAGS += -Wl,--gc-sections
endif
ifeq ($(PKI),1)
EXTRA_CFLAGS += -DOC_PKI
endif
ifeq ($(DYNAMIC),1)
EXTRA_CFLAGS += -DOC_DYNAMIC_ALLOCATION
endif
ifneq ($(SECURE),0)
SRC += $(addprefix ../../security/,oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c oc_tls.c oc_svr.c oc_store.c oc_pki.c oc_certs.c oc_sp.c oc_keypair.c oc_csr.c oc_roles.c)
SRC_COMMON += $(addprefix $(MBEDTLS_DIR)/library/,${DTLS})
MBEDTLS_PATCH_FILE := $(MBEDTLS_DIR)/patched.txt
ifeq ($(DYNAMIC),1)
SRC += ../../security/oc_obt.c ../../security/oc_obt_otm_justworks.c ../../security/oc_obt_otm_randompin.c
else
SRC_COMMON += $(MBEDTLS_DIR)/library/memory_buffer_alloc.c
endif
CFLAGS += ${DTLSFLAGS}
EXTRA_CFLAGS += -DOC_SECURITY
VPATH += ../../security/:../../deps/mbedtls/library:
endif
ifeq ($(IPV4),1)
EXTRA_CFLAGS += -DOC_IPV4
endif
ifeq ($(TCP),1)
EXTRA_CFLAGS += -DOC_TCP
endif
CFLAGS += $(EXTRA_CFLAGS)
CFLAGS += -DLONG_BIT=64
CONSTRAINED_LIBS = libiotivity-constrained-client-server.so
all: $(CONSTRAINED_LIBS)
.PHONY: clean
${SRC} ${SRC_COMMON}: $(MBEDTLS_PATCH_FILE)
${OBJDIR}/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS}
${OBJDIR}/server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_SERVER
${OBJDIR}/client/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT
${OBJDIR}/client_server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_api_wrap.o: ${SWIG_DIR}/oc_api_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -Wno-unused-function -Wno-pointer-bool-conversion -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_clock_wrap.o: ${SWIG_DIR}/oc_clock_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_buffer_settings_wrap.o: ${SWIG_DIR}/oc_buffer_settings_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_collection_wrap.o: ${SWIG_DIR}/oc_collection_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_core_res_wrap.o: ${SWIG_DIR}/oc_core_res_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_endpoint_wrap.o: ${SWIG_DIR}/oc_endpoint_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_rep_wrap.o: ${SWIG_DIR}/oc_rep_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_obt_wrap.o: ${SWIG_DIR}/oc_obt_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_pki_wrap.o: ${SWIG_DIR}/oc_pki_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_storage_wrap.o: ${SWIG_DIR}/oc_storage_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_uuid_wrap.o: ${SWIG_DIR}/oc_uuid_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
libiotivity-constrained-client-server.so: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER) $(OBJ_SWIG)
${CC} -shared $(OBJ_SWIG) $(OBJ_COMMON) $(OBJ_CLIENT_SERVER) ${LIBS} -llog -o libiotivity-lite-jni.so
ifneq ($(SECURE),0)
MBEDTLS_PATCHES ?= $(sort $(wildcard ../../patches/*.patch))
${MBEDTLS_DIR}/.git:
git submodule update --init ${@D}
$(MBEDTLS_PATCH_FILE): ${MBEDTLS_DIR}/.git ${MBEDTLS_PATCHES}
if [ -d ${MBEDTLS_DIR} ]; then \
cd ${MBEDTLS_DIR} && \
git clean -fdx . && \
git reset --hard && \
cd -; \
fi && \
git submodule update --init && \
cd ${MBEDTLS_DIR} && \
for patch in $(MBEDTLS_PATCHES); do patch -r - -s -N -p1 < $${patch} ; done && \
echo "Patches applied in $^" > ${@F}
endif
clean:
$(RM) -rf ${OBJDIR} $(CONSTRAINED_LIBS) *.so
cleanall: clean
$(RM) -rf ${all} $(MBEDTLS_PATCH_FILE)
distclean: cleanall
# Port for native Android compilation (without Java).
# Tested NDK versions:
# API Android version
# 19 4.4
# 21 5.0
# 23 6.0
# 24 7.0
#
# API version 24 is closest to regular Linux so far.
# With API 24 the Android port is almost identical to the Linux port
# except for the removal of the unsupported pthread_cancel and that
# the IP adapter assures that interfaces have multicast and broadcast
# enabled to avoid 3G/4G/5G interfaces.
#
# It is expected that higher versions then API 24 should work without any
# further modifications.
#
# Testing compilations on non-rooted Android phones:
# - Enable USB debugging on your phone.
# - Install ADB or Android Studio
# - adb start-server
# Your phone should query now if you trust the computer. Hit OK.
# - adb push simpleclient /data/local/tmp/
# Most likely your phone gives you in /data/local some more permissions
# Non-rooted devices are a bit restrictive what you can do in the file system.
# - adb shell
# - cd /data/local/tmp
# - chmod 755 simpleclient
# It was observed that the file has read-write permissions only after the upload
# on Android 7.
# - In a different terminal window start simpleserver on your developer box.
# - ./simpleclient
# - Kill client with Ctrl-C or Ctrl-\
# - exit
# - *** DISABLE USB debugging!!! *** (security issue if left on)
#
# Note: On regular Android phones the server versions will not be found
# (ie. simpleserver will not be discovered). But the clients
# should work.
#
# Download NDK: https://developer.android.com/ndk/downloads/index.html
# Unzip downloaded package.
# Choose architecture and API level.
# cd <NDK>/build/tools
# ./make_standalone_toolchain.py --arch <architecture> --api <level> --install-dir <path>
# For example: ./make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
# This makefile uses then the NDK in <install-dir>.
# For further setup see: https://developer.android.com/ndk/guides/standalone_toolchain.html
#
# Either set ANDROID_API and ANDROID_BASE in this makefile
# or invoke like this: make NDK_HOME=/opt/android-ndk ANDROID_API=24
# Location of the installation directory and the API level.
export OS=android
export ANDROID_API := 23
ifeq (${NDK_HOME},)
ANDROID_BASE := "${HOME}/android-arm-${ANDROID_API}"
else
ANDROID_BASE := "${NDK_HOME}"
endif
# Compiler prefix
ANDROID_HOST := arm-linux-androideabi-
BIN_BASE := ${ANDROID_BASE}/bin/${ANDROID_HOST}
ifeq ($(origin CC),default)
export CC = ${BIN_BASE}gcc
endif
ifeq ($(origin AR),default)
AR := ${BIN_BASE}ar
endif
RM ?= rm
MKDIR ?= mkdir
ROOT_DIR = ../..
SWIG_DIR = ${ROOT_DIR}/swig
OBJDIR ?= ./${ANDROID_HOST}obj
MBEDTLS_DIR := $(ROOT_DIR)/deps/mbedtls
DTLS= aes.c aesni.c arc4.c asn1parse.c asn1write.c base64.c \
bignum.c blowfish.c camellia.c ccm.c cipher.c cipher_wrap.c \
cmac.c ctr_drbg.c des.c dhm.c ecdh.c ecdsa.c \
ecjpake.c ecp.c ecp_curves.c entropy.c entropy_poll.c error.c \
gcm.c havege.c hmac_drbg.c md.c md2.c md4.c \
md5.c md_wrap.c oid.c padlock.c \
pem.c pk.c pk_wrap.c pkcs12.c pkcs5.c pkparse.c \
pkwrite.c platform.c ripemd160.c rsa.c sha1.c sha256.c \
sha512.c threading.c timing.c version.c version_features.c \
xtea.c pkcs11.c x509.c x509_crt.c debug.c net_sockets.c \
ssl_cache.c ssl_ciphersuites.c ssl_cli.c ssl_cookie.c \
ssl_srv.c ssl_ticket.c ssl_tls.c rsa_internal.c x509write_csr.c \
x509write_crt.c x509_create.c
DTLSFLAGS=-I../../deps/mbedtls/include -D__OC_RANDOM
CBOR=../../deps/tinycbor/src/cborencoder.c ../../deps/tinycbor/src/cborencoder_close_container_checked.c ../../deps/tinycbor/src/cborparser.c# ../../deps/tinycbor/src/cbortojson.c ../../deps/tinycbor/src/cborpretty.c ../../deps/tinycbor/src/cborparser_dup_string.c
CTIMESTAMP=../../api/c-timestamp/timestamp_format.c ../../api/c-timestamp/timestamp_valid.c ../../api/c-timestamp/timestamp_parse.c
SRC_COMMON:=$(wildcard ../../util/*.c) ${CBOR} ${CTIMESTAMP}
SRC:=$(wildcard ../../messaging/coap/*.c ../../api/*.c ../../port/android/*.c)
# From API level 24 on Android supports getifaddrs itself.
ifeq ($(shell if [ ${ANDROID_API} -gt 23 ]; then echo gt; fi),gt)
SRC:=$(filter-out ../../port/android/ifaddrs-android.c,${SRC})
endif
HEADERS = $(wildcard ../../include/*.h)
HEADERS += ../../port/android/oc_config.h
HEADERS_COAP = $(wildcard ../../messaging/coap/*.h)
HEADERS_UTIL = $(wildcard ../../util/*.h)
HEADERS_UTIL_PT = $(wildcard ../../util/pt/*.h)
HEADERS_PORT = $(wildcard ../../port/*.h)
HEADERS_TINYCBOR = $(wildcard ../../deps/tinycbor/src/*.h)
CFLAGS?=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-strict-overflow -I./ -I../../include/ -I../../ -std=gnu99 -Wall -D__ANDROID_API__=${ANDROID_API}
OBJ_COMMON=$(addprefix ${OBJDIR}/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix ${OBJDIR}/client/,$(notdir $(SRC:.c=.o)))
OBJ_SERVER=$(addprefix ${OBJDIR}/server/,$(filter-out oc_obt.o oc_obt.o oc_obt_otm_justworks.o oc_obt_otm_randompin.o,$(notdir $(SRC:.c=.o))))
OBJ_CLIENT_SERVER=$(addprefix ${OBJDIR}/client_server/,$(notdir $(SRC:.c=.o)))
VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../../deps/mbedtls/library:../../api/c-timestamp:
LIBS?= -lm -llog
SAMPLES := server client temp_sensor simpleserver simpleclient client_collections_linux \
server_collections_linux server_block_linux client_block_linux smart_home_server_linux multi_device_server multi_device_client \
smart_lock server_multithread_linux client_multithread_linux
OBT = onboarding_tool
ifeq ($(DEBUG),1)
CFLAGS += -DOC_DEBUG -g -O0
ifeq ($(DEBUG_TLS),1)
CFLAGS += -DOC_DEBUG_TLS
endif
else
CFLAGS += -Wl,--gc-sections
endif
ifeq ($(PKI),1)
EXTRA_CFLAGS += -DOC_PKI
endif
ifeq ($(DYNAMIC),1)
CFLAGS += -DOC_DYNAMIC_ALLOCATION
endif
ifeq ($(INTROSPECTION), 1)
EXTRA_CFLAGS += -DOC_IDD_FILE
endif
ifneq ($(SECURE),0)
SRC += $(addprefix ../../security/,oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c oc_tls.c oc_svr.c oc_store.c oc_pki.c oc_certs.c oc_sp.c oc_keypair.c oc_csr.c oc_roles.c)
SRC_COMMON += $(addprefix $(MBEDTLS_DIR)/library/,${DTLS})
MBEDTLS_PATCH_FILE := $(MBEDTLS_DIR)/patched.txt
ifeq ($(DYNAMIC),1)
SRC += ../../security/oc_obt.c ../../security/oc_obt_otm_justworks.c ../../security/oc_obt_otm_randompin.c
SAMPLES += ${OBT}
else
SRC_COMMON += $(MBEDTLS_DIR)/library/memory_buffer_alloc.c
endif
CFLAGS += ${DTLSFLAGS}
EXTRA_CFLAGS += -DOC_SECURITY
VPATH += ../../security/:../../deps/mbedtls/library:
endif
ifeq ($(IPV4),1)
EXTRA_CFLAGS += -DOC_IPV4
endif
ifeq ($(TCP),1)
EXTRA_CFLAGS += -DOC_TCP
endif
CFLAGS += $(EXTRA_CFLAGS)
CFLAGS += -DLONG_BIT=64
CONSTRAINED_LIBS = libiotivity-constrained-server.a libiotivity-constrained-client.a \
libiotivity-constrained-client-server.a
all: $(CONSTRAINED_LIBS) $(SAMPLES) swig
.PHONY: clean
${SRC} ${SRC_COMMON}: $(MBEDTLS_PATCH_FILE)
${OBJDIR}/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS}
${OBJDIR}/server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_SERVER
${OBJDIR}/client/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT
${OBJDIR}/client_server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER
libiotivity-constrained-server.a: $(OBJ_COMMON) $(OBJ_SERVER)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_SERVER)
libiotivity-constrained-client.a: $(OBJ_COMMON) $(OBJ_CLIENT)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT)
libiotivity-constrained-client-server.a: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
server: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
client: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
smart_lock: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/smart_lock_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
temp_sensor: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/temp_sensor_client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
simpleserver: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/simpleserver.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
simpleclient: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/simpleclient.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
client_collections_linux: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/client_collections_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
server_collections_linux: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/server_collections_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
client_block_linux: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/client_block_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
server_block_linux: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/server_block_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
smart_home_server_linux: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/smart_home_server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
multi_device_server: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/multi_device_server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
multi_device_client: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/multi_device_client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
${OBT}: libiotivity-constrained-client.a
${CC} -o $@ ../../onboarding_tool/obtmain.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
server_multithread_linux: libiotivity-constrained-server.a
${CC} -o $@ ../../apps/server_multithread_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
client_multithread_linux: libiotivity-constrained-client.a
${CC} -o $@ ../../apps/client_multithread_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
swig:
${MAKE} -C ${SWIG_DIR}
ifneq ($(SECURE),0)
MBEDTLS_PATCHES ?= $(sort $(wildcard ../../patches/*.patch))
${MBEDTLS_DIR}/.git:
git submodule update --init ${@D}
$(MBEDTLS_PATCH_FILE): ${MBEDTLS_DIR}/.git ${MBEDTLS_PATCHES}
if [ -d ${MBEDTLS_DIR} ]; then \
cd ${MBEDTLS_DIR} && \
git clean -fdx . && \
git reset --hard && \
cd -; \
fi && \
git submodule update --init && \
cd ${MBEDTLS_DIR} && \
for patch in $(MBEDTLS_PATCHES); do patch -r - -s -N -p1 < $${patch} ; done && \
echo "Patches applied in $^" > ${@F}
endif
clean:
$(RM) -rf ${OBJDIR} $(CONSTRAINED_LIBS)
cleanall: clean
$(RM) -rf ${all} $(SAMPLES) $(OBT) $(MBEDTLS_PATCH_FILE)
${MAKE} -C ${SWIG_DIR} clean
distclean: cleanall
......@@ -74,41 +74,30 @@ Developers wishing to use Android Studio can find details here:
Building IoTivity-Lite libraries
=================================================
Navigate to `<iotivity-lite>/swig/java_lang`
Get SWIG to generate the Java and JNI code:
./build_swig.sh android
Build `iotivity-lite.jar`:
./build-iotivity-lite.sh android
The script will copy the `iotivity-lite.jar` to the Android app libs directory for each project.
To build the `libiotivity-lite-jni.so` shared object library for Android cd to
To build for Android cd to
cd <iotivity-lite>/android/port
The Makefile-swig uses then the Android NDK that was installed above.
The Makefile uses then the Android NDK that was installed above.
Either set ANDROID_API and ANDROID_BASE in the Makefile-swig or invoke like this:
Either set ANDROID_API and ANDROID_BASE in the Makefile or invoke like this:
make NDK_HOME=/opt/android-ndk ANDROID_API=23
Example Usage:
make -f Makefile-swig DYNAMIC=1 TCP=1 IPV4=1 SECURE=1 DEBUG=1
make IPV4=1 DEBUG=1
or
make NDK_HOME=~/android-arm-23 ANDROID_API=23 -f Makefile-swig DYNAMIC=1 TCP=1 IPV4=1 SECURE=1 DEBUG=1
make NDK_HOME=~/android-arm-23 ANDROID_API=23 IPV4=1 DEBUG=1
Copy the libiotivity-lite-jni.so to the appropriate jniLibs sub-directories for each project:
cp libiotivity-lite-jni.so ../../swig/apps/android_simple_client/SimpleClient/app/src/main/jniLibs/armeabi/
cp libiotivity-lite-jni.so ../../swig/apps/android_simple_server/SimpleServer/app/src/main/jniLibs/armeabi/
The Makefile-swig also contains a version of these same build instructions.
The Makefile also contains a version of these same build instructions.
Building and Running Samples
=================================================
......
export CC = gcc
SED = sed
INSTALL = install
export OS = linux
ROOT_DIR = ../..
SWIG_DIR = ${ROOT_DIR}/swig
OUT_DIR = $(ROOT_DIR)/port/$(OS)
CHECK_SCRIPT = ../../tools/check.py
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
DYNAMIC ?= 1
SECURE ?= 1
PKI ?= 1
DESTDIR ?= /usr/local
install_bin_dir?=${DESTDIR}/opt/iotivity-constrained/bin/
prefix = $(DESTDIR)
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
includedir = $(prefix)/include
pkgconfigdir = $(libdir)/pkgconfig
EXTRA_CFLAGS =
MBEDTLS_DIR := $(ROOT_DIR)/deps/mbedtls
GTEST_DIR = $(ROOT_DIR)/deps/gtest
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h
GTEST = gtest_build
GTEST_CPPFLAGS += -isystem $(GTEST_DIR)/include
TEST_CXXFLAGS += -g -Wall -Wextra -pthread -std=c++0x -fpermissive -DOC_SERVER -DOC_CLIENT -fprofile-arcs -ftest-coverage
HEADER_DIR = -I$(ROOT_DIR)/include \
-I$(ROOT_DIR) \
-I$(OUT_DIR)
SECURITY_HEADERS = -I$(ROOT_DIR)/security \
-I$(MBEDTLS_DIR)/include
MESSAGING_HEADERS = -I$(ROOT_DIR)/messaging/coap
API_TEST_DIR = $(ROOT_DIR)/api/unittest
API_TEST_OBJ_DIR = $(API_TEST_DIR)/obj
API_TEST_SRC_FILES := $(wildcard $(API_TEST_DIR)/*.cpp)
API_TEST_OBJ_FILES := $(patsubst $(API_TEST_DIR)/%.cpp,$(API_TEST_OBJ_DIR)/%.o,$(API_TEST_SRC_FILES))
SECURITY_TEST_DIR = $(ROOT_DIR)/security/unittest
SECURITY_TEST_OBJ_DIR = $(SECURITY_TEST_DIR)/obj
SECURITY_TEST_SRC_FILES := $(wildcard $(SECURITY_TEST_DIR)/*.cpp)
SECURITY_TEST_OBJ_FILES := $(patsubst $(SECURITY_TEST_DIR)/%.cpp,$(SECURITY_TEST_OBJ_DIR)/%.o,$(SECURITY_TEST_SRC_FILES))
PLATFORM_TEST_DIR = $(ROOT_DIR)/port/unittest
PLATFORM_TEST_OBJ_DIR = $(PLATFORM_TEST_DIR)/obj
PLATFORM_TEST_SRC_FILES := $(wildcard $(PLATFORM_TEST_DIR)/*.cpp)
PLATFORM_TEST_OBJ_FILES := $(patsubst $(PLATFORM_TEST_DIR)/%.cpp,$(PLATFORM_TEST_OBJ_DIR)/%.o,$(PLATFORM_TEST_SRC_FILES))
STORAGE_TEST_DIR = storage_test
$(shell mkdir -p $(STORAGE_TEST_DIR))
MESSAGING_TEST_DIR = $(ROOT_DIR)/messaging/coap/unittest
MESSAGING_TEST_OBJ_DIR = $(MESSAGING_TEST_DIR)/obj
MESSAGING_TEST_SRC_FILES := $(wildcard $(MESSAGING_TEST_DIR)/*.cpp)
MESSAGING_TEST_OBJ_FILES := $(patsubst $(MESSAGING_TEST_DIR)/%.cpp,$(MESSAGING_TEST_OBJ_DIR)/%.o,$(MESSAGING_TEST_SRC_FILES))
UNIT_TESTS = apitest platformtest securitytest messagingtest
DTLS= aes.c aesni.c arc4.c asn1parse.c asn1write.c base64.c \
bignum.c blowfish.c camellia.c ccm.c cipher.c cipher_wrap.c \
cmac.c ctr_drbg.c des.c dhm.c ecdh.c ecdsa.c \
ecjpake.c ecp.c ecp_curves.c entropy.c entropy_poll.c error.c \
gcm.c havege.c hmac_drbg.c md.c md2.c md4.c \
md5.c md_wrap.c oid.c padlock.c \
pem.c pk.c pk_wrap.c pkcs12.c pkcs5.c pkparse.c \
pkwrite.c platform.c ripemd160.c rsa.c sha1.c sha256.c \
sha512.c threading.c timing.c version.c version_features.c \
xtea.c pkcs11.c x509.c x509_crt.c debug.c net_sockets.c \
ssl_cache.c ssl_ciphersuites.c ssl_cli.c ssl_cookie.c \
ssl_srv.c ssl_ticket.c ssl_tls.c rsa_internal.c x509write_csr.c\
x509write_crt.c x509_create.c
DTLSFLAGS=-I../../deps/mbedtls/include -D__OC_RANDOM
CBOR=../../deps/tinycbor/src/cborencoder.c ../../deps/tinycbor/src/cborencoder_close_container_checked.c ../../deps/tinycbor/src/cborparser.c# ../../deps/tinycbor/src/cbortojson.c ../../deps/tinycbor/src/cborpretty.c ../../deps/tinycbor/src/cborparser_dup_string.c
CTIMESTAMP=../../api/c-timestamp/timestamp_format.c ../../api/c-timestamp/timestamp_valid.c ../../api/c-timestamp/timestamp_parse.c
SRC_COMMON=$(wildcard ../../util/*.c) ${CBOR} ${CTIMESTAMP}
SRC=$(wildcard ../../messaging/coap/*.c ../../api/*.c ../../port/linux/*.c)
HEADERS = $(wildcard ../../include/*.h)
HEADERS += ../../port/linux/oc_config.h
HEADERS_COAP = $(wildcard ../../messaging/coap/*.h)
HEADERS_UTIL = $(wildcard ../../util/*.h)
HEADERS_UTIL_PT = $(wildcard ../../util/pt/*.h)
HEADERS_PORT = $(wildcard ../../port/*.h)
HEADERS_TINYCBOR = $(wildcard ../../deps/tinycbor/src/*.h)
CFLAGS=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I./ -I../../include/ -I../../ -std=gnu99 -Wall -Wextra -Werror -pedantic #-Wl,-Map,client.map