-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·181 lines (147 loc) · 4.87 KB
/
build.sh
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
#!/bin/bash
# SSD disk number to copy to in MMB file (if present)
#
SSDNUM=488
# Load address
#
ADDR=0x100
# List of seperate programs to build
#
PROGS="test.c mini.c spigot.c"
# Enable/disable assembler build
#
BUILD_S=1
# Enable/Disable C build
#
BUILD_C=1
# Control specific C builds
#
# A = Ack compiler with Ack assembler
# G = GCC compiler with GCC assembler
# P = PCC compiler with Unix V7 assembler
# Q = PCC compiler with GCC assembler (broken because of jbr/jcc)
# U = Unix V7 compiler with Unix V7 assembler
#
BUILD_C_TARGETS="A G P U"
add_file_to_ssd () {
md5sum $1
# beeb delete ${SSDFILE} -y $1
echo "$.$1 B000 B000" > $1.inf
beeb putfile ${SSDFILE} $1
# rm -f $1.inf
}
# Setup apout to point to a local unix_v7 directoty tree
export APOUT_ROOT=unix_v7
mkdir -p $APOUT_ROOT/tmp
# Swallow warning from apout that mentions a_magic2
run_apout () {
apout $* |& grep -v a_magic2
}
# Prepare the ssd image
SSDFILE=build.ssd
cp bbcpdp.ssd ${SSDFILE}
# Add in PIBAS
add_file_to_ssd PIBAS
# Prepare the PCC Libraries
PCC_LIBS=$(find lib -name '*.s')
# Compile the mangle program removes 0x100 bytes of the a.out file
gcc src/mangle.c -o mangle
# Package the Unix V7 libraries into an archive
UNIX_V7_LIB=lib/libunix.a
rm -f $UNIX_V7_LIB
for i in $PCC_LIBS
do
OBJ=${i%.s}.o
run_apout unix_v7/bin/as -o $OBJ $i
run_apout unix_v7/bin/ar cr $UNIX_V7_LIB $OBJ
done
echo "$UNIX_V7_LIB includes:"
run_apout unix_v7/bin/ar t $UNIX_V7_LIB
if [ $BUILD_S == "1" ]
then
for i in pieis.s
do
name=`echo ${i%.*} | tr "a-z" "A-Z"`
pdp11-aout-gcc -T src/$name.ld -nostdlib src/$i -o $name
pdp11-aout-objdump -D $name > $name.lst
pdp11-aout-strip -D $name
add_file_to_ssd $name
done
fi
if [ $BUILD_C == "1" ]
then
for b in $BUILD_C_TARGETS
do
for i in $PROGS
do
name=`echo ${b}${i%.*} | tr "a-z" "A-Z"`
case $b in
# A = Ack compiler with Ack assembler
A)
ack -w -mpdpv7 src/crt0_ack.s src/$i -o $name
./mangle ${name} ${name} -d
pdp11-aout-objdump -D $name --adjust-vma=$ADDR > $name.lst
pdp11-aout-strip -D $name
;;
# G = GCC compiler with GCC assembler
G)
pdp11-aout-gcc -nostdlib -Ttext $ADDR src/crt0_gcc.s src/$i -lgcc -o $name
pdp11-aout-objdump -D $name --adjust-vma=$ADDR > $name.lst
pdp11-aout-strip -D $name
;;
# Q = PCC compiler with GCC assembler
Q)
# Use PCC as a compiler only
pdp11-aout-bsd-pcc -S src/$i
asm=$name.s
mv ${i%.*}.s ${asm}
# Hacky fixups...
sed -i "s/jgt/bgt/" ${asm}
sed -i "s/jlt/blt/" ${asm}
sed -i "s/jle/ble/" ${asm}
sed -i "s/jge/bge/" ${asm}
sed -i "s/jeq/beq/" ${asm}
sed -i "s/jhi/bhi/" ${asm}
sed -i "s/jlo/blo/" ${asm}
sed -i "s/jne/bne/" ${asm}
sed -i "s/jlos/blos/" ${asm}
sed -i "s/jhos/bhos/" ${asm}
sed -i "s/jbr/br/" ${asm}
# Use GCC as an assembler/linker
pdp11-aout-gcc -nostdlib -Ttext $ADDR -o ${name} src/crt0_pcc.s $PCC_LIBS ${asm}
pdp11-aout-objdump -D $name --adjust-vma=$ADDR > $name.lst
pdp11-aout-strip -D $name
;;
# P = PCC compiler with Unix V7 assembler
P)
pdp11-aout-bsd-pcc -S src/$i
asm=$name.s
mv ${i%.*}.s ${asm}
run_apout unix_v7/bin/cc -o ${name} src/pad.s src/crt0_pcc.s ${asm} $UNIX_V7_LIB
./mangle ${name} ${name} -d
pdp11-aout-objdump -D $name --adjust-vma=$ADDR > $name.lst
pdp11-aout-strip -D $name
;;
# U = Unix V7 compiler with Unix V7 assembler
# TODO: this could use pad.s / crt0_pcc.s
U)
run_apout unix_v7/bin/cc -o ${name} src/crt0_v7.s src/v7/$i
./mangle ${name} ${name} -d
pdp11-aout-objdump -D $name --adjust-vma=$ADDR > $name.lst
pdp11-aout-strip -D $name
;;
esac
# Add the file into the SSD image
add_file_to_ssd $name
done
done
fi
# Final Packaging
beeb title ${SSDFILE} "PDP-11 Pi"
beeb info ${SSDFILE}
# Copy to the SD Card if it's present
if [ -f $BBC_FILE ];
then
beeb dkill -y ${SSDNUM}
beeb dput_ssd ${SSDNUM} ${SSDFILE}
fi