forked from ghaerr/elks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·110 lines (92 loc) · 2.42 KB
/
build.sh
File metadata and controls
executable file
·110 lines (92 loc) · 2.42 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
#!/bin/sh
# Quick and dirty build script for ELKS
# Probably buggy, but makes from-scratch builds easier
DELAY=7
pause () {
echo
# 'read -n/-s' are bashisms, so work around them
if [ -z "$BASH_VERSION" ]
then
echo "Starting in $DELAY seconds."
sleep $DELAY
else
echo -n "Press a key to continue... "
read -n 1 -s 2>/dev/null || sleep $DELAY
fi
echo
}
clean_exit () {
E="$1"
test -z $1 && E=0
if [ $E -eq 0 ]
then echo "Build script has terminated successfully."
else echo "Build script has terminated with error $E"
fi
exit $E
}
# Disk images cannot be built unless we're UID 0
if [ "$UID" != "0" ]
then echo "WARNING: Disk images can only be built logged in as 'root'"
fi
# A copy of dev86 is REQUIRED to build!
if [ ! -e "./dev86" ]
then
echo "ERROR: You must copy or symlink 'dev86' to the root of the"
echo " ELKS source tree. If you don't have dev86, you can obtain"
echo " a copy at: https://github.com/jbruchon/dev86"
echo "Cannot build without dev86 in the source tree. Aborting."
exit 1
fi
# bcc is required (but has no --version switch, so test for stdio output)
if [ -z "$(bcc 2>&1)" ]
then
echo "ERROR: Cannot execute 'bcc'. You must build and install dev86 to"
echo " your system before attempting to build ELKS. Aborting."
exit 1
fi
# Working directory
WD="$(pwd)"
### Clean if asked
if [ "$1" = "clean" ]
then echo
echo "Cleaning up. Please wait."
sleep 1
for X in elks elkscmd
do cd $X; make clean; cd "$WD"
done
clean_exit 0
fi
### Kernel build
echo
echo "Preparing to build the ELKS kernel. This will invoke 'make menuconfig'"
echo "for you to configure the system. The defaults should be OK for many"
echo "systems, but you may want to review them."
pause
cd elks || clean_exit 1
make clean
make menuconfig || clean_exit 2
test -e .config || clean_exit 3
make defconfig || clean_exit 4
make -j4 || clean_exit 4
test -e arch/i86/boot/Image || clean_exit 4
cd "$WD"
### dev86 verification
echo "Verifying dev86 is built."
sleep 1
cd dev86 || clean_exit 5
make || clean_exit 5
cd "$WD"
### elkscmd build
echo "Building 'elkscmd'"
sleep 1
cd elkscmd || clean_exit 7
make clean
make || clean_exit 7
### Make image files
test $UID -ne 0 && echo "Skipping image file build (not root)." && clean_exit 0
make images.zip || clean_exit 8
make images.tar.gz || clean_exit 8
make images.tar.xz || clean_exit 8
cd "$WD"
echo "Images and image file archives are under 'elkscmd'."
clean_exit 0