| 1 |
campana |
1.2 |
# Flight quick look - FQLOOK
|
| 2 |
|
|
# SOFTWARE VERSION
|
| 3 |
|
|
VER= v1r06
|
| 4 |
|
|
# An almost general purpouse Makefile for PAMELA repository
|
| 5 |
|
|
# Let's start with some usefull definition for colorize the echo
|
| 6 |
|
|
RED='\E[1;31;40m'
|
| 7 |
|
|
GREEN='\E[1;32;40m'
|
| 8 |
|
|
YELLOW='\E[1;33;40m'
|
| 9 |
|
|
BLUE='\E[1;34;40m'
|
| 10 |
|
|
WHITE='\E[1;37;40m'
|
| 11 |
|
|
VIOLET='\E[1;35;40m'
|
| 12 |
|
|
CYAN='\E[1;36;40m'
|
| 13 |
|
|
# Here the echo definition to use them
|
| 14 |
|
|
EVIOLET=echo -e ${VIOLET}
|
| 15 |
|
|
ECYAN=echo -e ${CYAN}
|
| 16 |
|
|
ERED=echo -e ${RED}
|
| 17 |
|
|
EGREEN=echo -e ${GREEN}
|
| 18 |
|
|
EYELLOW=echo -e ${YELLOW}
|
| 19 |
|
|
EBLUE=echo -e ${BLUE}
|
| 20 |
|
|
EWHITE=echo -e ${WHITE}
|
| 21 |
|
|
# Reset the terminal
|
| 22 |
|
|
RESET=tput sgr0
|
| 23 |
|
|
# Here the variables used to override the standard make flags
|
| 24 |
|
|
# C
|
| 25 |
|
|
CC=gcc
|
| 26 |
|
|
CFLAGS=-Wall -O -fPIC -pthread
|
| 27 |
|
|
# Enviroment:
|
| 28 |
|
|
GCCVER=`gcc --version | head -1`
|
| 29 |
|
|
UNAMEA=`uname -a`
|
| 30 |
|
|
TODAY=`date`
|
| 31 |
|
|
# F77
|
| 32 |
|
|
F77=g77
|
| 33 |
|
|
F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
|
| 34 |
|
|
# C++
|
| 35 |
|
|
CXX=g++
|
| 36 |
|
|
CXXFLAGS=-Wall -O -fPIC -pthread
|
| 37 |
|
|
# ROOTCINT
|
| 38 |
|
|
ROOTCINT=rootcint
|
| 39 |
|
|
# Here the variables definig the local directories
|
| 40 |
|
|
DIRTOP=${shell pwd}
|
| 41 |
|
|
DIRLIB=lib
|
| 42 |
|
|
DIRBIN=bin
|
| 43 |
|
|
DIRSRC=src
|
| 44 |
|
|
DIRINC=inc
|
| 45 |
|
|
DIRDOC=doc
|
| 46 |
|
|
DIRMACROS=macros
|
| 47 |
|
|
DIRCALIB=
|
| 48 |
|
|
# Here the PAMELA environmental variables to be checked
|
| 49 |
|
|
PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
|
| 50 |
|
|
# Here the local variables used to build the targets
|
| 51 |
|
|
|
| 52 |
|
|
CXXEXESRCS=${DIRSRC}/TofScan.cpp
|
| 53 |
|
|
CXXEXELIBS=$(CXXEXESRCS:${DIRSRC}/%.cpp=%)
|
| 54 |
|
|
EXESRCS= ${DIRBIN}/TofScan
|
| 55 |
|
|
DOCFILES=
|
| 56 |
|
|
|
| 57 |
|
|
# Here the Variables used for info target
|
| 58 |
|
|
PACKAGE=ToF flight quick look software
|
| 59 |
|
|
EXECUTABLES=
|
| 60 |
|
|
LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}
|
| 61 |
|
|
DOCS=
|
| 62 |
|
|
SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}
|
| 63 |
|
|
MACROS= ${MACROSSRCS}
|
| 64 |
|
|
NROOTINC=${shell root-config --incdir}
|
| 65 |
|
|
#
|
| 66 |
|
|
TOBEDEL =
|
| 67 |
|
|
# Let's start
|
| 68 |
|
|
all : test mkbindir mklibdir ${MACROSLIBS} ${CXXEXELIBS}
|
| 69 |
|
|
all:
|
| 70 |
|
|
@echo -e ${GREEN} ""
|
| 71 |
|
|
@(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
|
| 72 |
|
|
@echo -e ${GREEN} ""
|
| 73 |
|
|
@${RESET}
|
| 74 |
|
|
|
| 75 |
|
|
# Here some general rules to produce objects in our local dir
|
| 76 |
|
|
${CXXEXELIBS}: ${CXXEXESRCS}
|
| 77 |
|
|
@(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
|
| 78 |
|
|
${CXX} ${CXXFLAGS} -c ${DIRSRC}/$@.cpp -o ${DIRLIB}/$@.o -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
|
| 79 |
|
|
${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so `root-config --cflags --glibs`;
|
| 80 |
|
|
|
| 81 |
|
|
# A small target to check environmental variables
|
| 82 |
|
|
%_env:
|
| 83 |
|
|
@${test_env}
|
| 84 |
|
|
|
| 85 |
|
|
.PHONY: install installdoc installlib installmacros installinc installexe installcmacro
|
| 86 |
|
|
.PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
|
| 87 |
|
|
|
| 88 |
|
|
mkbindir: ${DIRBIN}
|
| 89 |
|
|
${DIRBIN}:
|
| 90 |
|
|
@${test_and_mk}
|
| 91 |
|
|
|
| 92 |
|
|
mklibdir: ${DIRLIB}
|
| 93 |
|
|
${DIRLIB}:
|
| 94 |
|
|
@${test_and_mk}
|
| 95 |
|
|
|
| 96 |
|
|
# Here what has to be deleted in clean target
|
| 97 |
|
|
clean: TOBEDEL= ${DIRBIN}
|
| 98 |
|
|
clean:
|
| 99 |
|
|
@${test_and_rm}
|
| 100 |
|
|
|
| 101 |
|
|
distclean: clean
|
| 102 |
|
|
distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
|
| 103 |
|
|
distclean:
|
| 104 |
|
|
@${test_and_rm}
|
| 105 |
|
|
|
| 106 |
|
|
forceinstall: FORCE=-f
|
| 107 |
|
|
forceinstall: install
|
| 108 |
|
|
|
| 109 |
|
|
upgrade: FORCE=-u
|
| 110 |
|
|
upgrade: install
|
| 111 |
|
|
|
| 112 |
|
|
install: installexe
|
| 113 |
|
|
|
| 114 |
|
|
installlib: LINK=y
|
| 115 |
|
|
installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
|
| 116 |
|
|
installlib: ORIGIN=${DIRLIB}
|
| 117 |
|
|
installlib:
|
| 118 |
|
|
@${test_and_cp}
|
| 119 |
|
|
|
| 120 |
|
|
installcmacro: LINK=y
|
| 121 |
|
|
installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
|
| 122 |
|
|
installcmacro: ORIGIN=${DIRLIB}
|
| 123 |
|
|
installcmacro:
|
| 124 |
|
|
@${test_and_cp}
|
| 125 |
|
|
|
| 126 |
|
|
installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
|
| 127 |
|
|
installinc: ORIGIN=${DIRINC}
|
| 128 |
|
|
installinc:
|
| 129 |
|
|
@${test_and_cp}
|
| 130 |
|
|
|
| 131 |
|
|
installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
|
| 132 |
|
|
installexe: ORIGIN=${DIRBIN}
|
| 133 |
|
|
installexe:
|
| 134 |
|
|
@${test_and_cp}
|
| 135 |
|
|
|
| 136 |
|
|
installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
|
| 137 |
|
|
installmacros: ORIGIN=${DIRMACROS}
|
| 138 |
|
|
installmacros:
|
| 139 |
|
|
@${test_and_cp}
|
| 140 |
|
|
|
| 141 |
|
|
installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
|
| 142 |
|
|
installcalib: ORIGIN=${DIRCALIB}
|
| 143 |
|
|
installcalib:
|
| 144 |
|
|
@${test_and_cp}
|
| 145 |
|
|
|
| 146 |
|
|
installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
|
| 147 |
|
|
installdoc: ORIGIN=${DIRDOC}
|
| 148 |
|
|
installdoc:
|
| 149 |
|
|
@${test_and_cp}
|
| 150 |
|
|
|
| 151 |
|
|
info:
|
| 152 |
|
|
@echo " "
|
| 153 |
|
|
@${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
|
| 154 |
|
|
@${EGREEN} " VERSION :" ${WHITE} ${VER}
|
| 155 |
|
|
@${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
|
| 156 |
|
|
@${EGREEN} " LIBS :" ${WHITE} ${LIBS}
|
| 157 |
|
|
@${EGREEN} " DOCS :" ${WHITE} ${DOCS}
|
| 158 |
|
|
@${EGREEN} " SRCS :" ${WHITE} ${SRCS}
|
| 159 |
|
|
@${EGREEN} " MACROS :" ${WHITE} ${MACROS}
|
| 160 |
|
|
@echo " "
|
| 161 |
|
|
@${RESET}
|
| 162 |
|
|
|
| 163 |
|
|
test: testpamenv
|
| 164 |
|
|
|
| 165 |
|
|
testpamenv: ${PAM_ENV}
|
| 166 |
|
|
|
| 167 |
|
|
root-config: OPT=--cflags
|
| 168 |
|
|
root-config:
|
| 169 |
|
|
@${test_cmd}
|
| 170 |
|
|
|
| 171 |
|
|
# Here follows some usefull macros
|
| 172 |
|
|
define test_and_cp
|
| 173 |
|
|
wd=`pwd`;\
|
| 174 |
|
|
for i in ${TOBEMOVED} ; do \
|
| 175 |
|
|
wv=$${i##/*/}; \
|
| 176 |
|
|
dest=$${i/$${wv}/}; \
|
| 177 |
|
|
${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
|
| 178 |
|
|
if [ ! "${FORCE}" ] ; then \
|
| 179 |
|
|
if [ ! -f $${i} ]; then \
|
| 180 |
|
|
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
|
| 181 |
|
|
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
|
| 182 |
|
|
cp ${ORIGIN}/$${i##/*/} $${i}; \
|
| 183 |
|
|
else \
|
| 184 |
|
|
${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
|
| 185 |
|
|
fi;\
|
| 186 |
|
|
else \
|
| 187 |
|
|
if [ "${FORCE}" == "-u" ] ; then \
|
| 188 |
|
|
if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
|
| 189 |
|
|
${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
|
| 190 |
|
|
rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
|
| 191 |
|
|
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
|
| 192 |
|
|
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
|
| 193 |
|
|
cp ${ORIGIN}/$${i##/*/} $${i}; \
|
| 194 |
|
|
else \
|
| 195 |
|
|
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
|
| 196 |
|
|
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
|
| 197 |
|
|
cp -f ${ORIGIN}/$${i##/*/} $${i}; \
|
| 198 |
|
|
fi; \
|
| 199 |
|
|
else \
|
| 200 |
|
|
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
|
| 201 |
|
|
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
|
| 202 |
|
|
cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
|
| 203 |
|
|
fi;\
|
| 204 |
|
|
fi ;\
|
| 205 |
|
|
if [ ! -z ${LINK} ] ; then \
|
| 206 |
|
|
${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
|
| 207 |
|
|
${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
|
| 208 |
|
|
cd $${dest}; \
|
| 209 |
|
|
ln -sf $${wv} $${wv/_${VER}/}; \
|
| 210 |
|
|
cd $${wd}; \
|
| 211 |
|
|
fi \
|
| 212 |
|
|
done
|
| 213 |
|
|
endef
|
| 214 |
|
|
|
| 215 |
|
|
define test_and_mk
|
| 216 |
|
|
${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
|
| 217 |
|
|
test -d "$@" || \
|
| 218 |
|
|
(${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
|
| 219 |
|
|
endef
|
| 220 |
|
|
|
| 221 |
|
|
define test_env
|
| 222 |
|
|
${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
|
| 223 |
|
|
printenv $(patsubst %_env,%,$@) 1>/dev/null || \
|
| 224 |
|
|
(${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
|
| 225 |
|
|
${RED} "not defined !!! Check your env. settings"; \
|
| 226 |
|
|
${RESET}; exit 1)
|
| 227 |
|
|
${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
|
| 228 |
|
|
endef
|
| 229 |
|
|
|
| 230 |
|
|
define test_cmd
|
| 231 |
|
|
${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
|
| 232 |
|
|
$@ ${OPT} 1>/dev/null 2>&1 || \
|
| 233 |
|
|
(${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
|
| 234 |
|
|
${RED} "not found !!! Check your installation"; \
|
| 235 |
|
|
${RESET}; exit 1)
|
| 236 |
|
|
${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
|
| 237 |
|
|
endef
|
| 238 |
|
|
|
| 239 |
|
|
define test_and_rm
|
| 240 |
|
|
for i in ${TOBEDEL}; do \
|
| 241 |
|
|
test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
|
| 242 |
|
|
rm -f $${i} ); \
|
| 243 |
|
|
test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
|
| 244 |
|
|
rm -rf $${i} ); \
|
| 245 |
|
|
done
|
| 246 |
|
|
endef
|