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() {
46 exit 2
47 }
49 error() {
51 exit 1
52 }
54 copy_source() {
55 for _src
56 do
59 fi
60 done
61 }
63 native_compile() {
65 }
67 native_link() {
74 fi
75 shift
77 fi
78 }
80 cpfront_import_list() {
81 echo
83 do
85 shift
88 fi
89 done
90 }
92 cpfront_main_module() {
94 shift
96 echo
98 echo
100 }
102 cpfront_compile() {
104 }
106 cpfront_link() {
111 fi
112 shift
114 local _list=
116 do
118 done
119 local _cc_cflags=
121 *gcc) _cc_cflags="-g -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
123 esac
124 local _cpu_cflags=
129 esac
130 local _system_cflags=
134 esac
135 "$CC" $_cc_cflags $_cpu_cflags $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl -lffi $_system_cflags
136 fi
137 }
139 compile() {
144 esac
145 }
147 link() {
152 esac
153 }
155 compile_all() {
156 ###^^^^^^^^^^^^^^^^^^^^^^^^###
157 ### Compile POSIX bindings ###
158 ###________________________###
161 compile Posix/Mod/Ctypes.cp \
162 Posix/Mod/Csys_types.cp \
163 Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \
164 Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \
165 Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \
166 Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \
167 Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \
168 Posix/Mod/Clibgen.cp \
169 Posix/Mod/Cmacro.cp
171 compile Lib/Mod/FFI.cp
172 fi
173 fi
175 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
176 ### Compile BlackBox Framework ###
177 ###____________________________###
179 compile System/Mod/Int.odc
181 compile System/Mod/Long.odc
182 compile System/Mod/Math.odc System/Mod/SMath.odc
183 else
184 compile System/Mod/Math.cp System/Mod/SMath.cp
185 fi
186 compile System/Mod/Kernel.cp \
187 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
188 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Meta.odc \
189 System/Mod/Services.odc System/Mod/Integers.odc
192 mv -t System Code Sym
193 fi
195 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
196 ### Compile Linux Host subsystem ###
197 ###______________________________###
199 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
200 Host/Mod/Files.cp
202 ###^^^^^^^^^^^^^^^^^^^^^^^###
203 ### Compile Dev subsystem ###
204 ###_______________________###
206 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
207 Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
208 Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
210 ###^^^^^^^^^^^^^^^^^^^^^^^^###
211 ### Compile Dev2 subsystem ###
212 ###________________________###
214 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
215 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
216 Dev2/Mod/LnkWritePe.odc
218 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
219 ### Compile CPfront subsystem ###
220 ###___________________________###
222 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
224 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
225 ### Compile bbdsw-specific modules ###
226 ###________________________________###
229 compile Dsw/Mod/Debug.odc
230 fi
231 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
232 Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
233 }
235 link_all() {
236 local _debug_module=
238 _debug_module=DswDebug
239 fi
241 link cpc486 \
242 PosixCtypes PosixCmacro \
243 Kernel Console Files Dates Math Strings Services Log \
245 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
246 DevCPL486 DevCPC486 DevCPV486 \
247 DswDocuments DswCompiler486Main
249 link cpl486 \
250 PosixCtypes PosixCmacro \
251 Kernel Console Files Math Strings Services Log \
253 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
254 Dev2LnkWriteElfStatic Dev2LnkWritePe \
255 DswLinker486Main
257 link cpfront \
258 PosixCtypes PosixCmacro \
259 Kernel Console Files Dates Math Strings Services Log \
261 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
262 CPfrontCPG CPfrontCPC CPfrontCPV\
263 DswDocuments DswCompilerCPfrontMain
266 chmod a+x cpc486 cpl486 cpfront
267 fi
268 }
270 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
271 ### Parse arguments and options ###
272 ###_____________________________###
274 while getopts c:l:o:bxh _name
275 do
280 b) _docompile=false ;;
281 x) _dolink=false ;;
282 h|?) usage ;;
283 esac
284 done
287 usage
288 fi
296 export CC=cc
297 fi
299 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
300 ### Check for supported cpu/target/os ###
301 ###___________________________________###
304 386|486|586|686) _cpu=486 ;;
305 arm|armv6|armv7) _cpu=arm ;;
308 esac
311 native) _target=native ;;
312 cpfront|c) _target=cpfront ;;
315 esac
318 linux) _useposix=true ;;
319 cygwin) _useposix=true ;;
322 esac
324 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
325 ### Select default compiler if not specified ###
326 ###__________________________________________###
330 native)
332 486) _compiler=cpc486 ;;
334 esac
335 ;;
336 cpfront) _compiler=cpfront ;;
338 esac
339 fi
343 native)
345 486) _linker=cpl486 ;;
347 esac
348 ;;
349 cpfront) _linker= ;;
351 esac
352 fi
357 else
359 fi
360 fi
365 else
367 fi
368 fi
370 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
371 ### Copy sources for changed system ###
372 ###_________________________________###
376 fi
383 fi
388 fi
392 ###^^^^^^^^^^^^^^^###
393 ### Build modules ###
394 ###_______________###
397 compile_all
398 fi
400 ###^^^^^^^^^^^^^^###
401 ### Link modules ###
402 ###______________###
404 link_all