#! /usr/bin/perl -w # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # GSEAGEN configuration script # Based on GENIE configuration script # # For help, type ./configure -h # # Carla Distefano # Laboratori Nazionali del Sud - INFN # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # print out info & exit if any of the command-line arguments was --help # if(($match = grep(/-h/i, @ARGV)) > 0 ) { print "\n"; print "*** gSeaGen configure script *** \n\n"; print "Set GSEAGEN environmental variable pointing to the top level gSeaGen directory\n"; print "Set GENIE environmental variable pointing to the top level GENIE directory\n"; print "Set GENIE_REWEIGHT environmental variable pointing to the top level GENIE ReWeight directory (GENIE v3.0.0 or later)\n\n"; print "Usage: ./configure [option]... [flag=value]... \n\n"; print " FLAG DESCRIPTION DEFAULT\n"; print "\n enable/disable options with either --enable- or --disable- (e.g. --enable-music)\n\n"; print " antares Enable ANTARES output file writing default: disabled \n"; print " km3net Enable KM3NeT output file writing default: disabled \n"; print " jpp Enable JPP libraries default: disabled \n"; print " music Enable MUSIC (version 2004) muon propagator default: disabled \n"; print " tausic Enable TAUSIC (version 2004) tau propagator default: disabled \n"; print " proposal Enable PROPOSAL charged lepton propagator default: disabled \n"; print " tauola Enable TAUOLA tau decay engine default: disabled \n"; print " all Enable ANATRES, MUSIC, PROPOSAL \n"; print "\n options for prefix with --with- (eg --with-music-lib=/some/path/)\n\n"; print " antares-inc Path to ANTARES I/O includes needed if you --enable-antares (if unset: tries to auto-detect it) \n"; print " antares-lib Path to ANTARES I/O libraries needed if you --enable-antares (if unset: tries to auto-detect it) \n"; print " km3net-inc Path to KM3NET-DATAFORMAT includes needed if you --enable-km3net (if unset: tries to auto-detect it) \n"; print " km3net-lib Path to KM3NET-DATAFORMAT libraries needed if you --enable-km3net (if unset: tries to auto-detect it) \n"; print " music-lib Path to MUSIC libraries needed if you --enable-music \n"; print " music-dat Path to MUSIC data files needed if you --enable-music \n"; print " tausic-lib Path to TAUSIC libraries needed if you --enable-tausic \n"; print " tausic-dat Path to TAUSIC data files needed if you --enable-tausic \n"; print " proposal-inc Path to PROPOSAL includes needed if you --enable-proposal (if unset: tries to auto-detect it) \n"; print " proposal-lib Path to PROPOSAL libraries needed if you --enable-proposal (if unset: tries to auto-detect it) \n"; print " proposal-res Path to PROPOSAL resources needed if you --enable-proposal (if unset: tries to auto-detect it) \n"; print " proposal-ver PROPOSAL version needed if you --enable-proposal (if unset: tries to auto-detect it) \n"; print " tbb-lib Path to TBB libraries needed if you --enable-proposal (if unset: tries to auto-detect it) \n"; print " tauola-inc Path to TAUOLA includes needed if you --enable-tauola (if unset: tries to auto-detect it) \n"; print " tauola-lib Path to TAUOLA library needed if you --enable-tauola (if unset: tries to auto-detect it) \n"; print " boost-inc Path to boost includes always needed (if unset: tries to auto-detect it) \n"; print " boost-lib Path to boost libraries always needed (if unset: tries to auto-detect it) \n"; print "\n./configure --help | more \n\n"; exit 0; } $GSEAGENLYON = "/pbs/throng/km3net/src/gSeaGen"; # Check that $GENIE is set # $GSEAGEN = $ENV{'GSEAGEN'}; die ("*** Error *** The GSEAGEN environmental variable (pointing to the top level gSeaGen directory) is not defined") unless defined $GSEAGEN; # Check that $GENIE is set # $GENIE = $ENV{'GENIE'}; die ("*** Error *** The GENIE environmental variable (pointing to the top level GENIE directory) is not defined") unless defined $GENIE; $gopt_genie_top=$GENIE; # Read Genie version info open(REL_INFO, "<$GENIE/VERSION") or die("Can not read the GENIE release information!"); @rel_info=; close(REL_INFO); chomp($GENIEVER = $rel_info[0]); $GENIEVER=~m/(\d+).(\d+).(\d+)/; my $gopt_genieversion_gteq3 = "NO"; my $gopt_genie_reweight_top=""; if( $1 >= 3 ){ $gopt_genieversion_gteq3 = "YES"; # Check that $GENIE_REWEIGHT is set # if (defined $ENV{GENIE_REWEIGHT}){$GENIE_REWEIGHT = $ENV{'GENIE_REWEIGHT'};} else { $GENIE_REWEIGHT=substr $GENIE,0,index($GENIE, "Generator"); $GENIE_REWEIGHT=$GENIE_REWEIGHT."Reweight"; my $file = "$GENIE_REWEIGHT/lib/libGRwClc.so"; if(! -e $file) { print "*** Error *** You need to specify the GENIE_REWEIGHT environmental variable pointing to the top level GENIE ReWeight directory \n\n"; exit 1; } print "\n*** Warning *** GENIE_REWEIGHT has not been defined, automatically set to $GENIE_REWEIGHT \n\n"; } } $gopt_genie_reweight_top=$GENIE_REWEIGHT; # Check that $ROOTSYS is set # $ROOTSYS = $ENV{'ROOTSYS'}; die ("*** Error *** The ROOTSYS environmental variable is not defined. Is ROOT installed?") unless defined $ROOTSYS; # Check whether ROOT itself was build with GSL enabled # (GENIE uses GSL via ROOT's MathMore library.) # { $mathmore_lib = "$ROOTSYS/lib/libMathMore.so"; if( ! -f $mathmore_lib ) { die ("*** Error *** ROOT needs to be built with GSL/MathMore enabled."); } } # Enable auto-detection? # system("find $GSEAGEN/configure"); print "\n"; $auto_detect = ($?==0) ? 1 : 0; if(! $auto_detect) { print "\n*** Warning *** Path auto-detection is turned off. You need the 'find' utility to use that feature\n\n"; } # Open Make.config to write configuration options # $MKCONF_FILE = "$GSEAGEN/src/make/Make.config"; open(MKCONF, ">$MKCONF_FILE") or die("Can not write out the Make.config file!"); print MKCONF "# \n"; print MKCONF "# Make.config \n"; print MKCONF "# This file was automatically generated by the 'configure' script \n"; print MKCONF "# and is included into the project Makefiles \n"; print MKCONF "# \n"; # Create a string by joining all the command line arguments # my $options = join(" ", @ARGV); # Default --enable/--disable config options (for a minimal gSeaGen build) # my $gopt_enable_antares = "NO"; my $gopt_enable_km3net = "NO"; my $gopt_enable_jpp = "NO"; my $gopt_enable_music = "NO"; my $gopt_enable_tausic = "NO"; my $gopt_enable_proposal = "NO"; my $gopt_enable_tauola = "NO"; # Check configure's command line arguments for non-default values # if(($match = grep(/--enable-antares/i, @ARGV)) > 0) { $gopt_enable_antares = "YES"; } if(($match = grep(/--enable-km3net/i, @ARGV)) > 0) { $gopt_enable_km3net = "YES"; } if(($match = grep(/--enable-jpp/i, @ARGV)) > 0) { $gopt_enable_jpp = "YES"; } if(($match = grep(/--enable-music/i, @ARGV)) > 0) { $gopt_enable_music = "YES"; } if(($match = grep(/--enable-tausic/i, @ARGV)) > 0) { $gopt_enable_tausic = "YES"; } if(($match = grep(/--enable-proposal/i, @ARGV)) > 0) { $gopt_enable_proposal = "YES"; } if(($match = grep(/--enable-tauola/i, @ARGV)) > 0) { $gopt_enable_tauola = "YES"; } if(($match = grep(/--enable-all/i, @ARGV)) > 0) { $gopt_enable_antares = "YES"; $gopt_enable_km3net = "YES"; $gopt_enable_music = "YES"; $gopt_enable_tausic = "YES"; $gopt_enable_proposal = "YES"; $gopt_enable_tauola = "YES"; } # ------------------------------------------------ # BOOST paths # ------------------------------------------------ my $gopt_with_boost_inc = ""; my $gopt_with_boost_lib = ""; # # --with-boost-inc= # if($options=~m/--with-boost-inc=(\S*)/i) { $gopt_with_boost_inc = $1; } if(! -d $gopt_with_boost_inc && $auto_detect) { print "\n*** Warning *** You didn't specify the boost include path \n"; print "Auto-detecting...\n"; $matched = auto_detect("json_parser.hpp"); if( $matched=~m/(\S*)\/boost\/property_tree\/json_parser.hpp/i ) { $gopt_with_boost_inc = $1; } print "Setting --with-boost-inc=$gopt_with_boost_inc\n"; } my $filet = "$gopt_with_boost_inc/boost/thread.hpp"; if(! -f $filet) { print "*** Error *** boost/thread.hpp not found. You need to specify the boost include path using --with-boost-inc=/some/path/\n\n"; exit 1; } my $filej = "$gopt_with_boost_inc/boost/property_tree/json_parser.hpp"; if(! -f $filej) { print "*** Error *** boost/property_tree/json_parser.hpp not found. You need to specify the boost include path using --with-boost-inc=/some/path/\n\n"; exit 1; } my $fileo = "$gopt_with_boost_inc/boost/program_options/options_description.hpp"; if(! -f $fileo) { print "*** Error *** boost/program_options/options_description.hpp not found. You need to specify the boost include path using --with-boost-inc=/some/path/\n\n"; exit 1; } # # --with-boost-lib= # if($options=~m/--with-boost-lib=(\S*)/i) { $gopt_with_boost_lib = $1; } if(! -d $gopt_with_boost_lib && $auto_detect) { print "\n*** Warning *** You didn't specify the boost library path \n"; print "Auto-detecting...\n"; $matched = auto_detect("libboost_thread.*"); if( $matched=~m/(\S*)\/libboost_thread\S*/i ) { $gopt_with_boost_lib = $1; } if (! -f $matched) { $matched = auto_detect("libboost_thread-mt.*"); if( $matched=~m/(\S*)\/libboost_thread\S*/i ) { $gopt_with_boost_lib = $1; } } print "Setting --with-boost-lib=$gopt_with_boost_lib\n"; } my $filetso = "$gopt_with_boost_lib/libboost_thread.so"; if(! -f $filetso) { print "*** Error *** libboost_thread not found. You need to specify the boost library path using --with-boost-lib=/some/path/\n\n"; exit 1; } my $filepso = "$gopt_with_boost_lib/libboost_program_options.so"; if(! -f $filepso) { print "*** Error *** libboost_program_options not found. You need to specify the boost library path using --with-boost-lib=/some/path/\n\n"; exit 1; } # ------------------------------------------------ # ANTARES-IO paths # ------------------------------------------------ # If --enable-antares was set then the full path to the ANTARES library must be specified # my $gopt_with_antares_lib = ""; if($gopt_enable_antares eq "YES") { if(($match = grep(/--with-antares-lib/i, @ARGV)) > 0) { $options=~m/--with-antares-lib=(\S*)/i; $gopt_with_antares_lib = $1; } if(! -d $gopt_with_antares_lib) { print "\n*** Warning *** ANTARES has been enabled but you didn't specify the ANTARES I/O library path \n"; print "Auto-detecting...\n"; $matched = auto_detect("io_gcc.o"); if( $matched=~m/(\S*)\/io_gcc\S*/i ) { $gopt_with_antares_lib = $1; } print "Setting --with-antares-lib=$gopt_with_antares_lib\n"; } # check my $file = "$gopt_with_antares_lib/io_gcc.o"; if(! -e $file) { print "*** Error *** You need to specify the path to ANTARES I/O library using --with-antares-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-antares\n\n"; exit 1; } } # If --enable-antares was set then the full path to the ANTARES includes must be specified # my $gopt_with_antares_inc = ""; if($gopt_enable_antares eq "YES") { if(($match = grep(/--with-antares-inc/i, @ARGV)) > 0) { $options=~m/--with-antares-inc=(\S*)/i; $gopt_with_antares_inc = $1; } if(! -d $gopt_with_antares_inc) { print "\n*** Warning *** ANTARES has been enabled but you didn't specify the ANTARES I/O includes path \n"; print "Auto-detecting...\n"; $matched = auto_detect("io_gcc.hh"); if( $matched=~m/(\S*)\/io_gcc\S*/i ) { $gopt_with_antares_inc = $1; } print "Setting --with-antares-inc=$gopt_with_antares_inc\n"; } # check my $file = "$gopt_with_antares_inc/io_gcc.hh"; if(! -e $file) { print "*** Error *** You need to specify the ANTARES I/O includes path using --with-antares-inc=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-antares\n\n"; exit 1; } } # ------------------------------------------------ # KM3NET-DATAFORMAT paths # ------------------------------------------------ # If --enable-km3net was set then the full path to the KM3NeT library must be specified # my $gopt_with_km3net_lib = ""; if($gopt_enable_km3net eq "YES") { if(($match = grep(/--with-km3net-lib/i, @ARGV)) > 0) { $options=~m/--with-km3net-lib=(\S*)/i; $gopt_with_km3net_lib = $1; } if(! -d $gopt_with_km3net_lib) { print "\n*** Warning *** KM3NeT has been enabled but you didn't specify the KM3NET-DATAFORMAT library path \n"; print "Auto-detecting...\n"; $matched = auto_detect("libKM3NeTROOT.so"); if( $matched=~m/(\S*)\/libKM3NeTROOT.so\S*/i ) { $gopt_with_km3net_lib = $1; } print "Setting --with-km3net-lib=$gopt_with_km3net_lib\n"; } # check my $file = "$gopt_with_km3net_lib/libKM3NeTROOT.so"; if(! -e $file) { print "*** Error *** You need to specify the path to KM3NET-DATAFORMAT library using --with-km3net-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-km3net\n\n"; exit 1; } } # If --enable-km3net was set then the full path to the KM3NeT includes must be specified # my $gopt_with_km3net_inc = ""; if($gopt_enable_km3net eq "YES") { if(($match = grep(/--with-km3net-inc/i, @ARGV)) > 0) { $options=~m/--with-km3net-inc=(\S*)/i; $gopt_with_km3net_inc = $1; } if(! -d $gopt_with_km3net_inc) { print "\n*** Warning *** KM3NeT has been enabled but you didn't specify the KM3NET-DATAFORMAT includes path \n"; print "Auto-detecting...\n"; $matched = auto_detect("Evt.hh"); if( $matched=~m/(\S*)\/Evt.hh\S*/i ) { $gopt_with_km3net_inc = $1; } print "Setting --with-km3net-inc=$gopt_with_km3net_inc\n"; } # check my $file = "$gopt_with_km3net_inc/Evt.hh"; if(! -e $file) { print "*** Error *** You need to specify the KM3NET-DATAFORMAT includes path using --with-km3net-inc=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-km3net\n\n"; exit 1; } } # ------------------------------------------------ # JPP paths # ------------------------------------------------ # If --enable-jpp was set check if JPP_DIR is defined if($gopt_enable_jpp eq "YES") { die ("*** Error *** The JPP_DIR environmental variable (pointing to the top level JPP directory) is not defined") unless defined $ENV{'JPP_DIR'}; # check my $file = "$ENV{'JPP_DIR'}/software"; if(! -d $file) { print "*** Error *** The JPP package couldn't be found\n"; print "*** Error *** Otherwise, you should --disable-jpp\n\n"; exit 1; } } # ------------------------------------------------ # CERNLIB paths # ------------------------------------------------ # If --enable-music was set then the full path to CERNLIB bin must be specified # if($gopt_enable_music eq "YES" or $gopt_enable_tausic eq "YES") { die ("*** Error *** The CERN environmental variable is not defined and MUSIC or TAUSIC enable") unless defined $ENV{'CERN'}; die ("*** Error *** The CERN_LEVEL environmental variable is not defined and MUSIC or TAUSIC enable") unless defined $ENV{'CERN_LEVEL'}; die ("*** Error *** The CERN_ROOT environmental variable is not defined and MUSIC or TAUSIC enable") unless defined $ENV{'CERN_ROOT'}; die ("*** Error *** The CVSCOSRC environmental variable is not defined and MUSIC or TAUSIC enable") unless defined $ENV{'CVSCOSRC'}; # check my $file = "$ENV{'CERN_ROOT'}/bin/cernlib"; if(! -e $file) { print "*** Error *** The cernlib executable couldn't be found\n"; print "*** Error *** Otherwise, you should --disable-music\n\n"; exit 1; } } # ------------------------------------------------ # MUSIC paths # ------------------------------------------------ # If --enable-music was set then the full path to the MUSIC library must be specified # my $gopt_with_music_lib = ""; if($gopt_enable_music eq "YES") { if(($match = grep(/--with-music-lib/i, @ARGV)) > 0) { $options=~m/--with-music-lib=(\S*)/i; $gopt_with_music_lib = $1; } if(! -d $gopt_with_music_lib) { print "\n*** Warning *** MUSIC has been enabled but you didn't specify the MUSIC libraries path \n"; print "Auto-detecting...\n"; $matched = auto_detect("music-sw-2004.*"); if( $matched=~m/(\S*)\/music-sw-2004\S*/i ) { $gopt_with_music_lib = $1; } print "Setting --with-music-lib=$gopt_with_music_lib\n"; } # check my $filesw = "$gopt_with_music_lib/music-sw-2004.f"; if(! -e $filesw) { print "*** Error *** You need to specify the path to MUSIC library using --with-music-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-music\n\n"; exit 1; } my $filesr = "$gopt_with_music_lib/music-sr-2004.f"; if(! -e $filesr) { print "*** Error *** You need to specify the path to MUSIC library using --with-music-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-music\n\n"; exit 1; } } # If --enable-music was set then the full path to the MUSIC data file must be specified # my $gopt_with_music_dat = ""; if($gopt_enable_music eq "YES") { if(($match = grep(/--with-music-dat/i, @ARGV)) > 0) { $options=~m/--with-music-dat=(\S*)/i; $gopt_with_music_dat = $1; } if(! -d $gopt_with_music_dat) { print "\n*** Warning *** MUSIC has been enabled but you didn't specify the MUSIC data files path \n"; $gopt_with_music_dat = $gopt_with_music_lib; my $filesw = "$gopt_with_music_lib/music-double-diff-seawater-f2.dat"; my $filesr = "$gopt_with_music_lib/music-double-diff-rock-f2.dat"; if(! -e $filesw && ! -e $filesr) { print "Auto-detecting...\n"; $matched = auto_detect("music-double-diff-seawater-f2.dat"); if( $matched=~m/(\S*)\/music-double-diff-seawater-f2\S*/i ) { $gopt_with_music_dat = $1; } } print "Setting --with-music-dat=$gopt_with_music_dat\n"; } # check my $filesw = "$gopt_with_music_dat/music-double-diff-seawater-f2.dat"; my $filesr = "$gopt_with_music_dat/music-double-diff-rock-f2.dat"; if(! -e $filesw && ! -e $filesr) { print "*** Error *** You need to specify the path to MUSIC data files --with-music-dta=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-music\n\n"; exit 1; } } # ------------------------------------------------ # TAUSIC paths # ------------------------------------------------ # If --enable-tausic was set then the full path to the TAUSIC library must be specified # my $gopt_with_tausic_lib = ""; if($gopt_enable_tausic eq "YES") { if(($match = grep(/--with-tausic-lib/i, @ARGV)) > 0) { $options=~m/--with-tausic-lib=(\S*)/i; $gopt_with_tausic_lib = $1; } if(! -d $gopt_with_tausic_lib) { print "\n*** Warning *** TAUSIC has been enabled but you didn't specify the TAUSIC libraries path \n"; print "Auto-detecting...\n"; $matched = auto_detect("tausic-sw-2004.*"); if( $matched=~m/(\S*)\/tausic-sw-2004\S*/i ) { $gopt_with_tausic_lib = $1; } print "Setting --with-tausic-lib=$gopt_with_tausic_lib\n"; } # check my $filesw = "$gopt_with_tausic_lib/tausic-sw-2004.f"; if(! -e $filesw) { print "*** Error *** You need to specify the path to TAUSIC library using --with-tausic-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-tausic\n\n"; exit 1; } my $filesr = "$gopt_with_tausic_lib/tausic-sr-2004.f"; if(! -e $filesr) { print "*** Error *** You need to specify the path to TAUSIC library using --with-tausic-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-tausic\n\n"; exit 1; } } # If --enable-tausic was set then the full path to the TAUSIC data file must be specified # my $gopt_with_tausic_dat = ""; if($gopt_enable_tausic eq "YES") { if(($match = grep(/--with-tausic-dat/i, @ARGV)) > 0) { $options=~m/--with-tausic-dat=(\S*)/i; $gopt_with_tausic_dat = $1; } if(! -d $gopt_with_tausic_dat) { print "\n*** Warning *** TAUSIC has been enabled but you didn't specify the TAUSIC data files path \n"; $gopt_with_tausic_dat = $gopt_with_tausic_lib; my $filesw = "$gopt_with_tausic_lib/tausic-double-diff-seawater-f2.dat"; my $filesr = "$gopt_with_tausic_lib/tausic-double-diff-rock-f2.dat"; if(! -e $filesw && ! -e $filesr) { print "Auto-detecting...\n"; $matched = auto_detect("tausic-double-diff-seawater-f2.dat"); if( $matched=~m/(\S*)\/tausic-double-diff-seawater-f2\S*/i ) { $gopt_with_tausic_dat = $1; } } print "Setting --with-tausic-dat=$gopt_with_tausic_dat\n"; } # check my $filesw = "$gopt_with_tausic_dat/tausic-double-diff-seawater-f2.dat"; my $filesr = "$gopt_with_tausic_dat/tausic-double-diff-rock-f2.dat"; if(! -e $filesw && ! -e $filesr) { print "*** Error *** You need to specify the path to TAUSIC data files --with-tausic-dta=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-tausic\n\n"; exit 1; } } # ------------------------------------------------ # PROPOSAL paths # ------------------------------------------------ # If --enable-proposal was set then the full path to the TBB library must be specified # my $gopt_with_tbb_lib = ""; if($gopt_enable_proposal eq "YES") { if(($match = grep(/--with-tbb-lib/i, @ARGV)) > 0) { $options=~m/--with-tbb-lib=(\S*)/i; $gopt_with_tbb_lib = $1; } if(! -d $gopt_with_tbb_lib) { print "\n*** Warning *** PROPOSAL has been enabled but you didn't specify the TBB library path \n"; print "Auto-detecting...\n"; $matched = auto_detect("libtbb.so"); if( $matched=~m/(\S*)\/libtbb\S*/i ) { $gopt_with_tbb_lib = $1; print "Setting --with-tbb-lib=$gopt_with_tbb_lib\n"; } } # check my $file = "$gopt_with_tbb_lib/libtbb.so"; if(! -e $file) { print "*** Error *** You need to specify the path to TBB library using --with-tbb-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-proposal\n\n"; exit 1; } } # If --enable-proposal was set then the full path to the PROPOSAL library must be specified # my $gopt_with_proposal_lib = ""; if($gopt_enable_proposal eq "YES") { if(($match = grep(/--with-proposal-lib/i, @ARGV)) > 0) { $options=~m/--with-proposal-lib=(\S*)/i; $gopt_with_proposal_lib = $1; } if(! -d $gopt_with_proposal_lib) { print "\n*** Warning *** PROPOSAL has been enabled but you didn't specify the PROPOSAL library path \n"; print "Auto-detecting...\n"; $matched = auto_detect("libPROPOSAL.so"); if( $matched=~m/(\S*)\/libPROPOSAL\S*/i ) { $gopt_with_proposal_lib = $1; print "Setting --with-proposal-lib=$gopt_with_proposal_lib\n"; } } # check my $file = "$gopt_with_proposal_lib/libPROPOSAL.so"; if(! -e $file) { print "*** Error *** You need to specify the path to PROPOSAL library using --with-proposal-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-proposal\n\n"; exit 1; } } # If --enable-proposal was set then the full path to the PROPOSAL includes must be specified # my $gopt_with_proposal_inc = ""; if($gopt_enable_proposal eq "YES") { if(($match = grep(/--with-proposal-inc/i, @ARGV)) > 0) { $options=~m/--with-proposal-inc=(\S*)/i; $gopt_with_proposal_inc = $1; } if(! -d $gopt_with_proposal_inc) { print "\n*** Warning *** PROPOSAL has been enabled but you didn't specify the PROPOSAL includes path \n"; print "Auto-detecting...\n"; $matched = auto_detect("PROPOSAL.h"); if( $matched=~m/(\S*)\/PROPOSAL\S*/i ) { $gopt_with_proposal_inc = $1; $gopt_with_proposal_inc=substr $gopt_with_proposal_inc,0,index($gopt_with_proposal_inc, "public/PROPOSAL")+6; print "Setting --with-proposal-inc=$gopt_with_proposal_inc\n"; } } # check my $file = "$gopt_with_proposal_inc/PROPOSAL/PROPOSAL.h"; if(! -e $file) { print "*** Error *** You need to specify the PROPOSAL includes path using --with-proposal-inc=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-proposal\n\n"; exit 1; } } # If --enable-proposal was set then the full path to the PROPOSAL resources must be specified # my $gopt_with_proposal_res = ""; if($gopt_enable_proposal eq "YES") { if(($match = grep(/--with-proposal-res/i, @ARGV)) > 0) { $options=~m/--with-proposal-res=(\S*)/i; $gopt_with_proposal_res = $1; } else { print "\n*** Error *** PROPOSAL has been enabled but you didn't specify the PROPOSAL table path \n"; exit 1; } if(! -d $gopt_with_proposal_res) { print "\n*** Error *** PROPOSAL has been enabled but you specified an invalid PROPOSAL table path \n"; exit 1; } } # If --enable-proposal was set then the code version must be specified # my $gopt_with_proposal_ver = ""; my $gopt_with_proposal_ver_major = ""; my $gopt_with_proposal_ver_minor = ""; my $gopt_with_proposal_ver_patch = ""; if($gopt_enable_proposal eq "YES") { if(($match = grep(/--with-proposal-ver/i, @ARGV)) > 0) { $options=~m/--with-proposal-ver=(\S*)/i; $gopt_with_proposal_ver = $1; } else { print "\n*** Warning *** PROPOSAL has been enabled but you didn't specify the PROPOSAL version\n"; print "Auto-detecting...\n"; my $version_file = "$gopt_with_proposal_inc/PROPOSAL/version.h"; my $json_incl = "$gopt_with_proposal_inc/PROPOSAL/json.hpp"; if(-e $version_file){ # check if version.h exists open(PROP_INFO, "<$version_file") or die("Can not read the PROPOSAL release information!"); while(){ if(index($_,"PROPOSAL_VERSION =") != -1){ my $p = index($_,"\""); $gopt_with_proposal_ver = substr $_, $p+1; $p = index($gopt_with_proposal_ver,"\""); $gopt_with_proposal_ver = substr $gopt_with_proposal_ver, 0, $p; } } close(PROP_INFO); } elsif(-e $json_incl){ $gopt_with_proposal_ver = "6.0.0"; } else{ $gopt_with_proposal_ver = "5.0.0"; } print "Setting --with-proposal-ver=$gopt_with_proposal_ver\n"; } $gopt_with_proposal_ver=~m/(\d+).(\d+).(\d+)/; if( $1 < 5 ){ print "*** Error *** gSeaGen requires PROPOSAL version 5.0.0 or later \n\n"; exit 1; } $gopt_with_proposal_ver_major = $1; $gopt_with_proposal_ver_minor = $2; $gopt_with_proposal_ver_patch = $3; } # ------------------------------------------------ # TAUOLA paths # ------------------------------------------------ # If --enable-tauola was set then the full path to the TAUOLA library must be specified # my $gopt_with_tauola_lib = ""; if($gopt_enable_tauola eq "YES") { if(($match = grep(/--with-tauola-lib/i, @ARGV)) > 0) { $options=~m/--with-tauola-lib=(\S*)/i; $gopt_with_tauola_lib = $1; } if(! -d $gopt_with_tauola_lib) { print "\n*** Warning *** TAUOLA has been enabled but you didn't specify the TAUOLA library path \n"; print "Auto-detecting...\n"; $matched = auto_detect("libTauolaCxxInterface.a"); if( $matched=~m/(\S*)\/libTauolaCxxInterface\S*/i ) { $gopt_with_tauola_lib = $1; print "Setting --with-tauola-lib=$gopt_with_tauola_lib\n"; } } # check my $file = "$gopt_with_tauola_lib/libTauolaCxxInterface.a"; if(! -e $file) { print "*** Error *** You need to specify the path to TAUOLA library using --with-tauola-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-tauola\n\n"; exit 1; } } # If --enable-tauola was set then the full path to the TAUOLA includes must be specified # my $gopt_with_tauola_inc = ""; if($gopt_enable_tauola eq "YES") { if(($match = grep(/--with-tauola-inc/i, @ARGV)) > 0) { $options=~m/--with-tauola-inc=(\S*)/i; $gopt_with_tauola_inc = $1; } if(! -d $gopt_with_tauola_inc) { print "\n*** Warning *** TAUOLA has been enabled but you didn't specify the TAUOLA includes path \n"; print "Auto-detecting...\n"; $matched = auto_detect("Tauola.h","Tauola/Tauola.h"); if( $matched=~m/(\S*)\/Tauola\/Tauola\S*/i ) { $gopt_with_tauola_inc = $1; print "Setting --with-tauola-inc=$gopt_with_tauola_inc\n"; } } # check my $file = "$gopt_with_tauola_inc/Tauola/Tauola.h"; if(! -e $file) { print "*** Error *** You need to specify the TAUOLA includes path using --with-tauola-inc=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-tauola\n\n"; exit 1; } } # Save config options # print MKCONF "GOPT_ENABLE_ANTARES=$gopt_enable_antares\n"; print MKCONF "GOPT_ENABLE_KM3NET=$gopt_enable_km3net\n"; print MKCONF "GOPT_ENABLE_MUSIC=$gopt_enable_music\n"; print MKCONF "GOPT_ENABLE_JPP=$gopt_enable_jpp\n"; print MKCONF "GOPT_ENABLE_TAUSIC=$gopt_enable_tausic\n"; print MKCONF "GOPT_ENABLE_PROPOSAL=$gopt_enable_proposal\n"; print MKCONF "GOPT_ENABLE_TAUOLA=$gopt_enable_tauola\n"; print MKCONF "GOPT_WITH_ANTARES_LIB=$gopt_with_antares_lib\n"; print MKCONF "GOPT_WITH_ANTARES_INC=$gopt_with_antares_inc\n"; print MKCONF "GOPT_WITH_KM3NET_LIB=$gopt_with_km3net_lib\n"; print MKCONF "GOPT_WITH_KM3NET_INC=$gopt_with_km3net_inc\n"; print MKCONF "GOPT_WITH_MUSIC_LIB=$gopt_with_music_lib\n"; print MKCONF "GOPT_WITH_MUSIC_DAT=$gopt_with_music_dat\n"; print MKCONF "GOPT_WITH_TAUSIC_LIB=$gopt_with_tausic_lib\n"; print MKCONF "GOPT_WITH_TAUSIC_DAT=$gopt_with_tausic_dat\n"; print MKCONF "GOPT_WITH_PROPOSAL_LIB=$gopt_with_proposal_lib\n"; print MKCONF "GOPT_WITH_PROPOSAL_INC=$gopt_with_proposal_inc\n"; print MKCONF "GOPT_WITH_PROPOSAL_RES=$gopt_with_proposal_res\n"; print MKCONF "GOPT_WITH_PROPOSAL_VER_MAJOR=$gopt_with_proposal_ver_major\n"; print MKCONF "GOPT_WITH_PROPOSAL_VER_MINOR=$gopt_with_proposal_ver_minor\n"; print MKCONF "GOPT_WITH_PROPOSAL_VER_PATCH=$gopt_with_proposal_ver_patch\n"; print MKCONF "GOPT_WITH_TBB_LIB=$gopt_with_tbb_lib\n"; print MKCONF "GOPT_WITH_TAUOLA_LIB=$gopt_with_tauola_lib\n"; print MKCONF "GOPT_WITH_TAUOLA_INC=$gopt_with_tauola_inc\n"; print MKCONF "GOPT_WITH_BOOST_LIB=$gopt_with_boost_lib\n"; print MKCONF "GOPT_WITH_BOOST_INC=$gopt_with_boost_inc\n"; print MKCONF "GOPT_GENIEVERSION_GTEQ3=$gopt_genieversion_gteq3\n"; print MKCONF "GOPT_GENIE=$gopt_genie_top\n"; print MKCONF "GOPT_GENIE_REWEIGHT=$gopt_genie_reweight_top\n"; close(MKCONF); # Create the setenv.* files my $gopt_enable_lhapdf = "NO"; my $gopt_enable_lhapdf5 = "NO"; my $gopt_enable_lhapdf6 = "NO"; my $gopt_with_lhapdf_lib = ""; my $gopt_with_lhapdf5_lib = ""; my $gopt_with_lhapdf6_lib = ""; my $gopt_with_pythia6_lib = ""; my $gopt_with_libxml2_lib = ""; my $gopt_with_apfel_lib = ""; $MKCONF_FILE_GENIE = "$GENIE/src/make/Make.config"; open(MKCONFRGENIE, "<$MKCONF_FILE_GENIE") or die("Can not read back the $GENIE/src/make/Make.config!"); @genie_conf=; close(MKCONFRGENIE); foreach $setting (@genie_conf) { chomp($setting); if ($setting=~m/\=/) { if ($setting=~m/YES/) { if($gopt_genieversion_gteq3 =~m/YES/){ if(grep(/GOPT_ENABLE_LHAPDF5/i, $setting)) {$gopt_enable_lhapdf5 = "YES";} if(grep(/GOPT_ENABLE_LHAPDF6/i, $setting)) {$gopt_enable_lhapdf6 = "YES";} } else{ if(grep(/GOPT_ENABLE_LHAPDF/i, $setting)) {$gopt_enable_lhapdf = "YES";} } } if(grep(/GOPT_WITH_LHAPDF_LIB/i, $setting)) {$gopt_with_lhapdf_lib = substr $setting, index($setting, "=")+1;} if(grep(/GOPT_WITH_LHAPDF5_LIB/i, $setting)) {$gopt_with_lhapdf5_lib = substr $setting, index($setting, "=")+1;} if(grep(/GOPT_WITH_LHAPDF6_LIB/i, $setting)) {$gopt_with_lhapdf6_lib = substr $setting, index($setting, "=")+1;} if(grep(/GOPT_WITH_PYTHIA6_LIB/i, $setting)) {$gopt_with_pythia6_lib = substr $setting, index($setting, "=")+1;} if(grep(/GOPT_WITH_LIBXML2_LIB/i, $setting)) {$gopt_with_libxml2_lib = substr $setting, index($setting, "=")+1;} if(grep(/GOPT_WITH_APFEL_LIB/i, $setting)) {$gopt_with_apfel_lib = substr $setting, index($setting, "=")+1;} } } my $LIBPATH = $ENV{'LD_LIBRARY_PATH'}; my $LIBNAME = "LD_LIBRARY_PATH"; $OSTYPE = $ENV{'OSTYPE'}; if($OSTYPE =~m/darwin/){ $LIBPATH = $ENV{'DYLD_LIBRARY_PATH'}; $LIBNAME = "DYLD_LIBRARY_PATH"; } $MSETENVC_FILE = "$GSEAGEN/setenv.csh"; open(MKSETENVC, ">$MSETENVC_FILE") or die("Can not write out $MSETENVC_FILE"); $MSETENVB_FILE = "$GSEAGEN/setenv.sh"; open(MKSETENVB, ">$MSETENVB_FILE") or die("Can not write out $MSETENVB_FILE"); print MKSETENVC "#!/bin/tcsh\n"; print MKSETENVB "#!/bin/bash\n"; print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "setenv GSEAGEN $GSEAGEN\n"; print MKSETENVB "export GSEAGEN=$GSEAGEN\n"; print MKSETENVC "setenv GENIE $GENIE\n"; print MKSETENVB "export GENIE=$GENIE\n"; if($gopt_genieversion_gteq3 =~m/YES/){ print MKSETENVC "setenv GENIE_REWEIGHT $GENIE_REWEIGHT\n"; print MKSETENVB "export GENIE_REWEIGHT=$GENIE_REWEIGHT\n"; } if(-e "$GENIE/genie_xsec/gSeaGen") { print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "setenv GXMLPATH \$GENIE/genie_xsec/gSeaGen\n"; print MKSETENVB "export GXMLPATH=\$GENIE/genie_xsec/gSeaGen\n"; } print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "if ( ! \$?PATH ) then\n"; print MKSETENVC " setenv PATH\n"; print MKSETENVC "endif\n"; print MKSETENVB "if [ -z \${PATH+x} ]; then\n"; print MKSETENVB " export PATH\n"; print MKSETENVB "fi\n"; print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "setenv PATH \$GSEAGEN/bin:\$PATH\n"; print MKSETENVB "export PATH=\$GSEAGEN/bin:\$PATH\n"; print MKSETENVC "setenv PATH \$GENIE/bin:\$PATH\n"; print MKSETENVB "export PATH=\$GENIE/bin:\$PATH\n"; print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "setenv LHAPATH \$GENIE/data/evgen/pdfs\n"; print MKSETENVB "export LHAPATH=\$GENIE/data/evgen/pdfs\n"; print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "cd $ROOTSYS/bin\n"; print MKSETENVC "source thisroot.csh\n"; print MKSETENVC "cd -\n"; print MKSETENVB "cd $ROOTSYS\n"; print MKSETENVB "source bin/thisroot.sh\n"; print MKSETENVB "cd -\n"; print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "if ( ! \$?LD_LIBRARY_PATH ) then\n"; print MKSETENVC " setenv LD_LIBRARY_PATH\n"; print MKSETENVC "endif\n"; print MKSETENVB "if [ -z \${LD_LIBRARY_PATH+x} ]; then\n"; print MKSETENVB " export LD_LIBRARY_PATH\n"; print MKSETENVB "fi\n"; print MKSETENVC "\n"; print MKSETENVB "\n"; print MKSETENVC "setenv $LIBNAME \$GSEAGEN/lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=\$GSEAGEN/lib:\$$LIBNAME\n"; print MKSETENVC "setenv $LIBNAME \$GENIE/lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=\$GENIE/lib:\$$LIBNAME\n"; if($gopt_genieversion_gteq3 =~m/YES/){ print MKSETENVC "setenv $LIBNAME \$GENIE_REWEIGHT/lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=\$GENIE_REWEIGHT/lib:\$$LIBNAME\n"; } if($gopt_enable_km3net =~m/YES/){ print MKSETENVC "setenv $LIBNAME $gopt_with_km3net_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_km3net_lib:\$$LIBNAME\n"; } if($gopt_enable_lhapdf =~m/YES/){ print MKSETENVC "setenv $LIBNAME $gopt_with_lhapdf_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_lhapdf_lib:\$$LIBNAME\n"; } if($gopt_enable_lhapdf5 =~m/YES/){ print MKSETENVC "setenv $LIBNAME $gopt_with_lhapdf5_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_lhapdf5_lib:\$$LIBNAME\n"; } if($gopt_enable_lhapdf6 =~m/YES/){ print MKSETENVC "setenv $LIBNAME $gopt_with_lhapdf6_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_lhapdf6_lib:\$$LIBNAME\n"; } print MKSETENVC "setenv $LIBNAME $gopt_with_pythia6_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_pythia6_lib:\$$LIBNAME\n"; print MKSETENVC "setenv $LIBNAME $gopt_with_libxml2_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_libxml2_lib:\$$LIBNAME\n"; print MKSETENVC "setenv $LIBNAME $gopt_with_boost_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_boost_lib:\$$LIBNAME\n"; if ($gopt_with_apfel_lib ne ""){ print MKSETENVC "setenv $LIBNAME $gopt_with_apfel_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_apfel_lib:\$$LIBNAME\n"; } if ($gopt_with_tauola_lib ne ""){ print MKSETENVC "setenv $LIBNAME $gopt_with_tauola_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_tauola_lib:\$$LIBNAME\n"; } if(-e "$GSEAGENLYON/log4cpp/lib"){ print MKSETENVC "setenv $LIBNAME $GSEAGENLYON/log4cpp/lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$GSEAGENLYON/log4cpp/lib:\$$LIBNAME\n"; } if($gopt_enable_proposal =~m/YES/){ print MKSETENVC "setenv $LIBNAME $gopt_with_proposal_lib:\$$LIBNAME\n"; print MKSETENVB "export $LIBNAME=$gopt_with_proposal_lib:\$$LIBNAME\n"; } print MKSETENVC "\n"; print MKSETENVB "\n"; close(MKSETENVC); close(MKSETENVB); print "\nYour input configuration options were: @ARGV"; if($#ARGV < 0) { print "(none)" }; print "\n\n"; if(-e $MKCONF_FILE) { print "The $MKCONF_FILE file has been succesfully generated! \n"; print "\nThe following config options were set: \n"; open(MKCONFR, "<$MKCONF_FILE") or die("Can not read back the $GSEAGEN/src/make/Make.config!"); @make_conf=; close(MKCONFR); # print "@make_conf\n" unless ; foreach $setting (@make_conf) { chomp($setting); if ($setting=~m/\=/) {print " $setting\n";} } # Copy only the enable/disable options, excluding paths, in a separate file for genie-config. #system("cat $MKCONF_FILE | grep GOPT_ENABLE_ > $MKCONF_FILE\_no_paths"); print "\nConfig options set in GENIE $GENIEVER will be used\n\n"; $MKCONF_FILE_GENIE = "$GENIE/src/make/Make.config"; open(MKCONFGENIE, "<$MKCONF_FILE_GENIE") or die("Can not read back the $GENIE/src/make/Make.config!"); @make_conf=; close(MKCONFGENIE); foreach $setting (@make_conf) { chomp($setting); if ($setting=~m/\=/) {print " $setting\n";} } print "\n"; print "*** To continue building gSeaGen type: make "; # Warning for SRT users if(defined $ENV{'SRT_ENV_SET'}) { print "(Don't forget to 'srt_setup --unsetup' first)"; } print "\n\n"; exit 0; } sub auto_detect { # First place to look when autodetecting is in the directories in LD_LIBRARY_PATH my @libdirs = ( ); push (@libdirs,split(":",$ENV{LD_LIBRARY_PATH})) if defined $ENV{LD_LIBRARY_PATH}; push (@libdirs,split(":",$ENV{DYLD_LIBRARY_PATH})) if defined $ENV{DYLD_LIBRARY_PATH}; #and the mac equivalent my @search_dir = (); foreach my $libdir (unique_entries(@libdirs)) { chomp($libdir); if (not $libdir) {next;} push (@search_dir, $libdir); # Append the LD library path directory @pathdirs = split("/",$libdir); $lastdir = pop(@pathdirs); $basedir = join("/",@pathdirs); if ($lastdir =~ m/lib/) {# If the LD_LIBRARY_PATH has "lib" in it, append "../include" push (@search_dir, $basedir."/include"); } } push (@search_dir,$GSEAGENLYON); push (@search_dir,"/usr"); # Add usr push (@search_dir,"/lib"); # Add opt push (@search_dir,"/opt"); # Add opt push (@search_dir,"$ENV{'HOME'}") if defined $ENV{'HOME'}; # add $HOME push (@search_dir,"/hep"); # add where I add ext apps in my mac book air push (@search_dir,"$ENV{'RSD_TOP_DIR'}") if defined $ENV{'RSD_TOP_DIR'}; # add where RSD puts ext supporting libs @search_dir = unique_entries(@search_dir); # Search each dir only once $search_file = shift; $optional_fullpath_substr = shift; # extra help in locating the correct file $optional_fullpath_substr = "" unless defined $optional_fullpath_substr; foreach(@search_dir) { $curr_dir = $_; if(! -d $curr_dir) {next;} @matches = `find $curr_dir/ -type f -maxdepth 7 -name \"$search_file\" 2> /dev/null | grep \"$optional_fullpath_substr\"`; $nmatches = @matches; if( $nmatches > 0) { return $matches[0]; } } return ""; } # Get unique entries in an array sub unique_entries { my %seen; return grep { !$seen{$_}++ } @_; }