1 #! /bin/sh
3 set -e
5 ###^^^^^^^^^^^^^^^^^^###
6 ### Global variables ###
7 ###__________________###
11 _cpu=
12 _target=
13 _system=
14 _compiler=
15 _linker=
16 _docompile=true
17 _dolink=true
20 _useposix=false
22 ###^^^^^^^^^^^###
23 ### Functions ###
24 ###___________###
26 usage() {
45 exit 2
46 }
48 error() {
50 exit 1
51 }
53 copy_source() {
54 for _src
55 do
58 fi
59 done
60 }
62 native_compile() {
64 }
66 native_link() {
69 fi
70 }
72 cpfront_import_list() {
73 echo
75 do
77 shift
80 fi
81 done
82 }
84 cpfront_main_module() {
86 shift
88 }
90 cpfront_compile() {
92 }
94 cpfront_link() {
99 fi
100 shift
102 local _list=
104 do
106 done
107 local _cc_cflags=
109 *gcc) _cc_cflags="-Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
111 esac
112 local _cpu_cflags=
117 esac
118 "$CC" $_cc_cflags $_cpu_cflags -lm -ldl $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list
119 fi
120 }
122 compile() {
127 esac
128 }
130 link() {
135 esac
136 }
138 compile_all() {
139 ###^^^^^^^^^^^^^^^^^^^^^^^^###
140 ### Compile POSIX bindings ###
141 ###________________________###
144 compile Posix/Mod/Ctypes.cp \
145 Posix/Mod/Csys_types.cp \
146 Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \
147 Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \
148 Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \
149 Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \
150 Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \
151 Posix/Mod/Clibgen.cp \
152 Posix/Mod/Cmacro.cp
153 fi
155 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
156 ### Compile BlackBox Framework ###
157 ###____________________________###
159 compile System/Mod/Int.odc
161 compile System/Mod/Long.odc
162 compile System/Mod/Math.odc System/Mod/SMath.odc
163 else
164 compile System/Mod/Math.cp System/Mod/SMath.cp
165 fi
166 compile System/Mod/Kernel.cp \
167 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
168 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Services.odc \
169 System/Mod/Integers.odc
172 mv -t System Code Sym
173 fi
175 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
176 ### Compile Linux Host subsystem ###
177 ###______________________________###
179 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
180 Host/Mod/Files.cp
182 ###^^^^^^^^^^^^^^^^^^^^^^^###
183 ### Compile Dev subsystem ###
184 ###_______________________###
186 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
187 Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
188 Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
190 ###^^^^^^^^^^^^^^^^^^^^^^^^###
191 ### Compile Dev2 subsystem ###
192 ###________________________###
194 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
195 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
196 Dev2/Mod/LnkWritePe.odc
198 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
199 ### Compile CPfront subsystem ###
200 ###___________________________###
202 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
204 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
205 ### Compile bbdsw-specific modules ###
206 ###________________________________###
209 compile Dsw/Mod/Debug.odc
210 fi
211 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
212 Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
213 }
215 link_all() {
216 local _debug_module=
218 _debug_module=DswDebug
219 fi
221 link cpc486 \
222 PosixCtypes PosixCmacro \
223 Kernel Console Files Dates Math Strings Services Log \
225 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
226 DevCPL486 DevCPC486 DevCPV486 \
227 DswDocuments DswCompiler486Main
229 link cpl486 \
230 PosixCtypes PosixCmacro \
231 Kernel Console Files Math Strings Services Log \
233 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
234 Dev2LnkWriteElfStatic Dev2LnkWritePe \
235 DswLinker486Main
237 link cpfront \
238 PosixCtypes PosixCmacro \
239 Kernel Console Files Dates Math Strings Services Log \
241 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
242 CPfrontCPG CPfrontCPC CPfrontCPV\
243 DswDocuments DswCompilerCPfrontMain
246 chmod a+x cpc486 cpl486 cpfront
247 fi
248 }
250 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
251 ### Parse arguments and options ###
252 ###_____________________________###
254 while getopts c:l:o:bxh _name
255 do
260 b) _docompile=false ;;
261 x) _dolink=false ;;
262 h|?) usage ;;
263 esac
264 done
267 usage
268 fi
276 export CC=cc
277 fi
279 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
280 ### Check for supported cpu/target/os ###
281 ###___________________________________###
284 386|486|586|686) _cpu=486 ;;
285 arm|armv6|armv7) _cpu=arm ;;
288 esac
291 native) _target=native ;;
292 cpfront|c) _target=cpfront ;;
295 esac
298 linux) _useposix=true ;;
301 esac
303 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
304 ### Select default compiler if not specified ###
305 ###__________________________________________###
309 native)
311 486) _compiler=cpc486 ;;
313 esac
314 ;;
315 cpfront) _compiler=cpfront ;;
317 esac
318 fi
322 native)
324 486) _linker=cpl486 ;;
326 esac
327 ;;
328 cpfront) _linker= ;;
330 esac
331 fi
336 else
338 fi
339 fi
344 else
346 fi
347 fi
349 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
350 ### Copy sources for changed system ###
351 ###_________________________________###
355 fi
362 fi
367 fi
371 ###^^^^^^^^^^^^^^^###
372 ### Build modules ###
373 ###_______________###
376 compile_all
377 fi
379 ###^^^^^^^^^^^^^^###
380 ### Link modules ###
381 ###______________###
383 link_all