--- PamelaLevel2/Makefile	2007/08/02 13:59:46	1.20
+++ PamelaLevel2/Makefile	2009/08/04 13:58:46	1.28
@@ -1,6 +1,6 @@
-# Calorimeter flight analysis software 
+# PamelaLevel2 software 
 # SOFTWARE VERSION
-VER= v3r04
+VER= v6r00
 # An almost general purpouse Makefile for PAMELA repository
 # Let's start with some usefull definition for colorize the echo 
 RED='\E[1;31;40m'
@@ -23,20 +23,32 @@
 # Here the variables used to override the standard make flags
 # C
 CC=gcc
-#CFLAGS=-Wall -O -fPIC -pthread -g
-CFLAGS=-Wall -O -fPIC -pthread
+#CFLAGS=-Wall -O -fPIC -pthread -g ${PAM_BIT} 
+CFLAGS=-Wall -O4 -fPIC -pthread ${PAM_BIT} 
 # Enviroment:
 GCCVER=`gcc --version | head -1`
 UNAMEA=`uname -a`
 TODAY=`date`
-# F77
+ifeq ($(GCC4),)
+export GCCVERS=$(shell echo `gcc -dumpversion | sed 's/\./\ /g'`)
+export GCCVERMAJ=$(word 1,$(GCCVERS))
+export GCC4=$(shell echo `echo "${GCCVERMAJ} > 3" |bc -l`)
+endif
+ifeq ($(GCC4),1)
+F77=gfortran
+LG2C=-lgfortran
+EXTRAOPT=
+else
 F77=g77
-#F77FLAGS=  -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
-F77FLAGS=  -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash
+LG2C=-lg2c
+EXTRAOPT=-Wno-globals -fvxt
+endif
+#F77FLAGS=  -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash ${PAM_BIT} 
+F77FLAGS=  -Wall -funroll-loops -fPIC $(EXTRAOPT) -fno-automatic -fbounds-check -extend_source -static -fno-backslash ${PAM_BIT} 
 # C++
 CXX=g++
-#CXXFLAGS=-Wall -O -fPIC -pthread -g
-CXXFLAGS=-Wall -O -fPIC -pthread
+#CXXFLAGS=-Wall -O -fPIC -pthread -g ${PAM_BIT} 
+CXXFLAGS=-Wall -O4 -fPIC -pthread ${PAM_BIT} 
 # ROOTCINT
 ROOTCINT=rootcint
 # Here the variables definig the local directories
@@ -130,7 +142,7 @@
 ${LIBF77LIBS}: ${LIBF77OBJS}
 	@(${EYELLOW} " F77 shared library --------------------------")
 	@(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
-	@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `doc/cernlib_pam mathlib`
+	@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ $(LG2C) `doc/cernlib_pam mathlib`
 
 
 ${LIBROOTLIBS}: ${LIBROOTSRCS} ${FOBJS}
@@ -155,7 +167,7 @@
 #	create .so
 #
 	@(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
-	@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} `doc/cernlib_pam mathlib` 1>/dev/null	 
+	@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $(LG2C) -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} `doc/cernlib_pam mathlib` 1>/dev/null	 
 #	@ln -sf  ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
 
 ${LIBCPPLIBS}: ${LIBCPPSRCS}
@@ -168,7 +180,7 @@
 #	create .so
 #
 	@(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
-	@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o 1>/dev/null
+	@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $(LG2C) -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o 1>/dev/null
 
 
 ${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS}