]> git.sur5r.net Git - cc65/commitdiff
Change target handling, use modules from the common directory.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 Aug 2000 14:13:24 +0000 (14:13 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 Aug 2000 14:13:24 +0000 (14:13 +0000)
New long options: --config and --mapfile.

git-svn-id: svn://svn.cc65.org/cc65/trunk@302 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ld65/main.c
src/ld65/make/gcc.mak
src/ld65/make/watcom.mak
src/ld65/target.c [deleted file]
src/ld65/target.h [deleted file]
src/ld65/tgtcfg.c [new file with mode: 0644]
src/ld65/tgtcfg.h [new file with mode: 0644]

index a7fbd5afd2545d8874c505099ed01393e5ba4eca..0d1f171ef0fcdb536e941b7d832c9f712a1d7d7d 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998    Ullrich von Bassewitz                                        */
-/*             Wacholderweg 14                                              */
-/*             D-70597 Stuttgart                                            */
-/* EMail:      uz@musoftware.de                                             */
+/* (C) 1998-2000 Ullrich von Bassewitz                                      */
+/*              Wacholderweg 14                                             */
+/*              D-70597 Stuttgart                                           */
+/* EMail:       uz@musoftware.de                                            */
 /*                                                                          */
 /*                                                                          */
 /* This software is provided 'as-is', without any expressed or implied      */
 #include <string.h>
 #include <errno.h>
 
-#include "../common/cmdline.h"
-#include "../common/libdefs.h"
-#include "../common/objdefs.h"
-#include "../common/version.h"
-#include "../common/xmalloc.h"
+/* common */
+#include "cmdline.h"
+#include "libdefs.h"
+#include "objdefs.h"
+#include "target.h"
+#include "version.h"
+#include "xmalloc.h"
 
-#include "global.h"
+/* ld65 */
+#include "binfmt.h"
+#include "config.h"
 #include "error.h"
-#include "target.h"
+#include "exports.h"
 #include "fileio.h"
-#include "scanner.h"
-#include "config.h"
-#include "objfile.h"
+#include "global.h"
 #include "library.h"
-#include "exports.h"
-#include "segments.h"
 #include "mapfile.h"
+#include "objfile.h"
+#include "scanner.h"
+#include "segments.h"
+#include "tgtcfg.h"
 
 
 
@@ -86,7 +90,7 @@ static void Usage (void)
                     "  -h\t\t\tHelp (this text)\n"
                     "  -m name\t\tCreate a map file\n"
                     "  -o name\t\tName the default output file\n"
-                    "  -t type\t\tType of target system\n"
+                    "  -t sys\t\tSet the target system\n"
                     "  -v\t\t\tVerbose mode\n"
                     "  -vm\t\t\tVerbose map file\n"
                     "  -C name\t\tUse linker config file\n"
@@ -97,6 +101,8 @@ static void Usage (void)
             "\n"
             "Long options:\n"
             "  --help\t\tHelp (this text)\n"
+            "  --mapfile name\tCreate a map file\n"
+                    "  --target sys\t\tSet the target system\n"
                     "  --version\t\tPrint the linker version\n",
             ProgName);
 }
@@ -207,6 +213,17 @@ static void LinkFile (const char* Name)
 
 
 
