-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure
executable file
·125 lines (112 loc) · 2.29 KB
/
configure
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
#!/bin/sh -e
BIN_DEPS="mkdir rm cat sed cp chmod"
DUMPINTERVAL=60
PREFIX=/opt/piranha
DEBUG=0
VERBOSE=0
CONFIG=".config.mk"
find_exec()
{
EXE=`which $1 2>/dev/null`
}
usage()
{
printf "Usage %s [--debug] [--verbose] [--prefix=</path/to/piranha>] [--dumpint=<seconds>] [--help]\n" $1
printf " --help : show help\n"
printf " --debug : enable debug code\n"
printf " --verbose : enable verbose compilation\n"
printf " --prefix : set base installation directory (default: /opt/piranha)\n"
printf " --dumpint : set dump interval in seconds (default: 60)\n"
exit 0
}
onoff()
{
if [ $1 -eq 1 ]
then
onoff="enabled"
else
onoff="disabled"
fi
}
show_conf()
{
printf "Piranha configuration script\n"
printf "\n"
printf "Detected Arch : %s\n" ${ARCH}
printf "Detected OS : %s %s\n" ${OS} ${OSVER}
printf "Detected Compiler : %s\n" ${CC}
printf "Installation prefix : %s\n" ${PREFIX}
onoff ${DEBUG}
printf "Debug code : %s\n" ${onoff}
onoff ${VERBOSE}
printf "Verbose compilation : %s\n" ${onoff}
printf "\n"
}
write_conf()
{
rm -f ${CONFIG}
for NAME in ARCH OS OSVER PREFIX DEBUG VERBOSE CC CCNAME DUMPINTERVAL
do
VALUE=`eval echo "\\$${NAME}"`
printf "%s=%s\n" ${NAME} ${VALUE} >> ${CONFIG}
done
for EXE in ${BIN_DEPS}
do
NAME=`echo ${EXE} | tr [:lower:] [:upper:]`
find_exec ${EXE}
if [ -z "${EXE}" ]
then
printf "ERROR: Failed to locate '%s'\n" ${NAME}
exit 1;
fi
printf "%s=%s\n" ${NAME} ${EXE} >> ${CONFIG}
done
}
detect_os()
{
OS=`uname -s | tr [a-z] [A-Z]`
OSVER=`uname -r`
ARCH=`uname -m`
CCNAME="GCC"
find_exec "gcc"
if [ -z "${EXE}" ]
then
find_exec "cc"
CCNAME="CC"
fi
CC=${EXE}
if [ -z "$CC" ]
then
printf "ERROR: Failed to locate gcc/ccn\n"
exit 1;
fi
}
for arg in "$@"
do
case $arg in
--prefix=*)
PREFIX=`echo -- "$arg" | awk -F= '{print $2}'`
;;
--dumpint=*)
DUMPINTERVAL=`echo -- "$arg" | awk -F= '{print $2}'`
echo "$DUMPINTERVAL" | egrep -q '^[0-9]+$' || { echo "ERROR: dump interval must be a number"; exit 1; }
echo "$DUMPINTERVAL" | egrep -q '^0$' && { echo "ERROR: dump interval cannot be 0"; exit 1; }
;;
--verbose)
VERBOSE=1
;;
--debug)
DEBUG=1
;;
--help)
usage $0
;;
*)
printf "Unknown argument '%s'\n" $arg
exit 1
;;
esac
done
detect_os
show_conf
write_conf