1 /*****************************************************************************/
5 /* Main module for the cl65 compile and link utility */
9 /* (C) 1999-2002 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
41 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__MINGW32__)
42 # include <process.h> /* DOS, OS/2 and Windows */
44 # include "spawn.h" /* All others */
60 /*****************************************************************************/
62 /*****************************************************************************/
66 /* Struct that describes a command */
67 typedef struct CmdDesc CmdDesc;
69 char* Name; /* The command name */
71 unsigned ArgCount; /* Count of arguments */
72 unsigned ArgMax; /* Maximum count of arguments */
73 char** Args; /* The arguments */
75 unsigned FileCount; /* Count of files to translate */
76 unsigned FileMax; /* Maximum count of files */
77 char** Files; /* The files */
80 /* Command descriptors for the different programs */
81 static CmdDesc CC65 = { 0, 0, 0, 0, 0, 0, 0 };
82 static CmdDesc CA65 = { 0, 0, 0, 0, 0, 0, 0 };
83 static CmdDesc LD65 = { 0, 0, 0, 0, 0, 0, 0 };
84 static CmdDesc GRC = { 0, 0, 0, 0, 0, 0, 0 };
93 FILETYPE_GR /* GEOS resource file */
96 /* Default file type, used if type unknown */
97 static unsigned DefaultFileType = FILETYPE_UNKNOWN;
99 /* Variables controlling the steps we're doing */
100 static int DontLink = 0;
101 static int DontAssemble = 0;
103 /* The name of the output file, NULL if none given */
104 static const char* OutputName = 0;
106 /* The name of the linker configuration file if given */
107 static const char* LinkerConfig = 0;
109 /* The name of the first input file. This will be used to construct the
110 * executable file name if no explicit name is given.
112 static const char* FirstInput = 0;
114 /* Remember if we should link a module */
115 static int Module = 0;
117 /* Name of the crt0 object file and the runtime library */
118 static char* TargetCRT0 = 0;
119 static char* TargetLib = 0;
123 /*****************************************************************************/
124 /* Determine a file type */
125 /*****************************************************************************/
129 static unsigned GetFileType (const char* File)
130 /* Determine the type of the given file */
132 /* Table mapping extensions to file types */
133 static const struct {
137 { ".c", FILETYPE_C },
138 { ".s", FILETYPE_ASM },
139 { ".asm", FILETYPE_ASM },
140 { ".a65", FILETYPE_ASM },
141 { ".o", FILETYPE_OBJ },
142 { ".obj", FILETYPE_OBJ },
143 { ".a", FILETYPE_LIB },
144 { ".lib", FILETYPE_LIB },
145 { ".grc", FILETYPE_GR },
150 /* Determine the file type by the extension */
151 const char* Ext = FindExt (File);
153 /* Do we have an extension? */
155 return DefaultFileType;
158 /* Check for known extensions */
159 for (I = 0; I < sizeof (FileTypes) / sizeof (FileTypes [0]); ++I) {
160 if (strcmp (FileTypes [I].Ext, Ext) == 0) {
162 return FileTypes [I].Type;
166 /* Not found, return the default */
167 return DefaultFileType;
172 /*****************************************************************************/
173 /* Command structure handling */
174 /*****************************************************************************/
178 static void CmdAddArg (CmdDesc* Cmd, const char* Arg)
179 /* Add a new argument to the command */
181 /* Expand the argument vector if needed */
182 if (Cmd->ArgCount == Cmd->ArgMax) {
183 unsigned NewMax = Cmd->ArgMax + 10;
184 char** NewArgs = xmalloc (NewMax * sizeof (char*));
185 memcpy (NewArgs, Cmd->Args, Cmd->ArgMax * sizeof (char*));
188 Cmd->ArgMax = NewMax;
191 /* Add a copy of the new argument, allow a NULL pointer */
193 Cmd->Args [Cmd->ArgCount++] = xstrdup (Arg);
195 Cmd->Args [Cmd->ArgCount++] = 0;
201 static void CmdDelArgs (CmdDesc* Cmd, unsigned LastValid)
202 /* Remove all arguments with an index greater than LastValid */
204 while (Cmd->ArgCount > LastValid) {
206 xfree (Cmd->Args [Cmd->ArgCount]);
207 Cmd->Args [Cmd->ArgCount] = 0;
213 static void CmdAddFile (CmdDesc* Cmd, const char* File)
214 /* Add a new file to the command */
216 /* Expand the file vector if needed */
217 if (Cmd->FileCount == Cmd->FileMax) {
218 unsigned NewMax = Cmd->FileMax + 10;
219 char** NewFiles = xmalloc (NewMax * sizeof (char*));
220 memcpy (NewFiles, Cmd->Files, Cmd->FileMax * sizeof (char*));
222 Cmd->Files = NewFiles;
223 Cmd->FileMax = NewMax;
226 /* If the file name is not NULL (which is legal and is used to terminate
227 * the file list), check if the file name does already exist in the file
228 * list and print a warning if so. Regardless of the search result, add
233 for (I = 0; I < Cmd->FileCount; ++I) {
234 if (strcmp (Cmd->Files[I], File) == 0) {
236 Warning ("Duplicate file in argument list: `%s'", File);
237 /* No need to search further */
243 Cmd->Files [Cmd->FileCount++] = xstrdup (File);
245 /* Add a NULL pointer */
246 Cmd->Files [Cmd->FileCount++] = 0;
252 static void CmdInit (CmdDesc* Cmd, const char* Path)
253 /* Initialize the command using the given path to the executable */
255 /* Remember the command */
256 Cmd->Name = xstrdup (Path);
258 /* Use the command name as first argument */
259 CmdAddArg (Cmd, Path);
264 static void CmdSetOutput (CmdDesc* Cmd, const char* File)
265 /* Set the output file in a command desc */
267 CmdAddArg (Cmd, "-o");
268 CmdAddArg (Cmd, File);
273 static void CmdSetTarget (CmdDesc* Cmd, target_t Target)
274 /* Set the output file in a command desc */
276 CmdAddArg (Cmd, "-t");
277 CmdAddArg (Cmd, TargetNames[Target]);
282 /*****************************************************************************/
283 /* Target handling */
284 /*****************************************************************************/
288 static void SetTargetFiles (void)
289 /* Set the target system files */
291 /* Determine the names of the default startup and library file */
292 if (Target != TGT_NONE) {
294 /* Get a pointer to the system name and its length */
295 const char* TargetName = TargetNames [Target];
296 unsigned TargetNameLen = strlen (TargetName);
298 /* Set the startup file */
299 TargetCRT0 = xmalloc (TargetNameLen + 2 + 1);
300 strcpy (TargetCRT0, TargetName);
301 strcat (TargetCRT0, ".o");
303 /* Set the library file */
304 TargetLib = xmalloc (TargetNameLen + 4 + 1);
305 strcpy (TargetLib, TargetName);
306 strcat (TargetLib, ".lib");
313 /*****************************************************************************/
315 /*****************************************************************************/
319 static void ExecProgram (CmdDesc* Cmd)
320 /* Execute a subprocess with the given name/parameters. Exit on errors. */
322 /* Call the program */
323 int Status = spawnvp (P_WAIT, Cmd->Name, Cmd->Args);
325 /* Check the result code */
327 /* Error executing the program */
328 Error ("Cannot execute `%s': %s", Cmd->Name, strerror (errno));
329 } else if (Status != 0) {
330 /* Called program had an error */
337 static void Link (void)
338 /* Link the resulting executable */
342 /* If we have a linker config file given, add it to the command line.
343 * Otherwise pass the target to the linker if we have one.
347 Error ("Cannot use -C and --module together");
349 CmdAddArg (&LD65, "-C");
350 CmdAddArg (&LD65, LinkerConfig);
352 CmdSetTarget (&LD65, TGT_MODULE);
353 } else if (Target != TGT_NONE) {
354 CmdSetTarget (&LD65, Target);
357 /* Determine which target libraries are needed */
360 /* Since linking is always the final step, if we have an output file name
361 * given, set it here. If we don't have an explicit output name given,
362 * try to build one from the name of the first input file.
366 CmdAddArg (&LD65, "-o");
367 CmdAddArg (&LD65, OutputName);
369 } else if (FirstInput && FindExt (FirstInput)) { /* Only if ext present! */
371 char* Output = MakeFilename (FirstInput, "");
372 CmdAddArg (&LD65, "-o");
373 CmdAddArg (&LD65, Output);
378 /* If we have a startup file, add its name as a parameter */
380 CmdAddArg (&LD65, TargetCRT0);
383 /* Add all object files as parameters */
384 for (I = 0; I < LD65.FileCount; ++I) {
385 CmdAddArg (&LD65, LD65.Files [I]);
388 /* Add the system runtime library */
390 CmdAddArg (&LD65, TargetLib);
393 /* Terminate the argument list with a NULL pointer */
394 CmdAddArg (&LD65, 0);
396 /* Call the linker */
402 static void Assemble (const char* File)
403 /* Assemble the given file */
405 /* Remember the current assembler argument count */
406 unsigned ArgCount = CA65.ArgCount;
408 /* Set the target system */
409 CmdSetTarget (&CA65, Target);
411 /* If we won't link, this is the final step. In this case, set the
414 if (DontLink && OutputName) {
415 CmdSetOutput (&CA65, OutputName);
417 /* The object file name will be the name of the source file
418 * with .s replaced by ".o". Add this file to the list of
421 char* ObjName = MakeFilename (File, ".o");
422 CmdAddFile (&LD65, ObjName);
426 /* Add the file as argument for the assembler */
427 CmdAddArg (&CA65, File);
429 /* Add a NULL pointer to terminate the argument list */
430 CmdAddArg (&CA65, 0);
432 /* Run the assembler */
435 /* Remove the excess arguments */
436 CmdDelArgs (&CA65, ArgCount);
441 static void Compile (const char* File)
442 /* Compile the given file */
446 /* Remember the current assembler argument count */
447 unsigned ArgCount = CC65.ArgCount;
449 /* Set the target system */
450 CmdSetTarget (&CC65, Target);
452 /* If we won't link, this is the final step. In this case, set the
455 if (DontAssemble && OutputName) {
456 CmdSetOutput (&CC65, OutputName);
458 /* The assembler file name will be the name of the source file
459 * with .c replaced by ".s".
461 AsmName = MakeFilename (File, ".s");
464 /* Add the file as argument for the compiler */
465 CmdAddArg (&CC65, File);
467 /* Add a NULL pointer to terminate the argument list */
468 CmdAddArg (&CC65, 0);
470 /* Run the compiler */
473 /* Remove the excess arguments */
474 CmdDelArgs (&CC65, ArgCount);
476 /* If this is not the final step, assemble the generated file, then
481 if (remove (AsmName) < 0) {
482 Warning ("Cannot remove temporary file `%s': %s",
483 AsmName, strerror (errno));
491 static void CompileRes (const char* File)
492 /* Compile the given geos resource file */
496 /* Remember the current assembler argument count */
497 unsigned ArgCount = GRC.ArgCount;
499 /* The assembler file name will be the name of the source file
500 * with .grc replaced by ".s".
502 AsmName = MakeFilename (File, ".s");
504 /* Add the file as argument for the resource compiler */
505 CmdAddArg (&GRC, File);
507 /* Add a NULL pointer to terminate the argument list */
510 /* Run the compiler */
513 /* Remove the excess arguments */
514 CmdDelArgs (&GRC, ArgCount);
516 /* If this is not the final step, assemble the generated file, then
521 if (remove (AsmName) < 0) {
522 Warning ("Cannot remove temporary file `%s': %s",
523 AsmName, strerror (errno));
527 /* Free the assembler file name which was allocated from the heap */
533 /*****************************************************************************/
535 /*****************************************************************************/
539 static void Usage (void)
540 /* Print usage information and exit */
543 "Usage: %s [options] file\n"
545 " -c\t\t\tCompiler and assemble but don't link\n"
546 " -d\t\t\tDebug mode\n"
547 " -g\t\t\tAdd debug info\n"
548 " -h\t\t\tHelp (this text)\n"
549 " -l\t\t\tCreate an assembler listing\n"
550 " -m name\t\tCreate a map file\n"
551 " -o name\t\tName the output file\n"
552 " -t sys\t\tSet the target system\n"
553 " -v\t\t\tVerbose mode\n"
554 " -vm\t\t\tVerbose map file\n"
555 " -A\t\t\tStrict ANSI mode\n"
556 " -C name\t\tUse linker config file\n"
557 " -Cl\t\t\tMake local variables static\n"
558 " -D sym[=defn]\t\tDefine a preprocessor symbol\n"
559 " -I dir\t\tSet a compiler include directory path\n"
560 " -Ln name\t\tCreate a VICE label file\n"
561 " -O\t\t\tOptimize code\n"
562 " -Oi\t\t\tOptimize code, inline functions\n"
563 " -Or\t\t\tOptimize code, honour the register keyword\n"
564 " -Os\t\t\tOptimize code, inline known C funtions\n"
565 " -S\t\t\tCompile but don't assemble and link\n"
566 " -T\t\t\tInclude source as comment\n"
567 " -V\t\t\tPrint the version number\n"
568 " -W\t\t\tSuppress warnings\n"
571 " --add-source\t\tInclude source as comment\n"
572 " --ansi\t\tStrict ANSI mode\n"
573 " --asm-include-dir dir\tSet an assembler include directory\n"
574 " --bss-name seg\tSet the name of the BSS segment\n"
575 " --check-stack\t\tGenerate stack overflow checks\n"
576 " --code-name seg\tSet the name of the CODE segment\n"
577 " --codesize x\t\tAccept larger code by factor x\n"
578 " --cpu type\t\tSet cpu type\n"
579 " --create-dep\t\tCreate a make dependency file\n"
580 " --data-name seg\tSet the name of the DATA segment\n"
581 " --debug\t\tDebug mode\n"
582 " --debug-info\t\tAdd debug info\n"
583 " --feature name\tSet an emulation feature\n"
584 " --help\t\tHelp (this text)\n"
585 " --include-dir dir\tSet a compiler include directory path\n"
586 " --listing\t\tCreate an assembler listing\n"
587 " --mapfile name\tCreate a map file\n"
588 " --module\t\tLink as a module\n"
589 " --module-id id\tSpecify a module id for the linker\n"
590 " --rodata-name seg\tSet the name of the RODATA segment\n"
591 " --signed-chars\tDefault characters are signed\n"
592 " --start-addr addr\tSet the default start address\n"
593 " --static-locals\tMake local variables static\n"
594 " --target sys\t\tSet the target system\n"
595 " --version\t\tPrint the version number\n"
596 " --verbose\t\tVerbose mode\n",
602 static void OptAddSource (const char* Opt attribute ((unused)),
603 const char* Arg attribute ((unused)))
604 /* Strict source code as comments to the generated asm code */
606 CmdAddArg (&CC65, "-T");
611 static void OptAnsi (const char* Opt attribute ((unused)),
612 const char* Arg attribute ((unused)))
613 /* Strict ANSI mode (compiler) */
615 CmdAddArg (&CC65, "-A");
620 static void OptAsmIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
621 /* Include directory (assembler) */
623 CmdAddArg (&CA65, "-I");
624 CmdAddArg (&CA65, Arg);
629 static void OptBssName (const char* Opt attribute ((unused)), const char* Arg)
630 /* Handle the --bss-name option */
632 CmdAddArg (&CC65, "--bss-name");
633 CmdAddArg (&CC65, Arg);
638 static void OptCheckStack (const char* Opt attribute ((unused)),
639 const char* Arg attribute ((unused)))
640 /* Handle the --check-stack option */
642 CmdAddArg (&CC65, "--check-stack");
647 static void OptCodeName (const char* Opt attribute ((unused)), const char* Arg)
648 /* Handle the --code-name option */
650 CmdAddArg (&CC65, "--code-name");
651 CmdAddArg (&CC65, Arg);
656 static void OptCodeSize (const char* Opt attribute ((unused)), const char* Arg)
657 /* Handle the --codesize option */
659 CmdAddArg (&CC65, "--codesize");
660 CmdAddArg (&CC65, Arg);
665 static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
666 /* Handle the --cpu option */
668 /* Add the cpu type to the assembler and compiler */
669 CmdAddArg (&CA65, "--cpu");
670 CmdAddArg (&CA65, Arg);
671 CmdAddArg (&CC65, "--cpu");
672 CmdAddArg (&CC65, Arg);
677 static void OptCreateDep (const char* Opt attribute ((unused)),
678 const char* Arg attribute ((unused)))
679 /* Handle the --create-dep option */
681 CmdAddArg (&CC65, "--create-dep");
686 static void OptDataName (const char* Opt attribute ((unused)), const char* Arg)
687 /* Handle the --data-name option */
689 CmdAddArg (&CC65, "--data-name");
690 CmdAddArg (&CC65, Arg);
695 static void OptDebug (const char* Opt attribute ((unused)),
696 const char* Arg attribute ((unused)))
697 /* Debug mode (compiler) */
699 CmdAddArg (&CC65, "-d");
704 static void OptDebugInfo (const char* Opt attribute ((unused)),
705 const char* Arg attribute ((unused)))
706 /* Debug Info - add to compiler and assembler */
708 CmdAddArg (&CC65, "-g");
709 CmdAddArg (&CA65, "-g");
714 static void OptFeature (const char* Opt attribute ((unused)), const char* Arg)
715 /* Emulation features for the assembler */
717 CmdAddArg (&CA65, "--feature");
718 CmdAddArg (&CA65, Arg);
723 static void OptHelp (const char* Opt attribute ((unused)),
724 const char* Arg attribute ((unused)))
725 /* Print help - cl65 */
733 static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
734 /* Include directory (compiler) */
736 CmdAddArg (&CC65, "-I");
737 CmdAddArg (&CC65, Arg);
742 static void OptListing (const char* Opt attribute ((unused)),
743 const char* Arg attribute ((unused)))
744 /* Create an assembler listing */
746 CmdAddArg (&CA65, "-l");
751 static void OptMapFile (const char* Opt attribute ((unused)), const char* Arg)
752 /* Create a map file */
754 /* Create a map file (linker) */
755 CmdAddArg (&LD65, "-m");
756 CmdAddArg (&LD65, Arg);
761 static void OptModule (const char* Opt attribute ((unused)),
762 const char* Arg attribute ((unused)))
763 /* Link as a module */
770 static void OptModuleId (const char* Opt attribute ((unused)), const char* Arg)
771 /* Specify a module if for the linker */
773 /* Pass it straight to the linker */
774 CmdAddArg (&LD65, "--module-id");
775 CmdAddArg (&LD65, Arg);
780 static void OptRodataName (const char* Opt attribute ((unused)), const char* Arg)
781 /* Handle the --rodata-name option */
783 CmdAddArg (&CC65, "--rodata-name");
784 CmdAddArg (&CC65, Arg);
789 static void OptSignedChars (const char* Opt attribute ((unused)),
790 const char* Arg attribute ((unused)))
791 /* Make default characters signed */
793 CmdAddArg (&CC65, "-j");
798 static void OptStartAddr (const char* Opt attribute ((unused)), const char* Arg)
799 /* Set the default start address */
801 CmdAddArg (&LD65, "-S");
802 CmdAddArg (&LD65, Arg);
807 static void OptStaticLocals (const char* Opt attribute ((unused)),
808 const char* Arg attribute ((unused)))
809 /* Place local variables in static storage */
811 CmdAddArg (&CC65, "-Cl");
816 static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
817 /* Set the target system */
819 if (Target != TGT_NONE) {
820 Error ("Cannot specify -t twice");
822 Target = FindTarget (Arg);
823 if (Target == TGT_UNKNOWN) {
824 Error ("No such target system: `%s'", Arg);
825 } else if (Target == TGT_MODULE) {
826 Error ("Cannot use `module' as target, use --module instead");
833 static void OptVerbose (const char* Opt attribute ((unused)),
834 const char* Arg attribute ((unused)))
835 /* Verbose mode (compiler, assembler, linker) */
837 CmdAddArg (&CC65, "-v");
838 CmdAddArg (&CA65, "-v");
839 CmdAddArg (&LD65, "-v");
844 static void OptVersion (const char* Opt attribute ((unused)),
845 const char* Arg attribute ((unused)))
846 /* Print version number */
849 "cl65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
850 VER_MAJOR, VER_MINOR, VER_PATCH);
855 int main (int argc, char* argv [])
856 /* Utility main program */
858 /* Program long options */
859 static const LongOpt OptTab[] = {
860 { "--add-source", 0, OptAddSource },
861 { "--ansi", 0, OptAnsi },
862 { "--asm-include-dir", 1, OptAsmIncludeDir },
863 { "--bss-name", 1, OptBssName },
864 { "--check-stack", 0, OptCheckStack },
865 { "--code-name", 1, OptCodeName },
866 { "--codesize", 1, OptCodeSize },
867 { "--cpu", 1, OptCPU },
868 { "--create-dep", 0, OptCreateDep },
869 { "--data-name", 1, OptDataName },
870 { "--debug", 0, OptDebug },
871 { "--debug-info", 0, OptDebugInfo },
872 { "--feature", 1, OptFeature },
873 { "--help", 0, OptHelp },
874 { "--include-dir", 1, OptIncludeDir },
875 { "--listing", 0, OptListing },
876 { "--mapfile", 1, OptMapFile },
877 { "--module", 0, OptModule },
878 { "--module-id", 1, OptModuleId },
879 { "--rodata-name", 1, OptRodataName },
880 { "--signed-chars", 0, OptSignedChars },
881 { "--start-addr", 1, OptStartAddr },
882 { "--static-locals", 0, OptStaticLocals },
883 { "--target", 1, OptTarget },
884 { "--verbose", 0, OptVerbose },
885 { "--version", 0, OptVersion },
890 /* Initialize the cmdline module */
891 InitCmdLine (&argc, &argv, "cl65");
893 /* Initialize the command descriptors */
894 CmdInit (&CC65, "cc65");
895 CmdInit (&CA65, "ca65");
896 CmdInit (&LD65, "ld65");
897 CmdInit (&GRC, "grc");
899 /* Our default target is the C64 instead of "none" */
902 /* Check the parameters */
904 while (I < ArgCount) {
906 /* Get the argument */
907 const char* Arg = ArgVec[I];
909 /* Check for an option */
910 if (Arg [0] == '-') {
915 LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
919 /* Strict ANSI mode (compiler) */
924 if (Arg[2] == 'l' && Arg[3] == '\0') {
925 /* Make local variables static */
926 OptStaticLocals (Arg, 0);
928 /* Specify linker config file */
929 LinkerConfig = GetArg (&I, 2);
934 /* Define a preprocessor symbol (compiler) */
935 CmdAddArg (&CC65, "-D");
936 CmdAddArg (&CC65, GetArg (&I, 2));
940 /* Include directory (compiler) */
941 OptIncludeDir (Arg, GetArg (&I, 2));
946 /* VICE label file (linker) */
947 CmdAddArg (&LD65, "-Ln");
948 CmdAddArg (&LD65, GetArg (&I, 3));
955 /* Optimize code (compiler, also covers -Oi and others) */
956 CmdAddArg (&CC65, Arg);
960 /* Dont assemble and link the created files */
961 DontLink = DontAssemble = 1;
965 /* Include source as comment (compiler) */
966 OptAddSource (Arg, 0);
970 /* Print version number */
975 /* Suppress warnings - compiler and assembler */
976 CmdAddArg (&CC65, "-W");
977 CmdAddArg (&CA65, "-W");
978 CmdAddArg (&CA65, "0");
982 /* Don't link the resulting files */
987 /* Debug mode (compiler) */
992 /* Debugging - add to compiler and assembler */
993 OptDebugInfo (Arg, 0);
998 /* Print help - cl65 */
1003 /* Default characters are signed */
1004 OptSignedChars (Arg, 0);
1008 /* Create an assembler listing */
1009 OptListing (Arg, 0);
1013 /* Create a map file (linker) */
1014 OptMapFile (Arg, GetArg (&I, 2));
1018 /* Name the output file */
1019 OutputName = GetArg (&I, 2);
1023 /* Set target system - compiler, assembler and linker */
1024 OptTarget (Arg, GetArg (&I, 2));
1028 if (Arg [2] == 'm') {
1029 /* Verbose map file (linker) */
1030 CmdAddArg (&LD65, "-vm");
1032 /* Verbose mode (compiler, assembler, linker) */
1033 OptVerbose (Arg, 0);
1038 UnknownOption (Arg);
1042 /* Remember the first file name */
1043 if (FirstInput == 0) {
1047 /* Determine the file type by the extension */
1048 switch (GetFileType (Arg)) {
1051 /* Compile the file */
1056 /* Assemble the file */
1057 if (!DontAssemble) {
1064 /* Add to the linker files */
1065 CmdAddFile (&LD65, Arg);
1069 /* Add to the resource compiler files */
1074 Error ("Don't know what to do with `%s'", Arg);
1084 /* Check if we had any input files */
1085 if (FirstInput == 0) {
1086 Warning ("No input files");
1089 /* Link the given files if requested and if we have any */
1090 if (DontLink == 0 && LD65.FileCount > 0) {
1094 /* Return an apropriate exit code */
1095 return EXIT_SUCCESS;