Commenting out unused include file
[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)
121bb192 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
121bb192 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)
6db31708 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)
9d9b9d1e 99execute_process(COMMAND $ENV{AMORE}/bin/amore-config --ldflags-da-static OUTPUT_VARIABLE _amore1 OUTPUT_STRIP_TRAILING_WHITESPACE)
d54ad8d4 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}")
9d9b9d1e 103set(AMOREDALIBS " ${_amore1} ${_amore2}")
104set(MONITORLIBS "${_monitor1} -lssl")
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
8c50ee13 184 #DAREVISION
185 execute_process(COMMAND svn info ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE _darevision OUTPUT_STRIP_TRAILING_WHITESPACE)
186 string(REGEX REPLACE ".*Revision: ([^\n]+)\n.*" "\\1" DAREVISION ${_darevision})
6db31708 187 # DAROOTRELEASE
188 execute_process(COMMAND root-config --version OUTPUT_VARIABLE _darootrelease OUTPUT_STRIP_TRAILING_WHITESPACE)
189 string(REGEX REPLACE "/" "." DAROOTRELEASE ${_darootrelease})
190
191 # DAALIROOTRELEASE
192 string(REGEX REPLACE ".*URL: .*/(.+)/${DASRC}.*$" "\\1" DAALIROOTRELEASE ${_daversion})
7251bfcc 193 string (REPLACE "-" "." DAALIROOTRELEASE "${DAALIROOTRELEASE}")
6db31708 194
195 set(DAARCNAME "${DATARGETNAME}")
8c50ee13 196 #string(REPLACE "-" "" DAARCNAME "${DAARCNAME}")
6db31708 197 set(DAARC "${DAARCNAME}-${DAVERSION}")
198 set(DATAR "${DATARGETDIR}/${DAARC}.src.tar.gz")
199 set(DASPECFILE "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.spec")
200 set(DAMAKEFILE "${DATARGETDIR}/${DAMODULE}${SUBDAMODULE}${DANAME}da.make")
6db31708 201
0a8abcad 202
6db31708 203 file(READ "$ENV{ALICE_ROOT}/${DASRC}" _dasrc)
204 getinfo(DACONTACT "Contact" ${_dasrc})
205 getinfo(DALINKPAGE "Link" ${_dasrc})
206 getinfo(DAREFRUN "Reference Run" ${_dasrc})
207 getinfo(DARUNTYPE "Run Type" ${_dasrc})
208 getinfo(DATYPE "DA Type" ${_dasrc})
209 getinfo(DANUMBEROFEVENTS "Number of events needed" ${_dasrc})
210 getinfo(DAINPUTFILES "Input Files" ${_dasrc})
211 getinfo(DAOUTPUTFILES "Output Files" ${_dasrc})
212 getinfo(DATRIGGERTYPE "Trigger types used" ${_dasrc})
213
214 if(NOT _dasrc)
215 message(FATAL_ERROR "SRC FILE MISSING")
216 endif(NOT _dasrc)
217
6db31708 218#----------- Targets ----------------------
219
45526b5e 220 set(CMAKE_CXX_FLAGS "${CXXFLAGS}")
221 set(CMAKE_C_FLAGS "${CFLAGS}")
9372fe67 222 set(CMAKE_Fortran_FLAGS ${FFLAGS})
6db31708 223 set(CMAKE_SHARED_LINKER_FLAGS ${SOFLAGS})
224 set(CMAKE_MODULE_LINKER_FLAGS ${LDFLAGS})
225
d54ad8d4 226add_dependencies(DA-all ${DATARGETNAME})
0a8abcad 227add_custom_target(${DATARGETNAME}
228WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
229)
230add_dependencies(${DATARGETNAME} ${DAEXE})
231
232set(ZIP)
233foreach(_lib ${ALIROOTALIBS})
234string(REGEX REPLACE "-static" "" _lib ${_lib})
235list(APPEND ZIP && ar x "../lib${_lib}.a")
236endforeach(_lib)
237list (APPEND ZIP && ar r "../lib${DALIB}.a" "*.o")
238
239add_custom_target(${DALIB}.a
240COMMAND rm -rf junk${DAEXE} && mkdir -p junk${DAEXE}
241COMMAND cd junk${DAEXE} ${ZIP}
242COMMAND cd ../ && rm -rf junk${DAEXE}
243DEPENDS ${ALIROOTALIBS}
244WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
245)
246
247add_custom_command(
248TARGET ${DATARGETNAME}-clean
249COMMAND echo "***** Cleaning ${DAMODULE} ${SUBDAMODULE} ${DANAME} detector-algorithm *****"
250COMMAND rm -f ${DASPECFILE}
251COMMAND rm -f ${DATAR}
252COMMAND rm -f ${DAEXE}
253COMMAND rm -f ${DAOBJ}
254COMMAND rm -f ${DADEP}
255COMMAND rm -f ${DAMAKEFILE}
256COMMAND rm -f ${DALIB}.a
257COMMAND rm -f ${ALIROOTALIBS}
258COMMAND rm -f ${EXTRAROOTLIB}
259)
260
d54ad8d4 261separate_arguments(SYSLIBS)
262#execute_process(COMMAND ${AMORE}/amore-config --ldflags-da-static | tr "\n" " " OUTPUT_VARIABLE _amore1 OUTPUT_STRIP_TRAILING_WHITESPACE)
263#execute_process(COMMAND date-config --rcproxylibs OUTPUT_VARIABLE _amore2 OUTPUT_STRIP_TRAILING_WHITESPACE)
264#execute_process(COMMAND date-config --monitorlibs=noshift OUTPUT_VARIABLE _monitor1 OUTPUT_STRIP_TRAILING_WHITESPACE)
265
266#set(AMOREDALIBS "-static ${_amore1} ${_amore2}\\")
267#set(MONITORLIBS "${_monitor1}\\")
0a8abcad 268
269add_custom_target(DAMAKEFILE_${DAEXE}_)
270add_custom_command(
271TARGET DAMAKEFILE_${DAEXE}_
272COMMAND rm -f ${DAMAKEFILE}
273COMMAND @echo "***** Making makefile ${DAMAKEFILE} *****"
274COMMAND @echo '\#***************************************************' >> ${DAMAKEFILE}
275COMMAND @echo '\# Makefile for Detector Algorithm' >> ${DAMAKEFILE}
276COMMAND @echo '\#' >> ${DAMAKEFILE}
277COMMAND @echo '\# It is necessary to setup build environment before' >> ${DAMAKEFILE}
278COMMAND @echo '\# using make:' >> ${DAMAKEFILE}
279COMMAND @echo '\# - define path to daqDAlib (env. DAQDALIB_PATH)' >> ${DAMAKEFILE}
280COMMAND @echo '\#' >> ${DAMAKEFILE}
281COMMAND @echo '\#*****************************************************' >> ${DAMAKEFILE}
282COMMAND @echo "" >> ${DAMAKEFILE}
283COMMAND @echo "CXX=g++" >> ${DAMAKEFILE}
284COMMAND @echo "LD=g++" >> ${DAMAKEFILE}
285COMMAND @echo "" >> ${DAMAKEFILE}
286COMMAND @echo "CXXFLAGS=${CXXFLAGS}" >> ${DAMAKEFILE}
287COMMAND @echo "LDFLAGS=${LDFLAGS}" >> ${DAMAKEFILE}
288COMMAND @echo "" >> ${DAMAKEFILE}
289COMMAND @echo 'ifeq ($$(DAQDALIB_PATH),)' >> ${DAMAKEFILE}
290COMMAND @echo "DAQDADIR=${ALICE}/daqDAlib" >> ${DAMAKEFILE}
291COMMAND @echo "else" >> ${DAMAKEFILE}
292COMMAND @echo 'DAQDADIR=$$(DAQDALIB_PATH)' >> ${DAMAKEFILE}
293COMMAND @echo "endif" >> ${DAMAKEFILE}
294COMMAND @echo "" >> ${DAMAKEFILE}
295COMMAND @echo 'DAQDALIB=$$(DAQDADIR)/libdaqDA.a' >> ${DAMAKEFILE}
d54ad8d4 296#COMMAND @echo 'AMOREDALIBS=-static $$(shell $$(AMORE)/amore-config --ldflags-da-static) $$(shell date-config --rcproxylibs)' >> ${DAMAKEFILE}
297#COMMAND @echo 'MONITORLIBS=$$(shell date-config --monitorlibs=noshift)' >> ${DAMAKEFILE}
298#COMMAND @echo 'AMOREDALIBS=-static ${_amore1} ${_amore2}' >> ${DAMAKEFILE}
299#COMMAND @echo 'MONITORLIBS=${monitor1}' >> ${DAMAKEFILE}
0a8abcad 300COMMAND @echo "" >> ${DAMAKEFILE}
301COMMAND @echo "${DAMODULE}${SUBDAMODULE}${DANAME}da.exe: ${DAMODULE}${SUBDAMODULE}${DANAME}da.o" >> ${DAMAKEFILE}
f173b8fc 302COMMAND @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 303COMMAND @echo "" >> ${DAMAKEFILE}
304COMMAND @echo "${DAMODULE}${SUBDAMODULE}${DANAME}da.o: ${DAMODULE}${SUBDAMODULE}${DANAME}da.cxx" >> ${DAMAKEFILE}
d54ad8d4 305COMMAND @echo -e '\t$$(CXX) -c $$(CXXFLAGS) -I$$(DAQDADIR) ${mod} ''$$''< -o ''$$''@' >> ${DAMAKEFILE}
0a8abcad 306COMMAND @echo "" >> ${DAMAKEFILE}
307COMMAND @echo "clean:" >> ${DAMAKEFILE}
d54ad8d4 308COMMAND @echo -e '\t@rm -f ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe ${DAMODULE}${SUBDAMODULE}${DANAME}da.o' >> ${DAMAKEFILE}
0a8abcad 309COMMAND @echo "" >> ${DAMAKEFILE}
310COMMAND @echo "install: ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe" >> ${DAMAKEFILE}
d54ad8d4 311COMMAND @echo -e '\tif [ $$(INSTALL_PATH) == '' ]; then \\' >> ${DAMAKEFILE}
312COMMAND @echo -e '\techo Environment variable INSTALL_PATH undefined, cannot continue\; \\' >> ${DAMAKEFILE}
313COMMAND @echo -e '\texit 1\; \\' >> ${DAMAKEFILE}
314COMMAND @echo -e '\tfi' >> ${DAMAKEFILE}
315COMMAND @echo -e '\t@cp -p ${DAMODULE}${SUBDAMODULE}${DANAME}da.exe $$(INSTALL_PATH)' >> ${DAMAKEFILE}
0a8abcad 316)
317
318add_custom_target(DATAR_${DAEXE}_)
319add_custom_command(
320TARGET DATAR_${DAEXE}_
321COMMAND @echo "***** Making archive ${DATAR} *****"
322COMMAND rm -rf ${DATAR}
323COMMAND rm -rf junk
324COMMAND mkdir junk && mkdir junk/${DAARC}
325COMMAND cp -a ${ALICE_ROOT}/${DASRC} junk/${DAARC}
326COMMAND cp -a ${DAMAKEFILE} junk/${DAARC}/Makefile
327COMMAND cp -a ${DASPECFILE} junk/${DAARC}/${DAMODULE}${SUBDAMODULE}${DANAME}da.spec
328COMMAND cd junk && tar czf ${DATAR} *
329COMMAND cd .. && rm -rf junk
330)
331add_dependencies(DATAR_${DAEXE}_ DAMAKEFILE_${DAEXE}_ DASPECFILE_${DAEXE}_ ${DASRC})
332
333add_custom_target(DASPECFILE_${DAEXE}_)
334
335add_custom_command(
336TARGET DASPECFILE_${DAEXE}_
337COMMAND rm -f ${DASPECFILE}
338COMMAND @echo "***** Making RPM spec-file ${DASPECFILE} *****"
339COMMAND @echo '\# RPM specfile for $(DAMODULE)${SUBDAMODULE}$(DANAME) Detector Algorithm' >> ${DASPECFILE}
340COMMAND @echo "Summary: ${ONLINEDETECTORNAME} Detector Algorithm" >> ${DASPECFILE}
341COMMAND @echo "Name: ${DAARCNAME}" >> ${DASPECFILE}
342COMMAND @echo "Version: ${DAVERSION}" >> ${DASPECFILE}
8c50ee13 343COMMAND @echo "Release: ${DAALIROOTRELEASE}.${DAREVISION}" >> ${DASPECFILE}
0a8abcad 344COMMAND @echo "License: CERN Alice DAQ/Offine" >> ${DASPECFILE}
345COMMAND @echo "Source: %{name}-%{version}.src.tar.gz" >> ${DASPECFILE}
346COMMAND @echo "Group: Applications/Alice" >> ${DASPECFILE}
347COMMAND @echo "Prefix: /opt/%{name}" >> ${DASPECFILE}
348COMMAND @echo "BuildRoot: %{_tmppath}/%{name}-root" >> ${DASPECFILE}
349COMMAND @echo "" >> ${DASPECFILE}
350COMMAND @echo '\# automatic dependencies' >> ${DASPECFILE}
351COMMAND @echo "AutoReqProv: yes" >> ${DASPECFILE}
352COMMAND @echo "" >> ${DASPECFILE}
353COMMAND @echo '\# list here required RPM packages for compilation' >> ${DASPECFILE}
354COMMAND @echo "BuildRequires: date" >> ${DASPECFILE}
355COMMAND @echo "" >> ${DASPECFILE}
356COMMAND @echo '\# list here required RPM packages for runtime' >> ${DASPECFILE}
357COMMAND @echo "Requires: date" >> ${DASPECFILE}
358COMMAND @echo "" >> ${DASPECFILE}
359COMMAND @echo '\# You can specify other dependencies in the description tag below.' >> ${DASPECFILE}
360COMMAND @echo "" >> ${DASPECFILE}
361COMMAND @echo '\# description of the package' >> ${DASPECFILE}
362COMMAND @echo "%description" >> ${DASPECFILE}
363COMMAND @echo "This is the ${ONLINEDETECTORNAME} ${DANAME} DA for online calibration." >> ${DASPECFILE}
364COMMAND @echo "It uses data from ${DAMODULE} detectors at run time." >> ${DASPECFILE}
365COMMAND @echo "Build requires: daqDAlib, date, AliRoot ${DAALIROOTRELEASE},ROOT ${DAROOTRELEASE}." >> ${DASPECFILE}
366COMMAND @echo "Runtime requires: date." >> ${DASPECFILE}
6050a6e8 367COMMAND @echo "Contact: ${DACONTACT}" >> ${DASPECFILE}
368COMMAND @echo "Link: ${DALINKPAGE}" >> ${DASPECFILE}
369COMMAND @echo "Reference Run: ${DAREFRUN}" >> ${DASPECFILE}
370COMMAND @echo "Run type: ${DARUNTYPE}" >> ${DASPECFILE}
371COMMAND @echo "DA type: ${DATYPE}" >> ${DASPECFILE}
372COMMAND @echo "Number of events needed: ${DANUMBEROFEVENTS}" >> ${DASPECFILE}
373COMMAND @echo "Input files: ${DAINPUTFILES}" >> ${DASPECFILE}
374COMMAND @echo "Output files: ${DAOUTPUTFILES}" >> ${DASPECFILE}
375COMMAND @echo "Trigger types used: ${DATRIGGERTYPE}" >> ${DASPECFILE}
0a8abcad 376COMMAND @echo "" >> ${DASPECFILE}
377COMMAND @echo '\#*****************************************************************' >> ${DASPECFILE}
378COMMAND @echo '\# Do not modify following scripts' >> ${DASPECFILE}
379COMMAND @echo '\#*****************************************************************' >> ${DASPECFILE}
380COMMAND @echo "" >> ${DASPECFILE}
381COMMAND @echo "%define debug_package %{nil}" >> ${DASPECFILE}
382COMMAND @echo "%define __os_install_post %{nil}" >> ${DASPECFILE}
383COMMAND @echo "" >> ${DASPECFILE}
384COMMAND @echo '\# here is defined the installation root directory' >> ${DASPECFILE}
385COMMAND @echo "%define pkgname %{name}-%{version}" >> ${DASPECFILE}
386COMMAND @echo "%define destdir %{prefix}" >> ${DASPECFILE}
387COMMAND @echo "" >> ${DASPECFILE}
388COMMAND @echo '\# pre-compilation script: extract from tarball' >> ${DASPECFILE}
389COMMAND @echo "%prep" >> ${DASPECFILE}
390COMMAND @echo '\# extract archive' >> ${DASPECFILE}
391COMMAND @echo "%setup -n %{pkgname}" >> ${DASPECFILE}
392COMMAND @echo "" >> ${DASPECFILE}
393COMMAND @echo '\# compile' >> ${DASPECFILE}
394COMMAND @echo "%build" >> ${DASPECFILE}
395COMMAND @echo "export DATE_SITE=" >> ${DASPECFILE}
396COMMAND @echo ". /date/setup.sh" >> ${DASPECFILE}
397COMMAND @echo "gmake" >> ${DASPECFILE}
398COMMAND @echo "" >> ${DASPECFILE}
399COMMAND @echo '\# install runtime files' >> ${DASPECFILE}
400COMMAND @echo "%install" >> ${DASPECFILE}
401COMMAND @echo '\#remove install dir if existing' >> ${DASPECFILE}
402COMMAND echo '[ -d ''$$''RPM_BUILD_ROOT ] && rm -rf ''$$''RPM_BUILD_ROOT' >> ${DASPECFILE}
403COMMAND @echo '\#make install in install root directory' >> ${DASPECFILE}
d54ad8d4 404COMMAND @echo 'mkdir -p ''$$''RPM_BUILD_ROOT%{prefix}' >> ${DASPECFILE}
405COMMAND @echo 'make install INSTALL_PATH=''$$''RPM_BUILD_ROOT%{prefix}' >> ${DASPECFILE}
0a8abcad 406COMMAND @echo "" >> ${DASPECFILE}
407COMMAND @echo '\# clean RPM build files' >> ${DASPECFILE}
408COMMAND @echo "%clean" >> ${DASPECFILE}
409COMMAND @echo '\# remove installed files' >> ${DASPECFILE}
410COMMAND @echo 'rm -rf ''$$''RPM_BUILD_ROOT' >> ${DASPECFILE}
411COMMAND @echo '\# remove source files' >> ${DASPECFILE}
412COMMAND @echo 'rm -rf ''$$''RPM_BUILD_DIR/%{pkgname}' >> ${DASPECFILE}
413COMMAND @echo "" >> ${DASPECFILE}
414COMMAND @echo '\# pre-install script' >> ${DASPECFILE}
415COMMAND @echo "%pre" >> ${DASPECFILE}
416COMMAND @echo "" >> ${DASPECFILE}
417COMMAND @echo '\# list of files to be installed' >> ${DASPECFILE}
418COMMAND @echo "%files" >> ${DASPECFILE}
419COMMAND @echo '%defattr (-,root,root)' >> ${DASPECFILE}
420COMMAND @echo "%{destdir}" >> ${DASPECFILE}
421COMMAND @echo "" >> ${DASPECFILE}
422COMMAND @echo '\# post-install script' >> ${DASPECFILE}
423COMMAND @echo '\# launched after rpm installed' >> ${DASPECFILE}
424COMMAND @echo "%post" >> ${DASPECFILE}
425COMMAND @echo "" >> ${DASPECFILE}
426COMMAND @echo '\# post-uninstall script' >> ${DASPECFILE}
427COMMAND @echo '\# launched after rpm removed' >> ${DASPECFILE}
428COMMAND @echo "%postun" >> ${DASPECFILE}
429)
430
d54ad8d4 431
0a8abcad 432add_custom_target( ${DATARGETNAME}-rpm
433)
d54ad8d4 434add_dependencies(${DATARGETNAME}-rpm DATAR_${DAEXE}_ DASPECFILE_${DAEXE}_ ${LIBPATH} ${DALIB}.a DADEP_${DAEXE}_ ${ROOTLIB}
0a8abcad 435)
d54ad8d4 436add_custom_command(TARGET ${DATARGETNAME}-rpm
437COMMAND 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
438COMMAND cp ${DATAR} ${CMAKE_BINARY_DIR}/junk/SOURCES
439COMMAND rpmbuild --verbose --define "_topdir ${CMAKE_BINARY_DIR}/junk" --nodeps -bb ${DASPECFILE}
8c50ee13 440COMMAND cp `find './junk/' -name '${DAARC}*.rpm'` ./
0a8abcad 441COMMAND rm -rf junk
d54ad8d4 442COMMAND echo "***** RPMS created and put ${CMAKE_BINARY_DIR} folder *****"
443WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0a8abcad 444)
445
446
447add_custom_target(${DAEXE}
448COMMAND echo "***** Making executable ${DAEXE} *****"
f173b8fc 449COMMAND 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 450WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
451)
62c1e3a4 452
453
454#target_link_libraries(${DAEXE} "-L" "lib${DALIB}.a" ${DAOBJ} ${EXTRAROOTLIB} "${ROOTALIBDIR}/libRoot.a" "${ROOTALIBDIR}/libfreetype.a" "${ROOTALIBDIR}/libpcre.a" ${SYSLIBS} ${DAQDALIB} ${MONITORLIBS} ${AMOREDALIBS})
0a8abcad 455
d54ad8d4 456add_dependencies(${DAEXE} ${DASRC} DAOBJ_${DAEXE}_ ${BINPATH} ${LIBPATH} ${DALIB}.a ${DAQDALIB} ${ROOTLIB})
0a8abcad 457
8c50ee13 458
0a8abcad 459add_custom_target(DAOBJ_${DAEXE}_
460)
461add_custom_command(
462TARGET DAOBJ_${DAEXE}_
463COMMAND echo "***** Compiling ${DASRC} *****"
8c50ee13 464COMMAND echo "${DFLAGS}"
465COMMAND g++ -c -D${CMAKE_SYSTEM_NAME} -DDATE_SYS=${CMAKE_SYSTEM_NAME} -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}
466#COMMAND g++ -c ${DATEFLAGS} -I${DAQDADIR} -I${ALICE_ROOT}/RAW -I${CMAKE_BINARY_DIR}/include -I$ENV{ROOTSYS}/include ${mod} ${date_head} ${ALICE_ROOT}/${DASRC} -o ${DAOBJ}
467
0a8abcad 468WORKING_DIRECTORY ${ALICE_ROOT}
469)
470add_dependencies(DAOBJ_${DAEXE}_ DADEP_${DAEXE}_ )
471
472
473
474add_custom_target(DADEP_${DAEXE}_)
475add_custom_command(
476TARGET DADEP_${DAEXE}_
477COMMAND echo "***** Making detector-algorithm dependencies ${DADEP} *****"
478COMMAND 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}
479WORKING_DIRECTORY ${ALICE_ROOT}
480)
481
482
0a8abcad 483add_custom_command(TARGET clean
484COMMAND rm -rf junk*.exe
485WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
6050a6e8 486
45526b5e 487
6db31708 488 endif(match)
489 endforeach(dafile)
490endforeach(detector)