/* */
/* */
/* */
-/* (C) 2000-2004 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2000-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include "mmodel.h"
#include "print.h"
#include "segnames.h"
+#include "strbuf.h"
#include "target.h"
#include "tgttrans.h"
#include "version.h"
#include "incpath.h"
#include "input.h"
#include "macrotab.h"
+#include "output.h"
#include "scanner.h"
-#include "standard.h"
#include "segments.h"
+#include "standard.h"
+#include "svnversion.h"
cbmsys ("__C128__");
break;
- case TGT_ACE:
- cbmsys ("__ACE__");
- break;
-
case TGT_PLUS4:
cbmsys ("__PLUS4__");
break;
static void OptVersion (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
-/* Print the assembler version */
+ const char* Arg attribute ((unused)))
+/* Print the compiler version */
{
fprintf (stderr,
- "cc65 V%u.%u.%u\n",
- VER_MAJOR, VER_MINOR, VER_PATCH);
+ "cc65 V%s\nSVN version: %s\n",
+ GetVersionAsString (), SVNVersion);
+ exit (EXIT_SUCCESS);
+}
+
+
+
+static void OptWarning (const char* Opt attribute ((unused)), const char* Arg)
+/* Handle the -W option */
+{
+ StrBuf W = AUTO_STRBUF_INITIALIZER;
+
+ /* Arg is a list of suboptions, separated by commas */
+ while (Arg) {
+
+ const char* Pos;
+ int Enabled = 1;
+ IntStack* S;
+
+ /* The suboption may be prefixed with '-' or '+' */
+ if (*Arg == '-') {
+ Enabled = 0;
+ ++Arg;
+ } else if (*Arg == '+') {
+ /* This is the default */
+ ++Arg;
+ }
+
+ /* Get the next suboption */
+ Pos = strchr (Arg, ',');
+ if (Pos) {
+ SB_CopyBuf (&W, Arg, Pos - Arg);
+ Arg = Pos + 1;
+ } else {
+ SB_CopyStr (&W, Arg);
+ Arg = 0;
+ }
+ SB_Terminate (&W);
+
+ /* Search for the warning */
+ S = FindWarning (SB_GetConstBuf (&W));
+ if (S == 0) {
+ InvArg (Opt, SB_GetConstBuf (&W));
+ }
+ IS_Set (S, Enabled);
+ }
+
+ /* Free allocated memory */
+ SB_Done (&W);
}
unsigned I;
- /* Initialize the output file name */
- const char* OutputFile = 0;
+ /* Initialize the input file name */
const char* InputFile = 0;
/* Initialize the cmdline module */
const char* Arg = ArgVec[I];
/* Check for an option */
- if (Arg [0] == '-') {
+ if (Arg[0] == '-') {
- switch (Arg [1]) {
+ switch (Arg[1]) {
case '-':
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
break;
case 'o':
- OutputFile = GetArg (&I, 2);
+ SetOutputName (GetArg (&I, 2));
break;
case 'r':
default:
UnknownOption (Arg);
break;
- }
+ }
}
break;
break;
case 'W':
- IS_Set (&WarnDisable, 1);
+ OptWarning (Arg, GetArg (&I, 2));
break;
default:
}
/* Create the output file name if it was not explicitly given */
- if (OutputFile == 0) {
- OutputFile = MakeFilename (InputFile, ".s");
- }
+ MakeDefaultOutputName (InputFile);
/* If no CPU given, use the default CPU for the target */
if (CPU == CPU_UNKNOWN) {
Compile (InputFile);
/* Create the output file if we didn't had any errors */
- if (ErrorCount == 0 || Debug) {
+ if (PreprocessOnly == 0 && (ErrorCount == 0 || Debug)) {
/* Open the file */
- FILE* F = fopen (OutputFile, "w");
- if (F == 0) {
- Fatal ("Cannot open output file `%s': %s", OutputFile, strerror (errno));
- }
- Print (stdout, 1, "Opened output file `%s'\n", OutputFile);
+ OpenOutputFile ();
/* Write the output to the file */
- WriteOutput (F);
- Print (stdout, 1, "Wrote output to `%s'\n", OutputFile);
+ WriteAsmOutput ();
+ Print (stdout, 1, "Wrote output to `%s'\n", OutputFilename);
/* Close the file, check for errors */
- if (fclose (F) != 0) {
- remove (OutputFile);
- Fatal ("Cannot write to output file (disk full?)");
- }
- Print (stdout, 1, "Closed output file `%s'\n", OutputFile);
+ CloseOutputFile ();
/* Create dependencies if requested */
if (CreateDep) {
- DoCreateDep (OutputFile);
+ DoCreateDep (OutputFilename);
Print (stdout, 1, "Creating dependeny file\n");
}