Ver código fonte

m68k: initial commit to add the Sinclair QL as a compiler target

git-svn-id: trunk@47307 -
Károly Balogh 4 anos atrás
pai
commit
519701960c

+ 2 - 0
.gitattributes

@@ -871,6 +871,7 @@ compiler/systems/i_nwl.pas svneol=native#text/plain
 compiler/systems/i_nwm.pas svneol=native#text/plain
 compiler/systems/i_os2.pas svneol=native#text/plain
 compiler/systems/i_palmos.pas svneol=native#text/plain
+compiler/systems/i_sinclairql.pas svneol=native#text/plain
 compiler/systems/i_sunos.pas svneol=native#text/plain
 compiler/systems/i_symbian.pas svneol=native#text/plain
 compiler/systems/i_watcom.pas svneol=native#text/plain
@@ -906,6 +907,7 @@ compiler/systems/t_nwl.pas svneol=native#text/plain
 compiler/systems/t_nwm.pas svneol=native#text/plain
 compiler/systems/t_os2.pas svneol=native#text/plain
 compiler/systems/t_palmos.pas svneol=native#text/plain
+compiler/systems/t_sinclairql.pas svneol=native#text/plain
 compiler/systems/t_sunos.pas svneol=native#text/plain
 compiler/systems/t_symbian.pas svneol=native#text/plain
 compiler/systems/t_watcom.pas svneol=native#text/plain

+ 3 - 0
compiler/m68k/cputarg.pas

@@ -53,6 +53,9 @@ implementation
     {$ifndef NOTARGETMACOS}
       ,t_macos
     {$endif}
+    {$ifndef NOTARGETSINCLAIRQL}
+      ,t_sinclairql
+    {$endif}
     {$ifndef NOTARGETEMBEDDED}
       ,t_embed
     {$endif}

+ 1 - 0
compiler/msg/errore.msg

