Compilation & Build
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.