How to build the dSS

Version 36 (Michael Troß, 02/02/2012 08:34 am)

1 1 Matias Fernandez
h1. How to build the dSS
2 1 Matias Fernandez
3 32 Michael Troß
{{toc}}
4 32 Michael Troß
5 32 Michael Troß
h2. Get the source
6 32 Michael Troß
7 36 Michael Troß
Get the dSS release tarballs from the "dss developer site":http://developer.digitalstrom.org/releases/release-1.3/. Packages for all dSS11 projects can be found on the "dss download site":http://developer.digitalstrom.org/download/dss/.
8 32 Michael Troß
9 32 Michael Troß
If you like to work with the current development snapshot get the source via git as explained [[Git_Repository|here]]. These development snapshots may have changed dependencies or build instructions or may even have functional limitations.
10 32 Michael Troß
11 1 Matias Fernandez
h2. Used libraries
12 1 Matias Fernandez
13 32 Michael Troß
The dSS relies on some external libraries. To build it from source your system needs the following libraries and their development headers.
14 21 Patrick Stählin
15 32 Michael Troß
* "Boost":http://www.boost.org
16 28 Johannes Winkelmann
17 32 Michael Troß
* "Poco":http://pocoproject.org
18 21 Patrick Stählin
19 1 Matias Fernandez
* "gSOAP":http://gsoap2.sourceforge.net
20 32 Michael Troß
21 34 Michael Troß
  The gSOAP packages for Ubuntu with version 2.7.15 and 2.8.3-3 (and older 2.8.x releases) have known limitations and do not work with the dSS. Please update to a recent gsoap version.
22 21 Patrick Stählin
23 32 Michael Troß
* "OpenSSL":http://www.openssl.org
24 1 Matias Fernandez
25 34 Michael Troß
* "Avahi":http://avahi.org
26 34 Michael Troß
27 32 Michael Troß
* "libical":http://sourceforge.net/projects/freeassociation/
28 21 Patrick Stählin
29 32 Michael Troß
* "SpiderMonkey":http://www.mozilla.org/js/spidermonkey
30 29 Johannes Winkelmann
31 32 Michael Troß
  Since dSS release 1.3.2 the SpiderMonkey scripting engine with version 1.8.5 is required.
32 21 Patrick Stählin
33 1 Matias Fernandez
* "librrd":http://oss.oetiker.ch/rrdtool/doc/librrd.en.html
34 1 Matias Fernandez
35 36 Michael Troß
* "libcurl":http://curl.haxx.se/libcurl
36 36 Michael Troß
37 1 Matias Fernandez
* "dS485 Stack":http://developer.digitalstrom.org/download/ds485-stack/
38 32 Michael Troß
39 33 Michael Troß
  Typically the dSS release tarballs do cleanly build with the latest dS485 Stack releases. This may not be the case for the dSS git development snapshots which require to build the dS485 from the git repositories, too.
