systems.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. {
  2. $Id$
  3. Copyright (C) 1995,97 by Florian Klaempfl
  4. This unit contains informations about the target systems supported
  5. (these are not processor specific)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit systems;
  20. interface
  21. type
  22. ttarget = (target_GO32V1,target_GO32V2,target_LINUX,target_OS2,
  23. target_WIN32,target_Amiga,target_Atari,target_Mac68k);
  24. tos = (os_GO32V1, os_GO32V2, os_Linux, os_OS2,
  25. os_WIN32, os_Amiga, os_Atari, os_Mac68k);
  26. tasm = (as_o
  27. {$ifdef i386}
  28. ,as_asw,as_nasmcoff, as_nasmelf, as_nasmobj, as_tasm, as_masm
  29. {$endif}
  30. {$ifdef m68k}
  31. ,as_gas,as_mit,as_mot
  32. {$endif}
  33. );
  34. tlink = (link_ld
  35. {$ifdef i386}
  36. ,link_ldgo32v1, link_ldgo32v2, link_ldw, link_ldos2
  37. {$endif i386}
  38. {$ifdef m68k}
  39. {$endif}
  40. );
  41. tendian = (endian_little,en_big_endian);
  42. tosinfo = record
  43. name : string[30];
  44. sharedlibext,
  45. staticlibext,
  46. sourceext,
  47. pasext,
  48. exeext,
  49. scriptext : string[4];
  50. Cprefix : string[2];
  51. newline : string[2];
  52. endian : tendian;
  53. use_function_relative_addresses : boolean;
  54. end;
  55. tasminfo = record
  56. id : tasm;
  57. idtxt : string[8];
  58. asmbin : string[8];
  59. asmcmd : string[50];
  60. externals : boolean;
  61. labelprefix : string[2];
  62. comment : string[2];
  63. end;
  64. tlinkinfo = record
  65. linkbin : string[8];
  66. linkcmd : string[50];
  67. bindbin : string[8];
  68. bindcmd : string[50];
  69. stripopt : string[2];
  70. libpathprefix : string[12];
  71. libpathsuffix : string[2];
  72. groupstart : string[8];
  73. groupend : string[2];
  74. inputstart : string[8];
  75. inputend : string[2];
  76. libprefix : string[2];
  77. end;
  78. ttargetinfo = record
  79. target : ttarget;
  80. short_name : string[8];
  81. unit_env : string[12];
  82. system_unit : string[8];
  83. smartext,
  84. unitext,
  85. unitlibext,
  86. asmext,
  87. objext,
  88. exeext : string[4];
  89. os : tos;
  90. link : tlink;
  91. assem : tasm;
  92. end;
  93. var
  94. target_info : ttargetinfo;
  95. target_os : tosinfo;
  96. target_asm : tasminfo;
  97. target_link : tlinkinfo;
  98. source_os : tosinfo;
  99. function set_string_target(const s : string) : boolean;
  100. function set_string_asm(const s : string) : boolean;
  101. implementation
  102. const
  103. {****************************************************************************
  104. OS Info
  105. ****************************************************************************}
  106. os_infos : array[tos] of tosinfo = (
  107. (
  108. name : 'GO32 V1 DOS extender';
  109. sharedlibext : '.DLL';
  110. staticlibext : '.A';
  111. sourceext : '.PP';
  112. pasext : '.PAS';
  113. exeext : ''; { No .exe, the linker only output a.out ! }
  114. scriptext : '.BAT';
  115. Cprefix : '_';
  116. newline : #13#10;
  117. endian : endian_little;
  118. use_function_relative_addresses : true
  119. ),
  120. (
  121. name : 'GO32 V2 DOS extender';
  122. sharedlibext : '.DLL';
  123. staticlibext : '.A';
  124. sourceext : '.PP';
  125. pasext : '.PAS';
  126. exeext : '.EXE';
  127. scriptext : '.BAT';
  128. Cprefix : '_';
  129. newline : #13#10;
  130. endian : endian_little;
  131. use_function_relative_addresses : true
  132. ),
  133. (
  134. name : 'Linux';
  135. sharedlibext : '.so';
  136. staticlibext : '.a';
  137. sourceext : '.pp';
  138. pasext : '.pas';
  139. exeext : '';
  140. scriptext : '.sh';
  141. Cprefix : '';
  142. newline : #10;
  143. endian : endian_little;
  144. use_function_relative_addresses : true
  145. ),
  146. (
  147. name : 'OS/2 (32bit)';
  148. sharedlibext : '.ao2';
  149. staticlibext : '.a';
  150. sourceext : '.pp';
  151. pasext : '.pas';
  152. exeext : '.exe';
  153. scriptext : '.cmd';
  154. Cprefix : '_';
  155. newline : #13#10;
  156. endian : endian_little;
  157. use_function_relative_addresses : false
  158. ),
  159. (
  160. name : 'Win32';
  161. sharedlibext : '.dll';
  162. staticlibext : '.a';
  163. sourceext : '.pp';
  164. pasext : '.pas';
  165. exeext : '.exe';
  166. scriptext : '.bat';
  167. Cprefix : '_';
  168. newline : #13#10;
  169. endian : endian_little;
  170. use_function_relative_addresses : true
  171. ),
  172. (
  173. name : 'Commodore Amiga';
  174. sharedlibext : '.library';
  175. staticlibext : '.a';
  176. sourceext : '.pp';
  177. pasext : '.pas';
  178. exeext : '';
  179. scriptext : '';
  180. Cprefix : '';
  181. newline : #10;
  182. endian : en_big_endian;
  183. use_function_relative_addresses : false
  184. ),
  185. (
  186. name : 'Atari ST/STE';
  187. sharedlibext : '.dll';
  188. staticlibext : '.a';
  189. sourceext : '.pp';
  190. pasext : '.pas';
  191. exeext : '.tpp';
  192. scriptext : '';
  193. Cprefix : '';
  194. newline : #10;
  195. endian : en_big_endian;
  196. use_function_relative_addresses : false
  197. ),
  198. (
  199. name : 'Macintosh m68k';
  200. sharedlibext : '.dll';
  201. staticlibext : '.a';
  202. sourceext : '.pp';
  203. pasext : '.pas';
  204. exeext : '.tpp';
  205. scriptext : '';
  206. Cprefix : '';
  207. newline : #10;
  208. endian : en_big_endian;
  209. use_function_relative_addresses : false
  210. )
  211. );
  212. {****************************************************************************
  213. Assembler Info
  214. ****************************************************************************}
  215. as_infos : array[tasm] of tasminfo = (
  216. (
  217. id : as_o;
  218. idtxt : 'O';
  219. asmbin : 'as';
  220. asmcmd : '-D -o $OBJ $ASM';
  221. externals : false;
  222. labelprefix : '.L';
  223. comment : '# '
  224. )
  225. {$ifdef i386}
  226. ,(
  227. id : as_asw;
  228. idtxt : 'ASW';
  229. asmbin : 'asw';
  230. asmcmd : '-D -o $OBJ $ASM';
  231. externals : false;
  232. labelprefix : '.L';
  233. comment : '# '
  234. )
  235. ,(
  236. id : as_nasmcoff;
  237. idtxt : 'NASMCOFF';
  238. asmbin : 'nasm';
  239. asmcmd : '-f coff -o $OBJ $ASM';
  240. externals : true;
  241. labelprefix : 'L';
  242. comment : '; '
  243. )
  244. ,(
  245. id : as_nasmelf;
  246. idtxt : 'NASMELF';
  247. asmbin : 'nasm';
  248. asmcmd : '-f elf -o $OBJ $ASM';
  249. externals : true;
  250. labelprefix : 'L';
  251. comment : '; '
  252. )
  253. ,(
  254. id : as_nasmobj;
  255. idtxt : 'NASMOBJ';
  256. asmbin : 'nasm';
  257. asmcmd : '-f obj -o $OBJ $ASM';
  258. externals : true;
  259. labelprefix : 'L';
  260. comment : '; '
  261. )
  262. ,(
  263. id : as_tasm;
  264. idtxt : 'TASM';
  265. asmbin : 'tasm';
  266. asmcmd : '/m2 $ASM $OBJ';
  267. externals : true;
  268. labelprefix : '.L';
  269. comment : '; '
  270. )
  271. ,(
  272. id : as_tasm;
  273. idtxt : 'MASM';
  274. asmbin : 'masm';
  275. asmcmd : '$ASM $OBJ';
  276. externals : true;
  277. labelprefix : '.L';
  278. comment : '; '
  279. )
  280. {$endif}
  281. {$ifdef m68k}
  282. ,(
  283. id : as_gas;
  284. idtxt : 'GAS';
  285. asmbin : 'as68k'; { Gas for the Amiga}
  286. asmcmd : '-D --register-prefix-optional -o $OBJ $ASM';
  287. externals : false;
  288. labelprefix : '__L';
  289. comment : '| '
  290. )
  291. ,(
  292. id : as_mit;
  293. idtxt : 'MIT';
  294. asmbin : '';
  295. asmcmd : '-o $OBJ $ASM';
  296. externals : false;
  297. labelprefix : '__L';
  298. comment : '| '
  299. )
  300. ,(
  301. id : as_mot;
  302. idtxt : 'MOT';
  303. asmbin : '';
  304. asmcmd : '-o $OBJ $ASM';
  305. externals : false;
  306. labelprefix : '__L';
  307. comment : '| '
  308. )
  309. {$endif}
  310. );
  311. {****************************************************************************
  312. Linker Info
  313. ****************************************************************************}
  314. link_infos : array[tlink] of tlinkinfo = (
  315. (
  316. linkbin : 'ld';
  317. linkcmd : '$OPT -o $EXE $RES';
  318. bindbin : '';
  319. bindcmd : '';
  320. stripopt : '-s';
  321. libpathprefix : 'SEARCH_DIR(';
  322. libpathsuffix : ')';
  323. groupstart : 'GROUP(';
  324. groupend : ')';
  325. inputstart : 'INPUT(';
  326. inputend : ')';
  327. libprefix : '-l'
  328. )
  329. {$ifdef i386}
  330. ,(
  331. linkbin : 'ld';
  332. linkcmd : '-oformat coff-go32 $OPT -o $EXE @$RES';
  333. bindbin : 'aout2exe';
  334. bindcmd : '$EXE';
  335. stripopt : '-s';
  336. libpathprefix : '-L';
  337. libpathsuffix : '';
  338. groupstart : '-(';
  339. groupend : '-)';
  340. inputstart : '';
  341. inputend : '';
  342. libprefix : '-l'
  343. )
  344. ,(
  345. linkbin : 'ld';
  346. linkcmd : '-oformat coff-go32-exe $OPT -o $EXE @$RES';
  347. bindbin : '';
  348. bindcmd : '';
  349. stripopt : '-s';
  350. libpathprefix : '-L';
  351. libpathsuffix : '';
  352. groupstart : '-(';
  353. groupend : '-)';
  354. inputstart : '';
  355. inputend : '';
  356. libprefix : '-l'
  357. )
  358. ,(
  359. linkbin : 'ldw';
  360. linkcmd : '$OPT -o $EXE $RES';
  361. bindbin : '';
  362. bindcmd : '';
  363. stripopt : '-s';
  364. libpathprefix : 'SEARCH_DIR(';
  365. libpathsuffix : ')';
  366. groupstart : 'GROUP(';
  367. groupend : ')';
  368. inputstart : 'INPUT(';
  369. inputend : ')';
  370. libprefix : '-l'
  371. )
  372. ,(
  373. linkbin : 'ld';
  374. linkcmd : '-o $EXE @$RES';
  375. bindbin : 'emxbind';
  376. bindcmd : '-o $EXE.exe $EXE -k$STACKKB -aim -s$HEAPKB';
  377. stripopt : '-s';
  378. libpathprefix : '-L';
  379. libpathsuffix : '';
  380. groupstart : '-(';
  381. groupend : '-)';
  382. inputstart : '';
  383. inputend : '';
  384. libprefix : ''
  385. )
  386. {$endif i386}
  387. );
  388. {****************************************************************************
  389. Targets Info
  390. ****************************************************************************}
  391. target_infos : array[ttarget] of ttargetinfo = (
  392. (
  393. target : target_GO32V1;
  394. short_name : 'GO32V1';
  395. unit_env : 'GO32V1UNITS';
  396. system_unit : 'SYSTEM';
  397. smartext : '.SL';
  398. unitext : '.PP1';
  399. unitlibext : '.PPL';
  400. asmext : '.S1';
  401. objext : '.O1';
  402. exeext : ''; { The linker procedures a.out }
  403. os : os_GO32V1;
  404. link : link_ldgo32v1;
  405. assem : as_o
  406. ),
  407. (
  408. target : target_GO32V2;
  409. short_name : 'GO32V2';
  410. unit_env : 'GO32V2UNITS';
  411. system_unit : 'SYSTEM';
  412. {$ifndef UseAnsiString}
  413. smartext : '.SL';
  414. unitext : '.PPU';
  415. unitlibext : '.PPL';
  416. asmext : '.S';
  417. objext : '.O';
  418. exeext : '.EXE';
  419. {$else UseAnsiString}
  420. smartext : '.SL';
  421. unitext : '.PAU';
  422. unitlibext : '.PPL';
  423. asmext : '.SA';
  424. objext : '.OA';
  425. exeext : '.EXE';
  426. {$endif UseAnsiString}
  427. os : os_GO32V2;
  428. link : link_ldgo32v2;
  429. assem : as_o
  430. ),
  431. (
  432. target : target_LINUX;
  433. short_name : 'LINUX';
  434. unit_env : 'LINUXUNITS';
  435. system_unit : 'syslinux';
  436. smartext : '.sl';
  437. unitext : '.ppu';
  438. unitlibext : '.ppl';
  439. asmext : '.s';
  440. objext : '.o';
  441. exeext : '';
  442. os : os_Linux;
  443. link : link_ld;
  444. assem : as_o
  445. ),
  446. (
  447. target : target_OS2;
  448. short_name : 'OS2';
  449. unit_env : 'OS2UNITS';
  450. system_unit : 'SYSOS2';
  451. smartext : '.sl';
  452. unitext : '.ppo';
  453. unitlibext : '.ppl';
  454. asmext : '.so2';
  455. objext : '.oo2';
  456. exeext : ''; { The linker procedures a.out }
  457. os : os_OS2;
  458. link : link_ldos2;
  459. assem : as_o
  460. ),
  461. (
  462. target : target_WIN32;
  463. short_name : 'WIN32';
  464. unit_env : 'WIN32UNITS';
  465. system_unit : 'SYSWIN32';
  466. smartext : '.sl';
  467. unitext : '.ppw';
  468. unitlibext : '.ppl';
  469. asmext : '.s';
  470. objext : '.o';
  471. exeext : '.exe';
  472. os : os_Win32;
  473. link : link_ldw;
  474. assem : as_asw
  475. ),
  476. (
  477. target : target_Amiga;
  478. short_name : 'AMIGA';
  479. unit_env : '';
  480. system_unit : 'sysamiga';
  481. smartext : '.sl';
  482. unitext : '.ppa';
  483. unitlibext : '.ppl';
  484. asmext : '.asm';
  485. objext : '.o';
  486. exeext : '';
  487. os : os_Amiga;
  488. link : link_ld;
  489. assem : as_o
  490. ),
  491. (
  492. target : target_Atari;
  493. short_name : 'ATARI';
  494. unit_env : '';
  495. system_unit : 'SYSATARI';
  496. smartext : '.sl';
  497. unitext : '.ppt';
  498. unitlibext : '.ppl';
  499. asmext : '.s';
  500. objext : '.o';
  501. exeext : '';
  502. os : os_Atari;
  503. link : link_ld;
  504. assem : as_o
  505. ),
  506. (
  507. target : target_Mac68k;
  508. short_name : 'MACOS';
  509. unit_env : '';
  510. system_unit : 'sysmac';
  511. smartext : '.sl';
  512. unitext : '.ppt';
  513. unitlibext : '.ppl';
  514. asmext : '.s';
  515. objext : '.o';
  516. exeext : '';
  517. os : os_Mac68k;
  518. link : link_ld;
  519. assem : as_o
  520. )
  521. );
  522. {****************************************************************************
  523. Helpers
  524. ****************************************************************************}
  525. procedure set_target(t : ttarget);
  526. begin
  527. target_info:=target_infos[t];
  528. target_os:=os_infos[target_info.os];
  529. target_asm:=as_infos[target_info.assem];
  530. target_link:=link_infos[target_info.link];
  531. end;
  532. {****************************************************************************
  533. Load from string
  534. ****************************************************************************}
  535. function set_string_target(const s : string) : boolean;
  536. var
  537. t : ttarget;
  538. begin
  539. set_string_target:=false;
  540. for t:=target_GO32V1 to target_mac68k do
  541. if target_infos[t].short_name=s then
  542. begin
  543. set_string_target:=true;
  544. set_target(t);
  545. end;
  546. end;
  547. function set_string_asm(const s : string) : boolean;
  548. var
  549. j : longint;
  550. begin
  551. set_string_asm:=false;
  552. for j:=0 to (sizeof(as_infos) div sizeof(tasminfo))-1 do
  553. if as_infos[tasm(j)].idtxt=s then
  554. begin
  555. target_asm:=as_infos[tasm(j)];
  556. set_string_asm:=true;
  557. end;
  558. end;
  559. {****************************************************************************
  560. Initialization of default target
  561. ****************************************************************************}
  562. procedure default_os(t:ttarget);
  563. begin
  564. set_target(t);
  565. source_os:=os_infos[target_info.os];
  566. end;
  567. begin
  568. {$ifdef tp}
  569. default_os(target_GO32V2);
  570. {$else}
  571. {$ifdef DOS}
  572. default_os(target_GO32V1);
  573. {$endif}
  574. {$ifdef GO32V1}
  575. default_os(target_GO32V1);
  576. {$endif}
  577. {$ifdef GO32V2}
  578. default_os(target_GO32V2);
  579. {$endif}
  580. {$ifdef OS2}
  581. default_os(target_OS2);
  582. {$endif}
  583. {$ifdef LINUX}
  584. default_os(target_LINUX);
  585. {$endif}
  586. {$ifdef WIN32}
  587. default_os(target_WIN32);
  588. {$endif}
  589. {$ifdef AMIGA}
  590. default_os(target_AMIGA);
  591. {$endif}
  592. {$ifdef ATARI}
  593. default_os(target_ATARI);
  594. {$endif}
  595. {$ifdef MACOS}
  596. default_os(target_MAC68k);
  597. {$endif}
  598. {$endif}
  599. end.
  600. {
  601. $Log$
  602. Revision 1.14 1998-05-29 13:24:45 peter
  603. + asw assembler
  604. Revision 1.13 1998/05/27 00:20:33 peter
  605. * some scanner optimizes
  606. * automaticly aout2exe for go32v1
  607. * fixed dynamiclinker option which was added at the wrong place
  608. Revision 1.12 1998/05/23 01:21:32 peter
  609. + aktasmmode, aktoptprocessor, aktoutputformat
  610. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  611. + $LIBNAME to set the library name where the unit will be put in
  612. * splitted cgi386 a bit (codeseg to large for bp7)
  613. * nasm, tasm works again. nasm moved to ag386nsm.pas
  614. Revision 1.11 1998/05/22 12:32:49 peter
  615. * fixed -L on the commandline, Dos commandline is only 128 bytes
  616. Revision 1.10 1998/05/11 13:07:58 peter
  617. + $ifdef NEWPPU for the new ppuformat
  618. + $define GDB not longer required
  619. * removed all warnings and stripped some log comments
  620. * no findfirst/findnext anymore to remove smartlink *.o files
  621. Revision 1.9 1998/05/06 08:38:49 pierre
  622. * better position info with UseTokenInfo
  623. UseTokenInfo greatly simplified
  624. + added check for changed tree after first time firstpass
  625. (if we could remove all the cases were it happen
  626. we could skip all firstpass if firstpasscount > 1)
  627. Only with ExtDebug
  628. Revision 1.8 1998/05/04 20:19:54 peter
  629. * small fix for go32v2
  630. Revision 1.7 1998/05/04 17:54:29 peter
  631. + smartlinking works (only case jumptable left todo)
  632. * redesign of systems.pas to support assemblers and linkers
  633. + Unitname is now also in the PPU-file, increased version to 14
  634. Revision 1.6 1998/05/01 07:43:57 florian
  635. + basics for rtti implemented
  636. + switch $m (generate rtti for published sections)
  637. Revision 1.5 1998/04/29 10:34:06 pierre
  638. + added some code for ansistring (not complete nor working yet)
  639. * corrected operator overloading
  640. * corrected nasm output
  641. + started inline procedures
  642. + added starstarn : use ** for exponentiation (^ gave problems)
  643. + started UseTokenInfo cond to get accurate positions
  644. Revision 1.4 1998/04/27 15:45:20 peter
  645. + -Xl for smartlink
  646. + target_info.arext = .a
  647. Revision 1.3 1998/04/16 10:50:45 daniel
  648. * Fixed some things that were broken for OS/2.
  649. }