@@ -4151,6 +4151,7 @@ F*2P<x>_Set target CPU (aarch64,arm,avr,i386,i8086,jvm,m68k,mips,mipsel,powerpc,
 6*2Tnetbsd_NetBSD
 6*2Tmacosclassic_Classic Mac OS
 6*2Tpalmos_PalmOS
+6*2Tql_Sinclair QL
 # i8086 targets
 8*2Tembedded_Embedded
 8*2Tmsdos_MS-DOS (and compatible)

+ 1 - 1
compiler/msgidx.inc

@@ -1134,7 +1134,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 86458;
+  MsgTxtSize = 86477;
 
   MsgIdxMax : array[1..20] of longint=(
     28,107,360,130,99,63,145,36,223,68,

+ 51 - 48
compiler/msgtxt.inc

@@ -1795,10 +1795,11 @@ const msgtxt : array[0..000360,1..240] of char=(
   '6*2Tnetbsd_NetBSD'#010+
   '6*2Tmacosclassic_Classic Mac OS'#010+
   '6*2Tpalmos_PalmOS'#010+
+  '6*2Tql_Sinclair QL'#010+
   '8*2Tembedded_Embedded'#010+
   '8*2Tmsdos_MS-DOS (and compatible)'#010+
-  '8*2Twin16_Windows 16 Bit'#010+
-  'A*2T','android_Android'#010+
+  '8*2Twin16_','Windows 16 Bit'#010+
+  'A*2Tandroid_Android'#010+
   'A*2Taros_AROS'#010+
   'A*2Tembedded_Embedded'#010+
   'A*2Tfreertos_FreeRTOS'#010+
@@ -1809,8 +1810,8 @@ const msgtxt : array[0..000360,1..240] of char=(
   'A*2Tnetbsd_NetBSD'#010+
   'A*2Tpalmos_PalmOS'#010+
   'A*2Tsymbian_Symbian'#010+
-  'A*2Twince_Windows CE'#010+
-  'a*2Tandroid_Andr','oid'#010+
+  'A*2Twince_Windows ','CE'#010+
+  'a*2Tandroid_Android'#010+
   'a*2Tdarwin_Darwin/Mac OS X'#010+
   'a*2Tios_iOS'#010+
   'a*2Tlinux_Linux'#010+
@@ -1822,8 +1823,8 @@ const msgtxt : array[0..000360,1..240] of char=(
   'm*2Tlinux_Linux'#010+
   'M*2Tembedded_Embedded'#010+
   'M*2Tlinux_Linux'#010+
-  'P*2Taix_AIX'#010+
-  'P*2Tamiga_AmigaOS'#010,
+  'P*2Taix_AIX',#010+
+  'P*2Tamiga_AmigaOS'#010+
   'P*2Tdarwin_Darwin/Mac OS X'#010+
   'P*2Tembedded_Embedded'#010+
   'P*2Tlinux_Linux'#010+
@@ -1834,8 +1835,8 @@ const msgtxt : array[0..000360,1..240] of char=(
   'p*2Taix_AIX'#010+
   'p*2Tdarwin_Darwin/Mac OS X'#010+
   'p*2Tembedded_Embedded'#010+
-  'p*2Tlinux_Linux'#010+
-  'R*2Tlinux_Linux'#010,
+  'p*2Tlinux_Lin','ux'#010+
+  'R*2Tlinux_Linux'#010+
   'R*2Tembedded_Embedded'#010+
   'r*2Tlinux_Linux'#010+
   'r*2Tembedded_Embedded'#010+
@@ -1847,153 +1848,155 @@ const msgtxt : array[0..000360,1..240] of char=(
   'x*2Tfreertos_FreeRTOS'#010+
   'x*2Tlinux_Linux'#010+
   'Z*2Tembedded_Embedded'#010+
-  'Z*2Tzxspectrum_ZX Spectr','um'#010+
+  'Z*2Tz','xspectrum_ZX Spectrum'#010+
   'Z*2Tmsxdos_MSX-DOS'#010+
   '**1u<x>_Undefines the symbol <x>'#010+
   '**1U_Unit options:'#010+
   '**2Un_Do not check where the unit name matches the file name'#010+
   '**2Ur_Generate release unit files (never automatically recompiled)'#010+
-  '**2Us_Compile a system unit'#010+
-  '**1v<x>_Be',' verbose. <x> is a combination of the following letters:'#010+
+  '**2Us_Compile a sys','tem unit'#010+
+  '**1v<x>_Be verbose. <x> is a combination of the following letters:'#010+
   '**2*_e : Show errors (default)       0 : Show nothing (except errors)'#010+
   '**2*_w : Show warnings               u : Show unit info'#010+
-  '**2*_n : Show notes                  t : Show tried/used ','files'#010+
+  '**2*_n : Show notes                  t',' : Show tried/used files'#010+
   '**2*_h : Show hints                  c : Show conditionals'#010+
   '**2*_i : Show general info           d : Show debug info'#010+
   '**2*_l : Show linenumbers            r : Rhide/GCC compatibility mode'#010+
-  '**2*_s : Show time stamps            q : Show me','ssage numbers'#010+
+  '**2*_s : Show time stamps    ','        q : Show message numbers'#010+
   '**2*_a : Show everything             x : Show info about invoked tools'+
   #010+
   '**2*_b : Write file names messages   p : Write tree.log with parse tre'+
   'e'#010+
-  '**2*_    with full path              v : Write fpcdebug.txt with'#010+
-  '**2*_z : Write out','put to stderr          lots of debugging info'#010+
+  '**2*_    with full path              v : Write fpcdebug.txt with',#010+
+  '**2*_z : Write output to stderr          lots of debugging info'#010+
   '**2*_m<x>,<y> : Do not show messages numbered <x> and <y>'#010+
   'F*1V<x>_Append '#039'-<x>'#039' to the used compiler binary name (e.g. f'+
   'or version)'#010+
   '**1W<x>_Target-specific options (targets)'#010+
-  '3*2WA_Specify native',' type application (Windows)'#010+
+  '3','*2WA_Specify native type application (Windows)'#010+
   '4*2WA_Specify native type application (Windows)'#010+
   'A*2WA_Specify native type application (Windows)'#010+
   '3*2Wb_Create a bundle instead of a library (Darwin)'#010+
-  'P*2Wb_Create a bundle instead of a library (Darwin)'#010+
-  'p*2Wb_Create',' a bundle instead of a library (Darwin)'#010+
+  'P*2Wb_Create a bundle instead of a library (D','arwin)'#010+
+  'p*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'a*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'A*2Wb_Create a bundle instead of a library (Darwin)'#010+
   '4*2Wb_Create a bundle instead of a library (Darwin)'#010+
-  '3*2WB_Create a relocatable image (Windows, S','ymbian)'#010+
+  '3*2WB_Create a relocatabl','e image (Windows, Symbian)'#010+
   '3*2WB<x>_Set image base to <x> (Windows, Symbian)'#010+
   '4*2WB_Create a relocatable image (Windows)'#010+
   '4*2WB<x>_Set image base to <x> (Windows)'#010+
   'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
-  'A*2WB<x>_Set image base to <x> (Windows, Symbi','an)'#010+
+  'A*2WB<x>_Set image base to ','<x> (Windows, Symbian)'#010+
   'Z*2WB<x>_Set image base to <x> (ZX Spectrum)'#010+
   '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
   '4*2WC_Specify console type application (Windows)'#010+
   'A*2WC_Specify console type application (Windows)'#010+
-  'P*2WC_Specify console type applic','ation (Classic Mac OS)'#010+
+  'P*2WC_Specify ','console type application (Classic Mac OS)'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   '4*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
   'A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
-  '3*2We_Use external resources (D','arwin)'#010+
+  '3*2We_Use ex','ternal resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
   'a*2We_Use external resources (Darwin)'#010+
   'A*2We_Use external resources (Darwin)'#010+
   'P*2We_Use external resources (Darwin)'#010+
   'p*2We_Use external resources (Darwin)'#010+
-  '3*2WF_Specify full-screen type application ','(EMX, OS/2)'#010+
+  '3*2WF_Specify full-scree','n type application (EMX, OS/2)'#010+
   '3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
   '4*2WG_Specify graphic type application (Windows)'#010+
   'A*2WG_Specify graphic type application (Windows)'#010+
-  'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
-  '3*2Wi_Use inte','rnal resources (Darwin)'#010+
+  'P*2WG_Specify graphic type application (Classic Mac',' OS)'#010+
+  '3*2Wi_Use internal resources (Darwin)'#010+
   '4*2Wi_Use internal resources (Darwin)'#010+
   'a*2Wi_Use internal resources (Darwin)'#010+
   'A*2Wi_Use internal resources (Darwin)'#010+
   'P*2Wi_Use internal resources (Darwin)'#010+
   'p*2Wi_Use internal resources (Darwin)'#010+
-  '3*2WI_Turn on/off the usag','e of import sections (Windows)'#010+
+  '3*2WI_T','urn on/off the usage of import sections (Windows)'#010+
   '4*2WI_Turn on/off the usage of import sections (Windows)'#010+
   'A*2WI_Turn on/off the usage of import sections (Windows)'#010+
   '8*2Wh_Use huge code for units (ignored for models with CODE in a uniqu'+
-  'e segment)'#010+
-  '8*2Wm<x>_Set m','emory model'#010+
+  'e segm','ent)'#010+
+  '8*2Wm<x>_Set memory model'#010+
   '8*3WmTiny_Tiny memory model'#010+
   '8*3WmSmall_Small memory model (default)'#010+
   '8*3WmMedium_Medium memory model'#010+
   '8*3WmCompact_Compact memory model'#010+
   '8*3WmLarge_Large memory model'#010+
   '8*3WmHuge_Huge memory model'#010+
-  '3*2WM<x>_Minimum Mac OS X deployment',' version: 10.4, 10.5.1, ... (Dar'+
+  '3*2WM<x>_Minimum ','Mac OS X deployment version: 10.4, 10.5.1, ... (Dar'+
   'win)'#010+
   '4*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
   'n)'#010+
   'p*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwi'+
   'n)'#010+
-  'P*2WM<x>_Minimum Mac OS X deployment version: 10.4, 10.5.','1, ... (Dar'+
+  'P*2WM<x>_Minimum Mac OS X deployment v','ersion: 10.4, 10.5.1, ... (Dar'+
   'win)'#010+
   '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   '4*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
-  'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
-  'A*2Wp<x>_Speci','fy the controller type; see fpc -i or fpc -iu for poss'+
-  'ible values'#010+
+  'A*2WN_Do not generate relocation code, needed for debugging (Wind','ows'+
+  ')'#010+
+  'A*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
+  'le values'#010+
   'm*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
   'le values'#010+
   'R*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
+  'le va','lues'#010+
+  'V*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
   'le values'#010+
-  'V*2Wp<x>_Speci','fy the controller type; see fpc -i or fpc -iu for poss'+
-  'ible values'#010+
   'x*2Wp<x>_Specify the controller type; see fpc -i or fpc -iu for possib'+
   'le values'#010+
   '3*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (iphonesim)'#010+
-  '4*2WP<x>_Minimum iOS depl','oyment version: 8.0, 8.0.2, ... (iphonesim)'+
+  '4*2WP<','x>_Minimum iOS deployment version: 8.0, 8.0.2, ... (iphonesim)'+
   #010+
   'a*2WP<x>_Minimum iOS deployment version: 7.0, 7.1.2, ... (Darwin)'#010+
   'A*2WP<x>_Minimum iOS deployment version: 3.0, 5.0.1, ... (Darwin)'#010+
   '3*2WR_Generate relocation code (Windows)'#010+
-  '4*2WR_Generate relocati','on code (Windows)'#010+
+  '4*2W','R_Generate relocation code (Windows)'#010+
   'A*2WR_Generate relocation code (Windows)'#010+
   '8*2Wt<x>_Set the target executable format'#010+
   '8*3Wtexe_Create a DOS .EXE file (default)'#010+
   '8*3Wtcom_Create a DOS .COM file (requires tiny memory model)'#010+
-  'P*2WT_Specify MPW tool type applicat','ion (Classic Mac OS)'#010+
+  'P*2WT_Specify MPW',' tool type application (Classic Mac OS)'#010+
   '**2WX_Enable executable stack (Linux)'#010+
   '**1X_Executable options:'#010+
   '**2X9_Generate linkerscript for GNU Binutils ld older than version 2.1'+
   '9.1 (Linux)'#010+
-  '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin'+
-  'ux)'#010,
+  '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwi','n, FreeBSD, L'+
+  'inux)'#010+
   '**2Xd_Do not search default library path (sometimes required for cross'+
   '-compiling when not using -XR)'#010+
   '**2Xe_Use external linker'#010+
   '**2Xf_Substitute pthread library name for linking (BSD)'#010+
-  '**2Xg_Create debuginfo in a separate file and add a debug','link sectio'+
+  '**2Xg_Create debuginfo in a separate f','ile and add a debuglink sectio'+
   'n to executable'#010+
   '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
   '**2Xi_Use internal linker'#010+
   'L*2XlS<x>_LLVM utilties suffix (e.g. -7 in case clang is called clang-'+
   '7)'#010+
-  '**2XLA_Define library substitutions for linkin','g'#010+
+  '**2XLA_Define library subst','itutions for linking'#010+
   '**2XLO_Define order of library linking'#010+
   '**2XLD_Exclude default order of standard libraries'#010+
   '**2Xm_Generate link map'#010+
   '**2XM<x>_Set the name of the '#039'main'#039' program routine (default i'+
   's '#039'main'#039')'#010+
-  '**2Xn_Use target system native linker instead of GNU',' ld (Solaris, AI'+
+  '**2Xn_Use target system native li','nker instead of GNU ld (Solaris, AI'+
   'X)'#010+
   'F*2Xp<x>_First search for the compiler binary in the directory <x>'#010+
   '**2XP<x>_Prepend the binutils names with the prefix <x>'#010+
   '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
-  'ile, see the ld manual for more ','information) (BeOS, Linux)'#010+
+  'ile, see the ','ld manual for more information) (BeOS, Linux)'#010+
   '**2XR<x>_Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD'+
   ', Linux, Mac OS, Solaris)'#010+
   '**2Xs_Strip all symbols from executable'#010+
-  '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
-  '**2Xt_L','ink with static libraries (-static is passed to linker)'#010+
+  '**2XS_Try to link units statically (default, defines FPC_L','INK_STATIC'+
+  ')'#010+
+  '**2Xt_Link with static libraries (-static is passed to linker)'#010+
   '**2Xv_Generate table for Virtual Entry calls'#010+
   '**2XV_Use VLink as external linker       (default on Amiga, MorphOS)'#010+
-  '**2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
-  '**1*','_'#010+
+  '**2XX_Try to smartlink units             (defines F','PC_LINK_SMART)'#010+
+  '**1*_'#010+
   '**1?_Show this help'#010+
   '**1h_Shows this help without waiting'
 );

+ 2 - 0
compiler/options.pas

@@ -3387,6 +3387,8 @@ begin
       lets disable the feature. }
     system_m68k_amiga:
       target_unsup_features:=[f_dynlibs];
+    system_m68k_sinclairql:
+      target_unsup_features:=[f_threading,f_dynlibs,f_commandargs,f_exitcode];
     system_z80_zxspectrum:
       target_unsup_features:=[f_threading,f_dynlibs{,f_fileio,f_textio},f_commandargs,f_exitcode];
     system_z80_msxdos:

+ 4 - 2
compiler/systems.inc

@@ -201,7 +201,8 @@
              system_z80_zxspectrum,     { 109 }
              system_z80_msxdos,         { 110 }
              system_aarch64_darwin,     { 111 }
-             system_z80_amstradcpc      { 112 }
+             system_z80_amstradcpc,     { 112 }
+             system_m68k_sinclairql     { 113 }
        );
 
      type
@@ -305,7 +306,8 @@
              ld_freertos,
              ld_zxspectrum,
              ld_msxdos,
-             ld_amstradcpc
+             ld_amstradcpc,
+             ld_sinclairql
        );
 
        tar = (ar_none

+ 1 - 1
compiler/systems.pas

@@ -385,7 +385,7 @@ interface
        systems_internal_sysinit = [system_i386_win32,system_x86_64_win64,
                                    system_i386_linux,system_powerpc64_linux,system_sparc64_linux,system_x86_64_linux,
                                    system_xtensa_linux,
-                                   system_m68k_atari,system_m68k_palmos,
+                                   system_m68k_atari,system_m68k_palmos,system_m68k_sinclairql,
                                    system_i386_haiku,system_x86_64_haiku,
                                    system_i386_openbsd,system_x86_64_openbsd,
                                    system_riscv32_linux,system_riscv64_linux,

+ 107 - 0
compiler/systems/i_sinclairql.pas

@@ -0,0 +1,107 @@
+{
+    Copyright (c) 2020 by Karoly Balogh
+
+    This unit implements support information structures for the Sinclair QL
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ****************************************************************************
+}
+{ This unit implements support information structures for the Sinclair QL. }
+unit i_sinclairql;
+
+{$i fpcdefs.inc}
+
+  interface
+
+    uses
+       systems;
+
+    const
+       system_m68k_sinclairql_info : tsysteminfo =
+          (
+            system       : system_m68k_sinclairql;
+            name         : 'Sinclair QL';
+            shortname    : 'ql';
+            flags        : [tf_use_8_3,tf_requires_proper_alignment,
+                            tf_smartlink_sections,tf_under_development];
+            cpu          : cpu_m68k;
+            unit_env     : '';
+            extradefines : '';
+            exeext       : '.bin';
+            defext       : '';
+            scriptext    : '';
+            smartext     : '.sl';
+            unitext      : '.ppu';
+            unitlibext   : '.ppl';
+            asmext       : '.s';
+            objext       : '.o';
+            resext       : '.res';
+            resobjext    : '.or';
+            sharedlibext : '.dll';
+            staticlibext : '.a';
+            staticlibprefix : '';
+            sharedlibprefix : '';
+            sharedClibext : '.dll';
+            staticClibext : '.a';
+            staticClibprefix : 'lib';
+            sharedClibprefix : '';
+            importlibprefix : 'libimp';
+            importlibext : '.a';
+            Cprefix      : '_';
+            newline      : #13#10;
+            dirsep       : '/'; { ... the underlying tools (binutils/vlink/vasm) prefer Unix paths }
+            assem        : as_m68k_as_aout;
+            assemextern  : as_m68k_as_aout;
+            link         : ld_sinclairql;
+            linkextern   : ld_sinclairql;
+            ar           : ar_gnu_ar;
+            res          : res_ext;
+            dbg          : dbg_stabs;
+            script       : script_unix;
+            endian       : endian_big;
+            alignment    :
+              (
+                procalign       : 4;
+                loopalign       : 4;
+                jumpalign       : 0;
+                jumpalignskipmax    : 0;
+                coalescealign   : 0;
+                coalescealignskipmax: 0;
+                constalignmin   : 0;
+                constalignmax   : 4;
+                varalignmin     : 0;
+                varalignmax     : 4;
+                localalignmin   : 0;
+                localalignmax   : 4;
+                recordalignmin  : 0;
+                recordalignmax  : 2;
+                maxCrecordalign : 4
+              );
+            first_parm_offset : 8;
+            stacksize    : 16384;
+            stackalign   : 2;
+            abi : abi_default;
+            llvmdatalayout : 'todo';
+          );
+
+  implementation
+
+initialization
+{$ifdef cpu68}
+  {$ifdef atari}
+    set_source_info(system_m68k_sinclairql_info);
+  {$endif atari}
+{$endif cpu68}
+end.

+ 283 - 0
compiler/systems/t_sinclairql.pas

@@ -0,0 +1,283 @@
+{
+    Copyright (c) 2020 by Free Pascal Development Team
+
+    This unit implements support import, export, link routines
+    for the m68k Sinclair QL target
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit t_sinclairql;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      rescmn, comprsrc, link;
+
+type
+  PLinkerSinclairQL = ^TLinkerSinclairQL;
+  TLinkerSinclairQL = class(texternallinker)
+    private
+      UseVLink: boolean;
+      function WriteResponseFile(isdll: boolean): boolean;
+      procedure SetSinclairQLInfo;
+      function MakeSinclairQLExe: boolean;
+    public
+      constructor Create; override;
+      procedure SetDefaultInfo; override;
+      procedure InitSysInitUnitName; override;
+      function  MakeExecutable: boolean; override;
+  end;
+
+
+implementation
+
+    uses
+       sysutils,cutils,cfileutl,cclasses,aasmbase,
+       globtype,globals,systems,verbose,cscript,fmodule,i_sinclairql;
+
+
+constructor TLinkerSinclairQL.Create;
+begin
+  UseVLink:=(cs_link_vlink in current_settings.globalswitches);
+
+  Inherited Create;
+  { allow duplicated libs (PM) }
+  SharedLibFiles.doubles:=true;
+  StaticLibFiles.doubles:=true;
+end;
+
+
+procedure TLinkerSinclairQL.SetSinclairQLInfo;
+begin
+  with Info do
+   begin
+    if not UseVLink then
+     begin
+      ExeCmd[1]:='ld $DYNLINK $OPT -d -n -o $EXE $RES';
+     end
+    else
+     begin
+      ExeCmd[1]:='vlink -b raw $FLAGS $GCSECTIONS $OPT $STRIP -o $EXE -T $RES';
+     end;
+   end;
+end;
+
+
+procedure TLinkerSinclairQL.SetDefaultInfo;
+begin
+  if target_info.system = system_m68k_Atari then
+    SetSinclairQLInfo;
+end;
+
+
+procedure TLinkerSinclairQL.InitSysInitUnitName;
+begin
+  sysinitunit:='si_prc';
+end;
+
+
+function TLinkerSinclairQL.WriteResponseFile(isdll: boolean): boolean;
+var
+  linkres  : TLinkRes;
+  i        : longint;
+  HPath    : TCmdStrListItem;
+  s        : string;
+  linklibc : boolean;
+begin
+  WriteResponseFile:=False;
+
+  { Open link.res file }
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName,true);
+
+  { Write path to search libraries }
+  HPath:=TCmdStrListItem(current_module.locallibrarysearchpath.First);
+  while assigned(HPath) do
+   begin
+    s:=HPath.Str;
+    if (cs_link_on_target in current_settings.globalswitches) then
+     s:=ScriptFixFileName(s);
+    LinkRes.Add('-L'+s);
+    HPath:=TCmdStrListItem(HPath.Next);
+   end;
+  HPath:=TCmdStrListItem(LibrarySearchPath.First);
+  while assigned(HPath) do
+   begin
+    s:=HPath.Str;
+    if s<>'' then
+     LinkRes.Add('SEARCH_DIR("'+s+'")');
+    HPath:=TCmdStrListItem(HPath.Next);
+   end;
+
+  LinkRes.Add('INPUT (');
+  { add objectfiles, start with prt0 always }
+  if not (target_info.system in systems_internal_sysinit) then
+    begin
+      s:=FindObjectFile('prt0','',false);
+      LinkRes.AddFileName(maybequoted(s));
+    end;
+  while not ObjectFiles.Empty do
+   begin
+    s:=ObjectFiles.GetFirst;
+    if s<>'' then
+     begin
+      { vlink doesn't use SEARCH_DIR for object files }
+      if UseVLink then
+       s:=FindObjectFile(s,'',false);
+      LinkRes.AddFileName(maybequoted(s));
+     end;
+   end;
+
+  { Write staticlibraries }
+  if not StaticLibFiles.Empty then
+   begin
+     { vlink doesn't need, and doesn't support GROUP }
+    if not UseVLink then
+     begin
+      LinkRes.Add(')');
+      LinkRes.Add('GROUP(');
+     end;
+    while not StaticLibFiles.Empty do
+     begin
+      S:=StaticLibFiles.GetFirst;
+      LinkRes.AddFileName(maybequoted(s));
+     end;
+   end;
+
+  if not UseVLink then
+   begin
+    LinkRes.Add(')');
+
+    { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
+      here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
+    linklibc:=false;
+    while not SharedLibFiles.Empty do
+     begin
+      S:=SharedLibFiles.GetFirst;
+      if s<>'c' then
+       begin
+        i:=Pos(target_info.sharedlibext,S);
+        if i>0 then
+         Delete(S,i,255);
+        LinkRes.Add('-l'+s);
+       end
+      else
+       begin
+        LinkRes.Add('-l'+s);
+        linklibc:=true;
+       end;
+     end;
+    { be sure that libc&libgcc is the last lib }
+    if linklibc then
+     begin
+      LinkRes.Add('-lc');
+      LinkRes.Add('-lgcc');
+     end;
+   end
+  else
+   begin
+    while not SharedLibFiles.Empty do
+     begin
+      S:=SharedLibFiles.GetFirst;
+      LinkRes.Add('lib'+s+target_info.staticlibext);
+     end;
+    LinkRes.Add(')');
+   end;
+
+{ Write and Close response }
+  linkres.writetodisk;
+  linkres.free;
+
+  WriteResponseFile:=True;
+end;
+
+
+function TLinkerSinclairQL.MakeSinclairQLExe: boolean;
+var
+  BinStr,
+  CmdStr  : TCmdStr;
+  StripStr: string[40];
+  DynLinkStr : string;
+  GCSectionsStr : string;
+  FlagsStr : string;
+  ExeName: string;
+begin
+  StripStr:='';
+  GCSectionsStr:='';
+  DynLinkStr:='';
+  FlagsStr:='';
+
+  if (cs_link_strip in current_settings.globalswitches) then
+    StripStr:='-s';
+  if rlinkpath<>'' then
+    DynLinkStr:='--rpath-link '+rlinkpath;
+  if UseVLink then
+    begin
+      if create_smartlink_sections then
+        GCSectionsStr:='-gc-all -sc';
+    end;
+
+  ExeName:=current_module.exefilename;
+  if apptype = app_gui then
+    Replace(ExeName,target_info.exeext,'.prg');
+
+  { Call linker }
+  SplitBinCmd(Info.ExeCmd[1],BinStr,CmdStr);
+  binstr:=FindUtil(utilsprefix+BinStr);
+  Replace(cmdstr,'$OPT',Info.ExtraOptions);
+  Replace(cmdstr,'$EXE',maybequoted(ScriptFixFileName(ExeName)));
+  Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));
+  Replace(cmdstr,'$FLAGS',FlagsStr);
+  Replace(cmdstr,'$STRIP',StripStr);
+  Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
+  Replace(cmdstr,'$DYNLINK',DynLinkStr);
+
+  MakeSinclairQLExe:=DoExec(BinStr,CmdStr,true,false);
+end;
+
+
+function TLinkerSinclairQL.MakeExecutable:boolean;
+var
+  success : boolean;
+begin
+  if not(cs_link_nolink in current_settings.globalswitches) then
+    Message1(exec_i_linking,current_module.exefilename);
+
+  { Write used files and libraries }
+  WriteResponseFile(false);
+
+  success:=MakeSinclairQLExe;
+
+  { Remove ReponseFile }
+  if (success) and not(cs_link_nolink in current_settings.globalswitches) then
+    DeleteFile(outputexedir+Info.ResName);
+
+  MakeExecutable:=success;   { otherwise a recursive call to link method }
+end;
+
+
+
+
+{*****************************************************************************
+                                     Initialize
+*****************************************************************************}
+
+initialization
+  RegisterLinker(ld_sinclairql,TLinkerSinclairQL);
+  RegisterTarget(system_m68k_sinclairql_info);
+end.

+ 2 - 1
compiler/utils/ppuutils/ppudump.pp

@@ -232,7 +232,8 @@ const
   { 109 } 'ZXSpectrum-Z80',
   { 110 } 'MSX-DOS-Z80',
   { 111 } 'Darwin-AArch64',
-  { 112 } 'AmstradCPC-Z80'
+  { 112 } 'AmstradCPC-Z80',
+  { 113 } 'SinclairQL-m68k'
   );
 
 const