-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
227 lines (197 loc) · 6.44 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
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
#!/bin/bash
##############################################################################
# --- BASH SHELL SCRIPT FOR BUILDING CSI COMMS CODE ---
#
# ---> Run 'source build.sh' from the Linux cmd line to build the code
# ---> build.sh MUST be in the parent directory of /bin, /debug, and /source
# ---> Output .hex file will be in /bin binary
# ---> /source directory will contain source code, assembler listings, and
# object files
# ---> /debug directory will contain debug information files generated by
# the SDCC compiler, see the SDCC user manual for more information
##############################################################################
# Where the files are
SRC_DIR="./source"
# Destination directory for outputted hex file
BIN_DEST_DIR="./bin"
# Destination directory for debug files
DEBUG_DEST_DIR="./debug"
echo " "
echo "CSI COMMS CODE BUILD PROCESS STARTED"
# Print out directory structure information
echo " "
echo "-------DIRECTORY INFORMATION-------"
echo "*** SOURCE DIR: $SRC_DIR"
echo "*** BINARY DESTINATION DIR: $BIN_DEST_DIR"
echo "*** DEBUG DESTINATION DIR: $DEBUG_DEST_DIR"
echo "-----------------------------------"
echo " "
# Compile source file
echo "-------------COMPILING-------------"
sdcc -c ./source/_heap.c -D HEAP_SIZE=8192 --model-large
sdcc -c ./source/AX25Frame.c --model-large
sdcc -c ./source/DataFrame.c --model-large
sdcc -c ./source/Radio.c --model-large
echo "*** Compiling AX25Frame.c"
echo "*** Compiling DataFrame.c"
echo "*** Compiling Radio.c"
echo "*** Compilation complete"
echo "-----------------------------------"
echo " "
echo "---------ORGANIZING FILES----------"
# Move and rename files to fit directory strucutre
# Check to see if Radio.asm, Radio.lst, Radio.rel, and Radio.sym exists
if [ -e "./Radio.asm" ]
then
echo "*** MOVING Radio.asm FILE TO SOURCE DIRECTORY"
mv ./Radio.asm $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! Radio.asm FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./Radio.lst" ]
then
echo "*** MOVING Radio.lst FILE TO SOURCE DIRECTORY"
mv ./Radio.lst $SRC_DIR
else
echo "!!! ERROR !!! Radio.lst FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./Radio.rel" ]
then
echo "*** MOVING Radio.rel FILE TO SOURCE DIRECTORY"
mv ./Radio.rel $SRC_DIR
else
echo "!!! ERROR !!! Radio.rel FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./Radio.sym" ]
then
echo "*** MOVING Radio.sym FILE TO DEBUG DIRECTORY"
mv ./Radio.sym $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! Radio.sym FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./AX25Frame.asm" ]
then
echo "*** MOVING AX25Frame.asm FILE TO SOURCE DIRECTORY"
mv ./AX25Frame.asm $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! AX25Frame.asm FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./AX25Frame.lst" ]
then
echo "*** MOVING AX25Frame.lst FILE TO SOURCE DIRECTORY"
mv ./AX25Frame.lst $SRC_DIR
else
echo "!!! ERROR !!! AX25Frame.lst FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./AX25Frame.rel" ]
then
echo "*** MOVING AX25Frame.rel FILE TO SOURCE DIRECTORY"
mv ./AX25Frame.rel $SRC_DIR
else
echo "!!! ERROR !!! AX25Frame.rel FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./AX25Frame.sym" ]
then
echo "*** MOVING AX25Frame.sym FILE TO DEBUG DIRECTORY"
mv ./AX25Frame.sym $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! AX25Frame.sym FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./DataFrame.asm" ]
then
echo "*** MOVING DataFrame.asm FILE TO SOURCE DIRECTORY"
mv ./DataFrame.asm $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! DataFrame.asm FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./DataFrame.lst" ]
then
echo "*** MOVING DataFrame.lst FILE TO SOURCE DIRECTORY"
mv ./DataFrame.lst $SRC_DIR
else
echo "!!! ERROR !!! DataFrame.lst FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./DataFrame.rel" ]
then
echo "*** MOVING DataFrame.rel FILE TO SOURCE DIRECTORY"
mv ./DataFrame.rel $SRC_DIR
else
echo "!!! ERROR !!! DataFrame.rel FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./DataFrame.sym" ]
then
echo "*** MOVING DataFrame.sym FILE TO DEBUG DIRECTORY"
mv ./DataFrame.sym $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! DataFrame.sym FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./_heap.asm" ]
then
echo "*** MOVING _heap.asm FILE TO SOURCE DIRECTORY"
mv ./_heap.asm $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! _heap.asm FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./_heap.lst" ]
then
echo "*** MOVING _heap.lst FILE TO SOURCE DIRECTORY"
mv ./_heap.lst $SRC_DIR
else
echo "!!! ERROR !!! _heap.lst FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./_heap.rel" ]
then
echo "*** MOVING _heap.rel FILE TO SOURCE DIRECTORY"
mv ./_heap.rel $SRC_DIR
else
echo "!!! ERROR !!! _heap.rel FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./_heap.sym" ]
then
echo "*** MOVING _heap.sym FILE TO DEBUG DIRECTORY"
mv ./_heap.sym $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! _heap.sym FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
echo "-----------------------------------"
echo " "
echo "--------LINKING OBJECT FILES-------"
# Link object files and generate output hex file
sdcc ./source/Radio.rel ./source/AX25Frame.rel ./source/DataFrame.rel ./source/_heap.rel --model-large
echo "*** Linking Radio.rel"
echo "*** Linking AX25Frame.rel"
echo "*** Linking DataFrame.rel"
echo "*** Linking complete"
echo "-----------------------------------"
echo " "
echo "---------ORGANIZING FILES----------"
if [ -e "./Radio.ihx" ]
then
echo "*** MOVING Radio.ihx FILE TO BIN DIRECTORY"
mv ./Radio.ihx $BIN_DEST_DIR/Radio.hex
else
echo "!!! ERROR !!! Radio.ihx FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./Radio.lk" ]
then
echo "*** MOVING Radio.lk FILE TO DEBUG DIRECTORY"
mv ./Radio.lk $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! Radio.lk FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./Radio.map" ]
then
echo "*** MOVING Radio.map FILE TO DEBUG DIRECTORY"
mv ./Radio.map $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! Radio.map FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
if [ -e "./Radio.mem" ]
then
echo "*** MOVING Radio.mem FILE TO DEBUG DIRECTORY"
mv ./Radio.mem $DEBUG_DEST_DIR
else
echo "!!! ERROR !!! Radio.mem FILE NOT FOUND - CHECK IF COMPILATION WAS SUCCESSFUL"
fi
echo "-----------------------------------"
echo " "