Difference between revisions of "Compilation & Build"

From MidasWiki
Jump to navigation Jump to search
m
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{Pagelinks}}
 +
 
== Introduction ==
 
== Introduction ==
 
This section covers the various options available for customization when building the MIDAS system. The options fall into the following categories:
 
This section covers the various options available for customization when building the MIDAS system. The options fall into the following categories:
* MIDAS Environment Variables
+
* Environment Variables
 
* Makefile Options
 
* Makefile Options
 
* Building Options
 
* Building Options
  
== MIDAS Environment variables ==
+
== Environment Variables ==
MIDAS uses a several environment variables to facilitate the startup of the different applications. Only [[#MIDASSYS]] is required. The MIDAS environment
 
variables must be defined before executing the [[MIDAS Makefile]]. The MIDAS environment variables are also discussed in the [[QuickStart]] section.
 
<br>
 
---------
 
<br>
 
=== MIDASSYS ===
 
This environmental variable is required. It should point to the main path of the installed MIDAS package,e.g.
 
;csh :    setenv MIDASSYS $HOME/packages/midas 
 
;bash :  export MIDASSYS=$HOME/packages/midas 
 
The application [[odbedit]] will generate a warning message unless this variable is defined.
 
 
 
 
 
<br>
 
--------
 
<br>
 
 
 
=== MIDAS_EXPTAB ===
 
This variable specifies the location of the optional [[exptab (Experiment Table)|exptab]] file containing the predefined MIDAS experiments, e.g.
 
 
 
;csh :  setenv MIDAS_EXPTAB $HOME/online/exptab
 
;bash : export MIDAS_EXPTAB = $HOME/online/exptab
 
 
 
If '''MIDAS_EXPTAB''' is not defined, the default location will be used (i.e. for OS_UNIX: ''/etc'', / and for OS_WINNT: ''\system32, \system '').
 
 
 
 
 
 
<br>
 
-----------
 
<br>
 
 
 
=== MIDAS_SERVER_HOST ===
 
 
 
This variable predefines the name of the host on which the MIDAS experiment shared memories are residing. It is needed when a connection to a remote experiment is requested. It obviates the need to add the
 
; "-h <hostname>"
 
argument to the application command (see [[Common Parameters to MIDAS Utilities]]).
 
'''MIDAS_SERVER_HOST''' will be superseded by [[#MIDAS_DIR |MIDAS_DIR]] if defined. This variable is valid for Unix as well as Windows OS.
 
 
 
<br>
 
--------
 
<br>
 
 
 
=== MIDAS_EXPT_NAME ===
 
 
 
Where there are multiple experiments available on the host, this variable predefines the name of the experiment to which the user wishes to connect. It prevents the requested application from asking for the experiment name. Defining MIDAS_EXPT_NAME makes adding the
 
;"-e <exptname>"
 
argument to the application command unnecessary (see [[Common Parameters to MIDAS Utilities]]). '''MIDAS_EXPT_NAME''' will be superseded by [[#MIDAS_DIR |MIDAS_DIR]] if defined. This variable is valid for Unix as well as Windows OS.
 
 
 
<br>
 
--------
 
<br>
 
 
 
=== MIDAS_DIR ===
 
This variable predefines the LOCAL directory path where the shared memories for the experiment are located. Defining this variable results in a single experiment called "Default". Since a given directory path can only refer to a single experiment, '''MIDAS_DIR''' supersedes the hostname and exptname parameters as well as the [[#MIDAS_SERVER_HOST |MIDAS_SERVER_HOST]] and [[#MIDAS_EXPT_NAME|MIDAS_EXPT_NAME]] environment variables.
 
 
 
;Note : If you wish to use the [[exptab]] file to define multiple experiments on a single host, do not define '''MIDAS_DIR'''.
 
 
 
<br>
 
------------
 
<br>
 
 
 
=== ROOTSYS ===
 
This variable must point to the ROOT package if generating a complete MIDAS/ROOT analyzer application. If not using ROOT, '''ROOTSYS''' should be undefined.
 
 
 
<br>
 
-----------
 
<br>
 
  
=== CERNLIB_PACK ===
+
The [[Environment Variables|MIDAS Environment Variables]] must be defined before executing the [[#MIDAS Makefile|MIDAS Makefile]].
In case of HBOOK/PAW analyzer application, this variable should be pointing to a valid cernpacklib.a library. See [[#HAVE_HBOOK |HAVE_HBOOK]].
 
 
 
<br>
 
----------
 
<br>
 
 
 
=== MIDAS_FRONTEND_INDEX ===
 
This variable predefines the index assigned to the equipment using the event builder option. Useful if the [[frontend]] applications are started from different hosts. Refer to [[Principle of the Event Builder ]] and related frontend fragment for more information.
 
<br>
 
---------
 
<br>
 
=== MCHART_DIR ===
 
This variable is used for the old [[mchart]] utility.
 
 
 
 
 
<br>
 
----------
 
<br>
 
  
 
== MIDAS Makefile  ==
 
== MIDAS Makefile  ==
Line 205: Line 123:
 
==== NEED_MSCB ====
 
==== NEED_MSCB ====
  
By default,  optional [[MSCB]] (MIDAS Slow Control Bus) support for mhttpd is included.
+
By default,  optional [https://midas.psi.ch/mscb MSCB (MIDAS Slow Control Bus)] support for [[mhttpd]] is included.
  
 
<br>
 
<br>
Line 246: Line 164:
  
 
==== NEED_ZLIB ====
 
==== NEED_ZLIB ====
If data compression is required by the data logger, the MIDAS package must be compiled with ZLIB support. The applications [[lazylogger]], [[mdump]] can be built with zlib.a in order to gain direct access to the data within a file with extension mid.gz. By default this option is disabled except for the system analyzer core code mana.c. However, if NEED_MYSQL is set, NEED_ZLIB will also be set.
+
If data compression is required by the data logger, the MIDAS package must be compiled with ZLIB support. The applications [[lazylogger]], [[Mdump|mdump]] can be built with zlib.a in order to gain direct access to the data within a file with extension mid.gz. By default this option is disabled except for the system analyzer core code mana.c. However, if NEED_MYSQL is set, NEED_ZLIB will also be set.
  
 
<br>
 
<br>
Line 264: Line 182:
 
---------
 
---------
 
<br>
 
<br>
 +
 +
[[Category:Build]] [[Category:Environment variable]]

Latest revision as of 17:56, 10 July 2015


Introduction

This section covers the various options available for customization when building the MIDAS system. The options fall into the following categories:

  • Environment Variables
  • Makefile Options
  • Building Options

Environment Variables

The MIDAS Environment Variables must be defined before executing the MIDAS Makefile.

MIDAS Makefile

The Makefile to make the MIDAS DAQ system is located at the path given by MIDASSYS.


  • "make", "make all" : compile the default midas system
  • "make clean" : remove all compiled object files and executables
  • "make linux32", "make clean32" : compile subset of midas with gcc "-m32" switch, useful for cross-compiling 32-bit midas on a 64-bit machine
  • "make linux64", "make clean64" : compile subset of midas with gcc "-m64" switch, useful for compiling 64-bit midas when default ROOTSYS. points to a 32-bit ROOT version
  • "make examples" : compile example code in .../examples


Building Options

By default, MIDAS is built with a minimum of pre-compiler flags. The MIDAS Makefile contains options for the user to apply customization by enabling internal options already available in the package. Generally the options are named "NEED_OPTION" where "OPTION" is replaced by the desired option (ZLIB,LIBROOTA etc.). This will set a compiler flag called "HAVE_OPTION" . To link MIDAS with the required option(s), say

> make ... NEED_OPTION=1

Other options are included automatically by the Makefile depending on whether certain software is present (e.g. HAVE_ODBC).

  • NEED_ZLIB NEED_RPATH NEED_LIBROOTA NEED_MYSQL NEED_STRLCPY SPECIFIC_OS_PRG

Other flags are available at the application level:

  • HAVE_ROOT , HAVE_HBOOK , MIDAS_MAX_EVENT_SIZE , HAVE_ODBC

Dynamic or Static Build

By default the MIDAS applications are built for use with dynamic library libmidas.so. If static build is required, the whole package can be built using the option static, i.e.

  • > make static

For development it could be useful to built individual application in static. This can be done using the USERFLAGS option such as:

  • > rm linux/bin/mstat; make USERFLAGS=-static linux/bin/mstat


Analyzer

The basic MIDAS package builds without external package library reference. But it does try to build an extra core analyzer application to be used in conjunction with ROOT if the environment variable ROOTSYS is found. This is required ONLY if the examples/experiment makefile is used for generating a complete Midas/ROOT analyzer application.

In the case of the HBOOK/PAW analyzer application, the build should be done from examples/hbookexpt directory and the environment variable CERNLIB_PACK should be pointing to a valid cernpacklib.a library.


OS Support

The makefile contains conditional code to determine the operating system (OS) of the host by evaluating the OSTYPE environment variable. Once OSTYPE is determined, the OS support is done through a fixed flag OSFLAGS in the makefile, e.g.

  • OSFLAGS = -DOS_LINUX ...

Currently the OS supported are:

  • OS_OSF1 , OS_ULTRIX , OS_FREEBSD , OS_DARWIN, OS_CYGWIN, OS_LINUX , OS_SOLARIS. (For OS_IRIX please contact Pierre.)

Other OS supported are:

  • OS_WINNT : See file makefile.nt.


64-bit or 32-bit build

For 32-bit built, the OSFLAGS should contains the -m32 flag. By default this flag is not enabled. It has to be applied to the Makefile for the frontend examples too.

 # add to compile MIDAS in 32-bit mode
 # OSFLAGS += -m32


Build Flags

USERFLAGS

This flag can be used at the command prompt for individual application built, e.g.

  • make USERFLAGS=-static linux/bin/mstat




HAVE_ROOT

This flag is used for the MIDAS analyzer in the case ROOT environment is required. An example of the makefile resides in examples/experiment/Makefile. This flag is enabled by the presence of a valid ROOTSYS environment variable. In the case that ROOTSYS is not found, the analyzer is build without ROOT support. In this latter case, the application rmidas will be missing. refer to the analyzer structure for further details.




HAVE_HBOOK

This flag is used for examples/hbookexpt/Makefile for building the MIDAS analyzer - event analysis against HBOOK and PAW. The path to the cernlib is requested and expected to be found under /cern/pro/lib (see makefile). This can always be overwritten during the make using the following command:

make CERNLIB_PACK=<your path>/libpacklib.a




NEED_MYSQL

This flag is used in mlogger to build the application with mySQL support. The build requires access to the mysql include files as well as the mysql library. The Makefile tries to figure out automatically if the mySQL library is installed in order to set the default value of NEED_MYSQL.




HAVE_SQLITE

The Makefile tries to figure out automatically if the sqlite library is installed in order to set the default value of NEED_SQLITE.




HAVE_ODBC

ODBC (Open DataBase Connectivity) is a standard database access method. In MIDAS, it may be used in the History system (see MIDAS SQL History system ). The Makefile will automatically include ODBC (HAVE_ODBC = 1) if the file /usr/include/sql.h is found. Otherwise ODBC will not be included.




NEED_MSCB

By default, optional MSCB (MIDAS Slow Control Bus) support for mhttpd is included.




MIDAS_MAX_EVENT_SIZE

By default the MIDAS package is build with the maximum event size set to 4MB (MAX_EVENT_SIZE/midas.h). This parameter is used for event transfer across network as well, therefore it has to be applied to all the MIDAS client involved in the experiment when different value is required and a complete MIDAS rebuid needs to be done.

> setenv MIDAS_MAX_EVENT_SIZE 8000000
> make
cc -c -g -O3 -Wall -Wuninitialized -Iinclude -Idrivers -I../mxml -Llinux/lib -DINCLUDE_FTPLIB  \
-DMAX_EVENT_SIZE=800000 -D_LARGEFILE64_SOURCE -DHAVE_MYSQL -I/usr/include/mysql -DHAVE_ROOT -pthread \
-m64 -I/triumfcs/trshare/olchansk/root/root_v5.12.00_SL42_amd64/include -DHAVE_ZLIB -DOS_LINUX -fPIC \
-Wno-unused-function -o linux/lib/midas.o src/midas.c
 ...

But at the frontend level, the user can define his/her own local maximum event size through the max_event_size (see frontend examples).




SPECIFIC_OS_PRG

This flag is for internal Makefile preference. Used in particular for additional applications build based on the OS selection. In the example below mspeaker and dio utilities are built only under OS_LINUX.

  • SPECIFIC_OS_PRG = $(BIN_DIR)/mlxspeaker $(BIN_DIR)/dio




NEED_LIBROOTA

This option if set links MIDAS with the static ROOT library. By default this option is disabled. To link with the static ROOT library,

  • make ... NEED_LIBROOTA=1




NEED_ZLIB

If data compression is required by the data logger, the MIDAS package must be compiled with ZLIB support. The applications lazylogger, mdump can be built with zlib.a in order to gain direct access to the data within a file with extension mid.gz. By default this option is disabled except for the system analyzer core code mana.c. However, if NEED_MYSQL is set, NEED_ZLIB will also be set.




NEED_RPATH

Option to set the shared library path on MIDAS executables. By default this option is enabled for Linux, disabled for MacOSX/Darwin.




NEED_STRLCPY

Option to use our own implementation of strlcat and strlcpy. By default this option is enabled.