mirror of
https://github.com/cc65/cc65.git
synced 2024-06-08 15:29:37 +00:00
Added long options. Added --asm-include-dir to set the include path for
the assembler. git-svn-id: svn://svn.cc65.org/cc65/trunk@13 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
78057df08b
commit
bca9ccd5b8
265
src/cl65/main.c
265
src/cl65/main.c
|
@ -586,7 +586,7 @@ static void Compile (const char* File)
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
@ -596,29 +596,40 @@ static void Usage (void)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Usage: %s [options] file\n"
|
"Usage: %s [options] file\n"
|
||||||
"Options:\n"
|
"Short options:\n"
|
||||||
"\t-A\t\tStrict ANSI mode\n"
|
" -A\t\t\tStrict ANSI mode\n"
|
||||||
"\t-C name\t\tUse linker config file\n"
|
" -C name\t\tUse linker config file\n"
|
||||||
"\t-Cl\t\tMake local variables static\n"
|
" -Cl\t\t\tMake local variables static\n"
|
||||||
"\t-D sym[=defn]\tDefine a preprocessor symbol\n"
|
" -D sym[=defn]\t\tDefine a preprocessor symbol\n"
|
||||||
"\t-I path\t\tSet an include directory path\n"
|
" -I dir\t\tSet a compiler include directory path\n"
|
||||||
"\t-Ln name\tCreate a VICE label file\n"
|
" -Ln name\t\tCreate a VICE label file\n"
|
||||||
"\t-O\t\tOptimize code\n"
|
" -O\t\t\tOptimize code\n"
|
||||||
"\t-Oi\t\tOptimize code, inline functions\n"
|
" -Oi\t\t\tOptimize code, inline functions\n"
|
||||||
"\t-Or\t\tOptimize code, honour the register keyword\n"
|
" -Or\t\t\tOptimize code, honour the register keyword\n"
|
||||||
"\t-Os\t\tOptimize code, inline known C funtions\n"
|
" -Os\t\t\tOptimize code, inline known C funtions\n"
|
||||||
"\t-S\t\tCompile but don't assemble and link\n"
|
" -S\t\t\tCompile but don't assemble and link\n"
|
||||||
"\t-V\t\tPrint the version number\n"
|
" -V\t\t\tPrint the version number\n"
|
||||||
"\t-W\t\tSuppress warnings\n"
|
" -W\t\t\tSuppress warnings\n"
|
||||||
"\t-c\t\tCompiler and assemble but don't link\n"
|
" -c\t\t\tCompiler and assemble but don't link\n"
|
||||||
"\t-d\t\tDebug mode\n"
|
" -d\t\t\tDebug mode\n"
|
||||||
"\t-g\t\tAdd debug info\n"
|
" -g\t\t\tAdd debug info\n"
|
||||||
"\t-h\t\tHelp (this text)\n"
|
" -h\t\t\tHelp (this text)\n"
|
||||||
"\t-m name\t\tCreate a map file\n"
|
" -m name\t\tCreate a map file\n"
|
||||||
"\t-o name\t\tName the output file\n"
|
" -o name\t\tName the output file\n"
|
||||||
"\t-t system\tSet the target system\n"
|
" -t sys\t\tSet the target system\n"
|
||||||
"\t-v\t\tVerbose mode\n"
|
" -v\t\t\tVerbose mode\n"
|
||||||
"\t-vm\t\tVerbose map file\n",
|
" -vm\t\t\tVerbose map file\n"
|
||||||
|
"\n"
|
||||||
|
"Long options:\n"
|
||||||
|
" --ansi\t\tStrict ANSI mode\n"
|
||||||
|
" --asm-include-dir dir\tSet an assembler include directory\n"
|
||||||
|
" --debug\t\tDebug mode\n"
|
||||||
|
" --debug-info\t\tAdd debug info\n"
|
||||||
|
" --help\t\tHelp (this text)\n"
|
||||||
|
" --include-dir dir\tSet a compiler include directory path\n"
|
||||||
|
" --version\t\tPrint the version number\n"
|
||||||
|
" --target sys\t\tSet the target system\n"
|
||||||
|
" --verbose\t\tVerbose mode\n",
|
||||||
ProgName);
|
ProgName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +657,7 @@ static const char* GetArg (int* ArgNum, char* argv [], unsigned Len)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ArgError (const char* Arg)
|
static void UnknownOption (const char* Arg)
|
||||||
/* Print an error about a wrong argument */
|
/* Print an error about a wrong argument */
|
||||||
{
|
{
|
||||||
Error ("Unknown option: `%s', use -h for help", Arg);
|
Error ("Unknown option: `%s', use -h for help", Arg);
|
||||||
|
@ -654,6 +665,137 @@ static void ArgError (const char* Arg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void NeedArg (const char* Arg)
|
||||||
|
/* Print an error about a missing option argument and exit. */
|
||||||
|
{
|
||||||
|
Error ("Option requires an argument: %s\n", Arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptAnsi (const char* Opt)
|
||||||
|
/* Strict ANSI mode (compiler) */
|
||||||
|
{
|
||||||
|
CmdAddArg (&CC65, "-A");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptAsmIncludeDir (const char* Opt, const char* Arg)
|
||||||
|
/* Include directory (assembler) */
|
||||||
|
{
|
||||||
|
if (Arg == 0) {
|
||||||
|
NeedArg (Opt);
|
||||||
|
}
|
||||||
|
CmdAddArg (&CA65, "-I");
|
||||||
|
CmdAddArg (&CA65, Arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptDebug (const char* Opt)
|
||||||
|
/* Debug mode (compiler) */
|
||||||
|
{
|
||||||
|
CmdAddArg (&CC65, "-d");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptDebugInfo (const char* Opt)
|
||||||
|
/* Debug Info - add to compiler and assembler */
|
||||||
|
{
|
||||||
|
CmdAddArg (&CC65, "-g");
|
||||||
|
CmdAddArg (&CA65, "-g");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptHelp (const char* Opt)
|
||||||
|
/* Print help - cl65 */
|
||||||
|
{
|
||||||
|
Usage ();
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptIncludeDir (const char* Opt, const char* Arg)
|
||||||
|
/* Include directory (compiler) */
|
||||||
|
{
|
||||||
|
if (Arg == 0) {
|
||||||
|
NeedArg (Opt);
|
||||||
|
}
|
||||||
|
CmdAddArg (&CC65, "-I");
|
||||||
|
CmdAddArg (&CC65, Arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptTarget (const char* Opt, const char* Arg)
|
||||||
|
/* Set the target system */
|
||||||
|
{
|
||||||
|
if (Arg == 0) {
|
||||||
|
NeedArg (Opt);
|
||||||
|
}
|
||||||
|
SetTargetByName (Arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptVerbose (const char* Opt)
|
||||||
|
/* Verbose mode (compiler, assembler, linker) */
|
||||||
|
{
|
||||||
|
CmdAddArg (&CC65, "-v");
|
||||||
|
CmdAddArg (&CA65, "-v");
|
||||||
|
CmdAddArg (&LD65, "-v");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void OptVersion (const char* Opt)
|
||||||
|
/* Print version number */
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"cl65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
|
||||||
|
VER_MAJOR, VER_MINOR, VER_PATCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void LongOption (int* ArgNum, char* argv [])
|
||||||
|
/* Handle a long command line option */
|
||||||
|
{
|
||||||
|
const char* Opt = argv [*ArgNum];
|
||||||
|
const char* Arg = argv [*ArgNum+1];
|
||||||
|
|
||||||
|
if (strcmp (Opt, "--ansi") == 0) {
|
||||||
|
OptAnsi (Opt);
|
||||||
|
} else if (strcmp (Opt, "--asm-include-dir") == 0) {
|
||||||
|
OptAsmIncludeDir (Opt, Arg);
|
||||||
|
++(*ArgNum);
|
||||||
|
} else if (strcmp (Opt, "--debug") == 0) {
|
||||||
|
OptDebug (Opt);
|
||||||
|
} else if (strcmp (Opt, "--debug-info") == 0) {
|
||||||
|
OptDebugInfo (Opt);
|
||||||
|
} else if (strcmp (Opt, "--help") == 0) {
|
||||||
|
OptHelp (Opt);
|
||||||
|
} else if (strcmp (Opt, "--include-dir") == 0) {
|
||||||
|
OptIncludeDir (Opt, Arg);
|
||||||
|
++(*ArgNum);
|
||||||
|
} else if (strcmp (Opt, "--target") == 0) {
|
||||||
|
OptTarget (Opt, Arg);
|
||||||
|
++(*ArgNum);
|
||||||
|
} else if (strcmp (Opt, "--verbose") == 0) {
|
||||||
|
OptVerbose (Opt);
|
||||||
|
} else if (strcmp (Opt, "--version") == 0) {
|
||||||
|
OptVersion (Opt);
|
||||||
|
} else {
|
||||||
|
UnknownOption (Opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char* argv [])
|
int main (int argc, char* argv [])
|
||||||
/* Utility main program */
|
/* Utility main program */
|
||||||
{
|
{
|
||||||
|
@ -676,13 +818,17 @@ int main (int argc, char* argv [])
|
||||||
|
|
||||||
switch (Arg [1]) {
|
switch (Arg [1]) {
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
LongOption (&I, argv);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'A':
|
case 'A':
|
||||||
/* Strict ANSI mode (compiler) */
|
/* Strict ANSI mode (compiler) */
|
||||||
CmdAddArg (&CC65, "-A");
|
OptAnsi (Arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (Arg[2] == 'l' && Arg[3] == '\0') {
|
if (Arg[2] == 'l' && Arg[3] == '\0') {
|
||||||
/* Make local variables static */
|
/* Make local variables static */
|
||||||
CmdAddArg (&CC65, "-Cl");
|
CmdAddArg (&CC65, "-Cl");
|
||||||
} else {
|
} else {
|
||||||
|
@ -699,17 +845,16 @@ int main (int argc, char* argv [])
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
/* Include directory (compiler) */
|
/* Include directory (compiler) */
|
||||||
CmdAddArg (&CC65, "-I");
|
OptIncludeDir (Arg, GetArg (&I, argv, 2));
|
||||||
CmdAddArg (&CC65, GetArg (&I, argv, 2));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
if (Arg[2] == 'n') {
|
if (Arg[2] == 'n') {
|
||||||
/* VICE label file (linker) */
|
/* VICE label file (linker) */
|
||||||
CmdAddArg (&LD65, "-Ln");
|
CmdAddArg (&LD65, "-Ln");
|
||||||
CmdAddArg (&LD65, GetArg (&I, argv, 3));
|
CmdAddArg (&LD65, GetArg (&I, argv, 3));
|
||||||
} else {
|
} else {
|
||||||
ArgError (Arg);
|
UnknownOption (Arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -723,49 +868,45 @@ int main (int argc, char* argv [])
|
||||||
DontLink = DontAssemble = 1;
|
DontLink = DontAssemble = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
/* Include source as comment (compiler) */
|
/* Include source as comment (compiler) */
|
||||||
CmdAddArg (&CC65, "-T");
|
CmdAddArg (&CC65, "-T");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
/* Print version number */
|
/* Print version number */
|
||||||
fprintf (stderr,
|
OptVersion (Arg);
|
||||||
"cl65 V%u.%u.%u - (C) Copyright 1998-99 Ullrich von Bassewitz\n",
|
break;
|
||||||
VER_MAJOR, VER_MINOR, VER_PATCH);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'W':
|
case 'W':
|
||||||
/* Suppress warnings - compiler and assembler */
|
/* Suppress warnings - compiler and assembler */
|
||||||
CmdAddArg (&CC65, "-W");
|
CmdAddArg (&CC65, "-W");
|
||||||
CmdAddArg (&CA65, "-W");
|
CmdAddArg (&CA65, "-W");
|
||||||
CmdAddArg (&CA65, "0");
|
CmdAddArg (&CA65, "0");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
/* Don't link the resulting files */
|
/* Don't link the resulting files */
|
||||||
DontLink = 1;
|
DontLink = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
/* Debug mode (compiler) */
|
/* Debug mode (compiler) */
|
||||||
CmdAddArg (&CC65, "-d");
|
OptDebug (Arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'g':
|
case 'g':
|
||||||
/* Debugging - add to compiler and assembler */
|
/* Debugging - add to compiler and assembler */
|
||||||
CmdAddArg (&CC65, "-g");
|
OptDebugInfo (Arg);
|
||||||
CmdAddArg (&CA65, "-g");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
/* Print help - cl65 */
|
/* Print help - cl65 */
|
||||||
Usage ();
|
OptHelp (Arg);
|
||||||
exit (EXIT_SUCCESS);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
/* Create a map file (linker) */
|
/* Create a map file (linker) */
|
||||||
CmdAddArg (&LD65, "-m");
|
CmdAddArg (&LD65, "-m");
|
||||||
CmdAddArg (&LD65, GetArg (&I, argv, 2));
|
CmdAddArg (&LD65, GetArg (&I, argv, 2));
|
||||||
|
@ -778,23 +919,21 @@ int main (int argc, char* argv [])
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
/* Set target system - compiler and linker */
|
/* Set target system - compiler and linker */
|
||||||
SetTargetByName (GetArg (&I, argv, 2));
|
OptTarget (Arg, GetArg (&I, argv, 2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
if (Arg [2] == 'm') {
|
if (Arg [2] == 'm') {
|
||||||
/* Verbose map file (linker) */
|
/* Verbose map file (linker) */
|
||||||
CmdAddArg (&LD65, "-vm");
|
CmdAddArg (&LD65, "-vm");
|
||||||
} else {
|
} else {
|
||||||
/* Verbose mode (compiler, assembler, linker) */
|
/* Verbose mode (compiler, assembler, linker) */
|
||||||
CmdAddArg (&CC65, "-v");
|
OptVerbose (Arg);
|
||||||
CmdAddArg (&CA65, "-v");
|
}
|
||||||
CmdAddArg (&LD65, "-v");
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ArgError (Arg);
|
UnknownOption (Arg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user