40 1 Matias Fernandez
41 32 Michael Troß
h2. Prerequisites on different distributions
42 1 Matias Fernandez
43 32 Michael Troß
To get you started we've compiled detailed instructions on how to get started on the following platforms:
44 1 Matias Fernandez
45 1 Matias Fernandez
* [[UbuntuSetup|Debian, Ubuntu]]
46 32 Michael Troß
* [[FedoraSetup|Red Hat, Fedora]]
47 32 Michael Troß
* [[Mac OS X]]
48 21 Patrick Stählin
49 1 Matias Fernandez
h2. Building the dS485 Stack 
50 1 Matias Fernandez
51 34 Michael Troß
The dSS requires the dSM-API and compaion library so those libraries have to be compiled first. The dS485 Stack uses
52 34 Michael Troß
cmake to automate the build process.
53 21 Patrick Stählin
54 32 Michael Troß
To install the library into a separate directory in your home (recommended) specify the prefix using @cmake -DCMAKE_INSTALL_PREFIX=/home/yournamehere/yourpath@ instead of calling cmake without parameter.
55 21 Patrick Stählin
56 35 Sergey Bostandzhyan
h2. Compiling dSS with autotools
57 35 Sergey Bostandzhyan
58 35 Sergey Bostandzhyan
Starting with dSS version 1.4.0, the build system was changed from CMake to autotools.
59 35 Sergey Bostandzhyan
60 35 Sergey Bostandzhyan
h3. Before you begin
61 35 Sergey Bostandzhyan
62 35 Sergey Bostandzhyan
Make sure to install all development packages for the required libraries before running the configure script.
63 35 Sergey Bostandzhyan
64 35 Sergey Bostandzhyan
If you checked out the sources directly from git you will first have to generate the configure script. Make sure to that autoconf, automake and libtool are installed on your system and issue the following command:
65 35 Sergey Bostandzhyan
66 35 Sergey Bostandzhyan
<pre>
67 35 Sergey Bostandzhyan
autoreconf -i
68 35 Sergey Bostandzhyan
</pre>
69 35 Sergey Bostandzhyan
70 35 Sergey Bostandzhyan
If you downloaded a release tarball, the configure script will already be there.
71 35 Sergey Bostandzhyan
72 35 Sergey Bostandzhyan
h3. Configuring
73 35 Sergey Bostandzhyan
74 35 Sergey Bostandzhyan
If you are happy with the default options, just run:
75 35 Sergey Bostandzhyan
<pre>
76 35 Sergey Bostandzhyan
./configure
77 35 Sergey Bostandzhyan
</pre>
78 35 Sergey Bostandzhyan
79 35 Sergey Bostandzhyan
However, if you installed some libraries in non standard locations you need to tell the configure script where to look for them. Also, there are some compile time options which can be used to build a specific dSS configuration, tune installation paths and more. To see all available options, run:
80 35 Sergey Bostandzhyan
<pre>
81 35 Sergey Bostandzhyan
./configure --help
82 35 Sergey Bostandzhyan
</pre>
83 35 Sergey Bostandzhyan
84 35 Sergey Bostandzhyan
Below are the most useful parameters.
85 35 Sergey Bostandzhyan
86 35 Sergey Bostandzhyan
*Features*
87 35 Sergey Bostandzhyan
88 35 Sergey Bostandzhyan
<pre>
89 35 Sergey Bostandzhyan
    --disable-soap          build dSS without SOAP support (default: enabled)
90 35 Sergey Bostandzhyan
    --enable-http           build with HTTP support (default: HTTPS only)
91 35 Sergey Bostandzhyan
    --disable-bonjour       build with bonjour support (default: enabled)
92 35 Sergey Bostandzhyan
</pre>
93 35 Sergey Bostandzhyan
94 35 Sergey Bostandzhyan
*Installation directories*
95 35 Sergey Bostandzhyan
96 35 Sergey Bostandzhyan
<pre>
97 35 Sergey Bostandzhyan
    --prefix=PREFIX                 install architecture-independent files in PREFIX [/usr/local]
98 35 Sergey Bostandzhyan
    --with-dss-data=DIR             use DIR as dSS data directory
99 35 Sergey Bostandzhyan
    --with-dss-config=DIR           use DIR as dSS config directory
100 35 Sergey Bostandzhyan
    --with-dss-webroot=DIR          use DIR as dSS webroot directory
101 35 Sergey Bostandzhyan
    --with-dss-js-logs=DIR          use DIR as dSS JavaScript logging directory
102 35 Sergey Bostandzhyan
    --with-dss-saved-properties=DIR save dSS add-on script properties in DIR
103 35 Sergey Bostandzhyan
</pre>
104 35 Sergey Bostandzhyan
105 35 Sergey Bostandzhyan
By default, @make install@ will install all the files in @/usr/local/bin@, @/usr/local/share/dss@ etc.  You can specify an installation prefix other than @/usr/local@ using @--prefix@, for instance @--prefix=$HOME/dSS@. This is quite useful if you do not want to do a system wide installation, but prefer to install the dSS somewhere in your home directory.
106 35 Sergey Bostandzhyan
107 35 Sergey Bostandzhyan
*Note:* the installation paths are compiled into the dSS binary, this means that if you ran @make install@ at least once, so that all expected paths were created, you can run the dSS binary from any place on your system. If needed, the configured paths can still be overriden on the dSS command line.
108 35 Sergey Bostandzhyan
109 35 Sergey Bostandzhyan
*Libraries in non standard locations*
110 35 Sergey Bostandzhyan
111 35 Sergey Bostandzhyan
If required libraries were not installed system wide (for example to prevent conflicts with libraries shipped by your distribution), you can tell the configure script where to look for your custom installed libraries and development headers. In most cases we use pkg-config to search for the libs, as it became a standard and is available in all major distributions.
112 35 Sergey Bostandzhyan
113 35 Sergey Bostandzhyan
<pre>
114 35 Sergey Bostandzhyan
  --with-js-pkgconfig=DIR    search for libjs.pc or mozjs185.c in DIR