+static void OptConfig (const char* Opt, const char* Arg)
+/* Define the config file */
+{
+    if (CfgAvail ()) {
+       Error ("Cannot use -C/-t twice");
+    }
+    CfgSetName (Arg);
+}
+
+
+
 static void OptHelp (const char* Opt, const char* Arg)
 /* Print usage information and exit */
 {
@@ -216,6 +233,35 @@ static void OptHelp (const char* Opt, const char* Arg)
 
 
 
+static void OptMapFile (const char* Opt, const char* Arg)
+/* Give the name of the map file */
+{
+    MapFileName = Arg;
+}
+
+
+
+static void OptTarget (const char* Opt, const char* Arg)
+/* Set the target system */
+{
+    const TargetDesc* D;
+
+    /* Map the target name to a target id */
+    Target = FindTarget (Arg);
+    if (Target == TGT_UNKNOWN) {
+               Error ("Invalid target name: `%s'", Arg);
+    }
+
+    /* Get the target description record */
+    D = &Targets[Target];
+
+    /* Set the target data */
+    DefaultBinFmt = D->BinFmt;
+    CfgSetBuf (D->Cfg);
+}
+
+
+
 static void OptVersion (const char* Opt, const char* Arg)
 /* Print the assembler version */
 {
@@ -231,8 +277,11 @@ int main (int argc, char* argv [])
 {
     /* Program long options */
     static const LongOpt OptTab[] = {
-               { "--help",             0,      OptHelp                 },
-       { "--version",          0,      OptVersion              },
+               { "--config",           1,      OptConfig               },
+               { "--help",             0,      OptHelp                 },
+       { "--mapfile",          1,      OptMapFile              },
+       { "--target",           1,      OptTarget               },
+       { "--version",          0,      OptVersion              },
     };
 
     int I;
@@ -255,7 +304,7 @@ int main (int argc, char* argv [])
     /* Check the parameters */
     I = 1;
     while (I < argc) {
-     
+
        /* Get the argument */
        const char* Arg = argv [I];
 
@@ -266,37 +315,34 @@ int main (int argc, char* argv [])
            switch (Arg [1]) {
 
                case '-':
-                   LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
-                   break;
-
-               case 'm':
-                   MapFileName = GetArg (&I, 2);
-                   break;
-
-               case 'o':
-                   OutputName = GetArg (&I, 2);
-                   break;
-
-               case 't':
-                   if (CfgAvail ()) {
-                       Error ("Cannot use -C/-t twice");
-                   }
-                   TgtSet (GetArg (&I, 2));
-                   break;
-
-               case 'v':
-                   switch (Arg [2]) {
-                       case 'm':   VerboseMap = 1;     break;
+                   LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
+                   break;
+
+               case 'm':
+                   OptMapFile (Arg, GetArg (&I, 2));
+                   break;
+
+               case 'o':
+                   OutputName = GetArg (&I, 2);
+                   break;
+
+               case 't':
+                   if (CfgAvail ()) {
+                       Error ("Cannot use -C/-t twice");
+                   }
+                   OptTarget (Arg, GetArg (&I, 2));
+                   break;
+
+               case 'v':
+                   switch (Arg [2]) {
+                       case 'm':   VerboseMap = 1;     break;
                        case '\0':  ++Verbose;          break;
                        default:    UnknownOption (Arg);
                    }
                    break;
 
                case 'C':
-                   if (CfgAvail ()) {
-                       Error ("Cannot use -C/-t twice");
-                   }
-                   CfgSetName (GetArg (&I, 2));
+                   OptConfig (Arg, GetArg (&I, 2));
                    break;
 
                case 'L':
@@ -315,9 +361,9 @@ int main (int argc, char* argv [])
                    OptVersion (Arg, 0);
                    break;
 
-               default:
-                   UnknownOption (Arg);
-                   break;
+               default:
+                   UnknownOption (Arg);
+                   break;
            }
 
        } else {
@@ -333,14 +379,12 @@ int main (int argc, char* argv [])
 
     /* Check if we had any object files */
     if (ObjFiles == 0) {
-       fprintf (stderr, "No object files to link\n");
-       exit (EXIT_FAILURE);
+       Error ("No object files to link");
     }
 
     /* Check if we have a valid configuration */
     if (!CfgAvail ()) {
-       fprintf (stderr, "Memory configuration missing\n");
-       exit (EXIT_FAILURE);
+               Error ("Memory configuration missing");
     }
 
     /* Read the config file */
index 7dbb365f2cdded3455fa299e7453480aff2168be..9fb16a6b7a05822827e6131367a01b9b62467b06 100644 (file)
@@ -29,7 +29,7 @@ OBJS =        bin.o           \
        objfile.o       \
        scanner.o       \
        segments.o      \
-       target.o
+       tgtcfg.o        
 
 LIBS = $(COMMON)/common.a
 
index e0bc92bb772e274f421a4b0fa57d4befbc93d9b5..cd3515ccff1af19ecf2dcf798b05e16db52bb52d 100644 (file)
@@ -85,7 +85,7 @@ OBJS =        bin.obj         \
        objfile.obj     \
        scanner.obj     \
        segments.obj    \
-       target.obj
+       tgtcfg.obj
 
 LIBS = ..\common\common.lib
 
@@ -93,16 +93,16 @@ LIBS = ..\common\common.lib
 # ------------------------------------------------------------------------------
 # Main targets
 
-all:           ld65
+all:           ld65
 
-ld65:          ld65.exe
+ld65:          ld65.exe
 
 
 # ------------------------------------------------------------------------------
 # Other targets
 
 
-ld65.exe:      $(OBJS) $(LIBS)
+ld65.exe:      $(OBJS) $(LIBS)
        $(LD) system $(SYSTEM) @&&|
 DEBUG ALL
 OPTION QUIET
@@ -125,7 +125,7 @@ FILE objdata.obj
 FILE objfile.obj
 FILE scanner.obj
 FILE segments.obj
-FILE target.obj
+FILE tgtcfg.obj
 LIBRARY ..\common\common.lib
 |
 
diff --git a/src/ld65/target.c b/src/ld65/target.c
deleted file mode 100644 (file)
index 27da095..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-/*****************************************************************************/
-/*                                                                           */
-/*                              target.c                                    */
-/*                                                                           */
-/*                Target system support for the ld65 linker                 */
-/*                                                                           */
-/*                                                                           */
-/*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
-/*                                                                           */
-/*                                                                           */
-/* This software is provided 'as-is', without any expressed or implied       */
-/* warranty.  In no event will the authors be held liable for any damages    */
-/* arising from the use of this software.                                    */
-/*                                                                           */
-/* Permission is granted to anyone to use this software for any purpose,     */
-/* including commercial applications, and to alter it and redistribute it    */
-/* freely, subject to the following restrictions:                            */
-/*                                                                           */
-/* 1. The origin of this software must not be misrepresented; you must not   */
-/*    claim that you wrote the original software. If you use this software   */
-/*    in a product, an acknowledgment in the product documentation would be  */
-/*    appreciated but is not required.                                       */
-/* 2. Altered source versions must be plainly marked as such, and must not   */
-/*    be misrepresented as being the original software.                      */
-/* 3. This notice may not be removed or altered from any source              */
-/*    distribution.                                                          */
-/*                                                                           */
-/*****************************************************************************/
-
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-
-#include "error.h"
-#include "global.h"
-#include "binfmt.h"
-#include "scanner.h"
-#include "config.h"
-#include "target.h"
-
-
-
-/*****************************************************************************/
-/*                          Target configurations                           */
-/*****************************************************************************/
-
-
-
-static const char CfgNone [] =
-    "MEMORY {"
-       "RAM: start = %S, size = $10000, file = %O;"
-    "}"
-    "SEGMENTS {"
-        "CODE: load = RAM, type = rw;"
-       "RODATA: load = RAM, type = rw;"
-       "DATA: load = RAM, type = rw;"
-       "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgAtari [] =
-    "MEMORY {"
-        "HEADER: start = $0000, size = $6, file = %O;"
-        "RAM: start = $1F00, size = $9D1F, file = %O;"   /* 9D1F: matches upper bound BC1F */
-    "}"
-    "SEGMENTS {"
-        "EXEHDR: load = HEADER, type = wprot;"
-        "CODE: load = RAM, type = wprot, define = yes;"
-        "RODATA: load = RAM, type = wprot;"
-        "DATA: load = RAM, type = rw;"
-        "BSS: load = RAM, type = bss, define = yes;"
-        "AUTOSTRT: load = RAM, type = wprot;"
-    "}";
-
-static const char CfgC64 [] =
-    "MEMORY {"
-       "RAM: start = $7FF, size = $c801, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = RAM, type = wprot;"
-       "RODATA: load = RAM, type = wprot;"
-       "DATA: load = RAM, type = rw;"
-       "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgC128 [] =
-    "MEMORY {"
-       "RAM: start = $1bff, size = $a401, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = RAM, type = wprot;"
-       "RODATA: load = RAM, type = wprot;"
-       "DATA: load = RAM, type = rw;"
-       "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgAce [] =
-    "";
-
-static const char CfgPlus4 [] =
-    "MEMORY {"
-       "RAM: start = $0fff, size = $7001, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = RAM, type = wprot;"
-       "RODATA: load = RAM, type = wprot;"
-       "DATA: load = RAM, type = rw;"
-       "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgCBM610 [] =
-    "MEMORY {"
-       "RAM: start = $0001, size = $FFF0, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = RAM, type = wprot;"
-       "RODATA: load = RAM, type = wprot;"
-       "DATA: load = RAM, type = rw;"
-       "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgPET [] =
-    "MEMORY {"
-       "RAM: start = $03FF, size = $7BFF, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = RAM, type = wprot;"
-       "RODATA: load = RAM, type = wprot;"
-       "DATA: load = RAM, type = rw;"
-       "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgNES [] =
-    "MEMORY {"
-       "RAM: start = $0200, size = $0600, file = \"\";"
-               "ROM: start = $8000, size = $8000, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = ROM, type = ro;"
-       "RODATA: load = ROM, type = ro;"
-       "DATA: load = ROM, run = RAM, type = rw, define = yes;"
-       "BSS: load = RAM, type = bss, define = yes;"
-       "VECTORS: load = ROM, type = ro, start = $FFFA;"
-    "}";
-
-static const char CfgLunix [] =
-    "MEMORY {"
-       "COMBINED: start = $0000, size = $FFFF, file = %O;"
-       "ZEROPAGE: start = $0000, size = $0100, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = COMBINED, type = wprot;"
-       "RODATA: load = COMBINED, type = wprot;"
-       "DATA: load = COMBINED, type = rw, define = yes;"
-       "BSS: load = COMBINED, type = bss, define = yes;"
-       "ZEROPAGE: load = ZEROPAGE, type = zp;"
-    "}"
-    "FILES {"
-               "%O: format = o65;"
-    "}"
-    "FORMATS {"
-               "o65: os = lunix, type = small,"
-                     "extsym = \"LUNIXKERNAL\", extsym = \"LIB6502\";"
-    "}";
-
-static const char CfgOSA65 [] =
-    "MEMORY {"
-               "COMBINED: start = $0000, size = $FFFF, file = %O;"
-       "ZEROPAGE: start = $0000, size = $0100, file = %O;"
-    "}"
-    "SEGMENTS {"
-               "CODE: load = COMBINED, type = wprot;"
-               "RODATA: load = COMBINED, type = wprot;"
-               "DATA: load = COMBINED, type = rw, define = yes;"
-               "BSS: load = COMBINED, type = bss, define = yes;"
-       "ZEROPAGE: load = ZEROPAGE, type = zp;"
-    "}"
-    "FILES {"
-       "%O: format = o65;"
-    "}"
-    "FORMATS {"
-       "o65: os = osa65, type = small,"
-             "extsym = \"OSA2KERNAL\", extsym = \"LIB6502\";"
-    "}";
-
-static const char CfgApple2 [] =
-    "MEMORY {"
-       "RAM: start = $800, size = $8E00, file = %O;"
-    "}"
-    "SEGMENTS { "
-        "CODE: load = RAM, type = ro;"
-        "RODATA: load = RAM, type = ro;"
-        "DATA: load = RAM, type = rw;"
-        "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-static const char CfgGeos [] =
-    "MEMORY {"
-       "HEADER: start = $204, size = 508, file = %O;"
-               "RAM: start = $400, size = $7C00, file = %O;"
-    "}"
-    "SEGMENTS { "
-       "HEADER: load = HEADER, type = ro;"
-        "CODE: load = RAM, type = ro;"
-        "RODATA: load = RAM, type = ro;"
-        "DATA: load = RAM, type = rw;"
-        "BSS: load = RAM, type = bss, define = yes;"
-    "}";
-
-
-
-/*****************************************************************************/
-/*                                          Data                                    */
-/*****************************************************************************/
-
-
-
-/* Supported systems */
-#define TGT_NONE        0
-#define TGT_ATARI       1              /* Atari 8 bit machines */
-#define TGT_C64                 2
-#define TGT_C128        3
-#define TGT_ACE                 4
-#define TGT_PLUS4       5
-#define TGT_CBM610      6              /* CBM 600/700 family */
-#define TGT_PET                 7              /* CBM PET family */
-#define TGT_NES                 8              /* Nintendo Entertainment System */
-#define TGT_LUNIX       9
-#define TGT_OSA65      10
-#define TGT_APPLE2     11
-#define TGT_GEOS       12
-#define TGT_COUNT      13              /* Count of supported systems */
-
-
-
-/* Structure describing a target */
-typedef struct TargetCfg_ TargetCfg;
-struct TargetCfg_ {
-    const char*                Name;           /* Name of the system */
-    unsigned char              BinFmt;         /* Default binary format for the target */
-    const char*                Cfg;            /* Pointer to configuration */
-};
-
-static const TargetCfg Targets [TGT_COUNT] = {
-    {          "none",   BINFMT_BINARY,        CfgNone         },
-    {          "atari",  BINFMT_BINARY,        CfgAtari        },
-    {          "c64",    BINFMT_BINARY,        CfgC64          },
-    {          "c128",   BINFMT_BINARY,        CfgC128         },
-    {          "ace",    BINFMT_BINARY,        CfgAce          },
-    {          "plus4",  BINFMT_BINARY,        CfgPlus4        },
-    {          "cbm610", BINFMT_BINARY,        CfgCBM610       },
-    {          "pet",    BINFMT_BINARY,        CfgPET          },
-    {          "nes",    BINFMT_BINARY,        CfgNES          },
-    {   "lunix",  BINFMT_O65,           CfgLunix       },
-    {   "osa65",  BINFMT_O65,          CfgOSA65        },
-    {   "apple2", BINFMT_BINARY,       CfgApple2       },
-    {   "geos",          BINFMT_BINARY,        CfgGeos         },
-};
-
-/* Selected target system type */
-static const TargetCfg* Target;
-
-
-
-/*****************************************************************************/
-/*                                          Code                                    */
-/*****************************************************************************/
-
-
-
-static int StrICmp (const char* S1, const char* S2)
-/* Compare two strings case insensitive */
-{
-    int Diff = 0;
-    while (1) {
-       Diff = tolower (*S1) - tolower (*S2);
-       if (Diff != 0 || *S1 == '\0') {
-           return Diff;
-       }
-       ++S1;
-       ++S2;
-    }
-}
-
-
-
-static int TgtMap (const char* Name)
-/* Map a target name to a system code. Return -1 in case of an error */
-{
-    unsigned I;
-
-    /* Check for a numeric target */
-    if (isdigit (*Name)) {
-       int Target = atoi (Name);
-       if (Target >= 0 && Target < TGT_COUNT) {
-           return Target;
-       }
-    }
-
-    /* Check for a target string */
-    for (I = 0; I < TGT_COUNT; ++I) {
-               if (StrICmp (Targets [I].Name, Name) == 0) {
-           return I;
-       }
-    }
-
-    /* Not found */
-    return -1;
-}
-
-
-
-void TgtSet (const char* T)
-/* Set the target system, initialize internal stuff for this target */
-{
-    /* Map the target to a number */
-    int TgtNum = TgtMap (T);
-    if (TgtNum == -1) {
-       Error ("Invalid target system: %s", T);
-    }
-    Target = &Targets [TgtNum];
-
-    /* Set the target data */
-    DefaultBinFmt = Target->BinFmt;
-    CfgSetBuf (Target->Cfg);
-}
-
-
-
-void TgtPrintList (FILE* F)
-/* Print a list of the available target systems */
-{
-    unsigned I;
-
-    /* Print a header */
-    fprintf (F, "Available targets:\n");
-
-    /* Print a list of the target systems */
-    for (I = 0; I < TGT_COUNT; ++I) {
-       fprintf (F, "  %s\n", Targets [I].Name);
-    }
-}
-
-
-
diff --git a/src/ld65/target.h b/src/ld65/target.h
deleted file mode 100644 (file)
index 43cf6ab..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************/
-/*                                                                           */
-/*                              target.h                                    */
-/*                                                                           */
-/*                Target system support for the ld65 linker                 */
-/*                                                                           */
-/*                                                                           */
-/*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
-/*                                                                           */
-/*                                                                           */
-/* This software is provided 'as-is', without any expressed or implied       */
-/* warranty.  In no event will the authors be held liable for any damages    */
-/* arising from the use of this software.                                    */
-/*                                                                           */
-/* Permission is granted to anyone to use this software for any purpose,     */
-/* including commercial applications, and to alter it and redistribute it    */
-/* freely, subject to the following restrictions:                            */
-/*                                                                           */
-/* 1. The origin of this software must not be misrepresented; you must not   */
-/*    claim that you wrote the original software. If you use this software   */
-/*    in a product, an acknowledgment in the product documentation would be  */
-/*    appreciated but is not required.                                       */
-/* 2. Altered source versions must be plainly marked as such, and must not   */
-/*    be misrepresented as being the original software.                      */
-/* 3. This notice may not be removed or altered from any source              */
-/*    distribution.                                                          */
-/*                                                                           */
-/*****************************************************************************/
-
-
-
-#ifndef TARGET_H
-#define TARGET_H
-
-
-
-#include <stdio.h>
-
-
-
-/*****************************************************************************/
-/*                                          Code                                    */
-/*****************************************************************************/
-
-
-
-void TgtSet (const char* T);
-/* Set the target system, initialize internal stuff for this target */
-
-void TgtPrintList (FILE* F);
-/* Print a list of the available target systems */
-
-
-
-/* End of target.h */
-
-#endif
-
-
-
diff --git a/src/ld65/tgtcfg.c b/src/ld65/tgtcfg.c
new file mode 100644 (file)
index 0000000..133e1bf
--- /dev/null
@@ -0,0 +1,233 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                              tgtcfg.c                                    */
+/*                                                                           */
+/*              Target machine configurations the ld65 linker               */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+                  
+#include "binfmt.h"
+#include "tgtcfg.h"
+
+
+
+/*****************************************************************************/
+/*                          Target configurations                           */
+/*****************************************************************************/
+
+
+
+static const char CfgNone [] =
+    "MEMORY {"
+       "RAM: start = %S, size = $10000, file = %O;"
+    "}"
+    "SEGMENTS {"
+        "CODE: load = RAM, type = rw;"
+       "RODATA: load = RAM, type = rw;"
+       "DATA: load = RAM, type = rw;"
+       "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgAtari [] =
+    "MEMORY {"
+        "HEADER: start = $0000, size = $6, file = %O;"
+        "RAM: start = $1F00, size = $9D1F, file = %O;"   /* 9D1F: matches upper bound BC1F */
+    "}"
+    "SEGMENTS {"
+        "EXEHDR: load = HEADER, type = wprot;"
+        "CODE: load = RAM, type = wprot, define = yes;"
+        "RODATA: load = RAM, type = wprot;"
+        "DATA: load = RAM, type = rw;"
+        "BSS: load = RAM, type = bss, define = yes;"
+        "AUTOSTRT: load = RAM, type = wprot;"
+    "}";
+
+static const char CfgC64 [] =
+    "MEMORY {"
+       "RAM: start = $7FF, size = $c801, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = RAM, type = wprot;"
+       "RODATA: load = RAM, type = wprot;"
+       "DATA: load = RAM, type = rw;"
+       "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgC128 [] =
+    "MEMORY {"
+       "RAM: start = $1bff, size = $a401, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = RAM, type = wprot;"
+       "RODATA: load = RAM, type = wprot;"
+       "DATA: load = RAM, type = rw;"
+       "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgAce [] =
+    "";
+
+static const char CfgPlus4 [] =
+    "MEMORY {"
+       "RAM: start = $0fff, size = $7001, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = RAM, type = wprot;"
+       "RODATA: load = RAM, type = wprot;"
+       "DATA: load = RAM, type = rw;"
+       "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgCBM610 [] =
+    "MEMORY {"
+       "RAM: start = $0001, size = $FFF0, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = RAM, type = wprot;"
+       "RODATA: load = RAM, type = wprot;"
+       "DATA: load = RAM, type = rw;"
+       "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgPET [] =
+    "MEMORY {"
+       "RAM: start = $03FF, size = $7BFF, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = RAM, type = wprot;"
+       "RODATA: load = RAM, type = wprot;"
+       "DATA: load = RAM, type = rw;"
+       "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgNES [] =
+    "MEMORY {"
+       "RAM: start = $0200, size = $0600, file = \"\";"
+               "ROM: start = $8000, size = $8000, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = ROM, type = ro;"
+       "RODATA: load = ROM, type = ro;"
+       "DATA: load = ROM, run = RAM, type = rw, define = yes;"
+       "BSS: load = RAM, type = bss, define = yes;"
+       "VECTORS: load = ROM, type = ro, start = $FFFA;"
+    "}";
+
+static const char CfgLunix [] =
+    "MEMORY {"
+       "COMBINED: start = $0000, size = $FFFF, file = %O;"
+       "ZEROPAGE: start = $0000, size = $0100, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = COMBINED, type = wprot;"
+       "RODATA: load = COMBINED, type = wprot;"
+       "DATA: load = COMBINED, type = rw, define = yes;"
+       "BSS: load = COMBINED, type = bss, define = yes;"
+       "ZEROPAGE: load = ZEROPAGE, type = zp;"
+    "}"
+    "FILES {"
+               "%O: format = o65;"
+    "}"
+    "FORMATS {"
+               "o65: os = lunix, type = small,"
+                     "extsym = \"LUNIXKERNAL\", extsym = \"LIB6502\";"
+    "}";
+
+static const char CfgOSA65 [] =
+    "MEMORY {"
+               "COMBINED: start = $0000, size = $FFFF, file = %O;"
+       "ZEROPAGE: start = $0000, size = $0100, file = %O;"
+    "}"
+    "SEGMENTS {"
+               "CODE: load = COMBINED, type = wprot;"
+               "RODATA: load = COMBINED, type = wprot;"
+               "DATA: load = COMBINED, type = rw, define = yes;"
+               "BSS: load = COMBINED, type = bss, define = yes;"
+       "ZEROPAGE: load = ZEROPAGE, type = zp;"
+    "}"
+    "FILES {"
+       "%O: format = o65;"
+    "}"
+    "FORMATS {"
+       "o65: os = osa65, type = small,"
+             "extsym = \"OSA2KERNAL\", extsym = \"LIB6502\";"
+    "}";
+
+static const char CfgApple2 [] =
+    "MEMORY {"
+       "RAM: start = $800, size = $8E00, file = %O;"
+    "}"
+    "SEGMENTS { "
+        "CODE: load = RAM, type = ro;"
+        "RODATA: load = RAM, type = ro;"
+        "DATA: load = RAM, type = rw;"
+        "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+static const char CfgGeos [] =
+    "MEMORY {"
+       "HEADER: start = $204, size = 508, file = %O;"
+               "RAM: start = $400, size = $7C00, file = %O;"
+    "}"
+    "SEGMENTS { "
+       "HEADER: load = HEADER, type = ro;"
+        "CODE: load = RAM, type = ro;"
+        "RODATA: load = RAM, type = ro;"
+        "DATA: load = RAM, type = rw;"
+        "BSS: load = RAM, type = bss, define = yes;"
+    "}";
+
+
+
+/*****************************************************************************/
+/*                                          Data                                    */
+/*****************************************************************************/
+
+
+
+/* Target configurations for all systems */
+const TargetDesc Targets [TGT_COUNT] = {
+    {          BINFMT_BINARY,  CfgNone         },
+    {          BINFMT_BINARY,  CfgAtari        },
+    {          BINFMT_BINARY,  CfgC64          },
+    {          BINFMT_BINARY,  CfgC128         },
+    {          BINFMT_BINARY,  CfgAce          },
+    {          BINFMT_BINARY,  CfgPlus4        },
+    {          BINFMT_BINARY,  CfgCBM610       },
+    {          BINFMT_BINARY,  CfgPET          },
+    {          BINFMT_BINARY,  CfgNES          },
+    {   BINFMT_O65,     CfgLunix       },
+    {   BINFMT_O65,    CfgOSA65        },
+    {   BINFMT_BINARY, CfgApple2       },
+    {   BINFMT_BINARY,  CfgGeos                },
+};
+
+
+
diff --git a/src/ld65/tgtcfg.h b/src/ld65/tgtcfg.h
new file mode 100644 (file)
index 0000000..d60711c
--- /dev/null
@@ -0,0 +1,69 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                              tgtcfg.h                                    */
+/*                                                                           */
+/*              Target machine configurations the ld65 linker               */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef TGTCFG_H
+#define TGTCFG_H
+
+
+
+/* common */
+#include "target.h"
+
+
+
+/*****************************************************************************/
+/*                          Target configurations                           */
+/*****************************************************************************/
+
+
+
+/* Structure describing a target */
+typedef struct TargetDesc TargetDesc;
+struct TargetDesc {
+    unsigned char              BinFmt; /* Default binary format for the target */
+    const char*                Cfg;    /* Pointer to configuration */
+};
+
+/* Target configurations for all systems */
+extern const TargetDesc Targets [TGT_COUNT];
+
+
+
+/* End of tgtcfg.h */
+
+#endif
+
+
+