option to linearize V0 response
[u/mrichter/AliRoot.git] / cmake / CMakeDA.cmake
CommitLineData
0a8abcad 1#--------------------------------------------------------------------
2# CMakeDA.cmake file for AliRoot Build System
3#
4# Author: Anshul Goel (anshul.goel@cern.ch)
5# Port of previous Makefile build to DAQ targets and RPM
6#
7
6b06712c 8cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
6db31708 9
10# -----------Utilities--------------------
11
12#list of detectors
d54ad8d4 13#set(ONLINEDETECTORS T00)
14set(ONLINEDETECTORS SPD SDD SSD ACO GRP TST HLT EMC TRI T00 PMD CPV PHS FMD TPC TRD ZDC V00 MTR MCH HMP TOF)
45526b5e 15function(expand output input)
16 string(REGEX MATCH "\\\${[^}]*}" m "${input}")
17 while(m)
18 string(REGEX REPLACE "\\\${(.*)}" "\\1" v "${m}")
19 string(REPLACE "\${${v}}" "${${v}}" input "${input}")
20 string(REGEX MATCH "\\\${[^}]*}" m "${input}")
21 endwhile()
22 set("${output}" "${input}" PARENT_SCOPE)
23endfunction()
24
6db31708 25#function to get module for detector
26function (detector_module _module detector)
27 #Map of online detectors to DA in pairs of ONLINEDETECTORNAME DAMODULE
28 set (DETECTORMODULEMAP SPD ITS SDD ITS SSD ITS HMP HMPID PHS PHOS CPV PHOS MCH MUON MTR MUON T00 T0 V00 VZERO ACO ACORDE EMC EMCAL)
29 list(FIND DETECTORMODULEMAP ${detector} _index)
30 if(_index STREQUAL "-1")
31 set(${_module} "${detector}" PARENT_SCOPE)
32 else()
33 math(EXPR _index "${_index}+1")
34 list(GET DETECTORMODULEMAP ${_index} _index)
35 set(${_module} ${_index} PARENT_SCOPE)
36 endif(_index STREQUAL "-1")
37endfunction()
38
39#function to get subDA for detector
40function (detector_subda _subda detector)
41 #Map of online detectors to SUBDAMODULE in pairs of ONLINEDETECTORNAME SUBDAMODULE
42 set (DETECTORSUBDAMAP SPD SPD SDD SDD SSD SSD CPV CPV MCH TRK MTR TRG)
43 list(FIND DETECTORSUBDAMAP ${detector} _index)
44 if(_index STREQUAL "-1")
45 set(${_subda} "" PARENT_SCOPE)
46 else()
47 math(EXPR _index "${_index}+1")
48 list(GET DETECTORSUBDAMAP ${_index} _index)
49 set(${_subda} ${_index} PARENT_SCOPE)
50 endif(_index STREQUAL "-1")
51endfunction()
52
53#function to extract info
54function (getinfo _info pattern file)
55 string(REGEX MATCH "${pattern}:[^\n]*" _match ${file})
56 if(_match)
57 string(REGEX REPLACE "${pattern}:[ ]*" "" _data ${_match})
6050a6e8 58 string(REPLACE "(" "\\(" _data "${_data}")
59 string(REPLACE ")" "\\)" _data "${_data}")
60 string(REPLACE "<" "\\<" _data "${_data}")
61 string(REPLACE ">" "\\>" _data "${_data}")
6db31708 62 endif(_match)
63 set(${_info} ${_data} PARENT_SCOPE)
64endfunction()
65
0a8abcad 66
67foreach(oldetect ${ONLINEDETECTORS})
68detector_module(h_module ${oldetect})
69list(APPEND mod "-I${ALICE_ROOT}/${h_module}")
70endforeach(oldetect ${ONLINEDETECTORS})
d54ad8d4 71list(APPEND mod "-I${ALICE_ROOT}/include" "-I${ALICE_ROOT}/STEER" "-I${ALICE_ROOT}/ANALYSIS" "-I${ALICE_ROOT}/RAW" "-I${ALICE_ROOT}/STEER/STEER" "-I${ALICE_ROOT}/STEER/CDB" "-I${ROOTSYS}/include" "-I${ALICE_ROOT}/STEER/STEERBase" "-I${ALICE_ROOT}/STEER/AOD" "-I${ALICE_ROOT}/STEER/ESD" "-I${ALICE_ROOT}/MUON/mapping" "-I$ENV{AMORE}/include/amore")
0a8abcad 72
6db31708 73# ----------Common stuff-------------------
74
75file(GLOB_RECURSE _dafiles $ENV{ALICE_ROOT}/*da.cxx)
9372fe67 76set(DAINSTALL "$ENV{ALICE_INSTALL}/DA")
6db31708 77
78file(MAKE_DIRECTORY ${DAINSTALL})
79
9372fe67 80string (REPLACE "-pedantic-errors" "" CXXFLAGS ${CXXFLAGS})
6db31708 81
6db31708 82find_program(XML2 xml2-config)
83
9372fe67 84if(AMORE_FOUND)
85 #Set compiler flags
86 set(CXXFLAGS "${CXXFLAGS} ${AMOREFLAGS}")
87 set(CFLAGS "${CFLAGS} ${AMOREFLAGS}")
88 set(CINTFLAGS "${CINTFLAGS} ${AMOREFLAGS}")
6db31708 89else()
90 set(AMORELIBS)
9372fe67 91endif(AMORE_FOUND)
6db31708 92
6db31708 93execute_process(COMMAND ${XML2} --libs OUTPUT_VARIABLE _xml2libs OUTPUT_STRIP_TRAILING_WHITESPACE)
9372fe67 94execute_process(COMMAND ${DATE_CONFIG} --monitorlibs=noshift OUTPUT_VARIABLE MONITORLIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
d54ad8d4 95execute_process(COMMAND $ENV{AMORE}/amore-config --ldflags-da-static OUTPUT_VARIABLE _amore1 OUTPUT_STRIP_TRAILING_WHITESPACE)
96execute_process(COMMAND date-config --rcproxylibs OUTPUT_VARIABLE _amore2 OUTPUT_STRIP_TRAILING_WHITESPACE)
97execute_process(COMMAND date-config --monitorlibs=noshift OUTPUT_VARIABLE _monitor1 OUTPUT_STRIP_TRAILING_WHITESPACE)
98string(REPLACE "\n" " " _amore1 "${_amore1}")
99set(AMOREDALIBS "-static ${_amore1} ${_amore2}")
100set(MONITORLIBS "${_monitor1}")
6db31708 101
9372fe67 102separate_arguments(MONITORLIBS)
d54ad8d4 103separate_arguments(AMOREDALIBS)
6db31708 104set(SYSLIBS -ldl -lpthread ${_xml2libs})
9372fe67 105
e74cf56b 106
6db31708 107set(EXTRAROOTLIB "libRootExtra.a")
d54ad8d4 108set(ROOTLIB "RootExtra")
6db31708 109file(GLOB _extraroot "$ENV{ROOTSYS}/montercarlo/vmc/src/*.o" "$ENV{ROOTSYS}/tree/treeplayer/src/*.o" "$ENV{ROOTSYS}/io/xmlparser/src/*.o" "$ENV{ROOTSYS}/math/minuit2/src/*.o")
9372fe67 110
d54ad8d4 111add_library(${ROOTLIB} STATIC ${_extraroot})
112set_target_properties(${ROOTLIB} PROPERTIES LINKER_LANGUAGE CXX)
e74cf56b 113
9372fe67 114set(DAQDALIB_PATH $ENV{DAQDALIB_PATH})
115if(DAQDALIB_PATH)
116 set(DAQDADIR "${DAQDALIB_PATH}")
117else()
118 set(DAQDADIR "$ENV{ALICE}/daqDAlib")
119endif(DAQDALIB_PATH)
120set(DAQDALIB "${DAQDADIR}/libdaqDA.a")
121
6050a6e8 122include_directories(${DAQDADIR} ${ALICE_ROOT}/RAW ${ALICE_ROOT}/include ${ALICE_ROOT}/STEER)
9372fe67 123include_directories(SYSTEM ${ROOTINCDIR})
124
6db31708 125# ----------Create All Valid targets---------
126
127foreach(detector ${ONLINEDETECTORS} )
6db31708 128
129 set(ONLINEDETECTORNAME ${detector})
9372fe67 130
6db31708 131 detector_module(DAMODULE ${ONLINEDETECTORNAME})
9372fe67 132
6db31708 133 detector_subda(SUBDAMODULE ${ONLINEDETECTORNAME})
45526b5e 134
135 #ALIROOTALIBS
9372fe67 136
45526b5e 137 set(ALIROOTALIBS)
d54ad8d4 138 set(BASIC_TARGET "daqDA-${ONLINEDETECTORNAME}-all")
139 add_custom_target(${BASIC_TARGET}
140 WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
141 )
142 set(BASIC_RPM "daqDA-${ONLINEDETECTORNAME}-all-rpm")
143 add_custom_target(${BASIC_RPM}
144 WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
145 )
146 list(APPEND ALIROOTALIBS RAWDatabase-static RAWDatarec-static RAWDatasim-static STEERBase-static STEER-static CDB-static ESD-static STAT-static AOD-static ANALYSIS-static ANALYSISalice-static )
45526b5e 147
148 expand(ALIROOTALIBS2 "\${${DAMODULE}ALIBS}")
149 expand(DAINCDIRS "\${${DAMODULE}INC}")
150 list(APPEND ALIROOTALIBS ${ALIROOTALIBS2})
151
45526b5e 152 include_directories(${DAMODULE} ${SUBDIR} ${DAINCDIRS})
6db31708 153#Get detector algorithms for this detector
9372fe67 154
6db31708 155 foreach(dafile ${_dafiles})
9372fe67 156
6db31708 157 string(REGEX MATCH "$ENV{ALICE_ROOT}/${DAMODULE}/${DAMODULE}${SUBDAMODULE}" match ${dafile})
158#Found a valid target name
159 if(match)
160 string(REGEX REPLACE "$ENV{ALICE_ROOT}/${DAMODULE}/${DAMODULE}${SUBDAMODULE}(.*)da\\.cxx" "\\1" DANAME ${dafile})
161#Check for default DA
162 if(DANAME)
163 set(DATARGETNAME "daqDA-${ONLINEDETECTORNAME}-${DANAME}")
d54ad8d4 164 else()
6db31708 165 set(DATARGETNAME "daqDA-${ONLINEDETECTORNAME}")
166 endif(DANAME)
d54ad8d4 167 add_dependencies(${BASIC_TARGET} ${DATARGETNAME})
168 add_dependencies(${BASIC_RPM} ${DATARGETNAME}-rpm)
169 set(DATARGETDIR "${DAINSTALL}/${DAMODULE}/tgt_$ENV{ALICE_TARGET}")
6db31708 170 file(MAKE_DIRECTORY ${DATARGETDIR})
0a8abcad 171 set(DAOBJ "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.o")
6db31708 172 set(DASRC "${DAMODULE}/${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx")
173 set(DALIB "${DAMODULE}${SUBDAMODULE}${DANAME}DA")
45526b5e 174 set(DAEXE "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe")
0a8abcad 175 set(DADEP "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.d")
6db31708 176 # DAVERSION
177 execute_process(COMMAND svn info $ENV{ALICE_ROOT}/${DASRC} OUTPUT_VARIABLE _daversion OUTPUT_STRIP_TRAILING_WHITESPACE)
178 string(REGEX REPLACE ".*Last Changed Rev: ([^\n]+)\n.*" "\\1" DAVERSION ${_daversion})
179
180 # DAROOTRELEASE
181 execute_process(COMMAND root-config --version OUTPUT_VARIABLE _darootrelease OUTPUT_STRIP_TRAILING_WHITESPACE)
182 string(REGEX REPLACE "/" "." DAROOTRELEASE ${_darootrelease})
183
184 # DAALIROOTRELEASE
185 string(REGEX REPLACE ".*URL: .*/(.+)/${DASRC}.*$" "\\1" DAALIROOTRELEASE ${_daversion})
7251bfcc 186 string (REPLACE "-" "." DAALIROOTRELEASE "${DAALIROOTRELEASE}")
6db31708 187
188 set(DAARCNAME "${DATARGETNAME}")
0a8abcad 189 string(REPLACE "-" "" DAARCNAME "${DAARCNAME}")
6db31708 190 set(DAARC "${DAARCNAME}-${DAVERSION}")
191 set(DATAR "${DATARGETDIR}/${DAARC}.src.tar.gz")
192 set(DASPECFILE "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.spec")
193 set(DAMAKEFILE "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.make")
6db31708 194
0a8abcad 195
6db31708 196 file(READ "$ENV{ALICE_ROOT}/${DASRC}" _dasrc)
197 getinfo(DACONTACT "Contact" ${_dasrc})
198 getinfo(DALINKPAGE "Link" ${_dasrc})
199 getinfo(DAREFRUN "Reference Run" ${_dasrc})
200 getinfo(DARUNTYPE "Run Type" ${_dasrc})
201 getinfo(DATYPE "DA Type" ${_dasrc})
202 getinfo(DANUMBEROFEVENTS "Number of events needed" ${_dasrc})
203 getinfo(DAINPUTFILES "Input Files" ${_dasrc})
204 getinfo(DAOUTPUTFILES "Output Files" ${_dasrc})
205 getinfo(DATRIGGERTYPE "Trigger types used" ${_dasrc})
206
207 if(NOT _dasrc)
208 message(FATAL_ERROR "SRC FILE MISSING")
209 endif(NOT _dasrc)
210
6db31708 211#----------- Targets ----------------------
212
45526b5e 213 set(CMAKE_CXX_FLAGS "${CXXFLAGS}")
214 set(CMAKE_C_FLAGS "${CFLAGS}")
9372fe67 215 set(CMAKE_Fortran_FLAGS ${FFLAGS})
6db31708 216 set(CMAKE_SHARED_LINKER_FLAGS ${SOFLAGS})
217 set(CMAKE_MODULE_LINKER_FLAGS ${LDFLAGS})
218
d54ad8d4 219add_dependencies(DA-all ${DATARGETNAME})
0a8abcad 220add_custom_target(${DATARGETNAME}
221WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
222)
223add_dependencies(${DATARGETNAME} ${DAEXE})
224
225set(ZIP)
226foreach(_lib ${ALIROOTALIBS})
227string(REGEX REPLACE "-static" "" _lib ${_lib})
228list(APPEND ZIP && ar x "../lib${_lib}.a")
229endforeach(_lib)
230list (APPEND ZIP && ar r "../lib${DALIB}.a" "*.o")
231
232add_custom_target(${DALIB}.a
233COMMAND rm -rf junk${DAEXE} && mkdir -p junk${DAEXE}
234COMMAND cd junk${DAEXE} ${ZIP}
235COMMAND cd ../ && rm -rf junk${DAEXE}
236DEPENDS ${ALIROOTALIBS}
237WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
238)
239
240add_custom_command(
241TARGET ${DATARGETNAME}-clean
242COMMAND echo "***** Cleaning ${DAMODULE} ${SUBDAMODULE} ${DANAME} detector-algorithm *****"
243COMMAND rm -f ${DASPECFILE}
244COMMAND rm -f ${DATAR}
245COMMAND rm -f ${DAEXE}
246COMMAND rm -f ${DAOBJ}
247COMMAND rm -f ${DADEP}
248COMMAND rm -f ${DAMAKEFILE}
249COMMAND rm -f ${DALIB}.a
250COMMAND rm -f ${ALIROOTALIBS}
251COMMAND rm -f ${EXTRAROOTLIB}
252)
253
d54ad8d4 254separate_arguments(SYSLIBS)
255#execute_process(COMMAND ${AMORE}/amore-config --ldflags-da-static | tr "\n" " " OUTPUT_VARIABLE _amore1 OUTPUT_STRIP_TRAILING_WHITESPACE)
256#execute_process(COMMAND date-config --rcproxylibs OUTPUT_VARIABLE _amore2 OUTPUT_STRIP_TRAILING_WHITESPACE)
257#execute_process(COMMAND date-config --monitorlibs=noshift OUTPUT_VARIABLE _monitor1 OUTPUT_STRIP_TRAILING_WHITESPACE)
258
259#set(AMOREDALIBS "-static ${_amore1} ${_amore2}\\")
260#set(MONITORLIBS "${_monitor1}\\")
0a8abcad 261
262add_custom_target(DAMAKEFILE_${DAEXE}_)
263add_custom_command(
264TARGET DAMAKEFILE_${DAEXE}_
265COMMAND rm -f ${DAMAKEFILE}
266COMMAND @echo "***** Making makefile ${DAMAKEFILE} *****"
267COMMAND @echo '\#***************************************************' >> ${DAMAKEFILE}
268COMMAND @echo '\# Makefile for Detector Algorithm' >> ${DAMAKEFILE}
269COMMAND @echo '\#' >> ${DAMAKEFILE}
270COMMAND @echo '\# It is necessary to setup build environment before' >> ${DAMAKEFILE}
271COMMAND @echo '\# using make:' >> ${DAMAKEFILE}
272COMMAND @echo '\# - define path to daqDAlib (env. DAQDALIB_PATH)' >> ${DAMAKEFILE}
273COMMAND @echo '\#' >> ${DAMAKEFILE}
274COMMAND @echo '\#*****************************************************' >> ${DAMAKEFILE}
275COMMAND @echo "" >> ${DAMAKEFILE}
276COMMAND @echo "CXX=g++" >> ${DAMAKEFILE}
277COMMAND @echo "LD=g++" >> ${DAMAKEFILE}
278COMMAND @echo "" >> ${DAMAKEFILE}
279COMMAND @echo "CXXFLAGS=${CXXFLAGS}" >> ${DAMAKEFILE}
280COMMAND @echo "LDFLAGS=${LDFLAGS}" >> ${DAMAKEFILE}
281COMMAND @echo "" >> ${DAMAKEFILE}
282COMMAND @echo 'ifeq ($$(DAQDALIB_PATH),)' >> ${DAMAKEFILE}
283COMMAND @echo "DAQDADIR=${ALICE}/daqDAlib" >> ${DAMAKEFILE}
284COMMAND @echo "else" >> ${DAMAKEFILE}
285COMMAND @echo 'DAQDADIR=$$(DAQDALIB_PATH)' >> ${DAMAKEFILE}
286COMMAND @echo "endif" >> ${DAMAKEFILE}
287COMMAND @echo "" >> ${DAMAKEFILE}
288COMMAND @echo 'DAQDALIB=$$(DAQDADIR)/libdaqDA.a' >> ${DAMAKEFILE}
d54ad8d4 289#COMMAND @echo 'AMOREDALIBS=-static $$(shell $$(AMORE)/amore-config --ldflags-da-static) $$(shell date-config --rcproxylibs)' >> ${DAMAKEFILE}
290#COMMAND @echo 'MONITORLIBS=$$(shell date-config --monitorlibs=noshift)' >> ${DAMAKEFILE}
291#COMMAND @echo 'AMOREDALIBS=-static ${_amore1} ${_amore2}' >> ${DAMAKEFILE}
292#COMMAND @echo 'MONITORLIBS=${monitor1}' >> ${DAMAKEFILE}
0a8abcad 293COMMAND @echo "" >> ${DAMAKEFILE}
294COMMAND @echo "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe: ${DAMODULE}${SUBDAMODULE}${DANAME}da.o" >> ${DAMAKEFILE}
d54ad8d4 295COMMAND @echo -e '\t$$(LD) $$(LDFLAGS) -o ''$$''@ ''$$''< ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${DALIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EXTRAROOTLIB} $$(ROOTSYS)/lib/libRoot.a $$(ROOTSYS)/lib/libfreetype.a $$(ROOTSYS)/lib/libpcre.a ${SYSLIBS} $$(DAQDALIB) ${AMOREDALIBS} ${MONITORLIBS}' >> ${DAMAKEFILE}
0a8abcad 296COMMAND @echo "" >> ${DAMAKEFILE}
297COMMAND @echo "${DAMODULE}${SUBDAMODULE}${DANAME}da.o: ${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx" >> ${DAMAKEFILE}
d54ad8d4 298COMMAND @echo -e '\t$$(CXX) -c $$(CXXFLAGS) -I$$(DAQDADIR) ${mod} ''$$''< -o ''$$''@' >> ${DAMAKEFILE}
0a8abcad 299COMMAND @echo "" >> ${DAMAKEFILE}
300COMMAND @echo "clean:" >> ${DAMAKEFILE}
d54ad8d4 301COMMAND @echo -e '\t@rm -f ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe ${DAMODULE}${SUBDAMODULE}${DANAME}da.o' >> ${DAMAKEFILE}
0a8abcad 302COMMAND @echo "" >> ${DAMAKEFILE}
303COMMAND @echo "install: ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe" >> ${DAMAKEFILE}
d54ad8d4 304COMMAND @echo -e '\tif [ $$(INSTALL_PATH) == '' ]; then \\' >> ${DAMAKEFILE}
305COMMAND @echo -e '\techo Environment variable INSTALL_PATH undefined, cannot continue\; \\' >> ${DAMAKEFILE}
306COMMAND @echo -e '\texit 1\; \\' >> ${DAMAKEFILE}
307COMMAND @echo -e '\tfi' >> ${DAMAKEFILE}
308COMMAND @echo -e '\t@cp -p ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe $$(INSTALL_PATH)' >> ${DAMAKEFILE}
0a8abcad 309)
310
311add_custom_target(DATAR_${DAEXE}_)
312add_custom_command(
313TARGET DATAR_${DAEXE}_
314COMMAND @echo "***** Making archive ${DATAR} *****"
315COMMAND rm -rf ${DATAR}
316COMMAND rm -rf junk
317COMMAND mkdir junk && mkdir junk/${DAARC}
318COMMAND cp -a ${ALICE_ROOT}/${DASRC} junk/${DAARC}
319COMMAND cp -a ${DAMAKEFILE} junk/${DAARC}/Makefile
320COMMAND cp -a ${DASPECFILE} junk/${DAARC}/${DAMODULE}${SUBDAMODULE}${DANAME}da.spec
321COMMAND cd junk && tar czf ${DATAR} *
322COMMAND cd .. && rm -rf junk
323)
324add_dependencies(DATAR_${DAEXE}_ DAMAKEFILE_${DAEXE}_ DASPECFILE_${DAEXE}_ ${DASRC})
325
326add_custom_target(DASPECFILE_${DAEXE}_)
327
328add_custom_command(
329TARGET DASPECFILE_${DAEXE}_
330COMMAND rm -f ${DASPECFILE}
331COMMAND @echo "***** Making RPM spec-file ${DASPECFILE} *****"
332COMMAND @echo '\# RPM specfile for $(DAMODULE)${SUBDAMODULE}$(DANAME) Detector Algorithm' >> ${DASPECFILE}
333COMMAND @echo "Summary: ${ONLINEDETECTORNAME} Detector Algorithm" >> ${DASPECFILE}
334COMMAND @echo "Name: ${DAARCNAME}" >> ${DASPECFILE}
335COMMAND @echo "Version: ${DAVERSION}" >> ${DASPECFILE}
336COMMAND @echo "Release: ${DAALIROOTRELEASE}" >> ${DASPECFILE}
337COMMAND @echo "License: CERN Alice DAQ/Offine" >> ${DASPECFILE}
338COMMAND @echo "Source: %{name}-%{version}.src.tar.gz" >> ${DASPECFILE}
339COMMAND @echo "Group: Applications/Alice" >> ${DASPECFILE}
340COMMAND @echo "Prefix: /opt/%{name}" >> ${DASPECFILE}
341COMMAND @echo "BuildRoot: %{_tmppath}/%{name}-root" >> ${DASPECFILE}
342COMMAND @echo "" >> ${DASPECFILE}
343COMMAND @echo '\# automatic dependencies' >> ${DASPECFILE}
344COMMAND @echo "AutoReqProv: yes" >> ${DASPECFILE}
345COMMAND @echo "" >> ${DASPECFILE}
346COMMAND @echo '\# list here required RPM packages for compilation' >> ${DASPECFILE}
347COMMAND @echo "BuildRequires: date" >> ${DASPECFILE}
348COMMAND @echo "" >> ${DASPECFILE}
349COMMAND @echo '\# list here required RPM packages for runtime' >> ${DASPECFILE}
350COMMAND @echo "Requires: date" >> ${DASPECFILE}
351COMMAND @echo "" >> ${DASPECFILE}
352COMMAND @echo '\# You can specify other dependencies in the description tag below.' >> ${DASPECFILE}
353COMMAND @echo "" >> ${DASPECFILE}
354COMMAND @echo '\# description of the package' >> ${DASPECFILE}
355COMMAND @echo "%description" >> ${DASPECFILE}
356COMMAND @echo "This is the ${ONLINEDETECTORNAME} ${DANAME} DA for online calibration." >> ${DASPECFILE}
357COMMAND @echo "It uses data from ${DAMODULE} detectors at run time." >> ${DASPECFILE}
358COMMAND @echo "Build requires: daqDAlib, date, AliRoot ${DAALIROOTRELEASE},ROOT ${DAROOTRELEASE}." >> ${DASPECFILE}
359COMMAND @echo "Runtime requires: date." >> ${DASPECFILE}
6050a6e8 360COMMAND @echo "Contact: ${DACONTACT}" >> ${DASPECFILE}
361COMMAND @echo "Link: ${DALINKPAGE}" >> ${DASPECFILE}
362COMMAND @echo "Reference Run: ${DAREFRUN}" >> ${DASPECFILE}
363COMMAND @echo "Run type: ${DARUNTYPE}" >> ${DASPECFILE}
364COMMAND @echo "DA type: ${DATYPE}" >> ${DASPECFILE}
365COMMAND @echo "Number of events needed: ${DANUMBEROFEVENTS}" >> ${DASPECFILE}
366COMMAND @echo "Input files: ${DAINPUTFILES}" >> ${DASPECFILE}
367COMMAND @echo "Output files: ${DAOUTPUTFILES}" >> ${DASPECFILE}
368COMMAND @echo "Trigger types used: ${DATRIGGERTYPE}" >> ${DASPECFILE}
0a8abcad 369COMMAND @echo "" >> ${DASPECFILE}
370COMMAND @echo '\#*****************************************************************' >> ${DASPECFILE}
371COMMAND @echo '\# Do not modify following scripts' >> ${DASPECFILE}
372COMMAND @echo '\#*****************************************************************' >> ${DASPECFILE}
373COMMAND @echo "" >> ${DASPECFILE}
374COMMAND @echo "%define debug_package %{nil}" >> ${DASPECFILE}
375COMMAND @echo "%define __os_install_post %{nil}" >> ${DASPECFILE}
376COMMAND @echo "" >> ${DASPECFILE}
377COMMAND @echo '\# here is defined the installation root directory' >> ${DASPECFILE}
378COMMAND @echo "%define pkgname %{name}-%{version}" >> ${DASPECFILE}
379COMMAND @echo "%define destdir %{prefix}" >> ${DASPECFILE}
380COMMAND @echo "" >> ${DASPECFILE}
381COMMAND @echo '\# pre-compilation script: extract from tarball' >> ${DASPECFILE}
382COMMAND @echo "%prep" >> ${DASPECFILE}
383COMMAND @echo '\# extract archive' >> ${DASPECFILE}
384COMMAND @echo "%setup -n %{pkgname}" >> ${DASPECFILE}
385COMMAND @echo "" >> ${DASPECFILE}
386COMMAND @echo '\# compile' >> ${DASPECFILE}
387COMMAND @echo "%build" >> ${DASPECFILE}
388COMMAND @echo "export DATE_SITE=" >> ${DASPECFILE}
389COMMAND @echo ". /date/setup.sh" >> ${DASPECFILE}
390COMMAND @echo "gmake" >> ${DASPECFILE}
391COMMAND @echo "" >> ${DASPECFILE}
392COMMAND @echo '\# install runtime files' >> ${DASPECFILE}
393COMMAND @echo "%install" >> ${DASPECFILE}
394COMMAND @echo '\#remove install dir if existing' >> ${DASPECFILE}
395COMMAND echo '[ -d ''$$''RPM_BUILD_ROOT ] && rm -rf ''$$''RPM_BUILD_ROOT' >> ${DASPECFILE}
396COMMAND @echo '\#make install in install root directory' >> ${DASPECFILE}
d54ad8d4 397COMMAND @echo 'mkdir -p ''$$''RPM_BUILD_ROOT%{prefix}' >> ${DASPECFILE}
398COMMAND @echo 'make install INSTALL_PATH=''$$''RPM_BUILD_ROOT%{prefix}' >> ${DASPECFILE}
0a8abcad 399COMMAND @echo "" >> ${DASPECFILE}
400COMMAND @echo '\# clean RPM build files' >> ${DASPECFILE}
401COMMAND @echo "%clean" >> ${DASPECFILE}
402COMMAND @echo '\# remove installed files' >> ${DASPECFILE}
403COMMAND @echo 'rm -rf ''$$''RPM_BUILD_ROOT' >> ${DASPECFILE}
404COMMAND @echo '\# remove source files' >> ${DASPECFILE}
405COMMAND @echo 'rm -rf ''$$''RPM_BUILD_DIR/%{pkgname}' >> ${DASPECFILE}
406COMMAND @echo "" >> ${DASPECFILE}
407COMMAND @echo '\# pre-install script' >> ${DASPECFILE}
408COMMAND @echo "%pre" >> ${DASPECFILE}
409COMMAND @echo "" >> ${DASPECFILE}
410COMMAND @echo '\# list of files to be installed' >> ${DASPECFILE}
411COMMAND @echo "%files" >> ${DASPECFILE}
412COMMAND @echo '%defattr (-,root,root)' >> ${DASPECFILE}
413COMMAND @echo "%{destdir}" >> ${DASPECFILE}
414COMMAND @echo "" >> ${DASPECFILE}
415COMMAND @echo '\# post-install script' >> ${DASPECFILE}
416COMMAND @echo '\# launched after rpm installed' >> ${DASPECFILE}
417COMMAND @echo "%post" >> ${DASPECFILE}
418COMMAND @echo "" >> ${DASPECFILE}
419COMMAND @echo '\# post-uninstall script' >> ${DASPECFILE}
420COMMAND @echo '\# launched after rpm removed' >> ${DASPECFILE}
421COMMAND @echo "%postun" >> ${DASPECFILE}
422)
423
d54ad8d4 424
0a8abcad 425add_custom_target( ${DATARGETNAME}-rpm
426)
d54ad8d4 427add_dependencies(${DATARGETNAME}-rpm DATAR_${DAEXE}_ DASPECFILE_${DAEXE}_ ${LIBPATH} ${DALIB}.a DADEP_${DAEXE}_ ${ROOTLIB}
0a8abcad 428)
d54ad8d4 429add_custom_command(TARGET ${DATARGETNAME}-rpm
430COMMAND mkdir -p ${CMAKE_BINARY_DIR}/junk/SOURCES ${CMAKE_BINARY_DIR}/junk/SPECS ${CMAKE_BINARY_DIR}/junk/BUILD ${CMAKE_BINARY_DIR}/junk/RPMS ${CMAKE_BINARY_DIR}/junk/SRPMS
431COMMAND cp ${DATAR} ${CMAKE_BINARY_DIR}/junk/SOURCES
432COMMAND rpmbuild --verbose --define "_topdir ${CMAKE_BINARY_DIR}/junk" --nodeps -bb ${DASPECFILE}
433COMMAND cp -p `find ${CMAKE_BINARY_DIR}/junk/ -name "${DAARC}-*.rpm"` . ;
0a8abcad 434COMMAND rm -rf junk
d54ad8d4 435COMMAND echo "***** RPMS created and put ${CMAKE_BINARY_DIR} folder *****"
436WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0a8abcad 437)
438
439
440add_custom_target(${DAEXE}
441COMMAND echo "***** Making executable ${DAEXE} *****"
442WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
443)
444target_link_libraries(${DAEXE} "-L" "lib${DALIB}.a" ${DAOBJ} ${EXTRAROOTLIB} "${ROOTALIBDIR}/libRoot.a" "${ROOTALIBDIR}/libfreetype.a" "${ROOTALIBDIR}/libpcre.a" ${SYSLIBS} ${DAQDALIB} ${MONITORLIBS} ${AMOREDALIBS})
445
d54ad8d4 446add_dependencies(${DAEXE} ${DASRC} DAOBJ_${DAEXE}_ ${BINPATH} ${LIBPATH} ${DALIB}.a ${DAQDALIB} ${ROOTLIB})
0a8abcad 447
448add_custom_target(DAOBJ_${DAEXE}_
449)
450add_custom_command(
451TARGET DAOBJ_${DAEXE}_
452COMMAND echo "***** Compiling ${DASRC} *****"
6050a6e8 453COMMAND g++ -c -DLinux -DDATE_SYS=Linux -Dlong32="int" -Dlong64="long long" -DdatePointer="long" -I/date/rorc -I/date/runControl -I/date/readList -I/date/eventBuilder -I/date/banksManager -I/date/bufferManager -I/date/db -I/date/commonDefs -I/date/monitoring -I/date/infoLogger -I/date/logbook -I${DAQDADIR} -I${ALICE_ROOT}/RAW -I${CMAKE_BINARY_DIR}/include -I$ENV{ROOTSYS}/include ${mod} ${date_head} ${ALICE_ROOT}/${DASRC} -o ${DAOBJ}
0a8abcad 454WORKING_DIRECTORY ${ALICE_ROOT}
455)
456add_dependencies(DAOBJ_${DAEXE}_ DADEP_${DAEXE}_ )
457
458
459
460add_custom_target(DADEP_${DAEXE}_)
461add_custom_command(
462TARGET DADEP_${DAEXE}_
463COMMAND echo "***** Making detector-algorithm dependencies ${DADEP} *****"
464COMMAND g++ -MM -DLinux -DDATE_SYS=Linux -Dlong32="int" -Dlong64="long long" -DdatePointer="long" -I/date/rorc -I/date/runControl -I/date/readList -I/date/eventBuilder -I/date/banksManager -I/date/bufferManager -I/date/db -I/date/commonDefs -I/date/monitoring -I/date/infoLogger -I/date/logbook -I${DAQDADIR} -I${ALICE_ROOT}/RAW -I${CMAKE_BINARY_DIR}/include -I$ENV{ROOTSYS}/include ${mod} ${date_head} ${ALICE_ROOT}/${DASRC} > ${DADEP}
465WORKING_DIRECTORY ${ALICE_ROOT}
466)
467
468
0a8abcad 469add_custom_command(TARGET clean
470COMMAND rm -rf junk*.exe
471WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
6050a6e8 472
45526b5e 473
6db31708 474 endif(match)
475 endforeach(dafile)
476endforeach(detector)