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
25 ###^^^^^^^^^^^###
26 ### Functions ###
27 ###___________###
29 usage() {
51 exit 2
52 }
54 error() {
56 exit 1
57 }
59 copy_source() {
60 for _src
61 do
64 fi
65 done
66 }
68 native_compile() {
70 }
72 native_link() {
79 fi
80 shift
81 "$_linker" $CPLFALGS -os "$_outsystem" -kernel Kernel -main Kernel -legacycodedir . -o "$_outexe" "$@"
82 fi
83 }
85 cpfront_import_list() {
86 echo
88 do
90 shift
93 fi
94 done
95 }
97 cpfront_main_module() {
99 shift
101 echo
103 echo
105 }
107 cpfront_compile() {
109 }
111 cpfront_link() {
116 fi
117 shift
119 local _list=
121 do
123 done
124 local _cc_cflags=
126 *gcc) _cc_cflags="-g -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
128 esac
129 local _cpu_cflags=
134 esac
135 local _system_cflags=
139 esac
140 "$CC" $_cc_cflags $_cpu_cflags $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl -lffi $_system_cflags
141 fi
142 }
144 compile() {
149 esac
150 }
152 link() {
157 esac
158 }
160 compile_all() {
161 ###^^^^^^^^^^^^^^^^^^^^^^^^###
162 ### Compile POSIX bindings ###
163 ###________________________###
166 compile Posix/Mod/Ctypes.cp \
167 Posix/Mod/Csys_types.cp \
168 Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \
169 Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \
170 Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \
171 Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \
172 Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \
173 Posix/Mod/Clibgen.cp \
174 Posix/Mod/Cmacro.cp
176 compile Lib/Mod/FFI.cp
177 fi
178 fi
180 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
181 ### Compile BlackBox Framework ###
182 ###____________________________###
184 compile System/Mod/Int.odc
186 compile System/Mod/Long.odc
187 compile System/Mod/Math.odc System/Mod/SMath.odc
188 else
189 compile System/Mod/Math.cp System/Mod/SMath.cp
190 fi
191 compile System/Mod/Kernel.cp \
192 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
193 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Meta.odc \
194 System/Mod/Services.odc System/Mod/Integers.odc
197 mv -t System Code Sym
198 fi
200 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
201 ### Compile Linux Host subsystem ###
202 ###______________________________###
204 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
205 Host/Mod/Files.cp
207 ###^^^^^^^^^^^^^^^^^^^^^^^###
208 ### Compile Dev subsystem ###
209 ###_______________________###
211 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
212 Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
213 Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
215 ###^^^^^^^^^^^^^^^^^^^^^^^^###
216 ### Compile Dev2 subsystem ###
217 ###________________________###
219 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
220 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
221 Dev2/Mod/LnkWritePe.odc
223 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
224 ### Compile CPfront subsystem ###
225 ###___________________________###
227 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
229 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
230 ### Compile bbdsw-specific modules ###
231 ###________________________________###
234 compile Dsw/Mod/Debug.odc
235 fi
236 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
237 Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
238 }
240 link_all() {
241 local _debug_module=
243 _debug_module=DswDebug
244 fi
246 link cpc486 \
247 PosixCtypes PosixCmacro \
248 Kernel Console Files Dates Math Strings Services Log \
250 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
251 DevCPL486 DevCPC486 DevCPV486 \
252 DswDocuments DswCompiler486Main
254 link cpl486 \
255 PosixCtypes PosixCmacro \
256 Kernel Console Files Math Strings Services Log \
258 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
259 Dev2LnkWriteElfStatic Dev2LnkWritePe \
260 DswLinker486Main
262 link cpfront \
263 PosixCtypes PosixCmacro \
264 Kernel Console Files Dates Math Strings Services Log \
266 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
267 CPfrontCPG CPfrontCPC CPfrontCPV\
268 DswDocuments DswCompilerCPfrontMain
271 chmod a+x cpc486 cpl486 cpfront
272 fi
273 }
275 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
276 ### Parse arguments and options ###
277 ###_____________________________###
279 while getopts c:l:o:bxh _name
280 do
285 b) _docompile=false ;;
286 x) _dolink=false ;;
287 h|?) usage ;;
288 esac
289 done
292 usage
293 fi
301 export CC=cc
302 fi
304 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
305 ### Check for supported cpu/target/os ###
306 ###___________________________________###
309 386|486|586|686) _cpu=486 ;;
310 arm|armv6|armv7) _cpu=arm ;;
313 esac
316 native) _target=native ;;
317 cpfront|c) _target=cpfront ;;
320 esac
323 linux) _useposix=true ;;
324 cygwin) _useposix=true ;;
327 esac
329 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
330 ### Select default compiler if not specified ###
331 ###__________________________________________###
335 native)
337 486) _compiler=cpc486 ;;
339 esac
340 ;;
341 cpfront) _compiler=cpfront ;;
343 esac
344 fi
348 native)
350 486) _linker=cpl486 ;;
352 esac
353 ;;
354 cpfront) _linker= ;;
356 esac
357 fi
362 else
364 fi
365 fi
370 else
372 fi
373 fi
375 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
376 ### Copy sources for changed system ###
377 ###_________________________________###
381 fi
388 fi
393 fi
397 ###^^^^^^^^^^^^^^^###
398 ### Build modules ###
399 ###_______________###
402 compile_all
403 fi
405 ###^^^^^^^^^^^^^^###
406 ### Link modules ###
407 ###______________###
409 link_all