summaryrefslogtreecommitdiff
path: root/utils/makellvm
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-07-22 12:35:28 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-07-22 12:35:28 +0000
commitdf3ac860e8e2c91d1322c828cc650f28660a9d61 (patch)
treec1cfd1fab5deb8f6b5e6d373bb2b99444244b80b /utils/makellvm
parent40c600e8f399042f1ae5b5ab0fab713c09ee8b44 (diff)
downloadllvm-df3ac860e8e2c91d1322c828cc650f28660a9d61.tar.gz
llvm-df3ac860e8e2c91d1322c828cc650f28660a9d61.tar.bz2
llvm-df3ac860e8e2c91d1322c828cc650f28660a9d61.tar.xz
(1) Pass 'VAR=string' arguments to gmake
(2) Detect LLVMDIR using the LEVEL variable in Makefile. (3) To perform #2 propertly, use the same Makefile search rules as gmake. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/makellvm')
-rwxr-xr-xutils/makellvm45
1 files changed, 40 insertions, 5 deletions
diff --git a/utils/makellvm b/utils/makellvm
index 9c8eab486d..25c812afdf 100755
--- a/utils/makellvm
+++ b/utils/makellvm
@@ -2,11 +2,8 @@
set pstatus = 0
onintr cleanup
-alias usage 'echo "USAGE: $0:t [-h] [-n] [gmake-flag...] [toolname]"; set pstatus = 1; goto cleanup'
+alias usage 'echo "USAGE: $0:t [-h] [-n] [gmake-flag...] [VAR=...] [toolname (default: opt)]"; set pstatus = 1; goto cleanup'
- ## LLVMDIR is simply the directory where this script resides!
-set thisExec = $0 ## cannot use :h on $0 for some reason
-set LLVMDIR = `echo {$thisExec:h} | sed 's/\/utils$//'`
set EXEC = opt
set GMAKE_OPTS = ""
@@ -16,19 +13,57 @@ while ( !( $?options_done ) && ($#argv > 0))
switch ($argv[1])
case -h :
usage
+ case -f :
+ if ($#argv < 2) usage
+ shift argv; set MFILE = $argv[1]; shift argv; breaksw
case -n :
set doit = 0; shift argv; breaksw
case -* :
set GMAKE_OPTS = ( $GMAKE_OPTS $argv[1] ); shift argv; breaksw
default :
- set options_done; breaksw
+ set optarg = `echo -n $argv[1] | sed 's/^[^=]*$//'`
+ if ($#optarg) then
+ set GMAKE_OPTS = ( $GMAKE_OPTS $optarg )
+ shift argv
+ else
+ set options_done
+ endif
+ breaksw
endsw
end
+if ($#argv > 1) then
+ echo 'ERROR: More than one tool is not supported by "makellvm"'
+ usage
+endif
if ($#argv > 0) then
set EXEC = $argv[1]
endif
+## Compute LLVMDIR: the root of the current LLVM tree.
+## It is recorded in the variable LEVEL in Makefile, to compute it
+##
+if (! $?MFILE) then
+ if (-f GNUmakefile) then
+ set MFILE = GNUmakefile
+ else if (-f makefile) then
+ set MFILE = makefile
+ else
+ set MFILE = Makefile
+ endif
+endif
+if (! -f $MFILE) then
+ echo "Missing or invalid makefile: $MFILE"
+ exit 1
+endif
+
+set LLVMDIR = `awk '/LEVEL[ ]*=/ {print $NF}' $MFILE`
+
+if ($?LLVMDIR == 0 || ! -d $LLVMDIR) then
+ echo "Unable to find LEVEL or LEVEL is invalid ($LEVEL)"
+ exit 1
+endif
+
set CMD = "gmake $GMAKE_OPTS && (cd $LLVMDIR/tools/$EXEC && gmake $GMAKE_OPTS)"
if ($doit == 1) then