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="-std=c89 -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
127 clang|clang-*) _cc_cflags="-std=c89 -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-pointer-sign -Wno-unused-value -Wno-return-type" ;;
130 esac
131 local _cpu_cflags=
136 esac
137 local _system_cflags=
141 esac
142 "$CC" -g -D_XOPEN_SOURCE=700 $_cc_cflags $_cpu_cflags $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl -lffi $_system_cflags
143 fi
144 }
146 compile() {
151 esac
152 }
154 link() {
159 esac
160 }
162 compile_all() {
163 ###^^^^^^^^^^^^^^^^^^^^^^^^###
164 ### Compile POSIX bindings ###
165 ###________________________###
168 compile Posix/Mod/Ctypes.cp \
169 Posix/Mod/Csys_types.cp \
170 Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \
171 Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \
172 Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \
173 Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \
174 Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \
175 Posix/Mod/Clibgen.cp \
176 Posix/Mod/Cmacro.cp
178 compile Lib/Mod/FFI.cp
179 fi
180 fi
182 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
183 ### Compile BlackBox Framework ###
184 ###____________________________###
186 compile System/Mod/Int.odc
188 compile System/Mod/Long.odc
189 compile System/Mod/Math.odc System/Mod/SMath.odc
190 else
191 compile System/Mod/Math.cp System/Mod/SMath.cp
192 fi
193 compile System/Mod/Kernel.cp \
194 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
195 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Meta.odc \
196 System/Mod/Services.odc System/Mod/Integers.odc
199 mv -t System Code Sym
200 fi
202 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
203 ### Compile Linux Host subsystem ###
204 ###______________________________###
206 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
207 Host/Mod/Files.cp
209 ###^^^^^^^^^^^^^^^^^^^^^^^###
210 ### Compile Dev subsystem ###
211 ###_______________________###
213 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
214 Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
215 Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
217 ###^^^^^^^^^^^^^^^^^^^^^^^^###
218 ### Compile Dev2 subsystem ###
219 ###________________________###
221 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
222 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
223 Dev2/Mod/LnkWritePe.odc
225 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
226 ### Compile CPfront subsystem ###
227 ###___________________________###
229 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
231 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
232 ### Compile bbdsw-specific modules ###
233 ###________________________________###
236 compile Dsw/Mod/Debug.odc
237 fi
238 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
239 Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
240 }
242 link_all() {
243 local _debug_module=
245 _debug_module=DswDebug
246 fi
248 link cpc486 \
249 PosixCtypes PosixCmacro \
250 Kernel Console Files Dates Math Strings Services Log \
252 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
253 DevCPL486 DevCPC486 DevCPV486 \
254 DswDocuments DswCompiler486Main
256 link cpl486 \
257 PosixCtypes PosixCmacro \
258 Kernel Console Files Math Strings Services Log \
260 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
261 Dev2LnkWriteElfStatic Dev2LnkWritePe \
262 DswLinker486Main
264 link cpfront \
265 PosixCtypes PosixCmacro \
266 Kernel Console Files Dates Math Strings Services Log \
268 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
269 CPfrontCPG CPfrontCPC CPfrontCPV\
270 DswDocuments DswCompilerCPfrontMain
273 chmod a+x cpc486 cpl486 cpfront
274 fi
275 }
277 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
278 ### Parse arguments and options ###
279 ###_____________________________###
281 while getopts c:l:o:bxh _name
282 do
287 b) _docompile=false ;;
288 x) _dolink=false ;;
289 h|?) usage ;;
290 esac
291 done
294 usage
295 fi
303 export CC=cc
304 fi
306 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
307 ### Check for supported cpu/target/os ###
308 ###___________________________________###
311 386|486|586|686) _cpu=486 ;;
312 arm|armv6|armv7) _cpu=arm ;;
315 esac
318 native) _target=native ;;
319 cpfront|c) _target=cpfront ;;
322 esac
325 linux) _useposix=true ;;
326 cygwin) _useposix=true ;;
329 esac
331 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
332 ### Select default compiler if not specified ###
333 ###__________________________________________###
337 native)
339 486) _compiler=cpc486 ;;
341 esac
342 ;;
343 cpfront) _compiler=cpfront ;;
345 esac
346 fi
350 native)
352 486) _linker=cpl486 ;;
354 esac
355 ;;
356 cpfront) _linker= ;;
358 esac
359 fi
364 else
366 fi
367 fi
372 else
374 fi
375 fi
377 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
378 ### Copy sources for changed system ###
379 ###_________________________________###
383 fi
390 fi
395 fi
399 ###^^^^^^^^^^^^^^^###
400 ### Build modules ###
401 ###_______________###
404 compile_all
405 fi
407 ###^^^^^^^^^^^^^^###
408 ### Link modules ###
409 ###______________###
411 link_all