Chambers occupancy stored in the ESDs, it has been packed with the reconstructed...
[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)
769f99cf 76set (DAINSTALL "$ENV{ALICE_INSTALL}/DA")
77if(DAINSTALL STREQUAL "/DA")
78 set(DAINSTALL "$ENV{ALICE_ROOT}/DA")
79endif(DAINSTALL STREQUAL "/DA")
80
6db31708 81
82file(MAKE_DIRECTORY ${DAINSTALL})
83
9372fe67 84string (REPLACE "-pedantic-errors" "" CXXFLAGS ${CXXFLAGS})
6db31708 85
6db31708 86find_program(XML2 xml2-config)
87
9372fe67 88if(AMORE_FOUND)
89 #Set compiler flags
90 set(CXXFLAGS "${CXXFLAGS} ${AMOREFLAGS}")
91 set(CFLAGS "${CFLAGS} ${AMOREFLAGS}")
92 set(CINTFLAGS "${CINTFLAGS} ${AMOREFLAGS}")
6db31708 93else()
94 set(AMORELIBS)
9372fe67 95endif(AMORE_FOUND)
6db31708 96
6db31708 97execute_process(COMMAND ${XML2} --libs OUTPUT_VARIABLE _xml2libs OUTPUT_STRIP_TRAILING_WHITESPACE)
9372fe67 98execute_process(COMMAND ${DATE_CONFIG} --monitorlibs=noshift OUTPUT_VARIABLE MONITORLIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
d54ad8d4 99execute_process(COMMAND $ENV{AMORE}/amore-config --ldflags-da-static OUTPUT_VARIABLE _amore1 OUTPUT_STRIP_TRAILING_WHITESPACE)
100execute_process(COMMAND date-config --rcproxylibs OUTPUT_VARIABLE _amore2 OUTPUT_STRIP_TRAILING_WHITESPACE)
101execute_process(COMMAND date-config --monitorlibs=noshift OUTPUT_VARIABLE _monitor1 OUTPUT_STRIP_TRAILING_WHITESPACE)
102string(REPLACE "\n" " " _amore1 "${_amore1}")
103set(AMOREDALIBS "-static ${_amore1} ${_amore2}")
104set(MONITORLIBS "${_monitor1}")
6db31708 105
9372fe67 106separate_arguments(MONITORLIBS)
d54ad8d4 107separate_arguments(AMOREDALIBS)
6db31708 108set(SYSLIBS -ldl -lpthread ${_xml2libs})
9372fe67 109
e74cf56b 110
6db31708 111set(EXTRAROOTLIB "libRootExtra.a")
d54ad8d4 112set(ROOTLIB "RootExtra")
6db31708 113file(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 114
d54ad8d4 115add_library(${ROOTLIB} STATIC ${_extraroot})
116set_target_properties(${ROOTLIB} PROPERTIES LINKER_LANGUAGE CXX)
e74cf56b 117
9372fe67 118set(DAQDALIB_PATH $ENV{DAQDALIB_PATH})
119if(DAQDALIB_PATH)
120 set(DAQDADIR "${DAQDALIB_PATH}")
121else()
122 set(DAQDADIR "$ENV{ALICE}/daqDAlib")
123endif(DAQDALIB_PATH)
124set(DAQDALIB "${DAQDADIR}/libdaqDA.a")
125
6050a6e8 126include_directories(${DAQDADIR} ${ALICE_ROOT}/RAW ${ALICE_ROOT}/include ${ALICE_ROOT}/STEER)
9372fe67 127include_directories(SYSTEM ${ROOTINCDIR})
128
6db31708 129# ----------Create All Valid targets---------
130
131foreach(detector ${ONLINEDETECTORS} )
6db31708 132
133 set(ONLINEDETECTORNAME ${detector})
9372fe67 134
6db31708 135 detector_module(DAMODULE ${ONLINEDETECTORNAME})
9372fe67 136
6db31708 137 detector_subda(SUBDAMODULE ${ONLINEDETECTORNAME})
45526b5e 138
139 #ALIROOTALIBS
9372fe67 140
45526b5e 141 set(ALIROOTALIBS)
d54ad8d4 142 set(BASIC_TARGET "daqDA-${ONLINEDETECTORNAME}-all")
143 add_custom_target(${BASIC_TARGET}
144 WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
145 )
146 set(BASIC_RPM "daqDA-${ONLINEDETECTORNAME}-all-rpm")
147 add_custom_target(${BASIC_RPM}
148 WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
149 )
150 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 151
152 expand(ALIROOTALIBS2 "\${${DAMODULE}ALIBS}")
153 expand(DAINCDIRS "\${${DAMODULE}INC}")
154 list(APPEND ALIROOTALIBS ${ALIROOTALIBS2})
155
45526b5e 156 include_directories(${DAMODULE} ${SUBDIR} ${DAINCDIRS})
6db31708 157#Get detector algorithms for this detector
9372fe67 158
6db31708 159 foreach(dafile ${_dafiles})
9372fe67 160
6db31708 161 string(REGEX MATCH "$ENV{ALICE_ROOT}/${DAMODULE}/${DAMODULE}${SUBDAMODULE}" match ${dafile})
162#Found a valid target name
163 if(match)
164 string(REGEX REPLACE "$ENV{ALICE_ROOT}/${DAMODULE}/${DAMODULE}${SUBDAMODULE}(.*)da\\.cxx" "\\1" DANAME ${dafile})
165#Check for default DA
166 if(DANAME)
167 set(DATARGETNAME "daqDA-${ONLINEDETECTORNAME}-${DANAME}")
d54ad8d4 168 else()
6db31708 169 set(DATARGETNAME "daqDA-${ONLINEDETECTORNAME}")
170 endif(DANAME)
d54ad8d4 171 add_dependencies(${BASIC_TARGET} ${DATARGETNAME})
172 add_dependencies(${BASIC_RPM} ${DATARGETNAME}-rpm)
173 set(DATARGETDIR "${DAINSTALL}/${DAMODULE}/tgt_$ENV{ALICE_TARGET}")
6db31708 174 file(MAKE_DIRECTORY ${DATARGETDIR})
0a8abcad 175 set(DAOBJ "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.o")
6db31708 176 set(DASRC "${DAMODULE}/${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx")
177 set(DALIB "${DAMODULE}${SUBDAMODULE}${DANAME}DA")
45526b5e 178 set(DAEXE "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe")
0a8abcad 179 set(DADEP "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.d")
6db31708 180 # DAVERSION
181 execute_process(COMMAND svn info $ENV{ALICE_ROOT}/${DASRC} OUTPUT_VARIABLE _daversion OUTPUT_STRIP_TRAILING_WHITESPACE)
182 string(REGEX REPLACE ".*Last Changed Rev: ([^\n]+)\n.*" "\\1" DAVERSION ${_daversion})
183
184 # DAROOTRELEASE
185 execute_process(COMMAND root-config --version OUTPUT_VARIABLE _darootrelease OUTPUT_STRIP_TRAILING_WHITESPACE)
186 string(REGEX REPLACE "/" "." DAROOTRELEASE ${_darootrelease})
187
188 # DAALIROOTRELEASE
189 string(REGEX REPLACE ".*URL: .*/(.+)/${DASRC}.*$" "\\1" DAALIROOTRELEASE ${_daversion})
7251bfcc 190 string (REPLACE "-" "." DAALIROOTRELEASE "${DAALIROOTRELEASE}")
6db31708 191
192 set(DAARCNAME "${DATARGETNAME}")
0a8abcad 193 string(REPLACE "-" "" DAARCNAME "${DAARCNAME}")
6db31708 194 set(DAARC "${DAARCNAME}-${DAVERSION}")
195 set(DATAR "${DATARGETDIR}/${DAARC}.src.tar.gz")
196 set(DASPECFILE "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.spec")
197 set(DAMAKEFILE "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.make")
6db31708 198
0a8abcad 199
6db31708 200 file(READ "$ENV{ALICE_ROOT}/${DASRC}" _dasrc)
201 getinfo(DACONTACT "Contact" ${_dasrc})
202 getinfo(DALINKPAGE "Link" ${_dasrc})
203 getinfo(DAREFRUN "Reference Run" ${_dasrc})
204 getinfo(DARUNTYPE "Run Type" ${_dasrc})
205 getinfo(DATYPE "DA Type" ${_dasrc})
206 getinfo(DANUMBEROFEVENTS "Number of events needed" ${_dasrc})
207 getinfo(DAINPUTFILES "Input Files" ${_dasrc})
208 getinfo(DAOUTPUTFILES "Output Files" ${_dasrc})
209 getinfo(DATRIGGERTYPE "Trigger types used" ${_dasrc})
210
211 if(NOT _dasrc)
212 message(FATAL_ERROR "SRC FILE MISSING")
213 endif(NOT _dasrc)
214
6db31708 215#----------- Targets ----------------------
216
45526b5e 217 set(CMAKE_CXX_FLAGS "${CXXFLAGS}")
218 set(CMAKE_C_FLAGS "${CFLAGS}")
9372fe67 219 set(CMAKE_Fortran_FLAGS ${FFLAGS})
6db31708 220 set(CMAKE_SHARED_LINKER_FLAGS ${SOFLAGS})
221 set(CMAKE_MODULE_LINKER_FLAGS ${LDFLAGS})
222
d54ad8d4 223add_dependencies(DA-all ${DATARGETNAME})
0a8abcad 224add_custom_target(${DATARGETNAME}
225WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
226)
227add_dependencies(${DATARGETNAME} ${DAEXE})
228
229set(ZIP)
230foreach(_lib ${ALIROOTALIBS})
231string(REGEX REPLACE "-static" "" _lib ${_lib})
232list(APPEND ZIP && ar x "../lib${_lib}.a")
233endforeach(_lib)
234list (APPEND ZIP && ar r "../lib${DALIB}.a" "*.o")
235
236add_custom_target(${DALIB}.a
237COMMAND rm -rf junk${DAEXE} && mkdir -p junk${DAEXE}
238COMMAND cd junk${DAEXE} ${ZIP}
239COMMAND cd ../ && rm -rf junk${DAEXE}
240DEPENDS ${ALIROOTALIBS}
241WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
242)
243
244add_custom_command(
245TARGET ${DATARGETNAME}-clean
246COMMAND echo "***** Cleaning ${DAMODULE} ${SUBDAMODULE} ${DANAME} detector-algorithm *****"
247COMMAND rm -f ${DASPECFILE}
248COMMAND rm -f ${DATAR}
249COMMAND rm -f ${DAEXE}
250COMMAND rm -f ${DAOBJ}
251COMMAND rm -f ${DADEP}
252COMMAND rm -f ${DAMAKEFILE}
253COMMAND rm -f ${DALIB}.a
254COMMAND rm -f ${ALIROOTALIBS}
255COMMAND rm -f ${EXTRAROOTLIB}
256)
257
d54ad8d4 258separate_arguments(SYSLIBS)
259#execute_process(COMMAND ${AMORE}/amore-config --ldflags-da-static | tr "\n" " " OUTPUT_VARIABLE _amore1 OUTPUT_STRIP_TRAILING_WHITESPACE)
260#execute_process(COMMAND date-config --rcproxylibs OUTPUT_VARIABLE _amore2 OUTPUT_STRIP_TRAILING_WHITESPACE)
261#execute_process(COMMAND date-config --monitorlibs=noshift OUTPUT_VARIABLE _monitor1 OUTPUT_STRIP_TRAILING_WHITESPACE)
262
263#set(AMOREDALIBS "-static ${_amore1} ${_amore2}\\")
264#set(MONITORLIBS "${_monitor1}\\")
0a8abcad 265
266add_custom_target(DAMAKEFILE_${DAEXE}_)
267add_custom_command(
268TARGET DAMAKEFILE_${DAEXE}_
269COMMAND rm -f ${DAMAKEFILE}
270COMMAND @echo "***** Making makefile ${DAMAKEFILE} *****"
271COMMAND @echo '\#***************************************************' >> ${DAMAKEFILE}
272COMMAND @echo '\# Makefile for Detector Algorithm' >> ${DAMAKEFILE}
273COMMAND @echo '\#' >> ${DAMAKEFILE}
274COMMAND @echo '\# It is necessary to setup build environment before' >> ${DAMAKEFILE}
275COMMAND @echo '\# using make:' >> ${DAMAKEFILE}
276COMMAND @echo '\# - define path to daqDAlib (env. DAQDALIB_PATH)' >> ${DAMAKEFILE}
277COMMAND @echo '\#' >> ${DAMAKEFILE}
278COMMAND @echo '\#*****************************************************' >> ${DAMAKEFILE}
279COMMAND @echo "" >> ${DAMAKEFILE}
280COMMAND @echo "CXX=g++" >> ${DAMAKEFILE}
281COMMAND @echo "LD=g++" >> ${DAMAKEFILE}
282COMMAND @echo "" >> ${DAMAKEFILE}
283COMMAND @echo "CXXFLAGS=${CXXFLAGS}" >> ${DAMAKEFILE}
284COMMAND @echo "LDFLAGS=${LDFLAGS}" >> ${DAMAKEFILE}
285COMMAND @echo "" >> ${DAMAKEFILE}
286COMMAND @echo 'ifeq ($$(DAQDALIB_PATH),)' >> ${DAMAKEFILE}
287COMMAND @echo "DAQDADIR=${ALICE}/daqDAlib" >> ${DAMAKEFILE}
288COMMAND @echo "else" >> ${DAMAKEFILE}
289COMMAND @echo 'DAQDADIR=$$(DAQDALIB_PATH)' >> ${DAMAKEFILE}
290COMMAND @echo "endif" >> ${DAMAKEFILE}
291COMMAND @echo "" >> ${DAMAKEFILE}
292COMMAND @echo 'DAQDALIB=$$(DAQDADIR)/libdaqDA.a' >> ${DAMAKEFILE}
d54ad8d4 293#COMMAND @echo 'AMOREDALIBS=-static $$(shell $$(AMORE)/amore-config --ldflags-da-static) $$(shell date-config --rcproxylibs)' >> ${DAMAKEFILE}
294#COMMAND @echo 'MONITORLIBS=$$(shell date-config --monitorlibs=noshift)' >> ${DAMAKEFILE}
295#COMMAND @echo 'AMOREDALIBS=-static ${_amore1} ${_amore2}' >> ${DAMAKEFILE}
296#COMMAND @echo 'MONITORLIBS=${monitor1}' >> ${DAMAKEFILE}
0a8abcad 297COMMAND @echo "" >> ${DAMAKEFILE}
298COMMAND @echo "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe: ${DAMODULE}${SUBDAMODULE}${DANAME}da.o" >> ${DAMAKEFILE}
f173b8fc 299COMMAND @echo -e '\t$$(LD) $$(LDFLAGS) -o ''$$''@ ''$$''< ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${DALIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EXTRAROOTLIB} $$(ROOTSYS)/lib/libRoot.a $$(ROOTSYS)/lib/liblzma.a $$(ROOTSYS)/lib/libfreetype.a $$(ROOTSYS)/lib/libpcre.a ${SYSLIBS} $$(DAQDALIB) ${AMOREDALIBS} ${MONITORLIBS}' >> ${DAMAKEFILE}
0a8abcad 300COMMAND @echo "" >> ${DAMAKEFILE}
301COMMAND @echo "${DAMODULE}${SUBDAMODULE}${DANAME}da.o: ${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx" >> ${DAMAKEFILE}
d54ad8d4 302COMMAND @echo -e '\t$$(CXX) -c $$(CXXFLAGS) -I$$(DAQDADIR) ${mod} ''$$''< -o ''$$''@' >> ${DAMAKEFILE}
0a8abcad 303COMMAND @echo "" >> ${DAMAKEFILE}
304COMMAND @echo "clean:" >> ${DAMAKEFILE}
d54ad8d4 305COMMAND @echo -e '\t@rm -f ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe ${DAMODULE}${SUBDAMODULE}${DANAME}da.o' >> ${DAMAKEFILE}
0a8abcad 306COMMAND @echo "" >> ${DAMAKEFILE}
307COMMAND @echo "install: ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe" >> ${DAMAKEFILE}
d54ad8d4 308COMMAND @echo -e '\tif [ $$(INSTALL_PATH) == '' ]; then \\' >> ${DAMAKEFILE}
309COMMAND @echo -e '\techo Environment variable INSTALL_PATH undefined, cannot continue\; \\' >> ${DAMAKEFILE}
310COMMAND @echo -e '\texit 1\; \\' >> ${DAMAKEFILE}
311COMMAND @echo -e '\tfi' >> ${DAMAKEFILE}
312COMMAND @echo -e '\t@cp -p ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe $$(INSTALL_PATH)' >> ${DAMAKEFILE}
0a8abcad 313)
314
315add_custom_target(DATAR_${DAEXE}_)
316add_custom_command(
317TARGET DATAR_${DAEXE}_
318COMMAND @echo "***** Making archive ${DATAR} *****"
319COMMAND rm -rf ${DATAR}
320COMMAND rm -rf junk
321COMMAND mkdir junk && mkdir junk/${DAARC}
322COMMAND cp -a ${ALICE_ROOT}/${DASRC} junk/${DAARC}
323COMMAND cp -a ${DAMAKEFILE} junk/${DAARC}/Makefile
324COMMAND cp -a ${DASPECFILE} junk/${DAARC}/${DAMODULE}${SUBDAMODULE}${DANAME}da.spec
325COMMAND cd junk && tar czf ${DATAR} *
326COMMAND cd .. && rm -rf junk
327)
328add_dependencies(DATAR_${DAEXE}_ DAMAKEFILE_${DAEXE}_ DASPECFILE_${DAEXE}_ ${DASRC})
329
330add_custom_target(DASPECFILE_${DAEXE}_)
331
332add_custom_command(
333TARGET DASPECFILE_${DAEXE}_
334COMMAND rm -f ${DASPECFILE}
335COMMAND @echo "***** Making RPM spec-file ${DASPECFILE} *****"
336COMMAND @echo '\# RPM specfile for $(DAMODULE)${SUBDAMODULE}$(DANAME) Detector Algorithm' >> ${DASPECFILE}
337COMMAND @echo "Summary: ${ONLINEDETECTORNAME} Detector Algorithm" >> ${DASPECFILE}
338COMMAND @echo "Name: ${DAARCNAME}" >> ${DASPECFILE}
339COMMAND @echo "Version: ${DAVERSION}" >> ${DASPECFILE}
340COMMAND @echo "Release: ${DAALIROOTRELEASE}" >> ${DASPECFILE}
341COMMAND @echo "License: CERN Alice DAQ/Offine" >> ${DASPECFILE}
342COMMAND @echo "Source: %{name}-%{version}.src.tar.gz" >> ${DASPECFILE}
343COMMAND @echo "Group: Applications/Alice" >> ${DASPECFILE}
344COMMAND @echo "Prefix: /opt/%{name}" >> ${DASPECFILE}
345COMMAND @echo "BuildRoot: %{_tmppath}/%{name}-root" >> ${DASPECFILE}
346COMMAND @echo "" >> ${DASPECFILE}
347COMMAND @echo '\# automatic dependencies' >> ${DASPECFILE}
348COMMAND @echo "AutoReqProv: yes" >> ${DASPECFILE}
349COMMAND @echo "" >> ${DASPECFILE}
350COMMAND @echo '\# list here required RPM packages for compilation' >> ${DASPECFILE}
351COMMAND @echo "BuildRequires: date" >> ${DASPECFILE}
352COMMAND @echo "" >> ${DASPECFILE}
353COMMAND @echo '\# list here required RPM packages for runtime' >> ${DASPECFILE}
354COMMAND @echo "Requires: date" >> ${DASPECFILE}
355COMMAND @echo "" >> ${DASPECFILE}
356COMMAND @echo '\# You can specify other dependencies in the description tag below.' >> ${DASPECFILE}
357COMMAND @echo "" >> ${DASPECFILE}
358COMMAND @echo '\# description of the package' >> ${DASPECFILE}
359COMMAND @echo "%description" >> ${DASPECFILE}
360COMMAND @echo "This is the ${ONLINEDETECTORNAME} ${DANAME} DA for online calibration." >> ${DASPECFILE}
361COMMAND @echo "It uses data from ${DAMODULE} detectors at run time." >> ${DASPECFILE}
362COMMAND @echo "Build requires: daqDAlib, date, AliRoot ${DAALIROOTRELEASE},ROOT ${DAROOTRELEASE}." >> ${DASPECFILE}
363COMMAND @echo "Runtime requires: date." >> ${DASPECFILE}
6050a6e8 364COMMAND @echo "Contact: ${DACONTACT}" >> ${DASPECFILE}
365COMMAND @echo "Link: ${DALINKPAGE}" >> ${DASPECFILE}
366COMMAND @echo "Reference Run: ${DAREFRUN}" >> ${DASPECFILE}
367COMMAND @echo "Run type: ${DARUNTYPE}" >> ${DASPECFILE}
368COMMAND @echo "DA type: ${DATYPE}" >> ${DASPECFILE}
369COMMAND @echo "Number of events needed: ${DANUMBEROFEVENTS}" >> ${DASPECFILE}
370COMMAND @echo "Input files: ${DAINPUTFILES}" >> ${DASPECFILE}
371COMMAND @echo "Output files: ${DAOUTPUTFILES}" >> ${DASPECFILE}
372COMMAND @echo "Trigger types used: ${DATRIGGERTYPE}" >> ${DASPECFILE}
0a8abcad 373COMMAND @echo "" >> ${DASPECFILE}
374COMMAND @echo '\#*****************************************************************' >> ${DASPECFILE}
375COMMAND @echo '\# Do not modify following scripts' >> ${DASPECFILE}
376COMMAND @echo '\#*****************************************************************' >> ${DASPECFILE}
377COMMAND @echo "" >> ${DASPECFILE}
378COMMAND @echo "%define debug_package %{nil}" >> ${DASPECFILE}
379COMMAND @echo "%define __os_install_post %{nil}" >> ${DASPECFILE}
380COMMAND @echo "" >> ${DASPECFILE}
381COMMAND @echo '\# here is defined the installation root directory' >> ${DASPECFILE}
382COMMAND @echo "%define pkgname %{name}-%{version}" >> ${DASPECFILE}
383COMMAND @echo "%define destdir %{prefix}" >> ${DASPECFILE}
384COMMAND @echo "" >> ${DASPECFILE}
385COMMAND @echo '\# pre-compilation script: extract from tarball' >> ${DASPECFILE}
386COMMAND @echo "%prep" >> ${DASPECFILE}
387COMMAND @echo '\# extract archive' >> ${DASPECFILE}
388COMMAND @echo "%setup -n %{pkgname}" >> ${DASPECFILE}
389COMMAND @echo "" >> ${DASPECFILE}
390COMMAND @echo '\# compile' >> ${DASPECFILE}
391COMMAND @echo "%build" >> ${DASPECFILE}
392COMMAND @echo "export DATE_SITE=" >> ${DASPECFILE}
393COMMAND @echo ". /date/setup.sh" >> ${DASPECFILE}
394COMMAND @echo "gmake" >> ${DASPECFILE}
395COMMAND @echo "" >> ${DASPECFILE}
396COMMAND @echo '\# install runtime files' >> ${DASPECFILE}
397COMMAND @echo "%install" >> ${DASPECFILE}
398COMMAND @echo '\#remove install dir if existing' >> ${DASPECFILE}
399COMMAND echo '[ -d ''$$''RPM_BUILD_ROOT ] && rm -rf ''$$''RPM_BUILD_ROOT' >> ${DASPECFILE}
400COMMAND @echo '\#make install in install root directory' >> ${DASPECFILE}
d54ad8d4 401COMMAND @echo 'mkdir -p ''$$''RPM_BUILD_ROOT%{prefix}' >> ${DASPECFILE}
402COMMAND @echo 'make install INSTALL_PATH=''$$''RPM_BUILD_ROOT%{prefix}' >> ${DASPECFILE}
0a8abcad 403COMMAND @echo "" >> ${DASPECFILE}
404COMMAND @echo '\# clean RPM build files' >> ${DASPECFILE}
405COMMAND @echo "%clean" >> ${DASPECFILE}
406COMMAND @echo '\# remove installed files' >> ${DASPECFILE}
407COMMAND @echo 'rm -rf ''$$''RPM_BUILD_ROOT' >> ${DASPECFILE}
408COMMAND @echo '\# remove source files' >> ${DASPECFILE}
409COMMAND @echo 'rm -rf ''$$''RPM_BUILD_DIR/%{pkgname}' >> ${DASPECFILE}
410COMMAND @echo "" >> ${DASPECFILE}
411COMMAND @echo '\# pre-install script' >> ${DASPECFILE}
412COMMAND @echo "%pre" >> ${DASPECFILE}
413COMMAND @echo "" >> ${DASPECFILE}
414COMMAND @echo '\# list of files to be installed' >> ${DASPECFILE}
415COMMAND @echo "%files" >> ${DASPECFILE}
416COMMAND @echo '%defattr (-,root,root)' >> ${DASPECFILE}
417COMMAND @echo "%{destdir}" >> ${DASPECFILE}
418COMMAND @echo "" >> ${DASPECFILE}
419COMMAND @echo '\# post-install script' >> ${DASPECFILE}
420COMMAND @echo '\# launched after rpm installed' >> ${DASPECFILE}
421COMMAND @echo "%post" >> ${DASPECFILE}
422COMMAND @echo "" >> ${DASPECFILE}
423COMMAND @echo '\# post-uninstall script' >> ${DASPECFILE}
424COMMAND @echo '\# launched after rpm removed' >> ${DASPECFILE}
425COMMAND @echo "%postun" >> ${DASPECFILE}
426)
427
d54ad8d4 428
0a8abcad 429add_custom_target( ${DATARGETNAME}-rpm
430)
d54ad8d4 431add_dependencies(${DATARGETNAME}-rpm DATAR_${DAEXE}_ DASPECFILE_${DAEXE}_ ${LIBPATH} ${DALIB}.a DADEP_${DAEXE}_ ${ROOTLIB}
0a8abcad 432)
d54ad8d4 433add_custom_command(TARGET ${DATARGETNAME}-rpm
434COMMAND 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
435COMMAND cp ${DATAR} ${CMAKE_BINARY_DIR}/junk/SOURCES
436COMMAND rpmbuild --verbose --define "_topdir ${CMAKE_BINARY_DIR}/junk" --nodeps -bb ${DASPECFILE}
437COMMAND cp -p `find ${CMAKE_BINARY_DIR}/junk/ -name "${DAARC}-*.rpm"` . ;
0a8abcad 438COMMAND rm -rf junk
d54ad8d4 439COMMAND echo "***** RPMS created and put ${CMAKE_BINARY_DIR} folder *****"
440WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0a8abcad 441)
442
443
444add_custom_target(${DAEXE}
445COMMAND echo "***** Making executable ${DAEXE} *****"
f173b8fc 446COMMAND g++ ${LDFLAGS} ${DAOBJ} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${DALIB}.a ${EXTRAROOTLIB} ${ROOTSYS}/lib/libRoot.a ${ROOTSYS}/lib/liblzma.a ${ROOTSYS}/lib/libfreetype.a ${ROOTSYS}/lib/libpcre.a ${SYSLIBS} ${DAQDALIB} ${AMOREDALIBS} ${MONITORLIBS} -o ${DAEXE}
0a8abcad 447WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
448)
62c1e3a4 449
450
451#target_link_libraries(${DAEXE} "-L" "lib${DALIB}.a" ${DAOBJ} ${EXTRAROOTLIB} "${ROOTALIBDIR}/libRoot.a" "${ROOTALIBDIR}/libfreetype.a" "${ROOTALIBDIR}/libpcre.a" ${SYSLIBS} ${DAQDALIB} ${MONITORLIBS} ${AMOREDALIBS})
0a8abcad 452
d54ad8d4 453add_dependencies(${DAEXE} ${DASRC} DAOBJ_${DAEXE}_ ${BINPATH} ${LIBPATH} ${DALIB}.a ${DAQDALIB} ${ROOTLIB})
0a8abcad 454
455add_custom_target(DAOBJ_${DAEXE}_
456)
457add_custom_command(
458TARGET DAOBJ_${DAEXE}_
459COMMAND echo "***** Compiling ${DASRC} *****"
6050a6e8 460COMMAND 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 461WORKING_DIRECTORY ${ALICE_ROOT}
462)
463add_dependencies(DAOBJ_${DAEXE}_ DADEP_${DAEXE}_ )
464
465
466
467add_custom_target(DADEP_${DAEXE}_)
468add_custom_command(
469TARGET DADEP_${DAEXE}_
470COMMAND echo "***** Making detector-algorithm dependencies ${DADEP} *****"
471COMMAND 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}
472WORKING_DIRECTORY ${ALICE_ROOT}
473)
474
475
0a8abcad 476add_custom_command(TARGET clean
477COMMAND rm -rf junk*.exe
478WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
6050a6e8 479
45526b5e 480
6db31708 481 endif(match)
482 endforeach(dafile)
483endforeach(detector)