blob: de3d288d7c3057b6864fc330df702b7dedb41198 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/csh -f
set pstatus = 0
onintr cleanup
alias usage 'echo "USAGE: $0:t [-h] [-n] [-obj obj-root] [gmake-flags] [VAR=...] [toolname (default: opt)]"; set pstatus = 1; goto cleanup'
set EXEC = opt
set GMAKE_OPTS = ""
set DEBUG = 0
set doit = 1
unset options_done
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 -obj :
set OBJROOT = $argv[1]; shift argv; shift argv; breaksw
case -d :
set doit = 0; set DEBUG = 1; shift argv; breaksw
case -* :
set GMAKE_OPTS = ( $GMAKE_OPTS $argv[1] ); shift argv; breaksw
default :
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
if ($DEBUG) then
echo "DEBUG: EXEC = $EXEC"
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 ($DEBUG) then
echo "DEBUG: MFILE = $MFILE"
endif
if (! -f $MFILE) then
echo "Missing or invalid makefile: $MFILE"
exit 1
endif
set LLVMDIR = `awk '/LEVEL[ ]*=/ {print $NF}' $MFILE`
if ($DEBUG) then
echo "DEBUG: LLVMDIR = $LLVMDIR"
endif
if ($#LLVMDIR == 0 || ! -d "$LLVMDIR") then
echo "Unable to find LLVM src-root directory or directory is invalid."
echo "Are you within a valid LLVM directory for running gmake?"
exit 1
endif
if ($?OBJROOT == 0) then
## Check if source root is obj-root by looking for Makefile.config there
if (-f ${LLVMDIR}/Makefile.config) then
set OBJROOT = ${LLVMDIR}
set BUILDROOT = .
else ## Otherwise assume a default location for OBJROOT
set OBJROOT = "/localhome/$USER/llvm"
set SRCROOT = `sh -c "cd $LLVMDIR; pwd | sed 's/\//\\\//g'"`
set CURSRCDIR = `echo $cwd | sed -e "s/${SRCROOT}//"`
set BUILDROOT = ${OBJROOT}/${CURSRCDIR}
unset SRCROOT CURSRCDIR
endif
echo "Using OBJ-ROOT = ${OBJROOT} (specify '-obj obj-root' to override)."
endif
if ($DEBUG) then
echo "DEBUG: BUILDROOT = $BUILDROOT"
endif
cd $BUILDROOT
set CMD = "gmake $GMAKE_OPTS && (cd $LLVMDIR/tools/$EXEC && gmake $GMAKE_OPTS)"
if ($doit == 1) then
csh -f -c "$CMD"
else
echo '(NOT EXECUTING) COMMAND:'
echo " $CMD"
endif
#=========================================================
# CODE TO BE EXECUTED IF INTERRUPT IS RECEIVED
#=========================================================
cleanup:
exit($pstatus)
|