#!/usr/bin/perl -w # # script to configure hoppet. To find out more type # # ./configure --help # # GPS created 2009-09-05 #---------------------------------------------------------------------- use Cwd; $usage=" Usage: ./configure [--prefix=...] [FC='...'] [FFLAGS='...'] [LDFLAGS='...'] --prefix='...' sets the location for installation --mod-prefix='...' sets the location for installation of modules (by default prefix/include/hoppet) FC='...' sets the fortran (and f90) compiler FFLAGS='...' sets the fortran (and f90) compiler options LDLAGS='...' sets the link options "; if ($#ARGV >=0 && ($ARGV[0] eq "-h" || $ARGV[0] eq "--help")) { print "$usage"; exit; } $configline=$0." ".join(" ",@ARGV); $prefix="/usr/local"; $modPrefix=""; foreach $arg (@ARGV) { if ($arg =~ /^--prefix=(.*)/) { $prefix= $1;} elsif ($arg =~ /^--mod-prefix=(.*)/) { $modPrefix= $1;} else {push @args, "\"".$arg."\"";} } push @args, "--prefix=$prefix"; if (!$modPrefix) {$modPrefix = "$prefix/include/hoppet";} push @args, "--mod-prefix=$modPrefix"; # NB: src comes last, because from src onwards we will include an option to install modules @dirs=split(" ","example_f90 benchmarking benchmarking/test_acc src"); $topdir = getcwd; #chdir "src"; # now generate the makefiles foreach $dir (@dirs) { # when we reach src, ensure that modules get installed if ($dir eq "src") {push @args, "--install-modules";} chdir $dir; print "Creating makefile in ".getcwd."\n"; # find out what we're already up to $mkmk=`grep -v '^#' mkmk | grep makef95makefile`; chomp($mkmk); $mkmk =~ s/\$[^ ]+//g; $mkmk =~ s/-remake.*//; $mkmk .= " ".join(" ",@args); #print $mkmk."\n"; print $dir, $mkmk,"\n"; system($mkmk); chdir $topdir; } # get things ready for the hoppet-config script $version=`grep 'Welcome to' src/welcome_message.f90 | sed -e 's/.*v\. //' -e 's/ .*//'`; chomp $version; $prefix=`cat src/.makef95.prefix`; chomp $prefix; ($escprefix = $prefix) =~ s/\//\\\//g; ($escmodprefix = $modPrefix) =~ s/\//\\\//g; system("sed -e 's/\@prefix\@/$escprefix/' -e 's/\@modprefix\@/$escmodprefix/' -e 's/\@VERSION\@/$version/' hoppet-config.in > hoppet-config"); system("chmod +x hoppet-config"); # write a file config.log open (LOG,">config.log") || die "Could not open config.log"; print LOG "# the last configure that was run was\n"; print LOG "$configline\n"; print LOG "prefix=$prefix\n"; close LOG;