From 8d410f19636e7b46995d20914b000b5a699f19d3 Mon Sep 17 00:00:00 2001 From: Evan Ramos Date: Wed, 23 Aug 2017 11:48:11 -0500 Subject: [PATCH] Make build and smart-build.pl work properly when the cwd is not their location Change-Id: Iec1ae518374e129efaa35684a3dc192f4b7234dc --- build | 2 +- smart-build.pl | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build b/build index 3dcf23066c..e01ca2dd1c 100755 --- a/build +++ b/build @@ -210,7 +210,7 @@ QUIET="" BUILD_OMP=0 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | ( less || more ) && exit 1 -[ $# -lt 2 ] && ./smart-build.pl && exit 1 +[ $# -lt 2 ] && $(dirname "$0")/smart-build.pl && exit 1 PROGRAM=$1 shift diff --git a/smart-build.pl b/smart-build.pl index 05d6f6956f..c43c813ed4 100755 --- a/smart-build.pl +++ b/smart-build.pl @@ -9,6 +9,10 @@ use strict; use warnings; +# Get location of script +use File::Basename; +my $dirname = dirname(__FILE__); + # Turn off I/O buffering $| = 1; @@ -190,7 +194,7 @@ if($arch eq "netlrts-darwin"){ #================ Choose SMP/PXSHM ================================= # find what options are available -my $opts = `./build charm++ $arch help 2>&1 | grep "Supported options"`; +my $opts = `$dirname/build charm++ $arch help 2>&1 | grep "Supported options"`; $opts =~ m/Supported options: (.*)/; $opts = $1; @@ -237,7 +241,7 @@ if ($counter != 1) { #================ Choose Compiler ================================= # Lookup list of compilers -my $cs = `./build charm++ $arch help 2>&1 | grep "Supported compilers"`; +my $cs = `$dirname/build charm++ $arch help 2>&1 | grep "Supported compilers"`; # prune away beginning of the line $cs =~ m/Supported compilers: (.*)/; $cs = $1; @@ -294,7 +298,7 @@ $explanations{"causalft"} = "Use causal message logging fault tolerance support" # Produce list of options - $opts = `./build charm++ $arch help 2>&1 | grep "Supported options"`; + $opts = `$dirname/build charm++ $arch help 2>&1 | grep "Supported options"`; # prune away beginning of line $opts =~ m/Supported options: (.*)/; $opts = $1; @@ -485,7 +489,7 @@ EOF # Compose the build line -my $build_line = "./build $target $arch $compilers $options $j $nobs ${compiler_flags}\n"; +my $build_line = "$dirname/build $target $arch $compilers $options $j $nobs ${compiler_flags}\n"; # Save the build line in the log @@ -504,7 +508,7 @@ print "\t$build_line\n\n"; print "Do you want to start the build now? [Y/n]"; my $p = promptUserYN(); if($p eq "yes" || $p eq "default"){ - if(-e "src/arch/$arch"){ + if(-e "$dirname/src/arch/$arch"){ print "Building with: ${build_line}\n"; # Execute the build line system($build_line); -- 2.11.4.GIT