115 35 Sergey Bostandzhyan
  --with-boost=DIR           prefix of Boost 1.46 [guess]
116 35 Sergey Bostandzhyan
  --with-boost=DIR           prefix of Boost 1.35 [guess]
117 35 Sergey Bostandzhyan
  --with-poco-h=DIR          search for poco headers in DIR
118 35 Sergey Bostandzhyan
  --with-poco-libs=DIR       search for poco libraries in DIR
119 35 Sergey Bostandzhyan
  --with-libdsm-api-h=DIR    search for libdsm-api headers in DIR
120 35 Sergey Bostandzhyan
  --with-libdsm-api-libs=DIR search for libdsm-api libraries in DIR
121 35 Sergey Bostandzhyan
  --with-gsoap-import=DIR    search for gSOAP import headers in DIR
122 35 Sergey Bostandzhyan
</pre>
123 35 Sergey Bostandzhyan
124 35 Sergey Bostandzhyan
Use these variables to override the choices made by @configure@ or to help it to find libraries and programs with nonstandard names/locations.
125 35 Sergey Bostandzhyan
126 35 Sergey Bostandzhyan
<pre>
127 35 Sergey Bostandzhyan
Some influential environment variables:
128 35 Sergey Bostandzhyan
  BOOST_ROOT        location of Boost installation
129 35 Sergey Bostandzhyan
  PKG_CONFIG        path to pkg-config utility
130 35 Sergey Bostandzhyan
  PKG_CONFIG_PATH   directories to add to pkg-config's search path
131 35 Sergey Bostandzhyan
  PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path
132 35 Sergey Bostandzhyan
  JS_CFLAGS         C compiler flags for JS, overriding pkg-config
133 35 Sergey Bostandzhyan
  JS_LIBS           linker flags for JS, overriding pkg-config
134 35 Sergey Bostandzhyan
  ICAL_CFLAGS       C compiler flags for ICAL, overriding pkg-config
135 35 Sergey Bostandzhyan
  ICAL_LIBS         linker flags for ICAL, overriding pkg-config
136 35 Sergey Bostandzhyan
  LIBXML2_CFLAGS    C compiler flags for LIBXML2, overriding pkg-config
137 35 Sergey Bostandzhyan
  LIBXML2_LIBS      linker flags for LIBXML2, overriding pkg-config
138 35 Sergey Bostandzhyan
  OPENSSL_CFLAGS    C compiler flags for OPENSSL, overriding pkg-config
139 35 Sergey Bostandzhyan
  OPENSSL_LIBS      linker flags for OPENSSL, overriding pkg-config
140 35 Sergey Bostandzhyan
  AVAHI_CFLAGS      C compiler flags for AVAHI, overriding pkg-config
141 35 Sergey Bostandzhyan
  AVAHI_LIBS        linker flags for AVAHI, overriding pkg-config
142 35 Sergey Bostandzhyan
  LIBRRD_CFLAGS     C compiler flags for LIBRRD, overriding pkg-config
143 35 Sergey Bostandzhyan
  LIBRRD_LIBS       linker flags for LIBRRD, overriding pkg-config
144 35 Sergey Bostandzhyan
  GSOAP_CFLAGS      C compiler flags for GSOAP, overriding pkg-config
145 35 Sergey Bostandzhyan
  GSOAP_LIBS        linker flags for GSOAP, overriding pkg-config
146 35 Sergey Bostandzhyan
</pre>
147 35 Sergey Bostandzhyan
148 35 Sergey Bostandzhyan
149 35 Sergey Bostandzhyan
In most cases you should not need to tune these settings, the usual "candiates" for non standard directories are the dS485 stack libraries and SpiderMonkey 1.8.5.
150 35 Sergey Bostandzhyan
151 35 Sergey Bostandzhyan
Here is an example from my system:
152 35 Sergey Bostandzhyan
<pre>
153 35 Sergey Bostandzhyan
./configure --with-libdsm-api-libs=/opt/dS485/installed/lib \
154 35 Sergey Bostandzhyan
            --with-libdsm-api-h=/opt/dS485/installed/include \
155 35 Sergey Bostandzhyan
            --with-js-pkgconfig=/opt/JS/installed/lib/pkgconfig
