This repository was archived by the owner on Feb 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
133 lines (119 loc) · 2.49 KB
/
bootstrap.sh
File metadata and controls
133 lines (119 loc) · 2.49 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
#! /bin/bash -x
function get_version_info()
{
export PACKAGE=$(basename $(dirname $0))
if [ "$PACKAGE" = "." ]; then
PACKAGE=$(basename $(pwd))
fi
if [ ! -d $PACKAGE ]; then
PACKAGE=$(echo $PACKAGE | sed s/^[^-]*-//g)
fi
echo PACKAGE=$PACKAGE
if [ ! -d $PACKAGE ]; then
echo "The $PACKAGE directory does not exist!"
echo "Bailing out"
(exit 1); exit 1;
fi
if [ ! -f $PACKAGE/version ]; then
echo "The $PACKAGE/version file does not exist or is not a regular file!"
echo "Bailing out"
(exit 1); exit 1;
fi
export VERSION=$(cat $PACKAGE/version)
echo VERSION=$VERSION
}
function gen_configure_ac()
{
BUILD_KERNEL=0
if [ x"$PACKAGE" = xkernel ]; then
BUILD_KERNEL=1
fi
cat > bootstrap.pl <<EOF
#! /usr/bin/perl -w
while (<>)
{
\$_ =~ s/\\\$\\\$__PACKAGE__\\\$\\\$/$PACKAGE/g;
\$_ =~ s/\\\$\\\$__VERSION__\\\$\\\$/$VERSION/g;
\$_ =~ s/\\\$\\\$__BUILD_KERNEL__\\\$\\\$/$BUILD_KERNEL/g;
print \$_;
}
EOF
cat configure.ac.in | perl bootstrap.pl > configure.ac
}
function gen_makefile_in()
{
PROGAMS=
LIBRARIES=
MODULES=
KERNEL=
# programs go here
if [ -d cpu-info ]; then
PROGRAMS="cpu-info $PROGRAMS"
fi
# modules go here
if [ -d bochs ]; then
MODULES="bochs $MODULES"
fi
if [ -d cpu ]; then
MODULES="cpu $MODULES"
fi
if [ -d bootstrap ]; then
MODULES="bootstrap $MODULES"
fi
if [ -d event ]; then
MODULES="event $MODULES"
fi
if [ -d mm ]; then
MODULES="mm $MODULES"
fi
if [ -d klib ]; then
MODULES="klib $MODULES"
fi
if [ -d sched ]; then
MODULES="sched $MODULES"
fi
if [ -d drivers ]; then
MODULES="drivers $MODULES"
fi
# libraries go here
if [ -d elf ]; then
MODULES="elf $MODULES"
fi
# the kernel goes here
if [ -d kernel ]; then
KERNEL="halos"
MODULES="kernel $MODULES"
fi
cat > bootstrap.pl <<EOF
#! /use/bin/perl -w
while (<>)
{
\$_ =~ s/\\\$\\\$__PACKAGE__\\\$\\\$/$PACKAGE/g;
\$_ =~ s/\\\$\\\$__VERSION__\\\$\\\$/$VERSION/g;
\$_ =~ s/\\\$\\\$__LIBRARIES__\\\$\\\$/$LIBRARIES/g;
\$_ =~ s/\\\$\\\$__PROGRAMS__\\\$\\\$/$PROGRAMS/g;
\$_ =~ s/\\\$\\\$__MODULES__\\\$\\\$/$MODULES/g;
\$_ =~ s/\\\$\\\$__KERNEL__\\\$\\\$/$KERNEL/g;
print \$_;
}
EOF
cat Makefile.in.in | perl bootstrap.pl > Makefile.in
}
function gen_link_mk()
{
rm -f link.mk
cat >link.mk <<EOF
cpu-info.exe : \$(OBJ)
\$(CC) \$(LDFLAGS) -o \$@ \$^
halos : \$(OBJ)
\$(LD) \$(LDFLAGS) -T\$(srcdir)/config/kernel.lds -o\$@ \$^
nm -C \$@ | cut -d ' ' -f 1,3 > halos.map
size \$@
EOF
}
get_version_info
gen_configure_ac
gen_makefile_in
gen_link_mk
aclocal && \
autoconf