Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / Readme.scons.txt
1 == Quick guide: build and run IoTivity projects on Ubuntu ==
2
3 1. Build
4         Go to the top directory of 'iotivity' project(Note: should always run 'scons'
5 command in this directory)
6
7     Install external libraries:
8       $ sudo apt-get install libboost-dev libboost-program-options-dev libexpat1-dev libboost-thread-dev uuid-dev libssl-dev
9
10     Build release binaries:
11       $ scons
12 (Note: C sdk requires tiny-cbor. Please follow the instruction in the build
13 message to install tiny-cbor)
14
15     Build debug binaries:
16       $scons RELEASE=false
17
18     Help:
19       $ scons -h
20
21     Clear:
22       $ scons -c
23
24 2. Run the samples
25       $ export LD_LIBRARY_PATH=<iotivity>/out/linux/x86_64/release
26       Run the c++ samples in <iotivity>/out/linux/x86_64/release/resource/examples
27       Run the c samples in <iotivity>/out/linux/x86_64/release/resource/csdk/stack/samples/linux/SimpleClientServer
28 ('<iotivity>' is the path to 'iotivity' project. If your device is x86, arm,
29 or arm64, please change 'x86_64' to the proper arch)
30
31 == How to build IoTivity projects ==
32
33 IoTivity includes a series of projects. You can find all these projects here:
34     https://gerrit.iotivity.org/gerrit/#/admin/projects/
35
36 You can build IoTivity project on Linux / Windows / MAC OSX for various OS(
37 Linux, Tizen, Android, Arduino, Windows, MAC OSX, IOS ...).
38 The output of the build is in:
39   <top directory of the project>/out/<target_os>/<target_arch>/<build_type>/
40 e.g.
41         iotivity/out/android/armeabi-v7a/release/.
42
43 This document takes 'iotivity' project as example, the way to build other
44 projects is almost the same.
45
46 === IoTivity project build tool scons ===
47
48 Scons is a cross-platform build tool, its usage is quite similar to GNU make.
49 To build a project, you just require to run following command at the directory
50 where a SConstruct file exists(SConstruct is the entrance of scons build, it's
51 equivalent to Makefile of 'make') :
52       $ scons [options] [target]
53
54 In additional, usually the scons build script of a project provides useful help
55 information(include build options). To see the help information:
56       $ scons [options] -h
57
58 Note: If no value is specified for an option, the default value will be used.
59 The change of options value may impact the help information and the behavior
60 of the building.
61
62 Generally, it's required to specify the target OS and target ARCH, that's to say
63 tell Scons which OS and which ARCH you'd like build this project for. By default,
64 the target OS and ARCH is the same as the host.
65
66 Some more options may be required, please care the 'error' notification when build.
67 For help about how to set an option, please run:
68      $ scons TARGET_OS=xxx TARGET_ARCH=yyy [XXX=zzz ...] -h
69
70
71 === Prerequites ===
72
73 * 1. Scons
74
75 Please refer to the following page to install scons:
76    http://www.scons.org/doc/production/HTML/scons-user.html#chap-build-install
77 (Note: on Windows, install Python 2.x before installing scons)
78
79 * 2. IDE/SDK Prerequites
80 To build for some OS (Android / Arduino / IOS ...), an IDE/SDK may be required,
81 please go to the relative page to download and install the required IDE/SDK.
82
83 Android:
84 To build for Android, Andorid NDK and SDK are required.
85   Android NDK: http://developer.android.com/tools/sdk/ndk/index.html
86   Android SDK: http://developer.android.com/sdk/index.html
87 (Note: as in some IoTivity projects, C++11 features are used, recommend Android
88  NDK >= r10)
89
90 Arduino:
91 To build for Arduino, Arduino IDE is required.
92   Arduino IDE: http://arduino.cc/en/Main/Software
93   (Note: recommend install Arduino IDE >=1.5.8)
94
95 Arduino builds are dependent on latest Time library. Download it from here:
96     http://www.pjrc.com/teensy/td_libs_Time.html
97 and extract to <arduino_ide_root>/libraries/
98
99 (Note: If you are using Arduino IDE 1.5.8 BETA on Windows, it may pop up some
100 dll isn't found. please copy relative dll from the IDE directory to
101 C:\Windows\SysWOW64. IDE 1.5.7 doesn't have this issue. Other version IDE isn't
102 tested.)
103
104 Apple:
105 To build for Mac OSX or IOS, Xcode is required.
106   Xcode: https://developer.apple.com/xcode/downloads/
107
108 Java:
109 To build the Java code, JDK is required.
110   JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
111 (If the project doesn't include Java code or you wouldn't like build the
112 Java codes, this isn't required)
113
114 (Note: for convenience, suggest add the IDE/SDK path in environment variable,
115 so you don't need to add it in command line each time. The build script will
116 guide you to do that.)
117
118 Tizen:
119 To build for tizen platform tiny-cbor library is needed.
120 Please download tiny-cbor if it is not present in extlibs/tiny-cbor folder
121 by doing the following:
122         $ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor
123
124
125 * 3. External libraries
126 IoTivity project depends on some external libraries, such as boost, expat ...
127 During building, the existence of external library will be checked, if it doesn't
128 exist, the build script will try to download, unpack and build the library or
129 notify user to install it.
130
131 Downloading and unpacking may fail due to network problem or required unpacking
132 tool isn't installed. An message will be displayed, please follow the message
133 to skip it.
134
135
136 === Build IoTivity project on Linux(Ubuntu) ===
137
138 1. Build IoTivity project for Linux
139       $ cd <top directory of the project>
140       $ sudo apt-get install libboost-dev libexpat1-dev libboost-thread-dev libssl-dev
141       $ scons
142
143 2. Build IoTivity project for Android
144       $ cd <top directory of the project>
145       $ scons TARGET_OS=android TARGET_ARCH=xxx
146 (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard. To see all of its
147 allowed value, please execute command 'scons TARGET_OS=android -Q -h')
148
149 3. Build IoTivity project for Arduino
150       $ cd <top directory of the project>
151       $ sudo apt-get install dos2unix
152       $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy SHIELD=zzz
153 (xxx can be avr, arm; yyy is the name of the board, zzz is the shield type, to
154 get allowed values run: scons TARGET_OS=arduino TARGET_ARCH=xxx SHIELD=zzz -h.
155 You may see a option 'CPU' in the output of above command line, that's due to
156 some boards have different processors, to specify the processor, add 'CPU=zzz'
157 in the command line. If no 'CPU' option exists, that means the board only
158 support one kind of processor, it's unnecessary to specify it)
159
160 4. Build Iotivity project for Tizen
161       $ cd <top directory of the project>
162       $ sh gbsbuild.sh
163 (we provide the spec file required by gbs tool at toools/tizen directory.
164 gbs is default build tool for Tizen platfrom, we can refer the following
165 wiki to setup Tizen development environment:
166 https://source.tizen.org/documentation/developer-guide/getting-started-guide)
167
168 Note: Currently most IoTivity project doesn't support Windows, so you can't set
169 TARGET_OS to 'windows' except the project support Windows.
170
171 That's to say if the project doesn't support Windows, run:
172       $ scons TARGET_OS=windows ....
173 or run on Windows
174       $ scons
175 may always fail.
176
177
178 === Build IoTivity project on Mac OSX ===
179
180 1. Build IoTivity project for Mac OSX
181       $ cd <top directory of the project>
182       $ scons SYS_VERSION=yyy
183 (yyy is the OSX version, e.g. 10.9)
184
185 2. Build IoTivity project for Android(It's the same as on Ubuntu)
186       $ cd <top directory of the project>
187       $ scons TARGET_OS=android TARGET_ARCH=xxx
188 (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard)
189
190 3. Build IoTivity project for IOS
191       $ cd <top directory of the project>
192       $ scons TARGET_OS=ios TARGET_ARCH=xxx SYS_VERSION=yyy
193 (xxx can be i386, x86_64, armv7, armv7s, arm64, yyy is IOS version, e.g. 7.0)
194
195 Note:
196 1) for convenience, a script (auto_build.sh) is provided to run possible build
197 at once. Following is the usage:
198
199 To build:
200      $ auto_build.sh <path-to-android-ndk>
201 To clean:
202      $ auto_build.sh -c