156 35 Sergey Bostandzhyan
            --prefix=/tmp/dss
157 35 Sergey Bostandzhyan
</pre>
158 35 Sergey Bostandzhyan
159 35 Sergey Bostandzhyan
h3. Compiling
160 35 Sergey Bostandzhyan
161 35 Sergey Bostandzhyan
Simply run @make@ followed by @make install@:
162 35 Sergey Bostandzhyan
163 35 Sergey Bostandzhyan
<pre>
164 35 Sergey Bostandzhyan
make
165 35 Sergey Bostandzhyan
make install
166 35 Sergey Bostandzhyan
</pre>
167 35 Sergey Bostandzhyan
168 35 Sergey Bostandzhyan
After running make, the dSS binary will be located in the @./build/@ directory. If you executed @make install@ at least once, you can run the dSS binary directly from your build tree, i.e. @./build/dss@
169 35 Sergey Bostandzhyan
170 35 Sergey Bostandzhyan
The tests are not installed by default, you can run them directly from your build tree, i.e. @./build/dsstests@
171 1 Matias Fernandez
    
172 35 Sergey Bostandzhyan
173 35 Sergey Bostandzhyan
h2. Compiling dSS with CMake
174 35 Sergey Bostandzhyan
175 36 Michael Troß
*Note:* CMake support is deprecated since version 1.4.0, however it will stay available for a short time to make transition to the new build system easier.
176 32 Michael Troß
177 21 Patrick Stählin
<pre>
178 21 Patrick Stählin
mkdir dss/build
179 1 Matias Fernandez
cd dss/build
180 32 Michael Troß
cmake .. [CMake Options]
181 32 Michael Troß
make
182 32 Michael Troß
</pre>
183 1 Matias Fernandez
184 1 Matias Fernandez
If you're compiling the dSS for development it's recommended that you set the data-directory to @data/@:
185 1 Matias Fernandez
186 1 Matias Fernandez
<pre>
187 1 Matias Fernandez
cmake .. -DWITH_DATADIR=data/
188 9 Patrick Stählin
</pre>
189 9 Patrick Stählin
190 1 Matias Fernandez
191 9 Patrick Stählin
h3. Options for CMake
192 9 Patrick Stählin
193 9 Patrick Stählin
* @-DWITH_DATADIR=path@ 
194 9 Patrick Stählin
  specifies the default location of the @data@ directory (default: @/usr/share/dss/data@).
195 9 Patrick Stählin
196 1 Matias Fernandez
* @-DWITH_TESTS=[yes|no]@ 
197 1 Matias Fernandez
  include tests in the build (default: @yes@).
198 1 Matias Fernandez
199 1 Matias Fernandez
* @-DWITH_SIM=[yes|no]@ 
200 9 Patrick Stählin
  include the simulation in the build (default: @yes@)
201 1 Matias Fernandez
202 1 Matias Fernandez
* @-DCMAKE_BUILD_TYPE=[Release|Debug]@
203 9 Patrick Stählin
  default: @Release@
204 1 Matias Fernandez
205 1 Matias Fernandez
* @-DLIBDSM_PREFIX=/path/to/libdsm@
206 9 Patrick Stählin
  searches for the dsm-api in @/path/to/libdsm@
207 1 Matias Fernandez
208 32 Michael Troß
* @-DSPIDERMONKEY_ROOT=/path/to/spidermonkey@
209 32 Michael Troß
  searches for the spidermonkey development files in @/path/to/spidermonkey@
210 32 Michael Troß
211 32 Michael Troß
* @-DWITH_SOAP=[yes|no]@ 
212 32 Michael Troß
  include the soap service in the build (default: @yes@)
213 32 Michael Troß
214 32 Michael Troß
* @-DWITH_HTTP=[yes|no]@ 
215 32 Michael Troß
  include the http protocol support in the build (default: @no@)
