]> git.sur5r.net Git - cc65/blobdiff - src/cl65/main.c
Removed obsolete comment
[cc65] / src / cl65 / main.c
index b79d4833ea2b7553f337430828fcbee1701c73e3..81e7de633675e2384a2d08add39370c6d7b18699 100644 (file)
@@ -58,6 +58,7 @@
 #include "cmdline.h"
 #include "filetype.h"
 #include "fname.h"
+#include "mmodel.h"
 #include "strbuf.h"
 #include "target.h"
 #include "version.h"
@@ -287,13 +288,13 @@ static void SetTargetFiles (void)
 
        /* Set the startup file */
        TargetCRT0 = xmalloc (TargetNameLen + 2 + 1);
-       strcpy (TargetCRT0, TargetName);
-       strcat (TargetCRT0, ".o");
+               memcpy (TargetCRT0, TargetName, TargetNameLen);
+               strcpy (TargetCRT0 + TargetNameLen, ".o");
 
        /* Set the library file */
        TargetLib = xmalloc (TargetNameLen + 4 + 1);
-       strcpy (TargetLib, TargetName);
-       strcat (TargetLib, ".lib");
+       memcpy (TargetLib, TargetName, TargetNameLen);
+       strcpy (TargetLib + TargetNameLen, ".lib");
 
     }
 }
@@ -348,7 +349,7 @@ static void Link (void)
                CmdAddArg2 (&LD65, "-C", LinkerConfig);
     } else if (Module) {
         CmdSetTarget (&LD65, TGT_MODULE);
-    } else if (Target != TGT_NONE) {
+    } else {
        CmdSetTarget (&LD65, Target);
     }
 
@@ -596,6 +597,7 @@ static void Usage (void)
                     "  -h\t\t\tHelp (this text)\n"
                     "  -l\t\t\tCreate an assembler listing\n"
                     "  -m name\t\tCreate a map file\n"
+             "  -mm model\t\tSet the memory model\n"
                     "  -o name\t\tName the output file\n"
              "  -r\t\t\tEnable register variables\n"
                     "  -t sys\t\tSet the target system\n"
@@ -629,6 +631,7 @@ static void Usage (void)
              "  --code-label name\tDefine and export a CODE segment label\n"
                     "  --code-name seg\tSet the name of the CODE segment\n"
             "  --codesize x\t\tAccept larger code by factor x\n"
+                    "  --config name\t\tUse linker config file\n"
                     "  --cpu type\t\tSet cpu type\n"
             "  --create-dep\t\tCreate a make dependency file\n"
              "  --data-label name\tDefine and export a DATA segment label\n"
@@ -636,12 +639,14 @@ static void Usage (void)
                     "  --debug\t\tDebug mode\n"
                     "  --debug-info\t\tAdd debug info\n"
             "  --feature name\tSet an emulation feature\n"
+                    "  --forget-inc-paths\tForget include search paths (compiler)\n"
                     "  --help\t\tHelp (this text)\n"
                     "  --include-dir dir\tSet a compiler include directory path\n"
              "  --lib file\t\tLink this library\n"
              "  --lib-path path\tSpecify a library search path\n"
                     "  --listing\t\tCreate an assembler listing\n"
             "  --mapfile name\tCreate a map file\n"
+             "  --memory-model model\tSet the memory model\n"
              "  --module\t\tLink as a module\n"
              "  --module-id id\tSpecify a module id for the linker\n"
              "  --o65-model model\tOverride the o65 model\n"
@@ -756,6 +761,17 @@ static void OptCodeSize (const char* Opt attribute ((unused)), const char* Arg)
 
 
 
+static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
+/* Config file (linker) */
+{
+    if (LinkerConfig) {
+        Error ("Cannot specify -C/--config twice");
+    }
+    LinkerConfig = Arg;
+}
+
+
+
 static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
 /* Handle the --cpu option */
 {
@@ -822,6 +838,14 @@ static void OptFeature (const char* Opt attribute ((unused)), const char* Arg)
 
 
 
+static void OptForgetIncPaths (const char* Opt attribute ((unused)), const char* Arg)
+/* Forget all currently defined include paths */
+{
+    CmdAddArg2 (&CC65, "--forget-inc-paths", Arg);
+}
+
+
+
 static void OptHelp (const char* Opt attribute ((unused)),
                     const char* Arg attribute ((unused)))
 /* Print help - cl65 */
@@ -874,6 +898,22 @@ static void OptMapFile (const char* Opt attribute ((unused)), const char* Arg)
 
 
 
+static void OptMemoryModel (const char* Opt attribute ((unused)), const char* Arg)
+/* Set the memory model */
+{
+    mmodel_t MemoryModel = FindMemoryModel (Arg);
+    if (MemoryModel == MMODEL_UNKNOWN) {
+        Error ("Unknown memory model: %s", Arg);
+    } else if (MemoryModel == MMODEL_HUGE) {
+        Error ("Unsupported memory model: %s", Arg);
+    } else {
+        CmdAddArg2 (&CA65, "-mm", Arg);
+        CmdAddArg2 (&CC65, "-mm", Arg);
+    }
+}
+
+
+
 static void OptModule (const char* Opt attribute ((unused)),
                        const char* Arg attribute ((unused)))
 /* Link as a module */
@@ -1035,6 +1075,7 @@ int main (int argc, char* argv [])
                { "--code-label",       1,      OptCodeLabel            },
        { "--code-name",        1,      OptCodeName             },
        { "--codesize",         1,      OptCodeSize             },
+        { "--config",           1,      OptConfig               },
         { "--cpu",                     1,      OptCPU                  },
        { "--create-dep",       0,      OptCreateDep            },
                { "--data-label",       1,      OptDataLabel            },
@@ -1042,12 +1083,14 @@ int main (int argc, char* argv [])
        { "--debug",            0,      OptDebug                },
        { "--debug-info",       0,      OptDebugInfo            },
        { "--feature",          1,      OptFeature              },
+               { "--forget-inc-paths", 0,      OptForgetIncPaths       },
        { "--help",             0,      OptHelp                 },
        { "--include-dir",      1,      OptIncludeDir           },
                { "--lib",              1,      OptLib                  },
                { "--lib-path",         1,      OptLibPath              },
        { "--listing",          0,      OptListing              },
        { "--mapfile",          1,      OptMapFile              },
+        { "--memory-model",     1,      OptMemoryModel          },
         { "--module",           0,      OptModule               },
         { "--module-id",        1,      OptModuleId             },
         { "--o65-model",        1,      OptO65Model             },
@@ -1108,7 +1151,7 @@ int main (int argc, char* argv [])
                        OptStaticLocals (Arg, 0);
                    } else {
                        /* Specify linker config file */
-                       LinkerConfig = GetArg (&I, 2);
+                       OptConfig (Arg, GetArg (&I, 2));
                    }
                    break;