diff --git a/NPLib/Makefile b/NPLib/Makefile index 41cede0101f4b850935eae500475eca163cd2fad..4a1f3f20b646507a4a16834dc0e6b0e84271bb39 100644 --- a/NPLib/Makefile +++ b/NPLib/Makefile @@ -1,4 +1,6 @@ +# include Makefile options for different platforms include $(NPTOOL)/NPLib/Makefile.arch + #include /usr/local/root-5.32.01/etc/Makefile.arch #------------------------------------------------------------------------------ SHARELIB = SharedLib @@ -6,7 +8,7 @@ FILLINC = FillIncludeDir FILLLIB = FillLibraryDir LIBLIST = liblistfile -all: $(FILLINC) $(SHARELIB) $(FILLLIB) $(LIBLIST) +all: $(SHARELIB) $(FILLLIB) $(LIBLIST) #------------------------------------------------------------------------------ ############### fillinclib ############## FillIncludeDir: @@ -29,14 +31,25 @@ SharedLib: ############# Clean and More ########## clean: - $(NPTOOL)/NPLib/scripts/makefile.sh clean + $(NPTOOL)/NPLib/scripts/makefile.sh clean detector + +cleancore: + $(NPTOOL)/NPLib/scripts/makefile.sh clean core distclean: + @echo " + Deleting libraries in lib directory....." rm -f ./lib/* + @echo " + Deleting header files in include directory....." rm -f ./include/* + @echo " + Deleting liblist file....." rm -f liblist rm -f ./scripts/NPToolLogon_C* - ./scripts/makefile.sh distclean + ./scripts/makefile.sh distclean detector + ./scripts/makefile.sh distclean core + +# include makefile created by the configure script +# where the wanted detector are defined +include $(NPTOOL)/NPLib/Makefile.detector .SUFFIXES: .$(SrcSuf) diff --git a/NPLib/configure b/NPLib/configure new file mode 100755 index 0000000000000000000000000000000000000000..9d915cab261ce27cfd0f5038c7acffa35311697f --- /dev/null +++ b/NPLib/configure @@ -0,0 +1,160 @@ +# ***************************************************************************** +# * Copyright (C) 2009 this file is part of the NPTool Project * +# * * +# * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * +# * For the list of contributors see $NPTOOL/Licence/Contributors * +# *****************************************************************************/ + +# ***************************************************************************** +# * Original Author: N. de Sereville contact address: deserevi@ipno.in2p3.fr * +# * * +# * Creation Date : January 2013 * +# * Last update : * +# *---------------------------------------------------------------------------* +# * Decription: This script is in charge of preparing the installation of the * +# * NPLib. It does several things: * +# * + copy all header files to the include directory * +# * + compile the core libraries (all libraries which are not * +# * related to a specific detector) * +# * + generate the Makefile.detector makefile which is included * +# * in the main Makefile. The Makefile.detector has one entry * +# * per declared detector. * +# * * +# * This scripts accepts as arguments detector names. The name * +# * should be a lower case version of the directory name associated * +# * to the detector. * +# * If no argument is given, then all detectors are considered. * +# * * +# *---------------------------------------------------------------------------* +# * Comment: * +# * * +# * * +# ***************************************************************************** + +#! /bin/bash + + +# arguments list +args="$@" + +############################################################ +# First of all, define .core_libs and .detector_libs files # +############################################################ +corelibs="initialconditions interactioncoordinates ioroot physics tools vdetector" + +# core libraries list +core_file=".core_libs" +# if file exists delete it +if [ -e $core_file ] ; then + rm $core_file +fi ; + +# detector libraries list +detector_file=".detector_libs" +# if file exists delete it +if [ -e $detector_file ] ; then + rm $detector_file +fi ; + +# fill files +core_string="" +detector_string="" +for file in */Makefile +do + # remove "Makefile" string from file name + name=${file%\/*} + # file name in lower case + lname=$(echo "$name" | tr '[A-Z]' '[a-z]') + # only build core libraries + if echo "$corelibs" | grep -q "$lname" ; then + core_string="$core_string""$lname " + else + if [ $# = 0 ] ; then + detector_string="$detector_string""$lname " + else + # only add Makefile.detector target if it is in the + # arguments list + if echo "$args" | grep -q "$lname" ; then + detector_string="$detector_string""$lname " + fi ; + fi ; + fi ; +done + +echo "$core_string" >> $core_file +echo "$detector_string" >> $detector_file + + +########################################################################### +# Create detector entry in Makefile file for detectors given in arguments # +########################################################################### +# output file +outfile="Makefile.detector" +echo " + Creating $outfile file....." + +# if output file exists delete it +if [ -e $outfile ] ; then + rm $outfile +fi ; + +# create output file +echo "# WARNING:" >> $outfile +echo "# This file is automatically generated by the configure script." >> $outfile +echo "# If you modify this file by hand, changes won't persist the next time you run ./configure." >> $outfile +echo "#" >> $outfile + +# loop recursively on sub-directories containing a Makefile file +for file in */Makefile +do + # remove "Makefile" string from file name + name=${file%\/*} + # file name in lower case + lname=$(echo "$name" | tr '[A-Z]' '[a-z]') + # if no arguments are given, add all detectors in Makefile.detector + # by default + if [ $# = 0 ] ; then + # build target + echo "$lname": >> $outfile + # build commands + ./scripts/makefile_detector.sh $name $outfile + else + # only add Makefile.detector target if it is in the + # arguments list + if echo "$args" | grep -q "$lname" ; then + # build target + echo "$lname": >> $outfile + # build commands + ./scripts/makefile_detector.sh $name $outfile + fi ; + fi ; +done + + +######################## +# Build core libraries # +######################## +# (I) fill include directory with associated headers +#echo " + Copying header files to the include directory....." +./scripts/fillincdir.sh + +# (II) compile core libraries +echo " + Building core libraries....." +# loop recursively on sub-directories containing a Makefile file +for file in */Makefile +do + # remove "Makefile" string from file name + name=${file%\/*} + # file name in lower case + lname=$(echo "$name" | tr '[A-Z]' '[a-z]') + # only build core libraries + if echo "$corelibs" | grep -q "$lname" ; then + # print informations + echo "\tEntering $name directory..." + # add "-C ./" pattern at the beginning of the name + cmd="-C ./$name" + # execute make command with target specified on command line + make --silent $cmd + fi ; +done + + diff --git a/NPLib/scripts/buildliblist.sh b/NPLib/scripts/buildliblist.sh index b19d77cf21c3578ade02e8747219a87a07583000..0f83838fd3f23e6f1ba3f34416e1cf0f71349e8b 100755 --- a/NPLib/scripts/buildliblist.sh +++ b/NPLib/scripts/buildliblist.sh @@ -21,6 +21,8 @@ #! /bin/bash +echo " + Creating liblist file....." + # output file outfile="liblist" diff --git a/NPLib/scripts/fillincdir.sh b/NPLib/scripts/fillincdir.sh index 15d104e25846f2f8e1fe8c8f8f0108baf7ab3380..047c85026f4055a6737ccf4fcdb4666441309314 100755 --- a/NPLib/scripts/fillincdir.sh +++ b/NPLib/scripts/fillincdir.sh @@ -21,6 +21,8 @@ #! /bin/bash +echo " + Copying header files to the include directory....." + # previously, clean include directory cd include/ rm -f * diff --git a/NPLib/scripts/filllibdir.sh b/NPLib/scripts/filllibdir.sh index f0b9491ac6eaad5aba15aba0189b17ea7ff73462..993944fbb4ff61d5e227a988c8a6e28d90c83572 100755 --- a/NPLib/scripts/filllibdir.sh +++ b/NPLib/scripts/filllibdir.sh @@ -21,6 +21,8 @@ #! /bin/bash +echo " + Copying libraries to the lib directory....." + # previously, clean lib/ directory cd lib/ rm -f * diff --git a/NPLib/scripts/makefile.sh b/NPLib/scripts/makefile.sh index 75cc49995a8988c303b57c42f3fb9e05352a5c05..f6fb86cb4a9ec1c448037197e4657a1bf0d554de 100755 --- a/NPLib/scripts/makefile.sh +++ b/NPLib/scripts/makefile.sh @@ -26,15 +26,33 @@ #! /bin/bash +if [ $# = 0 ] ; then + echo " + Building detector libraries....." +else + echo " + Cleaning $2 libraries....." +fi ; + +# read .detector_libs or .core_libs file created by the configure script +file=".""$2_libs" +if [ $# = 0 ] ; then + file=".detector_libs" +fi ; +read -r detectorlibs < "$file" + # loop recursively on Makefile files in sub-directories for file in */Makefile do # remove "Makefile" string from file name name=${file%\/*} - # print informations - echo "Entering $name directory..." - # add "-C ./" pattern at the beginning of the name - cmd="-C ./$name" - # execute make command with target specified on command line - make --silent $1 $cmd + # file name in lower case + lname=$(echo "$name" | tr '[A-Z]' '[a-z]') + # only build defined detector libraries + if echo "$detectorlibs" | grep -q "$lname" ; then + # print informations + echo "\tEntering $name directory..." + # add "-C ./" pattern at the beginning of the name + cmd="-C ./$name" + # execute make command with target specified on command line + make --silent $1 $cmd + fi ; done diff --git a/NPLib/scripts/makefile_detector.sh b/NPLib/scripts/makefile_detector.sh new file mode 100755 index 0000000000000000000000000000000000000000..93ba57dc309b61f51c56f679272cc661c95611ac --- /dev/null +++ b/NPLib/scripts/makefile_detector.sh @@ -0,0 +1,45 @@ +# ***************************************************************************** +# * Copyright (C) 2009 this file is part of the NPTool Project * +# * * +# * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * +# * For the list of contributors see $NPTOOL/Licence/Contributors * +# *****************************************************************************/ + +# ***************************************************************************** +# * Original Author: N. de Sereville contact address: deserevi@ipno.in2p3.fr * +# * * +# * Creation Date : January 2013 * +# * Last update : * +# *---------------------------------------------------------------------------* +# * Decription: This script writes the commands that should be called when * +# * compiling individual detectors * +# * and call it with the argument passed to the script. * +# * Two arguments should be given: * +# * + first one is the directory name * +# * + second one is the file name where the messages are redirected * +# * * +# *---------------------------------------------------------------------------* +# * Comment: * +# * This script is called by the configure script in $NPTOOL/NPLib * +# * * +# ***************************************************************************** + +#! /bin/bash + +# build message +echo "\t@echo \"Entering $1 directory...\"" >> $2 +# execute make command with target specified on command line +echo "\tmake --silent -C ./$1" >> $2 +# copy header files +echo "\tcd $1; cp -f *.h ../include" >> $2 +# remove *Dict header files +echo "\tcd include; rm *Dict.h" >> $2 +# copy library files +echo "\tcd $1; cp -f *.so ../lib" >> $2 +# deal with mac osx dylib files +#echo "ifeq (\$(findstring macosx, \$(ARCH)), macosx)" >> $2 +#echo "\t@echo \"to be done\"" +#echo "endif" >> $2 +# newline +echo "" >> $2 +