216 32 Michael Troß
217 32 Michael Troß
218 1 Matias Fernandez
h2. Configuring
219 3 Johannes Winkelmann
220 32 Michael Troß
As of version 0.7.7 the web server is using SSL, therefore you need to generate a private key and a certificate. A helper script that will do this for you is provided, it will generate a private key, a self signed certificate and it will put them in a file called @dsscert.pem@. The script is called in @create_cert.sh@ and is located in the tools directory in the source tree, make sure that openssl is installed on your system and run the create_cert.sh script without any parameters. After that, copy the dsscert.pem file to your dss data directory.
221 16 Sergey Bostandzhyan
222 5 Patrick Stählin
All options are published in the internal property tree. This tree can be accessed through the webbrowser at [http://yourhost:8080/browse/].
223 5 Patrick Stählin
224 19 Sergey Bostandzhyan
Note, that the SOAP interface is also using SSL, by default it is configured to use the default @dsscert.pem@ file from the dss config directory.
225 14 Patrick Stählin
226 32 Michael Troß
227 1 Matias Fernandez
h1. Building webpages
228 1 Matias Fernandez
229 19 Sergey Bostandzhyan
The web pages are built as a standalone package. If you checked out the web sources directly from git you will first have to generate the configure script. Make sure to that autoconf and automake are installed on your system and issue the following command:
230 32 Michael Troß
231 19 Sergey Bostandzhyan
<pre>
232 19 Sergey Bostandzhyan
autoreconf -i
233 19 Sergey Bostandzhyan
</pre>
234 19 Sergey Bostandzhyan
235 19 Sergey Bostandzhyan
To build the web sources make sure that you have installed sprocketize and issue the following commands:
236 32 Michael Troß
237 19 Sergey Bostandzhyan
<pre>
238 20 Sergey Bostandzhyan
./configure --prefix=/desired/prefix/path
239 19 Sergey Bostandzhyan
make
240 27 Sergey Bostandzhyan
make install
241 27 Sergey Bostandzhyan
</pre>
242 27 Sergey Bostandzhyan
243 32 Michael Troß
If you downloaded a release tarball of the web pages you can skip the above steps.
244 32 Michael Troß
245 27 Sergey Bostandzhyan
You can then either configure the webroot path via config.xml or start the dSS with @-w /path/to/websources@ parameter.
246 27 Sergey Bostandzhyan
247 27 Sergey Bostandzhyan
248 27 Sergey Bostandzhyan
It is possible to build a release and a debug version of the web interface, it will not minimize the JS code and will use debug ExtJS/Sencha libraries. To build the debug version specify the @--enable-debug@ parameter when running the configure script, then run make:
249 32 Michael Troß
250 27 Sergey Bostandzhyan
<pre>
251 27 Sergey Bostandzhyan
./configure --enable-debug
252 27 Sergey Bostandzhyan
make
253 27 Sergey Bostandzhyan
</pre>
254 3 Johannes Winkelmann
255 19 Sergey Bostandzhyan
The build system also supports a dist-release target, it will generate a tar file with ready to use web UI files that do not require any further processing. Just unpack it and point the dSS to the webroot directory using the @-w@ option. To generate a ready to use release tarball run the following commands:
256 32 Michael Troß
257 7 Patrick Stählin
<pre>
258 1 Matias Fernandez
./configure
259 7 Patrick Stählin
make
260 7 Patrick Stählin
make dist-release
261 1 Matias Fernandez
</pre>
262 19 Sergey Bostandzhyan
263 3 Johannes Winkelmann
264 7 Patrick Stählin
h1. Building a debian package
265 3 Johannes Winkelmann
266 3 Johannes Winkelmann
Run the following command to build a debian package (from the dss root source directory)
267 3 Johannes Winkelmann
<pre>
268 4 Johannes Winkelmann
  $ dpkg-buildpackage -rfakeroot
269 4 Johannes Winkelmann
</pre>
270 10 Patrick Stählin
271 10 Patrick Stählin
h2. Signed debian package
272 10 Patrick Stählin
273 18 Patrick Stählin
If you're intending to distribute the package, you might want to sign it using your GNUPG key:
274 11 Patrick Stählin
<pre>
275 11 Patrick Stählin
  $ dpkg-buildpackage -rfakeroot -k<GNUPG key>
276 11 Patrick Stählin
</pre>
277 10 Patrick Stählin
278 1 Matias Fernandez
Not that you'll have to pass your GnuPG key ID to this command, unless you have a key in your keychain which matches the last changelog entry
279 1 Matias Fernandez
280 1 Matias Fernandez
h1. Running tests
281 1 Matias Fernandez
282 1 Matias Fernandez
The make target @test@ runs the full test-suite. You should be able to run the test by issuing the following line in your @build@ directory:
283 1 Matias Fernandez
284 1 Matias Fernandez
<pre>
285 1 Matias Fernandez
make test
286 1 Matias Fernandez
</pre>