Makefile 18.5 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)
11 12 13 14 15 16 17 18 19

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
20
EXTRA_CFLAGS =
Kishen Maloor's avatar
Kishen Maloor committed
21

22 23 24 25 26
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
27
TEST_CXXFLAGS += -g -Wall -Wextra -pthread -std=c++0x -fpermissive -DOC_SERVER -DOC_CLIENT -fprofile-arcs -ftest-coverage
28 29 30 31 32
HEADER_DIR = $(ROOT_DIR)/include
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))
33 34 35 36 37
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))
UNIT_TESTS = apitest platformtest
38

Jaehong Jo's avatar
Jaehong Jo committed
39
DTLS_TAG ?= mbedtls-2.7.0
40 41
DTLS= 	aes.c		aesni.c 	asn1parse.c	asn1write.c	base64.c	\
	bignum.c	ccm.c		cipher.c	cipher_wrap.c	\
Kishen Maloor's avatar
Kishen Maloor committed
42 43 44 45 46
	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	\
47
	pkwrite.c	platform.c	ripemd160.c	sha1.c		sha256.c	\
Kishen Maloor's avatar
Kishen Maloor committed
48 49 50
	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			\
51
	ssl_srv.c	ssl_ticket.c	ssl_tls.c
52

Kush's avatar
Kush committed
53
ifneq ($(CODE_SIZE_OPT),1)
54
DTLS += arc4.c blowfish.c camellia.c rsa.c rsa_internal.c
55
endif
Kishen Maloor's avatar
Kishen Maloor committed
56 57 58
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
59
MBEDTLS_DIR := ../../deps/mbedtls
Kishen Maloor's avatar
Kishen Maloor committed
60

