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