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