Otavio Pontes's avatar
Otavio Pontes committed
61 62
SRC_COMMON=$(wildcard ../../util/*.c) ${CBOR}
SRC=$(wildcard ../../messaging/coap/*.c ../../api/*.c ../../port/linux/*.c)
63 64
SRC_CA=$(wildcard ../../service/cloud-access/src/*.c)
SRC_RD_CLIENT=$(wildcard ../../service/resource-directory/client/src/*.c)
Kishen Maloor's avatar
Kishen Maloor committed
65

Kush's avatar
Kush committed
66 67 68 69
ifeq ($(CODE_SIZE_OPT),1)
SRC +=../../port/oc_log.c
endif

70
HEADERS = $(wildcard ../../include/*.h)
71 72 73 74 75 76 77
HEADERS += ../../port/linux/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)
78

79
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../ -I../../ -I../../include/ -std=gnu99 -Wall -Wextra #-Wl,-Map,client.map
80 81
CFLAGS_CA=-I../../service/cloud-access/include
CFLAGS_RD_CLIENT=-I../../service/resource-directory/client/include
Otavio Pontes's avatar
Otavio Pontes committed
82 83
OBJ_COMMON=$(addprefix obj/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix obj/client/,$(notdir $(SRC:.c=.o)))
84
OBJ_SERVER=$(addprefix obj/server/,$(filter-out oc_obt.o,$(notdir $(SRC:.c=.o))))
85
OBJ_CLIENT_SERVER=$(addprefix obj/client_server/,$(notdir $(SRC:.c=.o)))
86 87
OBJ_CA=$(addprefix obj/ca/,$(notdir $(SRC_CA:.c=.o)))
OBJ_RD_CLIENT=$(addprefix obj/rd_client/,$(notdir $(SRC_RD_CLIENT:.c=.o)))
88
VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../../deps/mbedtls/library:../../service/easy-setup/enrollee/:../../service/easy-setup/enrollee/samsung/:../../service/cloud-access/src/:../../service/resource-directory/client/src/:../../port/:../../service/st-app-fw/src/:../../service/st-app-fw/src/port/linux:
Philippe Coval's avatar
Philippe Coval committed
89
LIBS?= -lm -pthread -lrt
Kishen Maloor's avatar
Kishen Maloor committed
90

91
SAMPLES = server simpleserver \
Kush's avatar
Kush committed
92
	  server_collections_linux smart_home_server_linux multi_device_server
93

Kush's avatar
Kush committed
94 95
ifneq ($(CODE_SIZE_OPT),1)
SAMPLES += server_block_linux client simpleclient temp_sensor cloud_linux client_collections_linux client_block_linux multi_device_client smart_lock client_multithread_linux server_multithread_linux
96
endif
Kishen Maloor's avatar
Kishen Maloor committed
97

Abhishek Pandey's avatar
Abhishek Pandey committed
98
ifeq ($(EASYSETUP),1)
99
SAMPLES += easysetup_linux sc_easysetup_linux
100 101 102 103 104 105
endif

ifeq ($(ST_APP_FW),1)
ifneq ($(EASYSETUP),1)
$(error To use ST_APP_FW you should include EASYSETUP flag also.)
endif
106
SAMPLES += st_things
Abhishek Pandey's avatar
Abhishek Pandey committed
107 108
endif

109
ifeq ($(SECURE),1)
110
ifneq ($(AUTH_OPTION),0)
111
SAMPLES += mfgserver
Oleksii Beketov's avatar
MFG OTM  
Oleksii Beketov committed
112
CFLAGS += -DOC_MFG
Aleksey's avatar
Aleksey committed
113
CFLAGS += -DOC_LOAD_CA
114 115 116 117 118
ifeq ($(AUTH_OPTION),1)
CFLAGS += -DOC_UNLOAD_CERT
endif
else
CFLAGS += -DOC_SKIP_CERT
Oleksii Beketov's avatar
MFG OTM  
Oleksii Beketov committed
119
endif
120
endif
Abhishek Pandey's avatar
Abhishek Pandey committed
121

122 123
OBT = onboarding_tool

Abhishek Pandey's avatar
Abhishek Pandey committed
124
ifeq ($(EASYSETUP),1)
125 126
	SRC_ES=$(wildcard ../../service/easy-setup/enrollee/*.c ../../service/easy-setup/enrollee/samsung/*.c)
	CFLAGS_ES=-I../../service/easy-setup/enrollee/include -I../../service/easy-setup/enrollee/ -I../../port -I../../service/easy-setup/enrollee/include/samsung/
Abhishek Pandey's avatar
Abhishek Pandey committed
127 128 129 130
	CFLAGS_ES+= -DEASYSETUP
	OBJ_ES=$(addprefix obj/es/,$(notdir $(SRC_ES:.c=.o)))
endif

131 132 133 134 135 136 137
ifeq ($(ST_APP_FW),1)
	SRC_ST=$(wildcard ../../service/st-app-fw/src/*.c ../../service/st-app-fw/src/port/linux/*.c)
	CFLAGS_ST=-I../../service/st-app-fw/include
	CFLAGS_ST+= -DST_APP_FW
	OBJ_ST=$(addprefix obj/st/,$(notdir $(SRC_ST:.c=.o)))
endif

Kishen Maloor's avatar
Kishen Maloor committed
138
ifeq ($(DEBUG),1)
139
	CFLAGS += -DOC_DEBUG -g -O0
140 141
else
	CFLAGS += -Wl,--gc-sections
Kishen Maloor's avatar
Kishen Maloor committed
142 143
endif

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

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

163
ifneq ($(IPV4),0)
Inho Oh's avatar
Inho Oh committed
164
	EXTRA_CFLAGS += -DOC_IPV4
Flavio Ceolin's avatar
Flavio Ceolin committed
165 166
endif

167
ifneq ($(TCP),0)
Inho Oh's avatar
Inho Oh committed
168
	EXTRA_CFLAGS += -DOC_TCP
Jaehyun Cho's avatar
Jaehyun Cho committed
169 170
endif

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

173 174
ifeq ($(MEMTRACE),1)
	CFLAGS += -DOC_MEMORY_TRACE
Jaehyun Cho's avatar
Jaehyun Cho committed
175 176
endif

Harry's avatar
Harry committed
177
ifneq ($(OIC),0)
178 179 180
    CFLAGS += -DOC_SPEC_VER_OIC
endif

Kush's avatar
Kush committed
181
ifeq ($(CODE_SIZE_OPT),1)
182
	CFLAGS += -DST_APP_OPTIMIZATION
Kush's avatar
Kush committed
183 184 185 186 187
	CFLAGS += -DST_MBEDTLS_OPT
	CFLAGS += -DST_OC_CLIENT_OPT
	CFLAGS += -DST_OC_INTROSPECTION_OPT
	CFLAGS += -DST_OC_PERIODIC_OPT
	CFLAGS += -DST_OC_CON_RES_OPT
188 189
endif

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

192
CONSTRAINED_LIBS = libiotivity-constrained-server.a libiotivity-constrained-client.a \
193
		   libiotivity-constrained-server.so libiotivity-constrained-client.so \
194 195 196
		   libiotivity-constrained-client-server.a libiotivity-constrained-client-server.so \
           libiotivity-constrained-easysetup.a \
		   libiotivity-constrained-cloudaccess.a libiotivity-constrained-cloudaccess.so \
197 198
		   libiotivity-constrained-rd-client.a libiotivity-constrained-rd-client.so \
		   libst-app-framework.a libst-app-framework.so
199

200 201
PC = iotivity-constrained-client.pc iotivity-constrained-server.pc \
     iotivity-constrained-client-server.pc
Otavio Pontes's avatar
Otavio Pontes committed
202

203
all: $(CONSTRAINED_LIBS) $(SAMPLES) $(PC)
Kishen Maloor's avatar
Kishen Maloor committed
204

205 206
test: $(UNIT_TESTS)
	for test in $^ ; do ./$${test} ; done
207

208 209 210 211 212 213 214 215 216 217 218
.PHONY: test clean

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

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

apitest: $(API_TEST_OBJ_FILES) libiotivity-constrained-client-server.a | $(GTEST)
	$(CXX) $(GTEST_CPPFLAGS) $(TEST_CXXFLAGS)  -I$(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
219

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

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

Jaehong Jo's avatar
Jaehong Jo committed
227
${SRC} ${SRC_COMMON}: $(MBEDTLS_PATCH_FILE)
228

Abhishek Pandey's avatar
Abhishek Pandey committed
229 230 231 232 233
obj/es/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} ${CFLAGS_ES} -DOC_SERVER


Kishen Maloor's avatar
Kishen Maloor committed
234
obj/%.o: %.c
Philippe Coval's avatar
Philippe Coval committed
235
	@mkdir -p ${@D}
Kishen Maloor's avatar
Kishen Maloor committed
236
	${CC} -c -o $@ $< ${CFLAGS}
Otavio Pontes's avatar
Otavio Pontes committed
237 238

obj/server/%.o: %.c
Philippe Coval's avatar
Philippe Coval committed
239
	@mkdir -p ${@D}
Otavio Pontes's avatar
Otavio Pontes committed
240 241 242
	${CC} -c -o $@ $< ${CFLAGS} -DOC_SERVER

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

246 247 248 249
obj/client_server/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER

250 251 252 253 254 255 256 257
obj/ca/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} ${CFLAGS_CA}

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

258 259 260 261
obj/st/%.o: %.c
	@mkdir -p ${@D}
	${CC} -c -o $@ $< ${CFLAGS} ${CFLAGS_ES} ${CFLAGS_CA} ${CFLAGS_RD_CLIENT} ${CFLAGS_ST} -DOC_CLIENT -DOC_SERVER

262 263 264 265 266
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
267

268 269
libiotivity-constrained-client.a: $(OBJ_COMMON) $(OBJ_CLIENT)
	$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT)
Otavio Pontes's avatar
Otavio Pontes committed
270

271 272
libiotivity-constrained-client.so: $(OBJ_COMMON) $(OBJ_CLIENT)
	$(CC) -shared -o $@ $(OBJ_COMMON) $(OBJ_CLIENT) $(LIBS)
Kishen Maloor's avatar
Kishen Maloor committed
273

274 275 276 277 278 279
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)

Abhishek Pandey's avatar
Abhishek Pandey committed
280 281 282
libiotivity-constrained-easysetup.a: $(OBJ_ES) libiotivity-constrained-server.a
	$(AR) -rcs $@ $(OBJ_ES)

283 284 285 286 287 288 289 290 291 292 293 294
libiotivity-constrained-cloudaccess.a: $(OBJ_CA)
	$(AR) -rcs $@ $(OBJ_CA)

libiotivity-constrained-cloudaccess.so: $(OBJ_CA)
	$(CC) -shared -o $@ $(OBJ_CA) $(LIBS)

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

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

295 296 297 298 299 300
libst-app-framework.a: $(OBJ_ST) $(OBJ_ES) $(OBJ_CA) $(OBJ_RD_CLIENT) $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
	$(AR) -rcs $@  $(OBJ_ST) $(OBJ_ES) $(OBJ_CA) $(OBJ_RD_CLIENT) $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)

libst-app-framework.so: $(OBJ_ST) $(OBJ_ES) $(OBJ_CA) $(OBJ_RD_CLIENT) $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
	$(CC) -shared -o $@ $(OBJ_ST) $(OBJ_ES) $(OBJ_CA) $(OBJ_RD_CLIENT) $(OBJ_COMMON) $(OBJ_CLIENT_SERVER) $(LIBS)

301
server: libiotivity-constrained-server.a
Kishen Maloor's avatar
Kishen Maloor committed
302
	@mkdir -p $@_creds
303
	${CC} -o $@ ../../apps/server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
304

305
client: libiotivity-constrained-client.a
Kishen Maloor's avatar
Kishen Maloor committed
306
	@mkdir -p $@_creds
307
	${CC} -o $@ ../../apps/client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
308

309 310 311 312
smart_lock: libiotivity-constrained-client.a
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/smart_lock_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}

313
temp_sensor: libiotivity-constrained-client.a
Kishen Maloor's avatar
Kishen Maloor committed
314
	@mkdir -p $@_creds
315
	${CC} -o $@ ../../apps/temp_sensor_client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS} ${LIBS}
316

317
simpleserver: libiotivity-constrained-server.a
Kishen Maloor's avatar
Kishen Maloor committed
318
	@mkdir -p $@_creds
319
	${CC} -o $@ ../../apps/simpleserver.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS}  ${LIBS}
320

321
simpleclient: libiotivity-constrained-client.a
Kishen Maloor's avatar
Kishen Maloor committed
322
	@mkdir -p $@_creds
323
	${CC} -o $@ ../../apps/simpleclient.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}
324

ol.beketov's avatar
MFG OTM  
ol.beketov committed
325 326 327 328 329
mfgserver: libiotivity-constrained-server.a
	@mkdir -p $@_creds
	@cp ../../apps/mfgserver_cred $@_creds/cred_0
	${CC} -o $@ ../../apps/mfgserver.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS}  ${LIBS}

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

server_collections_linux: libiotivity-constrained-server.a
Kishen Maloor's avatar
Kishen Maloor committed
335
	@mkdir -p $@_creds
336 337 338 339 340 341 342 343
	${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}

344
smart_home_server_linux: libiotivity-constrained-server.a
Kishen Maloor's avatar
Kishen Maloor committed
345
	@mkdir -p $@_creds
346 347
	${CC} -o $@ ../../apps/smart_home_server_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}

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

multi_device_client: libiotivity-constrained-client.a
Kishen Maloor's avatar
Kishen Maloor committed
353
	@mkdir -p $@_creds
354 355
	${CC} -o $@ ../../apps/multi_device_client_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

Abhishek Pandey's avatar
Abhishek Pandey committed
356 357 358 359
easysetup_linux: libiotivity-constrained-client-server.a libiotivity-constrained-easysetup.a
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/easysetup_linux.c libiotivity-constrained-server.a libiotivity-constrained-easysetup.a -DOC_SERVER ${CFLAGS} ${CFLAGS_ES} ${LIBS}	

360 361 362 363
sc_easysetup_linux: libiotivity-constrained-client-server.a libiotivity-constrained-easysetup.a
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/sc_easysetup_linux.c libiotivity-constrained-server.a libiotivity-constrained-easysetup.a -DOC_SERVER ${CFLAGS} ${CFLAGS_ES} ${LIBS}	

364 365 366 367
${OBT}: libiotivity-constrained-client.a
	@mkdir -p $@_creds
	${CC} -o $@ ../../onboarding_tool/obtmain.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

Jaehong Jo's avatar
Jaehong Jo committed
368
cloud_linux: libiotivity-constrained-client-server.a libiotivity-constrained-cloudaccess.a libiotivity-constrained-rd-client.a
369 370 371
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/cloud_linux.c libiotivity-constrained-client-server.a libiotivity-constrained-cloudaccess.a libiotivity-constrained-rd-client.a -DOC_CLIENT -DOC_SERVER ${CFLAGS} ${CFLAGS_CA} ${CFLAGS_RD_CLIENT} ${LIBS}

Jaehyun Cho's avatar
Jaehyun Cho committed
372 373 374
server_multithread_linux: libiotivity-constrained-server.a
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/server_multithread_linux.c libiotivity-constrained-server.a -DOC_SERVER ${CFLAGS} ${LIBS}
375

Jaehyun Cho's avatar
Jaehyun Cho committed
376 377 378 379
client_multithread_linux: libiotivity-constrained-client.a
	@mkdir -p $@_creds
	${CC} -o $@ ../../apps/client_multithread_linux.c libiotivity-constrained-client.a -DOC_CLIENT ${CFLAGS}  ${LIBS}

380
st_things: libst-app-framework.a
381
	@mkdir -p $@_creds
382 383
	${CC} -o $@ ../../apps/st_app/linux/st_ref_app.c  \
			libst-app-framework.a -DOC_CLIENT -DOC_SERVER ${CFLAGS} ${CFLAGS_ST} ${LIBS}
384

385 386 387 388 389
iotivity-constrained-server.pc: iotivity-constrained-server.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.pc: iotivity-constrained-client.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
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),' \
408
		-e 's,@includedir@,$(includedir),' \
Inho Oh's avatar
Inho Oh committed
409 410
		-e 's,@version@,$(VERSION),' \
		-e 's,@extra_cflags@,$(EXTRA_CFLAGS),'
411

Jaehong Jo's avatar
Jaehong Jo committed
412
ifneq ($(SECURE),0)
Jaehong Jo's avatar
Jaehong Jo committed
413
MBEDTLS_PATCHES ?= $(sort $(wildcard ../../patches/*.patch))
414 415 416
ifeq ($(AUTH_OPTION),0)
MBEDTLS_PATCHES += $(sort $(wildcard ../../patches/*.off))
endif
Jaehong Jo's avatar
Jaehong Jo committed
417 418 419 420
${MBEDTLS_DIR}/.git:
	git submodule update --init ${@D}

$(MBEDTLS_PATCH_FILE): ${MBEDTLS_DIR}/.git ${MBEDTLS_PATCHES}
421 422
	if [ -d ${MBEDTLS_DIR} ]; then \
	cd ${MBEDTLS_DIR} && \
423 424
	git clean -fdx . && \
	git reset --hard && \
ol.beketov's avatar
MFG OTM  
ol.beketov committed
425 426
	git fetch && \
	git reset --hard ${DTLS_TAG} && \
427 428 429 430 431 432
	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}
433 434
endif

Kishen Maloor's avatar
Kishen Maloor committed
435
clean:
436
	rm -rf obj $(PC) $(CONSTRAINED_LIBS) $(API_TEST_OBJ_FILES) $(PLATFORM_TEST_OBJ_FILES) $(UNIT_TESTS)
Philippe Coval's avatar
Philippe Coval committed
437 438

cleanall: clean
439
	rm -rf ${all} $(SAMPLES) $(TESTS) ${OBT} ${SAMPLES_CREDS} $(MBEDTLS_PATCH_FILE)
440
	${MAKE} -C ${GTEST_DIR}/make clean
441

Philippe Coval's avatar
Philippe Coval committed
442 443
distclean: cleanall

444 445 446 447
install: $(SAMPLES) $(PC) $(CONSTRAINED_LIBS)
	$(INSTALL) -d $(bindir)
	$(INSTALL) -d $(libdir)
	$(INSTALL) -d $(includedir)/iotivity-constrained
448 449 450 451 452
	$(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/
453 454
	$(INSTALL) -d $(pkgconfigdir)
	$(INSTALL) -m 644 $(HEADERS) $(includedir)/iotivity-constrained/
455 456 457 458 459
	$(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
460 461 462 463 464
	$(INSTALL) -m 644 $(PC) $(pkgconfigdir)
	$(INSTALL) -m 644 $(CONSTRAINED_LIBS) $(libdir)
# Installing the samples
	$(INSTALL) -d ${install_bin_dir}
	$(INSTALL) $(SAMPLES) ${install_bin_dir}
465 466 467

############# TESTS ##########################
TESTS = \
468
	tests/client_init_linux_test \
469
	tests/server_init_linux_test \
470 471
	tests/client_get_linux_test

472 473 474 475 476 477
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)

478 479 480 481 482 483
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)

484 485 486 487 488 489 490 491
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)"