/*****************************************************************************/
/* */
-/* main.c */
+/* main.c */
/* */
/* Main program for the co65 object file converter */
/* */
/* */
/* */
-/* (C) 2003 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2003-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
static void Usage (void)
/* Print usage information and exit */
{
- fprintf (stderr,
- "Usage: %s [options] file\n"
- "Short options:\n"
- " -V\t\t\tPrint the version number\n"
- " -g\t\t\tAdd debug info to object file\n"
- " -h\t\t\tHelp (this text)\n"
- " -m model\t\tOverride the o65 model\n"
- " -n\t\t\tDon't generate an output file\n"
- " -o name\t\tName the output file\n"
- " -v\t\t\tIncrease verbosity\n"
- "\n"
- "Long options:\n"
- " --bss-label name\tDefine and export a BSS segment label\n"
- " --bss-name seg\tSet the name of the BSS segment\n"
- " --code-label name\tDefine and export a CODE segment label\n"
- " --code-name seg\tSet the name of the CODE segment\n"
- " --data-label name\tDefine and export a DATA segment label\n"
- " --data-name seg\tSet the name of the DATA segment\n"
- " --debug-info\t\tAdd debug info to object file\n"
- " --help\t\tHelp (this text)\n"
- " --no-output\t\tDon't generate an output file\n"
- " --o65-model model\tOverride the o65 model\n"
- " --verbose\t\tIncrease verbosity\n"
- " --version\t\tPrint the version number\n"
- " --zeropage-label name\tDefine and export a ZEROPAGE segment label\n"
- " --zeropage-name seg\tSet the name of the ZEROPAGE segment\n",
- ProgName);
+ printf ("Usage: %s [options] file\n"
+ "Short options:\n"
+ " -V\t\t\tPrint the version number\n"
+ " -g\t\t\tAdd debug info to object file\n"
+ " -h\t\t\tHelp (this text)\n"
+ " -m model\t\tOverride the o65 model\n"
+ " -n\t\t\tDon't generate an output file\n"
+ " -o name\t\tName the output file\n"
+ " -v\t\t\tIncrease verbosity\n"
+ "\n"
+ "Long options:\n"
+ " --bss-label name\tDefine and export a BSS segment label\n"
+ " --bss-name seg\tSet the name of the BSS segment\n"
+ " --code-label name\tDefine and export a CODE segment label\n"
+ " --code-name seg\tSet the name of the CODE segment\n"
+ " --data-label name\tDefine and export a DATA segment label\n"
+ " --data-name seg\tSet the name of the DATA segment\n"
+ " --debug-info\t\tAdd debug info to object file\n"
+ " --help\t\tHelp (this text)\n"
+ " --no-output\t\tDon't generate an output file\n"
+ " --o65-model model\tOverride the o65 model\n"
+ " --verbose\t\tIncrease verbosity\n"
+ " --version\t\tPrint the version number\n"
+ " --zeropage-label name\tDefine and export a ZEROPAGE segment label\n"
+ " --zeropage-name seg\tSet the name of the ZEROPAGE segment\n",
+ ProgName);
}
{
/* Print an error and abort if the name is not ok */
if (!ValidSegName (Seg)) {
- Error ("Segment name `%s' is invalid", Seg);
+ Error ("Segment name `%s' is invalid", Seg);
}
}
static void OptDebug (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+ const char* Arg attribute ((unused)))
/* Enable debugging code */
{
++Debug;
static void OptDebugInfo (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+ const char* Arg attribute ((unused)))
/* Add debug info to the object file */
{
DebugInfo = 1;
static void OptHelp (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+ const char* Arg attribute ((unused)))
/* Print usage information and exit */
{
Usage ();
static void OptNoOutput (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+ const char* Arg attribute ((unused)))
/* Handle the --no-output option */
{
NoOutput = 1;
static void OptVerbose (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+ const char* Arg attribute ((unused)))
/* Increase verbosity */
{
++Verbosity;
static void OptVersion (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
+ const char* Arg attribute ((unused)))
/* Print the assembler version */
{
- fprintf (stderr,
- "co65 V%u.%u.%u - (C) Copyright 1998-2003 Ullrich von Bassewitz\n",
- VER_MAJOR, VER_MINOR, VER_PATCH);
+ fprintf (stderr, "co65 V%s\n", GetVersionAsString ());
}
{
/* Program long options */
static const LongOpt OptTab[] = {
- { "--bss-label", 1, OptBssLabel },
- { "--bss-name", 1, OptBssName },
- { "--code-label", 1, OptCodeLabel },
- { "--code-name", 1, OptCodeName },
- { "--data-label", 1, OptDataLabel },
- { "--data-name", 1, OptDataName },
- { "--debug", 0, OptDebug },
- { "--debug-info", 0, OptDebugInfo },
- { "--help", 0, OptHelp },
- { "--no-output", 0, OptNoOutput },
+ { "--bss-label", 1, OptBssLabel },
+ { "--bss-name", 1, OptBssName },
+ { "--code-label", 1, OptCodeLabel },
+ { "--code-name", 1, OptCodeName },
+ { "--data-label", 1, OptDataLabel },
+ { "--data-name", 1, OptDataName },
+ { "--debug", 0, OptDebug },
+ { "--debug-info", 0, OptDebugInfo },
+ { "--help", 0, OptHelp },
+ { "--no-output", 0, OptNoOutput },
{ "--o65-model", 1, OptO65Model },
- { "--verbose", 0, OptVerbose },
- { "--version", 0, OptVersion },
- { "--zeropage-label", 1, OptZeropageLabel },
- { "--zeropage-name", 1, OptZeropageName },
+ { "--verbose", 0, OptVerbose },
+ { "--version", 0, OptVersion },
+ { "--zeropage-label", 1, OptZeropageLabel },
+ { "--zeropage-name", 1, OptZeropageName },
};
unsigned I;
I = 1;
while (I < ArgCount) {
- /* Get the argument */
- const char* Arg = ArgVec [I];
+ /* Get the argument */
+ const char* Arg = ArgVec [I];
- /* Check for an option */
- if (Arg [0] == '-') {
- switch (Arg [1]) {
+ /* Check for an option */
+ if (Arg [0] == '-') {
+ switch (Arg [1]) {
- case '-':
- LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
- break;
+ case '-':
+ LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
+ break;
- case 'g':
- OptDebugInfo (Arg, 0);
- break;
+ case 'g':
+ OptDebugInfo (Arg, 0);
+ break;
- case 'h':
- OptHelp (Arg, 0);
- break;
+ case 'h':
+ OptHelp (Arg, 0);
+ break;
case 'm':
OptO65Model (Arg, GetArg (&I, 2));
OptNoOutput (Arg, 0);
break;
- case 'o':
- OutputName = GetArg (&I, 2);
- break;
-
- case 'v':
- OptVerbose (Arg, 0);
- break;
-
- case 'V':
- OptVersion (Arg, 0);
- break;
-
- default:
- UnknownOption (Arg);
- break;
-
- }
- } else {
- /* Filename. Check if we already had one */
- if (InputName) {
- Error ("Don't know what to do with `%s'\n", Arg);
- } else {
- InputName = Arg;
- }
- }
-
- /* Next argument */
- ++I;
+ case 'o':
+ OutputName = GetArg (&I, 2);
+ break;
+
+ case 'v':
+ OptVerbose (Arg, 0);
+ break;
+
+ case 'V':
+ OptVersion (Arg, 0);
+ break;
+
+ default:
+ UnknownOption (Arg);
+ break;
+
+ }
+ } else {
+ /* Filename. Check if we already had one */
+ if (InputName) {
+ Error ("Don't know what to do with `%s'", Arg);
+ } else {
+ InputName = Arg;
+ }
+ }
+
+ /* Next argument */
+ ++I;
}
/* Do we have an input file? */
if (InputName == 0) {
- Error ("No input file\n");
+ Error ("No input file");
}
/* Generate the name of the output file if none was specified */