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