-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·140 lines (124 loc) · 4.19 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#! /bin/sh
TEMPLATE=Makefile.in
TARGET=Makefile
helpmsg()
{
cat <<EOF
Usage: ./configure <required arguments> [optional arguments]
Required arguments:
--teensy-version|-t <30|31> : specify Teensy version used, either 3.0 or 3.1
--arduino-path|-p <path> : path where your Arduino+Teensyduino install is located
Optional arguments:
--frequency|-f <2|4|8|16|24|48|72|96|120|144|168> : specify Teensy core frequency (default=48)
--rtc-compensate|-r <number> : specify RTC adjustment for your crystal (default=0)
--debug|-d <0-3> : specify debug level (default=1)
--timezone <TZ> : specify default timezone (TZ format e.g. CET-1CEST,M3.5.0,M10.5.0/3 for Paris, autodetected from your build machine if not specified)
Example: ./configure --teensy-version 31 --frequency 96 --rtc-compensate -46 --arduino-path ~/arduino-1.0.6 --debug 0
EOF
}
if ! test -e $TEMPLATE ; then
echo "[ERROR] Missing required file $TEMPLATE"
exit 1
fi
FREQUENCY=48
TEENSY_VERSION=required
ARDUINO_PATH=required
RTC_COMPENSATE=0
PROJECT_DEBUG=1
TIMEZONE=`tail -n1 /etc/localtime`
savedargs="$@"
if [ -n "$1" ] ; then
TEMP=`getopt -o f:t:p:r:d:z: -l frequency:,teensy-version:,arduino-path:,rtc-compensate:,debug:,timezone: -n configure -- "$@"`
if [ $? != 0 ] ; then echo "configure: aborting..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-f|--frequency)
if [ "$2" != 168 ] && [ "$2" != 144 ] && [ "$2" != 120 ] && [ "$2" != 96 ] && [ "$2" != 72 ] && [ "$2" != 48 ] && [ "$2" != 24 ] && [ "$2" != 16 ] && [ "$2" != 8 ] && [ "$2" != 4 ] && [ "$2" != 2 ] ; then
echo "configure: frequency out of bounds ($2), expected one of: 2, 4, 8, 16, 24, 48 (default), 72, 96, 120, 144, 168."
exit 1
else
FREQUENCY=$2
fi
shift 2 ;;
-t|--teensy-version)
if [ "$2" != 30 ] && [ "$2" != 31 ]; then
echo "configure: teensy version unknown, expected one of: 30 (Teensy 3.0) or 31 (Teensy 3.1)."
exit 1;
else
TEENSY_VERSION=$2
fi
shift 2 ;;
-p|--arduino-path)
if [ ! -r "$2" ] || [ ! -d "$2" ]; then
echo "configure: specified Arduino path ($2) is either not a directory or not readable."
exit 1;
elif [ ! -d "$2/hardware/teensy" ] ; then
echo "configure: specified Arduino path ($2) doesn't seem correct or doesn't have Teensyduino installed."
exit 1;
else
ARDUINO_PATH="$2"
fi
shift 2 ;;
-r|--rtc-compensate)
if ! echo "$2" | grep -qE '^-?[0-9]+$'; then
echo "configure: expected a number instead of '$2'"
exit 1;
else
RTC_COMPENSATE=$2
fi
shift 2 ;;
-z|--timezone)
if ! echo "$2" | grep -qE '^[^;]+;[^;]+;[^;]+$'; then
echo "configure: expected a TZ instead of '$2' (e.g. CET-1CEST,M3.5.0,M10.5.0/3)"
exit 1;
else
TIMEZONE=$2
fi
shift 2 ;;
-d|--debug)
if [ "$2" != 0 ] && [ "$2" != 1 ] && [ "$2" != 2 ] && [ "$2" != 3 ] ; then
echo "configure: expected a number in the range 0-3 instead of '$2'"
exit 1;
else
PROJECT_DEBUG=$2
fi
shift 2 ;;
--) shift ; break ;;
*) echo "configure: options parsing internal error! ($1)"; exit 1 ;;
esac
done
if [ -n "$1" ] ; then
echo "configure: sparse arguments found: $@"
helpmsg
exit 1
fi
#for arg do echo '--> '"\`$arg'" ; done
fi
# check for required arguments
if [ "$TEENSY_VERSION" = "required" ] ; then
echo "configure: missing required option --teensy-version"
helpmsg
exit 1
elsif [ "$ARDUINO_PATH" = "required" ] ;
echo "configure: missing required option --arduino-path"
helpmsg
exit 1
fi
if [ -x "$ARDUINO_PATH/hardware/tools/arm/bin/arm-none-eabi-gcc" ] ; then
:
elif [ -x "$ARDUINO_PATH/hardware/tools/arm-none-eabi/bin/arm-none-eabi-gcc" ] ; then
:
else
echo "configure: coudln't find a valid ARM compiler under $ARDUINO_PATH/hardware/tools"
exit 1
fi
echo "# cmd used: $0 $savedargs" > $TARGET
cat $TEMPLATE >> $TARGET
sed -i -re "s%#TEENSY_VERSION#%$TEENSY_VERSION%g" $TARGET
sed -i -re "s%#FREQUENCY#%$FREQUENCY%g" $TARGET
sed -i -re "s%#ARDUINO_PATH#%$ARDUINO_PATH%g" $TARGET
sed -i -re "s%#RTC_COMPENSATE#%$RTC_COMPENSATE%g" $TARGET
sed -i -re "s%#PROJECT_DEBUG#%$PROJECT_DEBUG%g" $TARGET
sed -i -re "s%#TIMEZONE#%$TIMEZONE%g" $TARGET