blob: 681ba4c04cfa8f90064973ad13c71e3ed7b3a54b [file] [log] [blame]
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -04001#
2#==================================================================================
E. Scott Daniels29d87162019-06-12 13:48:25 -04003# Copyright (c) 2019 Nokia
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -04004# Copyright (c) 2018-2019 AT&T Intellectual Property.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#==================================================================================
18#
19
20
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -040021Building RMR
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -040022
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -040023The RIC Message Router (RMR) is built with CMake, and requires
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -040024a modern gcc compiler and make to be installed on the build
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -040025system. Typically, installing the following list of packages
26in a container (Ubuntu) is all that is needed to craft a
27development environment (containerised builds are also the
28recommended approach):
29
30 gcc git make vim cmake g++ ksh bash
31
32Kshell and vi are needed only if you wish to use the container
33interactively. Bash is assumed necessary for CMake.
34
35
36Build process
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -040037To build RMR, the usual CMake steps are followed:
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -040038 mkdir build
39 cd build
40 cmake .. [options]
41 make package
42
E. Scott Danielsd4f18ba2019-06-17 15:08:17 -040043
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -040044This will create a .deb (provided the system supports this) in
45the build directory. It's that simple.
46
E. Scott Daniels29cb1002019-06-20 08:23:11 -040047The following flags may be given on the 'cmake' command line
48(options) which are outside of "normal" CMake flags and affect
49the configuration:
50
51 -DBUILD_DOC=1 Man pages generated
52 -DDEV_PKG=1 Development package configuration
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -040053 -DIGNORE_LIBDIR Ignore the system preferred library directory and install in /usr/local/lib
E. Scott Daniels29cb1002019-06-20 08:23:11 -040054 -DMAN_PREFIX=<path> Supply a path where man pages are installed (default: /usr/share/man)
55 -DPACK_EXTERNALS=1 Include external libraries used to build in the run-time package
56 -DPRESERVE_PTYPE=1 Do not change the processor type when naming deb packages
E. Scott Daniels54098f62019-08-06 16:24:20 -040057 -DSKIP_EXTERNALS=1 Do not use Nano/NNG submodules when building; use installed packages
E. Scott Daniels5b8070a2019-09-25 13:02:30 -040058 (See caution in the 'Libraries' section below)
E. Scott Daniels29cb1002019-06-20 08:23:11 -040059
60
61Packages
62The build can be configured to generate either a run-time or
63development package. The run-time generation is the default and
64the -DDEV_PKG=1 option must be given to generate the development
65package. The run-time package contains only the shared library
66files (*.so), and the development package contains the headers,
67man pages (if the man option is set) and archive (.a) files.
68Resulting package names are illustrated in the CI section below.
69
70
E. Scott Danielsd4f18ba2019-06-17 15:08:17 -040071Continuous Integration Build
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -040072Use the Dockerfile in the ci/ subdirectory. This installs all
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -040073the required tools, then builds RMR and executes the unit and
E. Scott Daniels54098f62019-08-06 16:24:20 -040074program tests. If tests pass, then an image is created in the
E. Scott Danielsd4f18ba2019-06-17 15:08:17 -040075local registry with both run-time and development packages.
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -040076
E. Scott Daniels29d87162019-06-12 13:48:25 -040077To support the distribution of package(s) created during the
E. Scott Danielsd4f18ba2019-06-17 15:08:17 -040078build by the CI process, a YAML file is left in the /tmp
79directory (build_packages.yml) which contains a list of the
80packages available from the image. Currently, both .deb and
81.rpm packages are generated.
82
83The following is a sample YAML file generated during this process:
84
E. Scott Danielsd4f18ba2019-06-17 15:08:17 -040085 ---
E. Scott Danielsf6f4f122019-06-18 16:02:17 -040086 files:
87 - /tmp/rmr-dev_1.0.34_x86_64.deb
88 - /tmp/rmr-dev-1.0.34-x86_64.rpm
89 - /tmp/rmr_1.0.34_x86_64.deb
90 - /tmp/rmr-1.0.34-x86_64.rpm
E. Scott Danielsd4f18ba2019-06-17 15:08:17 -040091 ...
92
E. Scott Daniels29d87162019-06-12 13:48:25 -040093
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -040094
95Alternatives
96To build in a non-Linux environment, or to build with an
97alternate install path (or both) read on.
98
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -040099Instead of using 'make package' as listed above, using
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400100'make install' will build and install on the local system.
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -0400101By default, the target install is into /usr/local which may
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400102not be desired. To install into an alternate path add
103these two options when the 'cmake ..' command is given:
104
105 -DCMAKE_INSTALL_PREFIX=/path/to/dir
106 -DMAN_PREFIX=/path/to/dir
107
108
109The first will cause the make process to install into the named
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -0400110directory, which can be in your home directory. The second
111defines where manual pages are placed (if not defined
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400112/usr/share/man is the target). Manual pages are generally
113NOT built as the required tool has yet to be incorporated into
114the build process and generally is not available on most systems.
115
116
E. Scott Daniels29d87162019-06-12 13:48:25 -0400117Compiling and Linking User Applications
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400118Should the Rmr and NNG/Nano libraries be installed in a directory
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -0400119outside of the normal system spots (e.g. not in /usr/local)
120it might be necessary to define the specific directory for
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400121libraries (.e.g -L) on the command line, or via environment
122variables (e.g.. C_INCLUDE_PATH, LD_LIBRARY_PATH, LIBRARY_PATH).
123It may also be necessary to have the library directory defined
124in the environment at run time. It is difficult to know what
E. Scott Daniels54098f62019-08-06 16:24:20 -0400125each system needs, but the following linker options work when
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400126libraries are installed in the system spots:
127
128 -lrmr_nng -lnng -lpthread
129
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -0400130Adding -L is one way to compensate when libraries are installed
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400131a different spot (e.g. in $HOME/usr):
132
133 -L $HOME/usr -lrmr_nng -lnng -lpthread
134
135
136Libraries
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -0400137RMR supports only NNG as the underlying transport. Nanomsg
E. Scott Daniels54098f62019-08-06 16:24:20 -0400138support was dropped starting with version 1.0.45 as Nanomsg
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -0400139has reached end of life. The package generation and install
140will produce a single RMR library: librmr_nng. RMR is designed
141to support different underlying transport mechanisms, which
142might require separate libraries, and thus the library name is
143given a suffix of _nng to reflect the transport mechanism
144in use.
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400145
E. Scott Daniels5b8070a2019-09-25 13:02:30 -0400146NNG version with a commit ID of 906d5ea1b3d67bece941d8a4e0a049e5f6c65051
147is required to build RMR. That version (as yet untagged) adds a
148new error state which we must trap. While application environments
149are encouraged to also build and install at least this version of
150NNG, RMR is still compatable back to the version tagged as 1.1.1.
151If you opt to build with the -DSKIP_EXTERNALS=1 flag set, you must
152ensure that this version of NNG is present in your build environment.
153If you do not set this flag, the proper NNG source will be used
154automatically.
155
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -0400156Regardless of transport mechanism supported by an RMR library,
E. Scott Daniels54098f62019-08-06 16:24:20 -0400157the RMR API will be identical, thus it is possible for an application
158to shift mechanisms simply by referencing a different library (should
E. Scott Danielsb0ba22e2019-08-06 13:26:12 -0400159multiple RMR libraries become available).
Ashwin Sridharanfd9cc7a2019-04-03 16:47:02 -0400160
161
E. Scott Daniels15390d72019-05-06 20:19:59 +0000162Manual Pages
163By default the deb created does not include the manual pages. To
164enable their creation, and subsequent inclusion in the deb, add
165the following option to the cmake command:
166
167 -DBUILD_DOC=1
168
169This will cause the {X}fm text formatting package to be fetched
170(github) and built at cmake time (must exist before building)
171and will trigger the generation of the man pages in both postscript
Lott, Christopher (cl778h)f89eec52019-06-10 16:53:39 -0400172and troff format. The troff pages are placed into the deb and
173the postscript pages are left in the build directory for the
E. Scott Daniels15390d72019-05-06 20:19:59 +0000174developer to convert to PDF, or otherwise use.
E. Scott Daniels29d87162019-06-12 13:48:25 -0400175
E. Scott Danielsa1c1dc62019-09-30 13:05:12 -0400176Debug Mode
177Because RMR is designed to keep its overhead to an absolute minimum,
178messages written to standard error are by default very limited.
179The route table collection thread provides the means to enable
180debug messages on the fly, but only because that thread does not
181impact the sending and receiving of user messages.
E. Scott Daniels29d87162019-06-12 13:48:25 -0400182
E. Scott Danielsa1c1dc62019-09-30 13:05:12 -0400183If it becomes necessary, for development or problem soving, to have
184the RMR functions generate debugging messages the following
185CMake flag can be given when the CMake environment is created:
186 -DDEBUG=n
187
188The value for 'n' should be 1 or 2 to enable debugging. The default
189when not given is the same as setting n to zero.
190
191When running in debug mode, RMR will log messages received, sent,
192and other useful information. Because debugging uses fprintf() there
193is a significant amount of overhead with logging this information and
194thus in debugging mode the user should not expect that usual message
195rates can be achieved, and in some cases may cause messages to drop
196if TCP queues become full.