Repo Merge: Moving resource API down a directory
[platform/upstream/iotivity.git] / resource / csdk / libcoap-4.1.1 / examples / makefile
1 # //******************************************************************
2 # //
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 # //
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 # //
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
10 # //
11 # //      http://www.apache.org/licenses/LICENSE-2.0
12 # //
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.
18 # //
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #
21 VERSION:=4.1.1
22
23 #other options are android, arduino
24 PLATFORM=linux
25
26 ROOT_DIR = ../..
27 OCSOCK_DIR = $(ROOT_DIR)/ocsocket
28 LOGGER_DIR = $(ROOT_DIR)/logger
29 RANDOM_DIR = $(ROOT_DIR)/ocrandom
30 OBJ_DIR = ./
31 INC_DIRS = -I.. -I$(OCSOCK_DIR)/include/ -I$(LOGGER_DIR)/include -I$(RANDOM_DIR)/include
32
33 ifeq ($(PLATFORM),android)
34     CXX=arm-linux-androideabi-g++
35     CC=arm-linux-androideabi-gcc
36     AR=arm-linux-androideabi-ar
37     RANLIB=arm-linux-androideabi-ranlib
38     CFLAGS_ANDROID =  -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
39     LDFLAGS_ANDROID = -march=armv7-a -Wl,--fix-cortex-a8 -llog
40 else ifeq ($(PLATFORM),linux)
41     CXX=g++
42     CC=gcc
43     AR=ar
44     RANLIB=ranlib
45 else
46    $(error Wrong value for PLATFORM !!)
47 endif
48
49 DEP_LIBS = ../libcoap.a
50
51 CFLAGS += -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions \
52     -Wextra -Wno-variadic-macros -pedantic -std=gnu99 -DWITH_POSIX
53
54 PROGRAMS = coap-server coap-client
55
56 SOURCES:= client.c server.c
57
58 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
59
60 all: $(PROGRAMS)
61
62 %.o: %.c
63         $(CC) -c $(CFLAGS) $(CFLAGS_ANDROID) $(INC_DIRS) $< -o $@
64
65 coap-client: client.o $(DEP_LIBS)
66         $(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $^ -o $@
67
68 coap-server: server.o $(DEP_LIBS)
69         $(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $^ -o $@
70
71 install: all
72         @echo "Installing for PLATFORM $(PLATFORM)"
73 ifeq ($(PLATFORM),android)
74         adb push coap-client /data/local/tmp/
75         adb push coap-server /data/local/tmp/
76 endif
77
78 .PHONY: clean
79
80 clean:
81         rm -f *.o $(PROGRAMS)
82