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