Compilation & Build

From MidasWiki
Revision as of 18:11, 15 August 2013 by Suz (talk | contribs) (Created page with "== Introduction == This section covers the various options available for customization of the MIDAS data acquisition system. The options fall into the following categories: * ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


This section covers the various options available for customization of the MIDAS data acquisition system. The options fall into the following categories:

  • MIDAS Environment Variables
  • Makefile Options
  • Building Options

MIDAS 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.


This environmental variable is required. It should point to the main path of the installed MIDAS package,e.g.

   setenv MIDASSYS $HOME/packages/midas  

The application odbedit will generate a warning message unless this variable is defined.


This variable specifies the location of the optional exptab file containing the predefined MIDAS experiments, e.g.

setenv 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 ).


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 if defined. This variable is valid for Unix as well as Windows OS.


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 if defined. This variable is valid for Unix as well as Windows OS.


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 and #MIDAS_EXPT_NAME environment variables.


   If you wish to use the exptab file to define multiple experiments on a single host, do not define MIDAS_DIR. 


This variable must point to the ROOT package if generating a complete MIDAS/ROOT analyzer application (see Environment Variables ). If not using ROOT, ROOTSYS should be undefined.


In case of HBOOK/PAW analyzer application, this variable should be pointing to a valid cernpacklib.a library. See HAVE_HBOOK .


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.


This variable is used for the old mchart utility.

Makefile Options

  • "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 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).


Other flags are available at the application level:


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

   > make static

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.

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

The current OS support is done through a fixed flag established in the general Makefile . Currently the OS supported are:

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

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

Other OS supported are:

  • OS_WINNT : See file makefile.nt.


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

make USERFLAGS=-static linux/bin/mstat


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.


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


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.


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.


This flag enable the CAMAC RPC service within the frontend code.

   The application mcnaf utility and
   the web CNAF page (in versions prior to Dec 2009 )

are by default not CAMAC enabled (i.e. HAVE_CAMAC is undefined).


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).

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
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
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.
Option to set the shared library path on MIDAS executables. By default this option is enabled for Linux, disabled for MacOSX/Darwin.
Option to use our own implementation of strlcat and strlcpy. By default this option is enabled.