Vikram S. Adve | 631484c | 2002-09-15 16:33:32 +0000 | [diff] [blame] | 1 | #!/bin/csh -f |
| 2 | |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 3 | set pstatus = 0 |
| 4 | onintr cleanup |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 5 | alias usage 'echo "USAGE: $0:t [-h] [-n] [gmake-flag...] [VAR=...] [toolname (default: opt)]"; set pstatus = 1; goto cleanup' |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 6 | |
Vikram S. Adve | 631484c | 2002-09-15 16:33:32 +0000 | [diff] [blame] | 7 | set EXEC = opt |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 8 | set GMAKE_OPTS = "" |
Vikram S. Adve | ec6867e | 2003-09-08 15:32:47 +0000 | [diff] [blame^] | 9 | set DEBUG = 0 |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 10 | |
| 11 | set doit = 1 |
| 12 | unset options_done |
| 13 | while ( !( $?options_done ) && ($#argv > 0)) |
| 14 | switch ($argv[1]) |
| 15 | case -h : |
| 16 | usage |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 17 | case -f : |
| 18 | if ($#argv < 2) usage |
| 19 | shift argv; set MFILE = $argv[1]; shift argv; breaksw |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 20 | case -n : |
| 21 | set doit = 0; shift argv; breaksw |
Vikram S. Adve | ec6867e | 2003-09-08 15:32:47 +0000 | [diff] [blame^] | 22 | case -d : |
| 23 | set doit = 0; set DEBUG = 1; shift argv; breaksw |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 24 | case -* : |
| 25 | set GMAKE_OPTS = ( $GMAKE_OPTS $argv[1] ); shift argv; breaksw |
| 26 | default : |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 27 | set optarg = `echo -n $argv[1] | sed 's/^[^=]*$//'` |
| 28 | if ($#optarg) then |
| 29 | set GMAKE_OPTS = ( $GMAKE_OPTS $optarg ) |
| 30 | shift argv |
| 31 | else |
| 32 | set options_done |
| 33 | endif |
| 34 | breaksw |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 35 | endsw |
| 36 | end |
Vikram S. Adve | 631484c | 2002-09-15 16:33:32 +0000 | [diff] [blame] | 37 | |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 38 | if ($#argv > 1) then |
| 39 | echo 'ERROR: More than one tool is not supported by "makellvm"' |
| 40 | usage |
| 41 | endif |
Vikram S. Adve | 631484c | 2002-09-15 16:33:32 +0000 | [diff] [blame] | 42 | if ($#argv > 0) then |
Vikram S. Adve | 2d45660 | 2002-09-15 18:22:47 +0000 | [diff] [blame] | 43 | set EXEC = $argv[1] |
Vikram S. Adve | 631484c | 2002-09-15 16:33:32 +0000 | [diff] [blame] | 44 | endif |
Vikram S. Adve | ec6867e | 2003-09-08 15:32:47 +0000 | [diff] [blame^] | 45 | if ($DEBUG) then |
| 46 | echo "DEBUG: EXEC = $EXEC" |
| 47 | endif |
Vikram S. Adve | 631484c | 2002-09-15 16:33:32 +0000 | [diff] [blame] | 48 | |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 49 | ## Compute LLVMDIR: the root of the current LLVM tree. |
| 50 | ## It is recorded in the variable LEVEL in Makefile, to compute it |
| 51 | ## |
| 52 | if (! $?MFILE) then |
| 53 | if (-f GNUmakefile) then |
| 54 | set MFILE = GNUmakefile |
| 55 | else if (-f makefile) then |
| 56 | set MFILE = makefile |
| 57 | else |
| 58 | set MFILE = Makefile |
| 59 | endif |
| 60 | endif |
Vikram S. Adve | ec6867e | 2003-09-08 15:32:47 +0000 | [diff] [blame^] | 61 | if ($DEBUG) then |
| 62 | echo "DEBUG: MFILE = $MFILE" |
| 63 | endif |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 64 | if (! -f $MFILE) then |
| 65 | echo "Missing or invalid makefile: $MFILE" |
| 66 | exit 1 |
| 67 | endif |
| 68 | |
| 69 | set LLVMDIR = `awk '/LEVEL[ ]*=/ {print $NF}' $MFILE` |
Vikram S. Adve | ec6867e | 2003-09-08 15:32:47 +0000 | [diff] [blame^] | 70 | if ($DEBUG) then |
| 71 | echo "DEBUG: LLVMDIR = $LLVMDIR" |
| 72 | endif |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 73 | |
Vikram S. Adve | ec6867e | 2003-09-08 15:32:47 +0000 | [diff] [blame^] | 74 | if ($#LLVMDIR == 0 || ! -d "$LLVMDIR") then |
| 75 | echo "Unable to find LLVM obj-root directory or directory is invalid." |
| 76 | echo "Are you within a valid LLVM directory for running gmake?" |
Vikram S. Adve | df3ac86 | 2003-07-22 12:35:28 +0000 | [diff] [blame] | 77 | exit 1 |
| 78 | endif |
| 79 | |
Vikram S. Adve | 39c36e8 | 2002-09-19 14:54:53 +0000 | [diff] [blame] | 80 | set CMD = "gmake $GMAKE_OPTS && (cd $LLVMDIR/tools/$EXEC && gmake $GMAKE_OPTS)" |
| 81 | |
| 82 | if ($doit == 1) then |
| 83 | csh -f -c "$CMD" |
| 84 | else |
| 85 | echo '(NOT EXECUTING) COMMAND:' |
| 86 | echo " $CMD" |
| 87 | endif |
| 88 | |
| 89 | |
| 90 | #========================================================= |
| 91 | # CODE TO BE EXECUTED IF INTERRUPT IS RECEIVED |
| 92 | #========================================================= |
| 93 | cleanup: |
| 94 | exit($pstatus) |