#! /usr/bin/perl -w # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # MUPAGE configuration script # # created: 23 April 2021 # # 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 "*** MUAPGE configure script *** \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 " antcc Enable antcc library default: disabled \n"; print "\n options for prefix with --with- (eg --with-antares-lib=/some/path/)\n\n"; print " antares-inc Path to ANTARES I/O includes needed if you --enable-antares \n"; print " antares-lib Path to ANTARES I/O libraries needed if you --enable-antares \n"; print " km3net-inc Path to KM3NET-DATAFORMAT includes needed if you --enable-km3net \n"; print " km3net-lib Path to KM3NET-DATAFORMAT libraries needed if you --enable-km3net \n"; print " antcc-inc Path to antcc includes needed if you --enable-antcc \n"; print " antcc-lib Path to antcc libraries needed if you --enable-antcc \n"; print " clhep-inc Path to clhep includes needed if you --enable-antcc \n"; print "\n./configure --help | more \n\n"; exit 0; } # Check that $ROOTSYS is set # $ROOTSYS = $ENV{'ROOTSYS'}; die ("*** Error *** The ROOTSYS environmental variable is not defined. Is ROOT installed?") unless defined $ROOTSYS; # Open Make.config to write configuration options # $MKCONF_FILE = "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_antcc = "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-antcc/i, @ARGV)) > 0) { $gopt_enable_antcc = "YES"; } # ------------------------------------------------ # 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; # check my $file = "$gopt_with_antares_lib/io_gcc.o"; if(! -e $file) { print "*** Error *** You did not specify a valid path to ANTARES I/O library using --with-antares-lib=/some/path/\n"; exit 1; } } else { 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; # check my $file = "$gopt_with_antares_inc/io_gcc.hh"; if(! -e $file) { print "*** Error *** You did not specify a valid path to ANTARES I/O includes path using --with-antares-inc=/some/path/\n"; exit 1; } } else { 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; # check my $file = "$gopt_with_km3net_lib/libKM3NeTROOT.so"; if(! -e $file) { print "*** Error *** You did not specify a valid path to KM3NET-DATAFORMAT library using --with-km3net-lib=/some/path/\n"; exit 1; } } else { 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; $string = "km3net-dataformat/offline"; $gopt_with_km3net_inc =~ s/$string//; print "$gopt_with_km3net_inc"; # check my $file = "$gopt_with_km3net_inc/km3net-dataformat/offline/Evt.hh"; if(! -e $file) { print "*** Error *** You did not specify a valid path to KM3NET-DATAFORMAT includes path using --with-km3net-inc=/some/path/\n"; exit 1; } } else { 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; } } if($gopt_enable_km3net eq "YES") { print "\nYou enabled the KM3NET-DATAFORMAT. To run MUPAGE: add $gopt_with_km3net_lib to LD_LIBRARY_PATH\n\n"; } # ------------------------------------------------ # Antcc paths # ------------------------------------------------ # If --enable-antcc was set then the full path to the antcc library must be specified # my $gopt_with_antcc_lib = ""; if($gopt_enable_antcc eq "YES") { if($gopt_enable_antares ne "YES"){ print "*** Error *** You need to enable ANTARES I/O \n"; print "*** Error *** Otherwise, you should --disable-antcc\n\n"; exit 1; } if(($match = grep(/--with-antcc-lib/i, @ARGV)) > 0) { $options=~m/--with-antcc-lib=(\S*)/i; $gopt_with_antcc_lib = $1; # check my $file = "$gopt_with_antcc_lib/libantcc.a"; if(! -e $file) { print "*** Error *** You did not specify a valid path to antcc library using --with-antcc-lib=/some/path/\n"; exit 1; } } else { print "*** Error *** You need to specify the path to antcc library using --with-antcc-lib=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-antcc\n\n"; exit 1; } } # If --enable-antcc was set then the full path to the antcc includes must be specified # my $gopt_with_antcc_inc = ""; if($gopt_enable_antcc eq "YES") { if(($match = grep(/--with-antcc-inc/i, @ARGV)) > 0) { $options=~m/--with-antcc-inc=(\S*)/i; $gopt_with_antcc_inc = $1; # check my $file = "$gopt_with_antcc_inc/AlignEvent.hh"; if(! -e $file) { print "*** Error *** You did not specify a valid path to antcc includes path using --with-antcc-inc=/some/path/\n"; exit 1; } } else { print "*** Error *** You need to specify the antcc includes path using --with-antcc-inc=/some/path/\n"; print "*** Error *** Otherwise, you should --disable-antcc\n\n"; exit 1; } } # ------------------------------------------------ # CLHEP paths # ------------------------------------------------ # If --enable-antcc was set then the full path to the CLHEP includes must be specified # my $gopt_with_clhep_inc = ""; if($gopt_enable_antcc eq "YES") { if(($match = grep(/--with-clhep-inc/i, @ARGV)) > 0) { $options=~m/--with-clhep-inc=(\S*)/i; $gopt_with_clhep_inc = $1; } else { $gopt_with_clhep_inc = $ENV{'INCCLHEP'} } #check my $file = "$gopt_with_clhep_inc/CLHEP/ClhepVersion.h"; if(! -e $file) { print "*** Error *** You need to specify a valid CLHEP includes path using --with-clhep-inc=/some/path/ or defining the env. variable INCCLHEP \n"; print "*** Error *** Otherwise, you should --disable-antcc\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_ANTCC=$gopt_enable_antcc\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_ANTCC_LIB=$gopt_with_antcc_lib\n"; print MKCONF "GOPT_WITH_ANTCC_INC=$gopt_with_antcc_inc\n"; print MKCONF "GOPT_WITH_CLHEP_INC=$gopt_with_clhep_inc\n"; close(MKCONF); print "\nMUPAGE configuration done, type make to procede with the code compiling\n\n";