-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·129 lines (112 loc) · 3.36 KB
/
install
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#! /usr/bin/env bash
#
# Written by:
# Kevin J. Bowers, Ph.D.
# Plasma Physics Group (X-1)
# Applied Physics Division
# Los Alamos National Lab
# March/April 2004 - Original version
# global variable for use in functions
args=()
nargs=$#
cargs=$@
machine_file=$1
build_directory=$2
#-------------------------------------------------------------------------------
# check command-line and echo usage
#-------------------------------------------------------------------------------
function check_usage {
if [[ $nargs < 1 ]]; then
echo ""
echo "Usage: $0 machine-file [build directory] [arg1 arg2 ...]"
echo ""
echo "You must specify a valid machine file."
echo ""
echo "autoconf only:"
echo ""
echo " If a build directory is specified it will be created,"
echo " including its parents if they do not exist. The configuration"
echo " and build will take place in this directory."
echo ""
echo " Additional command-line arguments are passed to the build-"
echo " system and may be used to specify environment variables."
echo ""
exit
fi
} # check_usage
#-------------------------------------------------------------------------------
# strip leading command-line arguments to pass to build system
#-------------------------------------------------------------------------------
function parse_command_line {
if [[ $nargs > 1 ]] ; then
i=0
for el in $cargs ; do
args[$i]=$el
let i=$i+1
done
i=1
args=(${args[@]:0:$i} ${args[@]:$(($i + 1))})
i=0
args=(${args[@]:0:$i} ${args[@]:$(($i + 1))})
fi
} # parse_command_line
#-------------------------------------------------------------------------------
# check for autoconf-style machine file
#-------------------------------------------------------------------------------
function check_autoconf {
ac=`head -n 1 machine/$machine_file | grep autoconf | sed 's,#,,g'`
if [ -n "$ac" ] ; then
return 1
else
return 0
fi
} # check_autoconf
#-------------------------------------------------------------------------------
# run autoconf style configuration and build
#-------------------------------------------------------------------------------
function configure_autoconf {
cwd="./"
config/bootstrap
if [[ $nargs > 1 ]] ; then
cwd=`pwd`
if [ -d $build_directory ] ; then
echo "Warning $build_directory already exists."
echo "Do you want to remove it and continue? [Y/n]"
read ans
if [[ $ans == "" || $ans == "y" || $ans == "Y" ]] ; then
rm -rf $build_directory
else
echo "Exiting"
exit
fi
fi
mkdir -p $build_directory
cd $build_directory
fi
$cwd/configure --with-machine=$machine_file ${args[@]}
echo "running make clean"
make clean
echo "running make"
make -j4
} # configure_autoconf
#-------------------------------------------------------------------------------
# run imake style build
#-------------------------------------------------------------------------------
function configure_imake {
rm Makefile
imake -DMACHINE=machine/$machine_file
gmake clean
gmake -j4 all
} # configure_imake
################################################################################
# begin script execution
################################################################################
check_usage
parse_command_line
check_autoconf
ac=$? # this is the return value from check_autoconf
if [[ $ac == 1 ]] ; then
configure_autoconf
else
configure_imake
fi