--- /dev/null
+#Set the two variables below for the client build.
+CLIENTARCH=x86
+BUILDTYPE=release
+##
+
+YOCTOCXXFLAGS=-I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/stack -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ocrandom -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/logger -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/oc_logger
+
+YOCTOLDFLAGS=-loc -loctbstack -loc_logger -lmraa
+
+CXXFLAGS=-I../../resource/include -I../../resource/csdk/stack/include -I../../resource/csdk/ocrandom/include -I../../resource/csdk/logger/include -I../../resource/oc_logger/include
+
+LDFLAGS=-L../../out/linux/$(CLIENTARCH)/$(BUILDTYPE) -loc -loctbstack -loc_logger
+
+client: client.o
+ g++ -o client client.o $(LDFLAGS)
+
+client.o: client.cpp
+ g++ -std=c++0x -c -o $@ $< $(CXXFLAGS)
+
+observer.o: observer.cpp
+ $(CXX) -std=c++0x -c -o $@ $< $(YOCTOCXXFLAGS)
+
+server.o: server.cpp
+ifeq ($(SDKTARGETSYSROOT),)
+ echo "Error: Yocto cross-toolchain environment not initialized"
+ exit 1
+endif
+ $(CXX) -std=c++0x -c -o $@ $< $(YOCTOCXXFLAGS)
+
+server: server.o observer.o
+ $(CXX) -o server server.o observer.o $(YOCTOLDFLAGS)
+
+clean:
+ rm -rf server client *.o
+++ /dev/null
-#******************************************************************
-#
-# 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.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#This script builds edisonclient for Ubuntu and edisonserver for Yocto.
-
-#Client build for Ubuntu
-#Set IOTIVITY_ROOT to the root of oic-resource on Ubuntu.
-IOTIVITY_ROOT = ''
-#Set IOTIVITY_LIBS_PATH to path on Ubuntu that contains liboc.so, liboctbstack.so, liboc_logger.so and libcoap.so.
-IOTIVITY_LIBS_PATH = ''
-
-env = DefaultEnvironment()
-env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
-env.AppendUnique(LINKFLAGS = ['-pthread'])
-env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'coap'])
-
-envClient = env.Clone()
-envClient.AppendUnique(CPPPATH = [
- IOTIVITY_ROOT + '/resource/include',
- IOTIVITY_ROOT + '/resource/csdk/stack/include',
- IOTIVITY_ROOT + '/resource/oc_logger/include',
- ])
-envClient.AppendUnique(LIBPATH = [IOTIVITY_LIBS_PATH])
-envClient.Program('edisonclient', 'client.cpp')
-
-#Server build
-envServer = env.Clone()
-'''
-This code injects Yocto cross-compilation flags into scons' default environment
-in order to invoke the relevant tools while performing a build.
-'''
-import os.path, re
-sdk_root = ''
-try:
- CC = os.environ['CC']
- sdk_root = re.search(r'--sysroot=\S+', CC).group().split('=')[1]
- target_prefix = CC.split()[0]
- target_prefix = target_prefix[:len(target_prefix)-3]
- tools = {"CC" : target_prefix+"gcc",
- "CXX" : target_prefix+"g++",
- "AS" : target_prefix+"as",
- "LD" : target_prefix+"ld",
- "GDB" : target_prefix+"gdb",
- "STRIP" : target_prefix+"strip",
- "RANLIB" : target_prefix+"ranlib",
- "OBJCOPY" : target_prefix+"objcopy",
- "OBJDUMP" : target_prefix+"objdump",
- "AR" : target_prefix+"ar",
- "NM" : target_prefix+"nm",
- "M4" : "m4",
- "STRINGS": target_prefix+"strings"}
- PATH = os.environ['PATH'].split(os.pathsep)
- for tool in tools:
- if tool in os.environ:
- for path in PATH:
- if os.path.isfile(os.path.join(path, tools[tool])):
- envServer[tool] = os.path.join(path, os.environ[tool])
- envServer.Program('edisonserver', ['server.cpp', 'observer.cpp'])
- envServer.AppendUnique(LIBS = ['mraa'])
- envServer.AppendUnique(CPPPATH = [
- sdk_root + '/usr/include/iotivity/',
- sdk_root + '/usr/include/iotivity/stack/',
- sdk_root + '/usr/include/iotivity/oc_logger/',
- ])
-except:
- print "ERROR configuring Yocto cross-toolchain environment. This is required for building the server"
-