Makefile 21.3 KB
Newer Older
1 2 3
CC = gcc
SED = sed
INSTALL = install
4 5 6
OS = linux
ROOT_DIR = ../..
OUT_DIR = $(ROOT_DIR)/port/$(OS)
7
CHECK_SCRIPT = ../../tools/check.py
8 9 10
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
Kishen Maloor's avatar
Kishen Maloor committed
11
DYNAMIC ?= 1
12 13
SECURE ?= 1
PKI ?= 1
14 15 16 17 18 19 20 21
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
Inho Oh's avatar
Inho Oh committed
22
EXTRA_CFLAGS =
23 24 25
ifeq ($(DEBUG),1)
	EXTRA_CFLAGS += -fsanitize=address
endif
Kishen Maloor's avatar
Kishen Maloor committed
26

Mushfiqul Islam Antu's avatar
Mushfiqul Islam Antu committed
27
MBEDTLS_DIR := $(ROOT_DIR)/deps/mbedtls
28 29 30 31 32
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
towhid's avatar
towhid committed
33
TEST_CXXFLAGS += -g -Wall -Wextra -pthread -std=c++0x -fpermissive -DOC_SERVER -DOC_CLIENT -fprofile-arcs -ftest-coverage
Mushfiqul Islam Antu's avatar
Mushfiqul Islam Antu committed
34 35 36 37 38
HEADER_DIR = -I$(ROOT_DIR)/include \
             -I$(ROOT_DIR) \
             -I$(OUT_DIR)
SECURITY_HEADERS = -I$(ROOT_DIR)/security \
                   -I$(MBEDTLS_DIR)/include
Jaehyun Cho's avatar
Jaehyun Cho committed
39
MESSAGING_HEADERS = -I$(ROOT_DIR)/messaging/coap
40 41 42 43
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))
Mushfiqul Islam Antu's avatar
Mushfiqul Islam Antu committed
44 45 46 47
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))
48
PLATFORM_TEST_DIR = $(ROOT_DIR)/port/unittest
49 50 51
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))
52 53
STORAGE_TEST_DIR = storage_test
$(shell mkdir -p $(STORAGE_TEST_DIR))
Jaehyun Cho's avatar
Jaehyun Cho committed
54 55 56 57
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))
58 59 60 61 62 63 64 65 66 67 68

