build: install headers in iotivity namespace
authorPhilippe Coval <philippe.coval@open.eurogiciel.org>
Tue, 27 Jan 2015 17:01:19 +0000 (18:01 +0100)
committerPhilippe Coval <philippe.coval@osg.samsung.com>
Mon, 11 Jan 2016 11:11:38 +0000 (12:11 +0100)
Note, project name is used as namespace instead of iot or oic

Since it's unclear to me what is part of the standardized API
and what is just shared features...

Change-Id: I04c4be1661435f1c208b0dd7a55a4d34176a3e30
Forwarded: https://gerrit.iotivity.org/gerrit/#/c/261/
Signed-off-by: Philippe Coval <philippe.coval@open.eurogiciel.org>
resource/csdk/makefile [new file with mode: 0644]
resource/oc_logger/Makefile [new file with mode: 0644]

diff --git a/resource/csdk/makefile b/resource/csdk/makefile
new file mode 100644 (file)
index 0000000..8395d3f
--- /dev/null
@@ -0,0 +1,223 @@
+# //******************************************************************
+# //
+# // 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.
+# //
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# override with `make BUILD=debug`
+# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
+# default to release build
+# default to build for linux
+BUILD   := release
+PLATFORM := linux
+
+# override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
+ARDUINOWIFI := 0
+
+ifeq ($(ROOT_DIR), )
+ROOT_DIR       = ./
+endif
+
+PLATFORM_TYPE = linux
+
+ifeq ($(PLATFORM),linux)
+    CXX=g++
+    CC=gcc
+    AR=ar
+    RANLIB=ranlib
+    CFLAGS_PLATFORM = -DWITH_POSIX -std=c99
+    PLATFORM_TYPE=linux
+else ifeq ($(PLATFORM),arduinomega)
+    include local.properties
+    include $(PLATFORM).properties
+    CC=$(ARDUINO_TOOLS_DIR)/avr-g++
+    ifeq ($(wildcard $(ARDUINO_DIR)/libraries/Time/Time/),)
+        $(error Arduino Time library needs to be moved from <ARDUINO_DIR>/libraries/Time \
+        to <ARDUINO_DIR>/libraries/Time/Time. You may need to create \
+        <ARDUINO_DIR>/libraries/Time/Time directory. Please refer to the wiki or readme \
+        for more information)
+    endif
+    PLATFORM_TYPE=arduino
+else ifeq ($(PLATFORM),arduinodue)
+    include local.properties
+    include $(PLATFORM).properties
+    CC=$(ARDUINO_TOOLS_DIR)/arm-none-eabi-g++
+    PLATFORM_TYPE=arduino
+else
+    $(error Wrong value for PLATFORM !!)
+endif
+
+ifeq ($(PLATFORM_TYPE),arduino)
+    ifeq ($(ARDUINOWIFI),0)
+    ARDUINO_SHIELD_TYPE := "/ethernet_shield"
+    else ifeq ($(ARDUINOWIFI), 1)
+    ARDUINO_SHIELD_TYPE := "/wifi_shield"
+    endif
+    PLATFORM_SPECIFIC_BACKOUT:= ../../../../
+else
+    PLATFORM_SPECIFIC_BACKOUT := ../../../
+endif
+
+ifeq ($(OUT_DIR), )
+OUT_DIR        = $(PLATFORM)$(ARDUINO_SHIELD_TYPE)/$(BUILD)
+endif
+
+ifeq ($(OBJ_DIR), )
+OBJ_DIR        = $(OUT_DIR)/obj
+endif
+
+OCLOGGER_DIR   = logger
+OC_LOG_DIR      = ../oc_logger
+OCRANDOM_DIR   = ocrandom
+OCSOCKET_DIR   = ocsocket
+LCOAP_DIR      = libcoap-4.1.1
+OCCOAP_DIR     = occoap
+OCTBSTACK_DIR  = stack
+OCMALLOC_DIR   = ocmalloc
+EXTLIBS_DIR    = ../../extlibs
+CJSON_DIR      = $(EXTLIBS_DIR)/cjson
+TINYDTLS_DIR   = $(EXTLIBS_DIR)/tinydtls
+
+OCCOAP_SRC     = $(OCCOAP_DIR)/src
+OCTBSTACK_SRC  = $(OCTBSTACK_DIR)/src
+OCMALLOC_SRC   = $(OCMALLOC_DIR)/src
+CJSON_SRC      = $(CJSON_DIR)
+
+OCLOGGER_INC   = $(OCLOGGER_DIR)/include
+OC_LOG_INC     = $(OC_LOG_DIR)/include
+OCRANDOM_INC   = $(OCRANDOM_DIR)/include
+OCSOCKET_INC   = $(OCSOCKET_DIR)/include
+LCOAP_INC      = $(LCOAP_DIR)
+OCCOAP_INC     = $(OCCOAP_DIR)/include
+OCTBSTACK_INC  = $(OCTBSTACK_DIR)/include
+OCMALLOC_INC   = $(OCMALLOC_DIR)/include
+CJSON_INC      = $(CJSON_DIR)
+
+INC_DIRS       := -I$(OCLOGGER_INC)
+INC_DIRS       += -I$(OC_LOG_INC)
+INC_DIRS       += -I$(OCRANDOM_INC)
+INC_DIRS       += -I$(OCSOCKET_INC)
+INC_DIRS       += -I$(LCOAP_INC)
+INC_DIRS       += -I$(OCCOAP_INC)
+INC_DIRS       += -I$(OCMALLOC_INC)
+INC_DIRS       += -I$(OCTBSTACK_INC)
+INC_DIRS       += -I$(OCTBSTACK_INC)/internal
+INC_DIRS       += -I$(CJSON_INC)
+
+CC_FLAGS.debug         := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -fpic -DTB_LOG
+CC_FLAGS.release       := -Os -Wall -c -fmessage-length=0 -fpic
+
+CFLAGS         += $(CC_FLAGS.$(BUILD)) $(INC_DIRS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM)
+LDLIBS         += -lcoap
+
+CJSON_SOURCES          := $(CJSON_SRC)/cJSON.c
+
+OCCOAP_SOURCES         := $(OCCOAP_SRC)/occoap.c
+OCCOAP_SOURCES         += $(OCCOAP_SRC)/occoaphelper.c
+
+OCTBSTACK_SOURCES      := $(OCTBSTACK_SRC)/ocstack.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/occlientcb.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/ocresource.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/ocobserve.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/ocserverrequest.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/occollection.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/oicgroup.c
+OCTBSTACK_SOURCES      += $(OCTBSTACK_SRC)/ocsecurity.c
+
+SOURCES                        := $(CJSON_SOURCES)
+SOURCES                        += $(OCCOAP_SOURCES)
+SOURCES                        += $(OCTBSTACK_SOURCES)
+
+NAMESPACE?=iotivity
+
+HEADERS?=$(wildcard \
+       stack/include/*.h* \
+       stack/include/*.h* \
+       ocsocket/include/*.h* \
+       occoap/include/*.h* \
+       logger/include/*.h* \
+       )
+
+
+all:   make_lcoap objdirs obj_build liboctbstack.a
+
+buildScript_all: objdirs obj_build liboctbstack.a
+
+make_lcoap:
+       $(MAKE) -C $(LCOAP_DIR) "BUILD=$(BUILD)" "PLATFORM=$(PLATFORM)" "ARDUINOWIFI=$(ARDUINOWIFI)"
+
+objdirs:
+       mkdir -p $(PLATFORM)
+       mkdir -p $(PLATFORM)/$(ARDUINO_SHIELD_TYPE)
+       mkdir -p $(OUT_DIR)
+       mkdir -p $(OBJ_DIR)
+
+obj_build:
+       @echo "Building $@"
+       # Output all *.o files to $(OUT_DIR)/$(BUILD)/$(OBJ_DIR)
+       $(foreach source,$(SOURCES), $(CC) $(CFLAGS) $(source) -o $(patsubst %.c, %.o, $(patsubst %, $(OBJ_DIR)/%, $(notdir $(source))));)
+
+liboctbstack.a: obj_build
+       @echo "Building $@"
+       # Unpackage libcoap.a to $(OBJ_DIR)/$(BUILD). The output objects from OCStack and OCCoap are already at this location
+       @cd $(OBJ_DIR) && $(AR) -x $(PLATFORM_SPECIFIC_BACKOUT)$(LCOAP_DIR)/$(PLATFORM)$(ARDUINO_SHIELD_TYPE)/$(BUILD)/libcoap.a
+       # Repackage all the objects at this location into a single archive. This is OCStack, OCCoap, and LibCoap (LibCoap contains OCRandom, OCLogger, and OCSocket.).
+       $(AR) -r $(OUT_DIR)/$@ $(OBJ_DIR)/*.o
+
+    ifeq ($(PLATFORM),linux)
+     ifneq ($(wildcard $(TINYDTLS_DIR)/libtinydtls.a),)
+                       $(info "Building liboctbstack with DTLS support")
+                       mkdir -p $(OBJ_DIR)/tinydtls
+                       @cd $(OBJ_DIR)/tinydtls && $(AR) -x ../$(PLATFORM_SPECIFIC_BACKOUT)$(TINYDTLS_DIR)/libtinydtls.a
+                       $(AR) -q $(OUT_DIR)/$@ $(OBJ_DIR)/tinydtls/*.o
+     endif
+    endif
+
+.PHONY: clean print_vars
+
+clean: legacy_clean
+       -rm -rf linux
+       -rm -rf arduinomega
+       -rm -rf arduinodue
+
+deepclean: legacy_deepclean
+       -rm -rf linux
+       -rm -rf arduinomega
+       -rm -rf arduinodue
+
+legacy_clean:
+       @echo "Cleaning all."
+       rm -f $(OBJ_DIR)/$(BUILD)/*.o
+       rm -f $(ROOT_DIR)/$(BUILD)/liboctbstack.a
+       rm -rf $(OBJ_DIR)
+       rm -rf release
+       rm -rf debug
+
+legacy_deepclean:
+       @echo "Deep-Cleaning all."
+       rm -f $(OBJ_DIR)/$(BUILD)/*.o
+       rm -f $(ROOT_DIR)/liboctbstack.a
+       rm -rf $(OBJ_DIR)
+       $(MAKE) clean -C $(LCOAP_DIR)
+       rm -rf release
+       rm -rf debug
+
+install: ${HEADERS}
+       for file in $^ ; do \
+               install -d ${DESTDIR}/usr/include/${NAMESPACE} ;\
+               install $${file} ${DESTDIR}/usr/include/${NAMESPACE}/ ;\
+       done
diff --git a/resource/oc_logger/Makefile b/resource/oc_logger/Makefile
new file mode 100644 (file)
index 0000000..c183fac
--- /dev/null
@@ -0,0 +1,68 @@
+# //******************************************************************
+# //
+# // 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.
+# //
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# override with `make BUILD=debug`
+# default to release build
+BUILD := release
+
+LIB_DIR=./lib/
+BIN_DIR=./bin/
+
+NAMESPACE?=iotivity
+HEADERS?=$(wildcard include/*.h*)
+
+.PHONY: c_lib cpp_lib static_libs examples samples
+
+all: dirs c_lib cpp_lib static_libs examples samples
+
+dirs:
+       -mkdir -p $(LIB_DIR) $(BIN_DIR)
+
+c_lib:
+       cd c && $(MAKE) "BUILD=$(BUILD)"
+
+cpp_lib:
+       cd cpp && $(MAKE) "BUILD=$(BUILD)"
+
+static_libs:
+       ar -cvq $(LIB_DIR)/oc_logger_core.a $(BIN_DIR)/oc_logger.o
+       ar -cvq $(LIB_DIR)/oc_logger.a $(BIN_DIR)/oc_logger.o $(BIN_DIR)/targets/*.o
+
+examples:
+       cd examples && $(MAKE) "BUILD=$(BUILD)"
+
+samples:
+       cd samples/linux && $(MAKE) "BUILD=$(BUILD)"
+
+clean:
+       cd examples && $(MAKE) "clean"
+       cd samples/linux && $(MAKE) "clean"
+       rm -rf $(BIN_DIR)/targets/*.o
+       cd cpp && $(MAKE) clean
+       cd c && $(MAKE) clean
+
+
+install: ${HEADERS}
+       cd include && \
+       find . -iname "*.h*" -type f | while read file ; do \
+       dirname=$$(dirname -- "$${file}" ) ; \
+               install -d ${DESTDIR}/usr/include/${NAMESPACE}/$${dirname} ; \
+               install $${file} ${DESTDIR}/usr/include/${NAMESPACE}/$${dirname}/ ; \
+       done