summaryrefslogtreecommitdiff
path: root/resource/csdk/stack/test/linux/makefile
blob: 43ebff71a54187c041580a99b8c0e906020c2000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# //******************************************************************
# //
# // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
# //
# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# //
# // Licensed under the Apache License, Version 2.0 (the "License");
# // you may not use this file except in compliance with the License.
# // You may obtain a copy of the License at
# //
# //      http://www.apache.org/licenses/LICENSE-2.0
# //
# // Unless required by applicable law or agreed to in writing, software
# // distributed under the License is distributed on an "AS IS" BASIS,
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# // See the License for the specific language governing permissions and
# // limitations under the License.
# //
# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
VERSION:=4.1.1

# override with `make BUILD=release`
# default to release build
BUILD	 := release

#other options are android, arduino
PLATFORM=linux

ROOT_DIR = ../../..
OCSOCK_DIR = $(ROOT_DIR)/ocsocket
OCSTACK_DIR = $(ROOT_DIR)/stack
LOGGER_DIR = $(ROOT_DIR)/logger
OC_LOG_DIR = $(ROOT_DIR)/../oc_logger
RANDOM_DIR = $(ROOT_DIR)/ocrandom

OBJ_DIR = ./

INC_DIRS := -I$(OCSTACK_DIR)/include
INC_DIRS += -I$(OCSOCK_DIR)/include
INC_DIRS += -I$(LOGGER_DIR)/include
INC_DIRS += -I$(OC_LOG_DIR)/include
INC_DIRS += -I$(RANDOM_DIR)/include

ifeq ($(PLATFORM),android)
	CXX=arm-linux-androideabi-g++
	CC=arm-linux-androideabi-gcc
	AR=arm-linux-androideabi-ar
	RANLIB=arm-linux-androideabi-ranlib
	CFLAGS_ANDROID =  -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
	LDFLAGS_ANDROID = -march=armv7-a -Wl,--fix-cortex-a8 -llog
else ifeq ($(PLATFORM),linux)
	CXX=g++
	CC=gcc
	AR=ar
	RANLIB=ranlib
else
   $(error Wrong value for PLATFORM !!)
endif

DEP_LIBS = $(ROOT_DIR)/linux/$(BUILD)/liboctbstack.a

CFLAGS += -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions \
	-Wextra -Wno-variadic-macros -pedantic -std=gnu99 -DWITH_POSIX -DTB_LOG

PROGRAMS = ocserver occlient

SOURCES:= occlient.c ocserver.c

OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))

all: objdirs $(PROGRAMS)

%.o: %.c
	$(CC) -c $(CFLAGS) $(CFLAGS_ANDROID) $(INC_DIRS) $< -o $(BUILD)/$@

objdirs: $(ROOT_DIR)
	mkdir -p $(BUILD)
	
##Added -lm as needed by json calling floor()
occlient: occlient.o $(DEP_LIBS)
	$(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $(BUILD)/$^ -o $(BUILD)/$@ -lm

ocserver: ocserver.o $(DEP_LIBS)
	$(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $(BUILD)/$^ -o $(BUILD)/$@ -lm

install: all
	@echo "Installing for PLATFORM $(PLATFORM)"
ifeq ($(PLATFORM),android)
	adb push coap-client /data/local/tmp/
	adb push coap-server /data/local/tmp/
endif

.PHONY: clean

clean:
	rm -rf debug
	rm -rf release