1 #! /bin/bash
3 set -e
5 abspath() {
7 }
9 ###^^^^^^^^^^^^^^^^^^###
10 ### Global variables ###
11 ###__________________###
15 _cpu=
16 _target=
17 _system=
18 _compiler=
19 _linker=
20 _docompile=true
21 _dolink=true
24 _useposix=false
29 ###^^^^^^^^^^^###
30 ### Functions ###
31 ###___________###
33 usage() {
57 exit 2
58 }
60 error() {
62 exit 1
63 }
65 copy_source() {
66 for _src
67 do
70 fi
71 done
72 }
74 native_compile() {
76 }
78 native_link() {
87 fi
88 shift
89 "$_linker" $CPLFALGS -os "$_outsystem" -kernel Kernel -main Kernel -legacycodedir . -o "$_outexe" "$@"
90 fi
91 }
93 cpfront_import_list() {
94 echo
96 do
98 shift
101 fi
102 done
103 }
105 cpfront_main_module() {
107 shift
109 echo
111 echo
113 }
115 cpfront_compile() {
117 }
119 cpfront_link() {
124 fi
125 shift
127 local _list=
129 do
131 done
132 local _cc_cflags=
134 *gcc) _cc_cflags="-std=c89 -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
135 *gcc-4.2) _cc_cflags="-std=c89 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-implicit-function-declaration" ;;
136 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" ;;
139 esac
140 local _cpu_cflags=
146 esac
147 local _system_cflags=
152 esac
157 *) ;;
158 esac
159 "$CC" -g -D_XOPEN_SOURCE=700 $_cc_cflags $_cpu_cflags $CFLAGS -o "${_out_exe}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl -lffi $_system_cflags
160 fi
161 }
163 compile() {
168 esac
169 }
171 link() {
176 esac
177 }
179 compile_all() {
180 ###^^^^^^^^^^^^^^^^^^^^^^^^###
181 ### Compile POSIX bindings ###
182 ###________________________###
185 compile Posix/Mod/Ctypes.cp \
186 Posix/Mod/Csys_types.cp \
187 Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \
188 Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \
189 Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \
190 Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \
191 Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \
192 Posix/Mod/Clibgen.cp Posix/Mod/Csys_wait.cp \
193 Posix/Mod/Cmacro.cp
195 compile Lib/Mod/FFI.cp
196 fi
197 fi
199 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
200 ### Compile BlackBox Framework ###
201 ###____________________________###
203 compile System/Mod/Int.odc
205 compile System/Mod/Long.odc
206 compile System/Mod/Math.odc System/Mod/SMath.odc
207 else
208 compile System/Mod/Math.cp System/Mod/SMath.cp
209 fi
210 compile System/Mod/Kernel.cp \
211 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
212 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Meta.odc \
213 System/Mod/Services.odc System/Mod/Integers.odc
216 mv -t System Code Sym
217 fi
219 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
220 ### Compile Linux Host subsystem ###
221 ###______________________________###
223 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
224 Host/Mod/Files.cp
226 ###^^^^^^^^^^^^^^^^^^^^^^^###
227 ### Compile Dev subsystem ###
228 ###_______________________###
230 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPR.cp Dev/Mod/CPS.odc \
231 Dev/Mod/CPB.odc Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc \
232 Dev/Mod/CPL486.odc Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
234 ###^^^^^^^^^^^^^^^^^^^^^^^^###
235 ### Compile Dev2 subsystem ###
236 ###________________________###
238 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
239 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
240 Dev2/Mod/LnkWritePe.odc
242 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
243 ### Compile CPfront subsystem ###
244 ###___________________________###
246 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
248 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
249 ### Compile bbdsw-specific modules ###
250 ###________________________________###
253 compile Dsw/Mod/Debug.odc
254 fi
256 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Opts.cp Dsw/Mod/Procs.cp
257 compile Dsw/Mod/HostProcs.cp
259 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
260 ### Compile bbdsw executables ###
261 ###___________________________###
263 compile \
264 Dsw/Mod/Compiler486Main.cp \
265 Dsw/Mod/CompilerCPfrontMain.cp \
266 Dsw/Mod/Linker486Main.cp \
267 Dsw/Mod/MakeMain.cp
268 }
270 link_all() {
271 local _debug_module=
273 _debug_module=DswDebug
274 fi
276 link cpc486 \
277 PosixCtypes PosixCmacro \
278 Kernel Console Files Dates Math Strings Services Log \
280 DevCPM DevCPT DevCPR DevCPS DevCPB DevCPP DevCPE DevCPH \
281 DevCPL486 DevCPC486 DevCPV486 \
282 DswDocuments DswCompiler486Main
284 link cpl486 \
285 PosixCtypes PosixCmacro \
286 Kernel Console Files Math Strings Services Log \
288 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
289 Dev2LnkWriteElfStatic Dev2LnkWritePe \
290 DswLinker486Main
292 link cpfront \
293 PosixCtypes PosixCmacro \
294 Kernel Console Files Dates Math Strings Services Log \
296 DevCPM DevCPT DevCPR DevCPS DevCPB DevCPP DevCPE DevCPH \
297 CPfrontCPG CPfrontCPC CPfrontCPV\
298 DswDocuments DswCompilerCPfrontMain
300 link cpmake \
301 PosixCtypes PosixCmacro \
302 Kernel Console Files Dates Math Strings Services Log \
304 DevCPM DevCPT DevCPR DevCPS \
305 DswDocuments DswOpts DswProcs DswHostProcs DswMakeMain
308 chmod a+x cpc486 cpl486 cpfront
309 fi
310 }
312 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
313 ### Parse arguments and options ###
314 ###_____________________________###
316 while getopts c:l:o:bxh _name
317 do
322 b) _docompile=false ;;
323 x) _dolink=false ;;
324 h|?) usage ;;
325 esac
326 done
329 usage
330 fi
338 export CC=cc
339 fi
341 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
342 ### Check for supported cpu/target/os ###
343 ###___________________________________###
346 386|486|586|686) _cpu=486 ;;
347 arm|armv6|armv7) _cpu=arm ;;
348 powerpc|ppc|ppc32) _cpu=powerpc ;;
351 esac
354 native) _target=native ;;
355 cpfront|c) _target=cpfront ;;
358 esac
361 linux) _useposix=true ;;
362 cygwin) _useposix=true ;;
363 osx) _useposix=true ;;
366 esac
368 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
369 ### Select default compiler if not specified ###
370 ###__________________________________________###
374 native)
376 486) _compiler=cpc486 ;;
378 esac
379 ;;
380 cpfront) _compiler=cpfront ;;
382 esac
383 fi
387 native)
389 486) _linker=cpl486 ;;
391 esac
392 ;;
393 cpfront) _linker= ;;
395 esac
396 fi
401 else
403 fi
404 fi
409 else
411 fi
412 fi
414 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
415 ### Copy sources for changed system ###
416 ###_________________________________###
420 fi
427 fi
432 fi
436 ###^^^^^^^^^^^^^^^###
437 ### Build modules ###
438 ###_______________###
441 compile_all
442 fi
444 ###^^^^^^^^^^^^^^###
445 ### Link modules ###
446 ###______________###
448 link_all