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="-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 $_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
170 fi
172 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
173 ### Compile BlackBox Framework ###
174 ###____________________________###
176 compile System/Mod/Int.odc
178 compile System/Mod/Long.odc
179 compile System/Mod/Math.odc System/Mod/SMath.odc
180 else
181 compile System/Mod/Math.cp System/Mod/SMath.cp
182 fi
183 compile System/Mod/Kernel.cp \
184 System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \
185 System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Services.odc \
186 System/Mod/Integers.odc
189 compile System/Mod/Meta.odc
190 mv -t System Code Sym
191 fi
193 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
194 ### Compile Linux Host subsystem ###
195 ###______________________________###
197 compile Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp \
198 Host/Mod/Files.cp
200 ###^^^^^^^^^^^^^^^^^^^^^^^###
201 ### Compile Dev subsystem ###
202 ###_______________________###
204 compile Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
205 Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
206 Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
208 ###^^^^^^^^^^^^^^^^^^^^^^^^###
209 ### Compile Dev2 subsystem ###
210 ###________________________###
212 compile Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
213 Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
214 Dev2/Mod/LnkWritePe.odc
216 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
217 ### Compile CPfront subsystem ###
218 ###___________________________###
220 compile CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
222 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
223 ### Compile bbdsw-specific modules ###
224 ###________________________________###
227 compile Dsw/Mod/Debug.odc
228 fi
229 compile Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
230 Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
231 }
233 link_all() {
234 local _debug_module=
236 _debug_module=DswDebug
237 fi
239 link cpc486 \
240 PosixCtypes PosixCmacro \
241 Kernel Console Files Dates Math Strings Services Log \
243 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
244 DevCPL486 DevCPC486 DevCPV486 \
245 DswDocuments DswCompiler486Main
247 link cpl486 \
248 PosixCtypes PosixCmacro \
249 Kernel Console Files Math Strings Services Log \
251 Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
252 Dev2LnkWriteElfStatic Dev2LnkWritePe \
253 DswLinker486Main
255 link cpfront \
256 PosixCtypes PosixCmacro \
257 Kernel Console Files Dates Math Strings Services Log \
259 DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
260 CPfrontCPG CPfrontCPC CPfrontCPV\
261 DswDocuments DswCompilerCPfrontMain
264 chmod a+x cpc486 cpl486 cpfront
265 fi
266 }
268 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
269 ### Parse arguments and options ###
270 ###_____________________________###
272 while getopts c:l:o:bxh _name
273 do
278 b) _docompile=false ;;
279 x) _dolink=false ;;
280 h|?) usage ;;
281 esac
282 done
285 usage
286 fi
294 export CC=cc
295 fi
297 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
298 ### Check for supported cpu/target/os ###
299 ###___________________________________###
302 386|486|586|686) _cpu=486 ;;
303 arm|armv6|armv7) _cpu=arm ;;
306 esac
309 native) _target=native ;;
310 cpfront|c) _target=cpfront ;;
313 esac
316 linux) _useposix=true ;;
317 cygwin) _useposix=true ;;
320 esac
322 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
323 ### Select default compiler if not specified ###
324 ###__________________________________________###
328 native)
330 486) _compiler=cpc486 ;;
332 esac
333 ;;
334 cpfront) _compiler=cpfront ;;
336 esac
337 fi
341 native)
343 486) _linker=cpl486 ;;
345 esac
346 ;;
347 cpfront) _linker= ;;
349 esac
350 fi
355 else
357 fi
358 fi
363 else
365 fi
366 fi
368 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
369 ### Copy sources for changed system ###
370 ###_________________________________###
374 fi
381 fi
386 fi
390 ###^^^^^^^^^^^^^^^###
391 ### Build modules ###
392 ###_______________###
395 compile_all
396 fi
398 ###^^^^^^^^^^^^^^###
399 ### Link modules ###
400 ###______________###
402 link_all