CLOUD_TEST_DIR = $(ROOT_DIR)/service/cloud/unittest
CLOUD_TEST_OBJ_DIR = $(CLOUD_TEST_DIR)/obj
CLOUD_TEST_SRC_FILES := $(wildcard $(CLOUD_TEST_DIR)/*.cpp)
CLOUD_TEST_OBJ_FILES := $(patsubst $(CLOUD_TEST_DIR)/%.cpp,$(CLOUD_TEST_OBJ_DIR)/%.o,$(CLOUD_TEST_SRC_FILES))

RD_CLIENT_TEST_DIR = $(ROOT_DIR)/service/resource-directory/client/unittest
RD_CLIENT_TEST_OBJ_DIR = $(RD_CLIENT_TEST_DIR)/obj
RD_CLIENT_TEST_SRC_FILES := $(wildcard $(RD_CLIENT_TEST_DIR)/*.cpp)
RD_CLIENT_TEST_OBJ_FILES := $(patsubst $(RD_CLIENT_TEST_DIR)/%.cpp,$(RD_CLIENT_TEST_OBJ_DIR)/%.o,$(RD_CLIENT_TEST_SRC_FILES))

Jaehyun Cho's avatar
Jaehyun Cho committed
69
UNIT_TESTS = apitest platformtest securitytest messagingtest
70

Kishen Maloor's avatar
Kishen Maloor committed
71 72 73 74 75 76 77 78 79 80 81
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			\
Kishen Maloor's avatar
Kishen Maloor committed
82 83
	ssl_srv.c	ssl_ticket.c	ssl_tls.c	rsa_internal.c	x509write_csr.c\
	x509write_crt.c	x509_create.c
Kishen Maloor's avatar
Kishen Maloor committed
84 85 86
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
Mushfiqul Islam Antu's avatar
Mushfiqul Islam Antu committed
87

88
CTIMESTAMP=../../api/c-timestamp/timestamp_format.c ../../api/c-timestamp/timestamp_valid.c ../../api/c-timestamp/timestamp_parse.c
Kishen Maloor's avatar
Kishen Maloor committed
89

90
SRC_COMMON=$(wildcard ../../util/*.c) ${CBOR} ${CTIMESTAMP}
Otavio Pontes's avatar
Otavio Pontes committed
91
SRC=$(wildcard ../../messaging/coap/*.c ../../api/*.c ../../port/linux/*.c)
92 93
SRC_CLOUD=$(wildcard ../../service/cloud/src/*.c)
SRC_RD_CLIENT=$(wildcard ../../service/resource-directory/client/src/*.c)
Kishen Maloor's avatar
Kishen Maloor committed
94

95
HEADERS = $(wildcard ../../include/*.h)
96
HEADERS += ../../port/linux/oc_config.h
97 98 99 100 101 102

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)
103

104 105
CFLAGS_CLOUD=-I../../service/cloud/include
CFLAGS_RD_CLIENT=-I../../service/resource-directory/client/include
Kishen Maloor's avatar
Kishen Maloor committed
106
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
Otavio Pontes's avatar
Otavio Pontes committed
107 108
OBJ_COMMON=$(addprefix obj/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix obj/client/,$(notdir $(SRC:.c=.o)))
109
OBJ_SERVER=$(addprefix obj/server/,$(filter-out oc_obt.o oc_obt_otm_justworks.o oc_obt_otm_randompin.o,$(notdir $(SRC:.c=.o))))
110
OBJ_CLIENT_SERVER=$(addprefix obj/client_server/,$(notdir $(SRC:.c=.o)))
111 112 113
OBJ_CLOUD=$(addprefix obj/cloud/,$(notdir $(SRC_CLOUD:.c=.o)))
OBJ_RD_CLIENT=$(addprefix obj/rd_client/,$(notdir $(SRC_RD_CLIENT:.c=.o)))
VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../../deps/mbedtls/library:../../api/c-timestamp:../../service/cloud/src/:../../service/resource-directory/client/src/:
Philippe Coval's avatar
Philippe Coval committed
114
LIBS?= -lm -pthread -lrt
Kishen Maloor's avatar
Kishen Maloor committed
115

116
SAMPLES = server client temp_sensor simpleserver simpleserver_pki simpleclient client_collections_linux \
Jaehyun Cho's avatar
Jaehyun Cho committed
117
	  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
Kishen Maloor's avatar
Kishen Maloor committed
118

119 120 121 122 123 124 125 126
ifeq ($(CLOUD),1)
	HEADERS += $(wildcard ../../service/cloud/include/*.h)
	HEADERS += $(wildcard ../../service/resource-directory/client/include/*.h)
    CFLAGS += -DOC_CLOUD
	TCP=1
	IPV4=1
endif

127 128
OBT = onboarding_tool

Kishen Maloor's avatar
Kishen Maloor committed
129
ifeq ($(DEBUG),1)
130
	CFLAGS += -DOC_DEBUG -g -O0
Oleksandr Dmytrenko's avatar
Oleksandr Dmytrenko committed
131 132 133
ifeq ($(DEBUG_TLS),1)
	CFLAGS += -DOC_DEBUG_TLS
endif
134 135
else
	CFLAGS += -Wl,--gc-sections
Kishen Maloor's avatar
Kishen Maloor committed
136 137
endif

138 139 140 141
ifeq ($(PKI),1)
	EXTRA_CFLAGS += -DOC_PKI
endif

142
ifeq ($(DYNAMIC),1)
Inho Oh's avatar
Inho Oh committed
143
	EXTRA_CFLAGS += -DOC_DYNAMIC_ALLOCATION
144 145
endif

Jaehong Jo's avatar
Jaehong Jo committed
146
ifneq ($(SECURE),0)
147
	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)
148
	SRC_COMMON += $(addprefix $(MBEDTLS_DIR)/library/,${DTLS})
149
	MBEDTLS_PATCH_FILE := $(MBEDTLS_DIR)/patched.txt
Kishen Maloor's avatar
Kishen Maloor committed
150
ifeq ($(DYNAMIC),1)
151
	SRC += ../../security/oc_obt.c ../../security/oc_obt_otm_justworks.c ../../security/oc_obt_otm_randompin.c
152
	SAMPLES += ${OBT}
Kishen Maloor's avatar
Kishen Maloor committed
153
else
154
	SRC_COMMON += $(MBEDTLS_DIR)/library/memory_buffer_alloc.c
Kishen Maloor's avatar
Kishen Maloor committed
155
endif
Inho Oh's avatar
Inho Oh committed
156 157
	CFLAGS += ${DTLSFLAGS}
	EXTRA_CFLAGS += -DOC_SECURITY
Kishen Maloor's avatar
Kishen Maloor committed
158
	VPATH += ../../security/:../../deps/mbedtls/library:
Kishen Maloor's avatar
Kishen Maloor committed
159 160
endif

Flavio Ceolin's avatar
Flavio Ceolin committed
161
ifeq ($(IPV4),1)
Inho Oh's avatar
Inho Oh committed
162
	EXTRA_CFLAGS += -DOC_IPV4
Flavio Ceolin's avatar
Flavio Ceolin committed
163 164
endif

Jaehyun Cho's avatar
Jaehyun Cho committed
165
ifeq ($(TCP),1)
Inho Oh's avatar
Inho Oh committed
166
	EXTRA_CFLAGS += -DOC_TCP
Jaehyun Cho's avatar
Jaehyun Cho committed
167 168
endif

169 170


Inho Oh's avatar
Inho Oh committed
171 172
CFLAGS += $(EXTRA_CFLAGS)

173 174 175 176
ifeq ($(MEMTRACE),1)
	CFLAGS += -DOC_MEMORY_TRACE
endif

177
SAMPLES_CREDS = $(addsuffix _creds, ${SAMPLES} ${OBT})
Kishen Maloor's avatar
Kishen Maloor committed
178

179
CONSTRAINED_LIBS = libiotivity-constrained-server.a libiotivity-constrained-client.a \
180 181
		   libiotivity-constrained-server.so libiotivity-constrained-client.so \
		   libiotivity-constrained-client-server.so libiotivity-constrained-client-server.a
182

183 184
PC = iotivity-constrained-client.pc iotivity-constrained-server.pc \
     iotivity-constrained-client-server.pc
Otavio Pontes's avatar
Otavio Pontes committed
185

186 187 188 189 190 191 192 193
ifeq ($(CLOUD),1)
	CONSTRAINED_LIBS += libiotivity-constrained-cloud.a libiotivity-constrained-cloud.so \
			libiotivity-constrained-rd-client.a libiotivity-constrained-rd-client.so
	UNIT_TESTS += cloudtest rdclienttest
	PC += iotivity-constrained-rd-client.pc iotivity-constrained-cloud.pc
	SAMPLES += cloud_linux
endif

194
all: $(CONSTRAINED_LIBS) $(SAMPLES) $(PC)
Kishen Maloor's avatar
Kishen Maloor committed
195

196 197
test: $(UNIT_TESTS)
	for test in $^ ; do ./$${test} ; done
198

199 200 201 202 203 204 205
.PHONY: test clean

$(GTEST):
	$(MAKE) --directory=$(GTEST_DIR)/make

$(API_TEST_OBJ_DIR)/%.o: $(API_TEST_DIR)/%.cpp
	@mkdir -p ${@D}
206
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) -I$(ROOT_DIR)/deps/tinycbor/src -c $< -o $@
207 208

apitest: $(API_TEST_OBJ_FILES) libiotivity-constrained-client-server.a | $(GTEST)
Kishen Maloor's avatar
Kishen Maloor committed
209
	$(CXX) $^ -o $@ $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) -L$(OUT_DIR) -L$(GTEST_DIR)/make -l:gtest_main.a -liotivity-constrained-client-server -lpthread
Mushfiqul Islam Antu's avatar
Mushfiqul Islam Antu committed
210 211 212

$(SECURITY_TEST_OBJ_DIR)/%.o: $(SECURITY_TEST_DIR)/%.cpp
	@mkdir -p ${@D}
213
	$(CXX) $< -o $@ $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) $(SECURITY_HEADERS) -c
Mushfiqul Islam Antu's avatar
Mushfiqul Islam Antu committed
214 215 216

securitytest: $(SECURITY_TEST_OBJ_FILES) libiotivity-constrained-client-server.a | $(GTEST)
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS)  $(HEADER_DIR) -l:gtest_main.a -liotivity-constrained-client-server -L$(OUT_DIR) -L$(GTEST_DIR)/make -lpthread $^ -o $@
Philippe Coval's avatar
Philippe Coval committed
217

218 219
$(PLATFORM_TEST_OBJ_DIR)/%.o: $(PLATFORM_TEST_DIR)/%.cpp
	@mkdir -p ${@D}
220
	$(CXX) $< -o $@ $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) -I$(ROOT_DIR)/deps/tinycbor/src -c
221 222

platformtest: $(PLATFORM_TEST_OBJ_FILES) libiotivity-constrained-client-server.a | $(GTEST)
223
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) -l:gtest_main.a -liotivity-constrained-client-server -L$(OUT_DIR) -L$(GTEST_DIR)/make -lpthread $^ -o $@
224

225 226 227 228 229 230 231 232 233 234 235 236 237 238
$(CLOUD_TEST_OBJ_DIR)/%.o: $(CLOUD_TEST_DIR)/%.cpp
	@mkdir -p ${@D}
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) $(CFLAGS_CLOUD) -I$(ROOT_DIR)/service/cloud/src -I$(ROOT_DIR)/deps/tinycbor/src -c $< -o $@

cloudtest: $(CLOUD_TEST_OBJ_FILES) libiotivity-constrained-cloud.a libiotivity-constrained-rd-client.a libiotivity-constrained-client-server.a | $(GTEST)
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) $(CFLAGS_CLOUD) -l:gtest_main.a -liotivity-constrained-cloud -liotivity-constrained-rd-client -liotivity-constrained-client-server -L$(OUT_DIR) -L$(GTEST_DIR)/make -lpthread $^ -o $@

$(RD_CLIENT_TEST_OBJ_DIR)/%.o: $(RD_CLIENT_TEST_DIR)/%.cpp
	@mkdir -p ${@D}
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) $(CFLAGS_RD_CLIENT) -I$(ROOT_DIR)/deps/tinycbor/src -c $< -o $@

rdclienttest: $(RD_CLIENT_TEST_OBJ_FILES) libiotivity-constrained-rd-client.a libiotivity-constrained-client-server.a | $(GTEST)
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) $(CFLAGS_RD_CLIENT) -l:gtest_main.a -liotivity-constrained-rd-client -liotivity-constrained-client-server -L$(OUT_DIR) -L$(GTEST_DIR)/make -lpthread $^ -o $@

Jaehyun Cho's avatar
Jaehyun Cho committed
239 240 241 242 243 244 245
$(MESSAGING_TEST_OBJ_DIR)/%.o: $(MESSAGING_TEST_DIR)/%.cpp
	@mkdir -p ${@D}
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS) $(HEADER_DIR) $(MESSAGING_HEADERS) -c $< -o $@

messagingtest: $(MESSAGING_TEST_OBJ_FILES) libiotivity-constrained-client-server.a | $(GTEST)
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS) $(EXTRA_CFLAGS)  $(HEADER_DIR) -l:gtest_main.a -liotivity-constrained-client-server -L$(OUT_DIR) -L$(GTEST_DIR)/make -lpthread $^ -o $@

Philippe Coval's avatar
Philippe Coval committed
246
${SRC} ${SRC_COMMON}: $(MBEDTLS_PATCH_FILE)
247

Kishen Maloor's avatar
Kishen Maloor committed
248
obj/%.o: %.c
Philippe Coval's avatar
Philippe Coval committed
249
	@mkdir -p ${@D}
Kishen Maloor's avatar
Kishen Maloor committed
250
	${CC} -c -o $@ $< ${CFLAGS}
Otavio Pontes's avatar
Otavio Pontes committed
251 252

obj/server/%.o: %.c
Philippe Coval's avatar
Philippe Coval committed
253
	@mkdir -p ${@D}
Otavio Pontes's avatar
Otavio Pontes committed
254 255 256
	${CC} -c -o $@ $< ${CFLAGS} -DOC_SERVER

obj/client/%.o: %.c
Philippe Coval's avatar
Philippe Coval committed
257
	@mkdir -p ${@D}
Otavio Pontes's avatar
Otavio Pontes committed
258 259
	${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT

260 261 262 263
obj/client_server/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER

264 265 266 267 268 269 270 271
obj/cloud/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} ${CFLAGS_CLOUD} ${CFLAGS_RD_CLIENT}

obj/rd_client/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} ${CFLAGS_RD_CLIENT}

Kishen Maloor's avatar
Kishen Maloor committed
272 273 274 275
obj/server/oc_introspection.o: ../../include/server_introspection.dat.h
obj/client/oc_introspection.o: ../../include/server_introspection.dat.h
obj/client_server/oc_introspection.o: ../../include/server_introspection.dat.h

276 277 278 279 280
libiotivity-constrained-server.a: $(OBJ_COMMON) $(OBJ_SERVER)
	$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_SERVER)

libiotivity-constrained-server.so: $(OBJ_COMMON) $(OBJ_SERVER)
	$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_SERVER) $(LIBS)
Otavio Pontes's avatar
Otavio Pontes committed
281

282 283
libiotivity-constrained-client.a: $(OBJ_COMMON) $(OBJ_CLIENT)
	$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT)
Otavio Pontes's avatar
Otavio Pontes committed
284

285 286
libiotivity-constrained-client.so: $(OBJ_COMMON) $(OBJ_CLIENT)
	$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_CLIENT) $(LIBS)
Kishen Maloor's avatar
Kishen Maloor committed
287

288 289 290 291 292 293
libiotivity-constrained-client-server.a: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
	$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)

libiotivity-constrained-client-server.so: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
	$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_CLIENT_SERVER) $(LIBS)

294 295 296 297 298 299 300 301 302 303 304 305
libiotivity-constrained-cloud.a: $(OBJ_CLOUD)
	$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLOUD)

libiotivity-constrained-cloud.so: $(OBJ_CLOUD)
	$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_CLOUD) $(LIBS)

libiotivity-constrained-rd-client.a: $(OBJ_RD_CLIENT)
	$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_RD_CLIENT)

libiotivity-constrained-rd-client.so: $(OBJ_RD_CLIENT)
	$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_RD_CLIENT) $(LIBS)

Kishen Maloor's avatar
Kishen Maloor committed
306
server: libiotivity-constrained-server.a $(ROOT_DIR)/apps/server_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
307
	@mkdir -p $@_creds
308
	${CC} -o $@ ../../apps/server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
309

Kishen Maloor's avatar
Kishen Maloor committed
310
client: libiotivity-constrained-client.a $(ROOT_DIR)/apps/client_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
311
	@mkdir -p $@_creds
312
	${CC} -o $@ ../../apps/client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
313

Kishen Maloor's avatar
Kishen Maloor committed
314
smart_lock: libiotivity-constrained-client.a $(ROOT_DIR)/apps/smart_lock_linux.c
315 316 317
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/smart_lock_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
318
temp_sensor: libiotivity-constrained-client.a $(ROOT_DIR)/apps/temp_sensor_client_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
319
	@mkdir -p $@_creds
320
	${CC} -o $@ ../../apps/temp_sensor_client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
321

Kishen Maloor's avatar
Kishen Maloor committed
322
simpleserver: libiotivity-constrained-server.a $(ROOT_DIR)/apps/simpleserver.c
Kishen Maloor's avatar
Kishen Maloor committed
323
	@mkdir -p $@_creds
324
	${CC} -o $@ ../../apps/simpleserver.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS}  ${LIBS}
325

326 327 328 329
simpleserver_pki: libiotivity-constrained-server.a $(ROOT_DIR)/apps/simpleserver_pki.c
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/simpleserver_pki.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS}  ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
330
simpleclient: libiotivity-constrained-client.a $(ROOT_DIR)/apps/simpleclient.c
Kishen Maloor's avatar
Kishen Maloor committed
331
	@mkdir -p $@_creds
332
	${CC} -o $@ ../../apps/simpleclient.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}
333

Kishen Maloor's avatar
Kishen Maloor committed
334
client_collections_linux: libiotivity-constrained-client.a $(ROOT_DIR)/apps/client_collections_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
335
	@mkdir -p $@_creds
336 337
	${CC} -o $@ ../../apps/client_collections_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
338
server_collections_linux: libiotivity-constrained-server.a $(ROOT_DIR)/apps/server_collections_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
339
	@mkdir -p $@_creds
340 341
	${CC} -o $@ ../../apps/server_collections_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
342
client_block_linux: libiotivity-constrained-client.a $(ROOT_DIR)/apps/client_block_linux.c
343 344
	${CC} -o $@ ../../apps/client_block_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
345
server_block_linux: libiotivity-constrained-server.a $(ROOT_DIR)/apps/server_block_linux.c
346 347
	${CC} -o $@ ../../apps/server_block_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
348
smart_home_server_linux: libiotivity-constrained-server.a $(ROOT_DIR)/apps/smart_home_server_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
349
	@mkdir -p $@_creds
350 351
	${CC} -o $@ ../../apps/smart_home_server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
352
multi_device_server: libiotivity-constrained-server.a $(ROOT_DIR)/apps/multi_device_server_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
353
	@mkdir -p $@_creds
354 355
	${CC} -o $@ ../../apps/multi_device_server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
356
multi_device_client: libiotivity-constrained-client.a $(ROOT_DIR)/apps/multi_device_client_linux.c
Kishen Maloor's avatar
Kishen Maloor committed
357
	@mkdir -p $@_creds
358 359
	${CC} -o $@ ../../apps/multi_device_client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

360 361 362 363
cloud_linux: libiotivity-constrained-client-server.a libiotivity-constrained-cloud.a libiotivity-constrained-rd-client.a $(ROOT_DIR)/apps/cloud_linux.c
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/cloud_linux.c libiotivity-constrained-client-server.a libiotivity-constrained-cloud.a libiotivity-constrained-rd-client.a -DOC_CLIENT -DOC_SERVER ${CFLAGS} ${CFLAGS_CLOUD} ${CFLAGS_ST} ${CFLAGS_RD_CLIENT} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
364
${OBT}: libiotivity-constrained-client.a $(ROOT_DIR)/onboarding_tool/obtmain.c
365 366 367
	@mkdir -p $@_creds
	${CC} -o $@ ../../onboarding_tool/obtmain.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
368
server_multithread_linux: libiotivity-constrained-server.a $(ROOT_DIR)/apps/server_multithread_linux.c
Jaehyun Cho's avatar
Jaehyun Cho committed
369 370 371
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/server_multithread_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

Kishen Maloor's avatar
Kishen Maloor committed
372
client_multithread_linux: libiotivity-constrained-client.a $(ROOT_DIR)/apps/client_multithread_linux.c
Jaehyun Cho's avatar
Jaehyun Cho committed
373 374 375
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/client_multithread_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

376 377 378 379 380
iotivity-constrained-server.pc: iotivity-constrained-server.pc.in
	$(SED) > $@ < $< \
		-e 's,@prefix@,$(prefix),' \
		-e 's,@exec_prefix@,$(exec_prefix),' \
		-e 's,@libdir@,$(libdir),' \
381
		-e 's,@includedir@,$(includedir),' \
Inho Oh's avatar
Inho Oh committed
382 383
		-e 's,@version@,$(VERSION),' \
		-e 's,@extra_cflags@,$(EXTRA_CFLAGS),'
384 385 386 387 388 389

iotivity-constrained-client.pc: iotivity-constrained-client.pc.in
	$(SED) > $@ < $< \
		-e 's,@prefix@,$(prefix),' \
		-e 's,@exec_prefix@,$(exec_prefix),' \
		-e 's,@libdir@,$(libdir),' \
390
		-e 's,@includedir@,$(includedir),' \
Inho Oh's avatar
Inho Oh committed
391 392
		-e 's,@version@,$(VERSION),' \
		-e 's,@extra_cflags@,$(EXTRA_CFLAGS),'
393

394 395 396 397 398
iotivity-constrained-client-server.pc: iotivity-constrained-client-server.pc.in
	$(SED) > $@ < $< \
		-e 's,@prefix@,$(prefix),' \
		-e 's,@exec_prefix@,$(exec_prefix),' \
		-e 's,@libdir@,$(libdir),' \
399
		-e 's,@includedir@,$(includedir),' \
Inho Oh's avatar
Inho Oh committed
400 401
		-e 's,@version@,$(VERSION),' \
		-e 's,@extra_cflags@,$(EXTRA_CFLAGS),'
402

403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
iotivity-constrained-rd-client.pc: iotivity-constrained-rd-client.pc.in
	$(SED) > $@ < $< \
		-e 's,@prefix@,$(prefix),' \
		-e 's,@exec_prefix@,$(exec_prefix),' \
		-e 's,@libdir@,$(libdir),' \
		-e 's,@includedir@,$(includedir),' \
		-e 's,@version@,$(VERSION),' \
		-e 's,@extra_cflags@,$(EXTRA_CFLAGS),'

iotivity-constrained-cloud.pc: iotivity-constrained-cloud.pc.in
	$(SED) > $@ < $< \
		-e 's,@prefix@,$(prefix),' \
		-e 's,@exec_prefix@,$(exec_prefix),' \
		-e 's,@libdir@,$(libdir),' \
		-e 's,@includedir@,$(includedir),' \
		-e 's,@version@,$(VERSION),' \
		-e 's,@extra_cflags@,$(EXTRA_CFLAGS),'

Jaehong Jo's avatar
Jaehong Jo committed
421
ifneq ($(SECURE),0)
Philippe Coval's avatar
Philippe Coval committed
422 423 424 425 426
MBEDTLS_PATCHES ?= $(sort $(wildcard ../../patches/*.patch))
${MBEDTLS_DIR}/.git:
	git submodule update --init ${@D}

$(MBEDTLS_PATCH_FILE): ${MBEDTLS_DIR}/.git ${MBEDTLS_PATCHES}
427 428
	if [ -d ${MBEDTLS_DIR} ]; then \
	cd ${MBEDTLS_DIR} && \
429 430
	git clean -fdx . && \
	git reset --hard && \
431 432 433 434 435 436
	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}
437 438
endif

Kishen Maloor's avatar
Kishen Maloor committed
439
clean:
440
	rm -rf obj $(PC) $(CONSTRAINED_LIBS) $(API_TEST_OBJ_FILES) $(SECURITY_TEST_OBJ_FILES) $(PLATFORM_TEST_OBJ_FILES) $(MESSAGING_TEST_OBJ_FILES) $(UNIT_TESTS) $(STORAGE_TEST_DIR) $(CLOUD_TEST_OBJ_FILES) $(RD_CLIENT_TEST_OBJ_FILES)
Philippe Coval's avatar
Philippe Coval committed
441 442

cleanall: clean
443
	rm -rf ${all} $(SAMPLES) $(TESTS) ${OBT} ${SAMPLES_CREDS} $(MBEDTLS_PATCH_FILE)
444
	${MAKE} -C ${GTEST_DIR}/make clean
445

Philippe Coval's avatar
Philippe Coval committed
446 447
distclean: cleanall

448 449 450 451
install: $(SAMPLES) $(PC) $(CONSTRAINED_LIBS)
	$(INSTALL) -d $(bindir)
	$(INSTALL) -d $(libdir)
	$(INSTALL) -d $(includedir)/iotivity-constrained
452 453 454 455 456
	$(INSTALL) -d $(includedir)/iotivity-constrained/port
	$(INSTALL) -d $(includedir)/iotivity-constrained/util
	$(INSTALL) -d $(includedir)/iotivity-constrained/util/pt
	$(INSTALL) -d $(includedir)/iotivity-constrained/messaging/coap
	$(INSTALL) -d $(includedir)/iotivity-constrained/deps/tinycbor/src/
457 458
	$(INSTALL) -d $(pkgconfigdir)
	$(INSTALL) -m 644 $(HEADERS) $(includedir)/iotivity-constrained/
459 460 461 462 463
	$(INSTALL) -m 644 $(HEADERS_PORT) $(includedir)/iotivity-constrained/port
	$(INSTALL) -m 644 $(HEADERS_UTIL) $(includedir)/iotivity-constrained/util
	$(INSTALL) -m 644 $(HEADERS_UTIL_PT) $(includedir)/iotivity-constrained/util/pt
	$(INSTALL) -m 644 $(HEADERS_COAP) $(includedir)/iotivity-constrained/messaging/coap
	$(INSTALL) -m 644 $(HEADERS_TINYCBOR) $(includedir)/iotivity-constrained/deps/tinycbor/src
464 465 466 467 468
	$(INSTALL) -m 644 $(PC) $(pkgconfigdir)
	$(INSTALL) -m 644 $(CONSTRAINED_LIBS) $(libdir)
# Installing the samples
	$(INSTALL) -d ${install_bin_dir}
	$(INSTALL) $(SAMPLES) ${install_bin_dir}
469 470 471

############# TESTS ##########################
TESTS = \
472
	tests/client_init_linux_test \
473
	tests/server_init_linux_test \
474 475
	tests/client_get_linux_test

476 477 478 479 480 481
tests/client_init_linux_test: libiotivity-constrained-client.a
	@mkdir -p $(@D)
	$(CC) -o $@ ../../tests/client_init_linux.c \
		libiotivity-constrained-client.a \
		-DOC_CLIENT $(CFLAGS) $(LIBS)

482 483 484 485 486 487
tests/server_init_linux_test: libiotivity-constrained-server.a
	@mkdir -p $(@D)
	$(CC) -o $@ ../../tests/server_init_linux.c \
		libiotivity-constrained-server.a \
		-DOC_SERVER $(CFLAGS) $(LIBS)

488 489 490 491 492 493 494 495
tests/client_get_linux_test: libiotivity-constrained-client-server.a
	@mkdir -p $(@D)
	$(CC) -o $@ ../../tests/client_get_linux.c \
		libiotivity-constrained-client-server.a -DOC_SERVER \
		-DOC_CLIENT $(CFLAGS) $(LIBS)

check: $(TESTS)
	$(Q)$(PYTHON) $(CHECK_SCRIPT) --tests="$(TESTS)"