forked from greatbridf/osdev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·134 lines (121 loc) · 2.76 KB
/
configure
File metadata and controls
executable file
·134 lines (121 loc) · 2.76 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
#!/bin/sh
DEFAULT_ARCH="x86_64"
if [ "$OUT" = "" ]; then
OUT="Makefile"
fi
printf "Configuring for %s...\n" "$OUT"
event() {
printf "$1... "
}
ARCH=${ARCH:-"$DEFAULT_ARCH"}
# Define toolchain and QEMU/GDB settings for per architecture
event "target architecture"
echo "$ARCH"
case "$ARCH" in
x86_64)
QEMU_EXECUTABLES="qemu-system-x86_64"
GDB_EXECUTABLES="gdb x86_64-elf-gdb"
: "${CROSS_COMPILE:=}"
;;
riscv64)
QEMU_EXECUTABLES="qemu-system-riscv64"
GDB_EXECUTABLES="gdb riscv64-unknown-elf-gdb"
: "${CROSS_COMPILE:=riscv64-unknown-elf-}"
;;
aarch64)
QEMU_EXECUTABLES="qemu-system-aarch64"
GDB_EXECUTABLES="gdb aarch64-none-elf-gdb"
: "${CROSS_COMPILE:=aarch64-none-elf-}"
;;
*)
echo "Unsupported ARCH: $ARCH"
exit 1
;;
esac
if [ "$QEMU" = "" ]; then
event "checking default qemu"
QEMU="qemu-system-$ARCH"
if $QEMU --version > /dev/null 2>&1; then
QEMU="qemu-system-\$(ARCH)"
break
fi
else
event "checking given qemu"
for item in $QEMU; do
if $item --version > /dev/null 2>&1; then
QEMU="$item"
break
fi
done
QEMU=""
fi
if [ "$QEMU" = "" ]; then
echo "failed"
exit 1
fi
echo "$QEMU"
check_gdb_arch() {
local item="$1"
if $item --init-eval-command 'set arch' \
--init-eval-command 'q' 2>&1 \
| grep "$ARCH" >/dev/null 2>&1; then
return 0
else
return 1
fi
}
if [ "$GDB" = "" ]; then
event "checking default gdb"
if check_gdb_arch "$ARCH-elf-gdb"; then
GDB="\$(ARCH)-elf-gdb"
break
fi
else
event 'checking given gdb'
for item in $GDB; do
if check_gdb_arch "$GDB"; then
GDB="$item"
break
fi
done
GDB=""
fi
if [ "$GDB" = "" ]; then
echo "failed"
exit 1
fi
echo "$GDB"
event "checking util-linux fdisk"
if [ "$FDISK" = "" ]; then
if ! which fdisk > /dev/null 2>&1; then
echo "no"
exit 1
fi
FDISK=`which fdisk`
fi
if ! $FDISK -v 2>&1 | grep util-linux > /dev/null 2>&1 ; then
echo "no, fdisk is not from util-linux"
exit 1
else
echo "$FDISK"
fi
event "checking mkfs tool"
if ! which mkfs.fat > /dev/null 2>&1; then
echo "no"
exit 1
else
echo `which mkfs.fat`
fi
event "checking additional image"
if [ "$IMG" = "" ]; then
echo "no"
else
echo "$IMG"
fi
cp Makefile.src "$OUT"
sed -i '' -e "s|##DEFAULT_ARCH##|$ARCH|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##GDB##|$GDB|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##QEMU##|$QEMU|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##FDISK##|$FDISK|" "$OUT" > /dev/null 2>&1
sed -i '' -e "s|##IMAGE##|$IMG|" "$OUT" > /dev/null 2>&1
exit 0