-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·342 lines (281 loc) · 8.8 KB
/
configure
File metadata and controls
executable file
·342 lines (281 loc) · 8.8 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#!/bin/bash
sdkdir=hex
script=$(basename $0)
top_dir=$(cd $(dirname $0)/.. && pwd)
top_srcdir=$(cd $(dirname $0)/.. && pwd)
top_sdkdir=$(cd $top_dir/$sdkdir && pwd)
top_blddir=$(pwd)
Error() { echo "Error: $*" >&2 ; exit 1 ; }
Usage()
{
cat <<EOF >&2
Usage: $script [ <options> ] [ <custom-build-tag> ]
-v Enable verbose output
-R Reconfigure mode (do not replace local.mk)
-r Generate rootfs from scratch rather than from fakeroot core
-D Print directories being traversed by make
-p Configure for production mode
-t Configure for trial mode
-i Configure for interactive mode
-d Configure for debugging (default is release)
-x Configure for execution profiling
-m Enable mock language pack generation
EOF
exit 1
}
# Do not include -R flag in SAVE_ARGS
RECONFIGURE=0
if [ x"$1" = x"-R" ]; then
RECONFIGURE=1
shift 1
fi
SAVE_ARGS="$*"
VERBOSE=0
PRINT_DIRS=0
PRODUCTION=0
TRIAL=0
INTERACTIVE=0
CUSTOM_BUILD=""
DEBUG=0
PROFILE=0
PROJ_DEV_LANG=0
USE_CORE=1
WEAK_DEP=0
SKIP_DIR="node_modules"
while getopts "vDptxdm" OPT ; do
case $OPT in
v) VERBOSE=1 ;;
r) USE_CORE=0 ;;
D) PRINT_DIRS=1 ;;
p) PRODUCTION=1 ;;
t) TRIAL=1 ;;
i) INTERACTIVE=1 ;;
x) PROFILE=1 ;;
d) DEBUG=1 ;;
m) PROJ_DEV_LANG=1 ;;
*) Usage ;;
esac
done
shift $(($OPTIND - 1))
# Optional custom build tag (can be a space separated multiword string)
if [ $# -ge 1 ]; then
CUSTOM_BUILD="$@"
fi
set -e
[ $EUID = 0 ] || Error "Must be run as root"
[ x$(printenv DEVOPS_ENV) != 'x__JAIL__' ] && Error "Must be run in build jail"
[ "$top_srcdir" != "$top_blddir" ] || Error "Must be run in a separate build directory"
[ -f /etc/hex.manifest ] || Error "Could not find HEX manifest: /etc/hex.manifest"
source /etc/hex.manifest
HEX_VER=${_HEX_VER}
HEX_ARCH=${_HEX_ARCH}
HEX_DIST=${_HEX_DIST}
WEAK_DEP=${_WEAK_DEP}
if [ ! -f local.mk -o $RECONFIGURE -eq 0 ]; then
if [ $VERBOSE -eq 0 ]; then
echo " GEN local.mk"
else
echo "Generating local.mk"
fi
cat <<EOF >local.mk
# Generated by $script on $(date)
# NOTE: To override any of the variables listed below in a single subdirectory, you
# must set them before including build.mk.
# If non-zero, pass "quiet" boot arg to linux kernel in all boot loaders
# Implied by PRODUCTION equal to 1 or greater
#
# Can also be overridden on the command line using the shorthand flag "QB", e.g.:
#
# make QB=0 testall
#
QUIETBOOT ?= 1
# If VERBOSE=1, then show make commands as they are executed
# If VERBOSE=2, then enable script tracing
# If VERBOSE=3, then enable script tracing and no cleanup temp files and directories
#
# Can also be overridden on the command line using the shorthand flag "V", e.g.:
#
# make V=1 all
#
VERBOSE ?= ${VERBOSE}
# If non-zero, enable production mode:
# 1. Do not include unrestricted shell or extra development tools in build
#
# Can also be overridden on the command line using the shorthand flag "P", e.g.:
#
# make P=1 all
#
PRODUCTION ?= ${PRODUCTION}
# If non-zero, enable trial mode:
# Can also be overridden on the command line using the shorthand flag "T", e.g.:
#
# make T=1 all
#
TRIAL ?= ${TRIAL}
# If non-zero, enable interactive mode:
#
# Can also be overridden on the command line using the shorthand flag "I", e.g.:
#
# make I=1 testall
#
INTERACTIVE ?= ${INTERACTIVE}
# If non-zero, generate initrd and rootfs from core files defined in project_definition.mk
#
USE_CORE ?= ${USE_CORE}
# If non-zero, enable directory change messages (makeflag --no-print-directory)
# Implied by VERBOSE equal to 1 or greater
#
# Can also be overridden on the command line using the shorthand flag "D", e.g.:
#
# make D=1 all
#
PRINT_DIRS ?= ${PRINT_DIRS}
# If set to 1 compile for debugging
#
DEBUG ?= ${DEBUG}
# If set to 1, use MEMCHECK when running unit tests
USE_MEMCHECK ?= 1
# If set to 1, ignore memory check errors and generate suppression rules for all errors
GEN_MEMCHECK_SUPPRESSIONS ?= 0
# If set to 1 dump deb dependencies, file lists, and pre/post scripts during install
DUMP_DEB_INFO ?= 0
# If PROFILE=1 compile with gcc -pg argument to generate code for execution profiling
#
PROFILE ?= ${PROFILE}
# Additional kernel args to use for both live boot and hard disk installs.
#
KERNEL_ARGS ?=
# Single user mode during mini_initramfs init.sh, before 1st hwdetect and switch_root
#KERNEL_ARGS ?= single_early
# Single user mode during mini_initramfs init.sh, after 1st hwdetect, and just before switch_root
#KERNEL_ARGS ?= single_preswitchroot
# Single user mode during rc.sysinit, after switch_root, and just before 2nd hwdetect
#KERNEL_ARGS ?= single_postswitchroot
# Single user mode during rc.sysinit, after 2nd hwdetect, and just before bootstrapping application
#KERNEL_ARGS ?= single
# Trace mini_initramfs init.sh and rc.sysinit scripts with "set -vx"
#KERNEL_ARGS ?= trace_verbose
# Trace mini_initramfs init.sh and rc.sysinit scripts with "set -x" (implied by QUIETBOOT=0)
#KERNEL_ARGS ?= trace_init
# Trace modprobe invocations
#KERNEL_ARGS ?= trace_modprobe
# Uncomment to log all kernel messages. Should also set QUIETBOOT=0.
# Softlockup and hung task should both cause kernel panic
# Lower hung task timeout to 60 seconds (instead of 120)
# Reboot 3 seconds after kernel panic
#
#KERNEL_ARGS ?= ignore_loglevel softlockup_panic=1 hung_task_panic=1 hung_task_timeout_secs=60 panic=3
# Serial console speed. Production BIOS will be set to 9600 bps by default.
# Valid values are 9600, 19200, 38400, 57600, and 115200.
# Be sure to change the BIOS to match before booting.
#
CONSOLE_SPEED ?= 115200
# Custom build tag
# Typically empty
CUSTOM_BUILD ?= ${CUSTOM_BUILD}
# Fake Lang pack will be used if this is enabled
PROJ_DEV_LANG ?= ${PROJ_DEV_LANG}
EOF
fi # [ ! -f local.mk ]
# process Custom build tags
if [ -n "$CUSTOM_BUILD" ] ; then
echo -e "\n# Custom build tags" >> local.mk
for tag in $CUSTOM_BUILD ; do
echo "CUSTOM_$tag := 1" >> local.mk
done
fi
if [ $VERBOSE -eq 0 ]; then
echo " GEN build.mk"
else
echo "Generating build.mk"
fi
cat <<EOF >build.mk
# DO NOT EDIT THIS FILE
# Generated by $script on $(date)
HEX_VER := ${HEX_VER}
HEX_ARCH := ${HEX_ARCH}
HEX_DIST := ${HEX_DIST}
WEAK_DEP := ${WEAK_DEP}
# Full (non-relative) paths to top of build and source directories
TOP_DIR := ${top_dir}
TOP_SRCDIR := ${top_srcdir}
TOP_BLDDIR := ${top_blddir}
include \$(TOP_BLDDIR)/local.mk
HEX_MAKEDIR := ${top_sdkdir}/make
include \$(HEX_MAKEDIR)/hex_sdk_first.mk
EOF
Run()
{
[ $VERBOSE -eq 0 ] && echo "$2" || echo $1
eval $1
}
LinkMakefile()
{
srcdir=$1
blddir=$2
# find all makefile from source dir
for f in $(find $srcdir -name Makefile -not -path ".*/$SKIP_DIR/*") ; do
# replace source dir with build dir
newfile=`echo $f | sed "s!$srcdir!$blddir!"`
dir=`dirname $newfile`
# build dir doesn't exist, create one
if [ ! -d "$dir" ]; then
b=`echo $dir | sed "s!$top_blddir/!!"`
Run "mkdir -p $dir" " MKDIR $b"
fi
# create a link file points to source file
if [ ! -f "$newfile" ]; then
b=`echo $newfile | sed "s!$top_blddir/!!"`
Run "ln -sf $f $newfile" " LN $b"
fi
done
}
LinkMakefile $top_sdkdir $top_blddir/$sdkdir
LinkMakefile $top_srcdir $top_blddir
# find and report deleted source directories
# (look for Makefiles in blddir that are broken symlinks)
for f in $(find $top_blddir -depth -name Makefile -type l ) ; do
# if broken symlinks
if stat -L $f >/dev/null 2>&1 ; then
:
else
b=`echo $f | sed "s!$top_blddir/!!"`
d=`dirname $f`
bd=`echo $d | sed "s!$top_blddir/!!"`
Run "rm -f $f" " RM $b"
rm -rf $top_blddir/${d}_deleted
Run "mv $d ${d}_deleted" " MV $bd ${bd}_deleted"
fi
done
# find and report build directories that are marked for deletion
for f in $(find $top_blddir -type d -name \*_deleted) ; do
d=`echo $f | sed -e "s!$top_blddir/!!"`
[ $VERBOSE -eq 0 ] && echo " WARNING obsolete directory: $d" || echo "Warning: obsolete directory: $d"
done
if [ $RECONFIGURE -eq 0 ]; then
if [ $VERBOSE -eq 0 ]; then
echo " GEN reconfigure"
else
echo "Generating reconfigure"
fi
cat <<EOF >reconfigure
#!/bin/bash
bash $0 -R $SAVE_ARGS
EOF
chmod a+x reconfigure
else
touch reconfigure
fi
#;;; Local Variables: ***
#;;; mode:shell-script ***
if [ -f $top_sdkdir/scripts/helpers ]; then
rm -rf /usr/sbin/hex_helper
ln -s $top_sdkdir/scripts/helpers /usr/sbin/hex_helper
fi
if [ $(ls -1 /dev/loop* 2>/dev/null | wc -l) -lt 16 ]; then
for i in $(seq 0 15) ; do
rm -f /dev/loop$i
mknod -m 0660 /dev/loop$i b 7 $(($i * 4)) 2>/dev/null || true
done
fi
#;;; End: ***