1 # //******************************************************************
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # // Licensed under the Apache License, Version 2.0 (the "License");
8 # // you may not use this file except in compliance with the License.
9 # // You may obtain a copy of the License at
11 # // http://www.apache.org/licenses/LICENSE-2.0
13 # // Unless required by applicable law or agreed to in writing, software
14 # // distributed under the License is distributed on an "AS IS" BASIS,
15 # // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # // See the License for the specific language governing permissions and
17 # // limitations under the License.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 # override with `make BUILD=release`
24 # default to release build
27 #other options are android, arduino
31 OCSOCK_DIR = $(ROOT_DIR)/ocsocket
32 OCSTACK_DIR = $(ROOT_DIR)/stack
33 LOGGER_DIR = $(ROOT_DIR)/logger
34 OC_LOG_DIR = $(ROOT_DIR)/../oc_logger
35 RANDOM_DIR = $(ROOT_DIR)/ocrandom
39 INC_DIRS := -I$(OCSTACK_DIR)/include
40 INC_DIRS += -I$(OCSOCK_DIR)/include
41 INC_DIRS += -I$(LOGGER_DIR)/include
42 INC_DIRS += -I$(OC_LOG_DIR)/include
43 INC_DIRS += -I$(RANDOM_DIR)/include
45 ifeq ($(PLATFORM),android)
46 CXX=arm-linux-androideabi-g++
47 CC=arm-linux-androideabi-gcc
48 AR=arm-linux-androideabi-ar
49 RANLIB=arm-linux-androideabi-ranlib
50 CFLAGS_ANDROID = -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
51 LDFLAGS_ANDROID = -march=armv7-a -Wl,--fix-cortex-a8 -llog
52 else ifeq ($(PLATFORM),linux)
58 $(error Wrong value for PLATFORM !!)
61 DEP_LIBS = $(ROOT_DIR)/linux/$(BUILD)/liboctbstack.a
63 CFLAGS += -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions \
64 -Wextra -Wno-variadic-macros -pedantic -std=gnu99 -DWITH_POSIX -DTB_LOG
66 PROGRAMS = ocserver occlient
68 SOURCES:= occlient.c ocserver.c
70 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
72 all: objdirs $(PROGRAMS)
75 $(CC) -c $(CFLAGS) $(CFLAGS_ANDROID) $(INC_DIRS) $< -o $(BUILD)/$@
80 ##Added -lm as needed by json calling floor()
81 occlient: occlient.o $(DEP_LIBS)
82 $(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $(BUILD)/$^ -o $(BUILD)/$@ -lm
84 ocserver: ocserver.o $(DEP_LIBS)
85 $(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $(BUILD)/$^ -o $(BUILD)/$@ -lm
88 @echo "Installing for PLATFORM $(PLATFORM)"
89 ifeq ($(PLATFORM),android)
90 adb push coap-client /data/local/tmp/
91 adb push coap-server /data/local/tmp/