2002-06-04 05:25:37 +00:00
|
|
|
/*
|
|
|
|
options.c
|
|
|
|
|
|
|
|
command line options handlnig
|
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
|
2002-06-04 05:25:37 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Author: Jeff Teunissen <deek@d2dc.net>
|
|
|
|
Date: 2002/06/04
|
2002-06-04 05:25:37 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2005-08-04 15:27:09 +00:00
|
|
|
static __attribute__ ((used)) const char rcsid[] =
|
2003-01-15 15:31:36 +00:00
|
|
|
"$Id$";
|
|
|
|
|
2002-06-04 05:25:37 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
#include "QF/pr_comp.h"
|
2002-06-04 05:25:37 +00:00
|
|
|
#include "QF/va.h"
|
|
|
|
|
2002-06-04 18:44:03 +00:00
|
|
|
#include "cpp.h"
|
2002-11-01 18:05:12 +00:00
|
|
|
#include "linker.h"
|
2002-06-04 18:44:03 +00:00
|
|
|
#include "options.h"
|
2002-08-20 21:13:18 +00:00
|
|
|
#include "qfcc.h"
|
2002-06-04 05:25:37 +00:00
|
|
|
|
|
|
|
const char *this_program;
|
2002-06-25 21:36:10 +00:00
|
|
|
const char **source_files;
|
|
|
|
static int num_files;
|
|
|
|
static int files_size;
|
2002-06-04 05:25:37 +00:00
|
|
|
|
2007-04-28 05:40:22 +00:00
|
|
|
// keep me sane when adding long options :P
|
|
|
|
enum {
|
|
|
|
start_opts = 255, // not used, just for starting the enum.
|
|
|
|
OPT_ADVANCED,
|
|
|
|
OPT_CPP,
|
|
|
|
OPT_INCLUDE,
|
|
|
|
OPT_PROGDEFS,
|
2009-12-25 07:59:25 +00:00
|
|
|
OPT_QCCX_ESCAPES,
|
2007-04-28 05:40:22 +00:00
|
|
|
OPT_TRADITIONAL,
|
|
|
|
};
|
|
|
|
|
2002-06-04 05:25:37 +00:00
|
|
|
static struct option const long_options[] = {
|
2007-04-28 05:40:22 +00:00
|
|
|
{"advanced", no_argument, 0, OPT_ADVANCED},
|
2007-04-11 10:48:04 +00:00
|
|
|
{"code", required_argument, 0, 'C'},
|
2007-04-28 05:40:22 +00:00
|
|
|
{"cpp", required_argument, 0, OPT_CPP},
|
2007-04-11 10:48:04 +00:00
|
|
|
{"define", required_argument, 0, 'D'},
|
|
|
|
{"files", no_argument, 0, 'F'},
|
|
|
|
{"help", no_argument, 0, 'h'},
|
2007-04-28 05:40:22 +00:00
|
|
|
{"include", required_argument, 0, OPT_INCLUDE},
|
2007-04-11 10:48:04 +00:00
|
|
|
{"notice", required_argument, 0, 'N'},
|
2002-06-24 22:53:21 +00:00
|
|
|
{"output-file", required_argument, 0, 'o'},
|
2007-04-28 05:40:22 +00:00
|
|
|
{"progdefs", no_argument, 0, OPT_PROGDEFS},
|
2002-06-04 05:25:37 +00:00
|
|
|
{"progs-src", required_argument, 0, 'P'},
|
2009-12-25 07:59:25 +00:00
|
|
|
{"qccx-escapes", no_argument, 0, OPT_QCCX_ESCAPES},
|
2002-06-04 05:25:37 +00:00
|
|
|
{"quiet", no_argument, 0, 'q'},
|
2007-04-11 10:48:04 +00:00
|
|
|
{"relocatable", no_argument, 0, 'r'},
|
|
|
|
{"save-temps", no_argument, 0, 'S'},
|
|
|
|
{"source", required_argument, 0, 's'},
|
2002-06-04 05:25:37 +00:00
|
|
|
{"strip-path", required_argument, 0, 'p'},
|
2007-04-28 05:40:22 +00:00
|
|
|
{"traditional", no_argument, 0, OPT_TRADITIONAL},
|
2002-06-04 05:25:37 +00:00
|
|
|
{"undefine", required_argument, 0, 'U'},
|
2007-04-11 10:48:04 +00:00
|
|
|
{"verbose", no_argument, 0, 'v'},
|
|
|
|
{"version", no_argument, 0, 'V'},
|
|
|
|
{"warn", required_argument, 0, 'W'},
|
2002-06-04 05:25:37 +00:00
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *short_options =
|
2002-06-25 21:36:10 +00:00
|
|
|
"-" // magic option parsing mode doohicky (must come first)
|
2007-04-10 13:00:21 +00:00
|
|
|
"C:" // code options
|
2002-06-21 20:46:56 +00:00
|
|
|
"c" // separate compilation
|
2007-04-10 13:00:21 +00:00
|
|
|
"D:" // define
|
2010-01-13 06:42:26 +00:00
|
|
|
"E" // only preprocess
|
2002-06-21 20:46:56 +00:00
|
|
|
"F" // generate files.dat
|
|
|
|
"g" // debug
|
|
|
|
"h" // help
|
2007-04-10 13:00:21 +00:00
|
|
|
"I:" // set includes
|
|
|
|
"l:" // lib file
|
|
|
|
"L:" // lib path
|
|
|
|
"M::"
|
|
|
|
"N:" // notice options
|
|
|
|
"o:" // output file
|
|
|
|
"P:" // progs.src name
|
2002-06-21 20:46:56 +00:00
|
|
|
"p:" // strip path
|
2007-04-10 13:00:21 +00:00
|
|
|
"q" // quiet
|
|
|
|
"r" // partial linking
|
2002-06-21 20:46:56 +00:00
|
|
|
"S" // save temps
|
2007-04-10 13:00:21 +00:00
|
|
|
"s:" // source dir
|
2002-06-21 20:46:56 +00:00
|
|
|
"U:" // undefine
|
2007-04-10 13:00:21 +00:00
|
|
|
"V" // version
|
|
|
|
"v" // verbose
|
|
|
|
"W:" // warning options
|
2003-02-23 23:43:43 +00:00
|
|
|
"z" // compress qfo files
|
2002-06-21 20:46:56 +00:00
|
|
|
;
|
2002-06-04 05:25:37 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
usage (int status)
|
|
|
|
{
|
|
|
|
printf ("%s - QuakeForge Code Compiler\n", this_program);
|
2003-05-15 17:48:59 +00:00
|
|
|
printf ("Usage: %s [options] [files]\n", this_program);
|
2002-06-04 05:25:37 +00:00
|
|
|
printf (
|
|
|
|
"Options:\n"
|
2003-09-20 04:13:32 +00:00
|
|
|
" --advanced Advanced Ruamoko mode\n"
|
|
|
|
" default for separate compilation mode\n"
|
2002-06-04 05:25:37 +00:00
|
|
|
" -C, --code OPTION,... Set code generation options\n"
|
2010-01-13 06:42:26 +00:00
|
|
|
" -c Only compile, don't link\n"
|
2007-04-10 13:00:21 +00:00
|
|
|
" --cpp CPPSPEC cpp execution command line\n"
|
2004-02-13 04:46:50 +00:00
|
|
|
" -D, --define SYMBOL[=VAL] Define symbols for the preprocessor\n"
|
2010-01-13 06:42:26 +00:00
|
|
|
" -E Only preprocess\n"
|
2007-04-10 13:00:21 +00:00
|
|
|
" -F, --files Generate files.dat\n"
|
|
|
|
" -g Generate debugging info\n"
|
|
|
|
" -h, --help Display this help and exit\n"
|
2004-02-13 04:46:50 +00:00
|
|
|
" -I DIR Set directories for the preprocessor\n"
|
|
|
|
" to search for #includes\n"
|
|
|
|
" --include FILE Process file as if `#include \"file\"'\n"
|
|
|
|
" appeared as the first line of the primary\n"
|
|
|
|
" source file.\n"
|
2003-05-15 17:48:59 +00:00
|
|
|
" -L DIR Add linker library search path\n"
|
|
|
|
" -l LIB Link with libLIB.a\n"
|
2007-04-10 13:00:21 +00:00
|
|
|
" -M[flags] Generate depency info. Dependent on cpp\n"
|
|
|
|
" -N, --notice OPTION,... Set notice options\n"
|
|
|
|
" -o, --output-file FILE Specify output file name\n"
|
|
|
|
" -P, --progs-src FILE File to use instead of progs.src\n"
|
|
|
|
" -p, --strip-path NUM Strip NUM leading path elements from file\n"
|
|
|
|
" names\n"
|
2009-12-25 07:59:25 +00:00
|
|
|
" --qccx-escapes Use QCCX escape sequences instead of standard\n"
|
|
|
|
" C/QuakeForge sequences.\n"
|
2007-04-10 13:00:21 +00:00
|
|
|
" -q, --quiet Inhibit usual output\n"
|
2007-04-11 10:48:04 +00:00
|
|
|
" -r, --relocatable Incremental linking\n"
|
2007-04-10 13:00:21 +00:00
|
|
|
" -S, --save-temps Do not delete temporary files\n"
|
|
|
|
" -s, --source DIR Look for progs.src in DIR instead of \".\"\n"
|
|
|
|
" --traditional Traditional QuakeC mode: implies v6only\n"
|
|
|
|
" default when using progs.src\n"
|
|
|
|
" -U, --undefine SYMBOL Undefine preprocessor symbols\n"
|
|
|
|
" -V, --version Output version information and exit\n"
|
|
|
|
" -v, --verbose Display more output than usual\n"
|
|
|
|
" -W, --warn OPTION,... Set warning options\n"
|
2003-05-15 17:48:59 +00:00
|
|
|
" -z Compress object files\n"
|
|
|
|
"\n"
|
2007-04-10 14:53:44 +00:00
|
|
|
"For help on options for --code, --notice and --warn, see the qfcc(1) manual\n"
|
|
|
|
"page, or use `help' as the option.\n"
|
2002-06-04 05:25:37 +00:00
|
|
|
);
|
|
|
|
exit (status);
|
|
|
|
}
|
|
|
|
|
2007-04-10 13:10:53 +00:00
|
|
|
static void
|
|
|
|
code_usage (void)
|
|
|
|
{
|
|
|
|
printf ("%s - QuakeForge Code Compiler\n", this_program);
|
|
|
|
printf ("Code generation options\n");
|
2007-04-10 14:53:44 +00:00
|
|
|
printf (
|
|
|
|
" [no-]cow Allow assignment to initialized globals.\n"
|
|
|
|
" [no-]cpp Preprocess all input files with cpp.\n"
|
|
|
|
" [no-]debug Generate debug information.\n"
|
|
|
|
" [no-]fast-float Use float values directly in \"if\" statements.\n"
|
|
|
|
" help Display his text.\n"
|
|
|
|
" [no-]local-merging Merge the local variable blocks into one.\n"
|
|
|
|
" [no-]short-circuit Generate short circuit code for logical\n"
|
|
|
|
" operators.\n"
|
|
|
|
" [no-]single-cpp Convert progs.src to cpp input file.\n"
|
|
|
|
" [no-]vector-calls Generate slower but data efficient code for\n"
|
|
|
|
" passing\n"
|
|
|
|
" vectors to functiosn.\n"
|
|
|
|
" [no-]v6only Restrict output code to version 6 progs\n"
|
|
|
|
" features.\n"
|
|
|
|
"\n"
|
|
|
|
"For details, see the qfcc(1) manual page\n"
|
|
|
|
);
|
2007-04-10 13:10:53 +00:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
warning_usage (void)
|
|
|
|
{
|
|
|
|
printf ("%s - QuakeForge Code Compiler\n", this_program);
|
|
|
|
printf ("Warnings options\n");
|
2007-04-10 14:53:44 +00:00
|
|
|
printf (
|
|
|
|
" all Turn on all warnings.\n"
|
|
|
|
" [no-]cow Warn about assignement to initialized globals.\n"
|
|
|
|
" [no-]error Treat warnings as errors.\n"
|
|
|
|
" [no-]executable Warn about statements with no effect.\n"
|
|
|
|
" help Display his text.\n"
|
|
|
|
" [no-]initializer Warn about excessive structure/array\n"
|
|
|
|
" initializers.\n"
|
|
|
|
" [no-]integer-divide Warn about division of integer constants.\n"
|
|
|
|
" [no-]interface-check Warn about methods not declared in the\n"
|
|
|
|
" interface.\n"
|
|
|
|
" none Turn off all warnings.\n"
|
|
|
|
" [no-]precedence Warn about potentially ambiguous logic.\n"
|
2010-02-20 12:01:49 +00:00
|
|
|
" [no-]redeclared Warn about redeclared local variables.\n"
|
2007-04-10 14:53:44 +00:00
|
|
|
" [no-]traditional Warn about bad code that qcc allowed.\n"
|
|
|
|
" [no-]undef-function Warn about calling a yet to be defined\n"
|
|
|
|
" function.\n"
|
|
|
|
" [no-]unimplemented Warn about unimplemented class methods.\n"
|
|
|
|
" [no-]unused Warn about unused local variables.\n"
|
|
|
|
" [no-]uninited-var Warn about using uninitialied variables.\n"
|
|
|
|
" [no-]vararg-integer Warn about passing integer constants to\n"
|
|
|
|
" functions with variable args.\n"
|
|
|
|
"\n"
|
|
|
|
"For details, see the qfcc(1) manual page\n"
|
|
|
|
);
|
2007-04-10 13:10:53 +00:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
notice_usage (void)
|
|
|
|
{
|
|
|
|
printf ("%s - QuakeForge Code Compiler\n", this_program);
|
|
|
|
printf ("Notice options\n");
|
2007-04-10 14:53:44 +00:00
|
|
|
printf (
|
|
|
|
" help Display his text.\n"
|
|
|
|
" none Turn off all notices.\n"
|
|
|
|
" warn Change notices to warnings.\n"
|
|
|
|
"\n"
|
|
|
|
"For details, see the qfcc(1) manual page\n"
|
|
|
|
);
|
2007-04-10 13:10:53 +00:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2002-06-25 21:36:10 +00:00
|
|
|
static void
|
|
|
|
add_file (const char *file)
|
|
|
|
{
|
|
|
|
if (num_files >= files_size - 1) {
|
|
|
|
files_size += 16;
|
|
|
|
source_files = realloc (source_files, files_size * sizeof (char *));
|
|
|
|
}
|
2002-11-01 18:05:12 +00:00
|
|
|
source_files[num_files++] = save_string (file);
|
2002-06-25 21:36:10 +00:00
|
|
|
source_files[num_files] = 0;
|
|
|
|
}
|
|
|
|
|
2002-06-04 05:25:37 +00:00
|
|
|
int
|
|
|
|
DecodeArgs (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int c;
|
2004-11-13 13:22:00 +00:00
|
|
|
int saw_E = 0, saw_MD = 0;
|
2002-06-04 05:25:37 +00:00
|
|
|
|
|
|
|
add_cpp_def ("-D__QFCC__=1");
|
|
|
|
add_cpp_def ("-D__QUAKEC__=1");
|
|
|
|
|
2003-10-22 08:27:38 +00:00
|
|
|
options.code.short_circuit = -1;
|
2007-04-10 13:00:21 +00:00
|
|
|
options.code.local_merging = -1;
|
2004-04-27 20:24:37 +00:00
|
|
|
options.code.fast_float = true;
|
2002-06-04 05:25:37 +00:00
|
|
|
options.warnings.uninited_variable = true;
|
2004-02-17 00:39:21 +00:00
|
|
|
options.warnings.unused = true;
|
|
|
|
options.warnings.executable = true;
|
|
|
|
options.warnings.traditional = true;
|
|
|
|
options.warnings.precedence = true;
|
|
|
|
options.warnings.initializer = true;
|
|
|
|
options.warnings.unimplemented = true;
|
2010-02-20 12:01:49 +00:00
|
|
|
options.warnings.redeclared = true;
|
2002-06-04 05:25:37 +00:00
|
|
|
|
2006-05-24 14:35:39 +00:00
|
|
|
options.single_cpp = true;
|
2002-06-04 05:25:37 +00:00
|
|
|
options.save_temps = false;
|
|
|
|
options.verbosity = 0;
|
|
|
|
options.strip_path = 0;
|
|
|
|
|
|
|
|
sourcedir = "";
|
|
|
|
progs_src = "progs.src";
|
|
|
|
|
|
|
|
while ((c = getopt_long (argc, argv, short_options, long_options, 0))
|
|
|
|
!= EOF) {
|
|
|
|
switch (c) {
|
2002-06-25 21:36:10 +00:00
|
|
|
case 1: // ordinary file
|
2003-02-24 21:51:08 +00:00
|
|
|
add_file (NORMALIZE (optarg));
|
2002-06-25 21:36:10 +00:00
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
if (options.output_file) {
|
|
|
|
fprintf (stderr, "%s: -o must not be used more than once\n",
|
|
|
|
this_program);
|
|
|
|
exit (1);
|
|
|
|
} else {
|
2003-02-24 21:51:08 +00:00
|
|
|
options.output_file = save_string (NORMALIZE (optarg));
|
2002-06-25 21:36:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'l': // lib file
|
2003-02-24 21:51:08 +00:00
|
|
|
add_file (va ("-l%s", NORMALIZE (optarg)));
|
2002-06-25 21:36:10 +00:00
|
|
|
break;
|
2002-11-01 18:05:12 +00:00
|
|
|
case 'L':
|
2003-02-24 21:51:08 +00:00
|
|
|
linker_add_path (NORMALIZE (optarg));
|
2002-11-01 18:05:12 +00:00
|
|
|
break;
|
2002-06-04 05:25:37 +00:00
|
|
|
case 'h': // help
|
|
|
|
usage (0);
|
|
|
|
break;
|
|
|
|
case 'V': // version
|
2010-08-19 06:01:43 +00:00
|
|
|
printf ("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
2002-06-04 05:25:37 +00:00
|
|
|
exit (0);
|
|
|
|
break;
|
|
|
|
case 's': // src dir
|
2003-02-24 21:51:08 +00:00
|
|
|
sourcedir = save_string (NORMALIZE (optarg));
|
2002-06-04 05:25:37 +00:00
|
|
|
break;
|
|
|
|
case 'P': // progs-src
|
2003-02-24 21:51:08 +00:00
|
|
|
progs_src = save_string (NORMALIZE (optarg));
|
2002-06-04 05:25:37 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
options.strip_path = atoi (optarg);
|
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
options.files_dat = true;
|
|
|
|
break;
|
2007-04-28 05:40:22 +00:00
|
|
|
case OPT_PROGDEFS:
|
|
|
|
options.progdefs_h = true;
|
|
|
|
break;
|
2009-12-25 07:59:25 +00:00
|
|
|
case OPT_QCCX_ESCAPES:
|
|
|
|
options.qccx_escapes = true;
|
|
|
|
break;
|
2002-06-04 05:25:37 +00:00
|
|
|
case 'q': // quiet
|
|
|
|
options.verbosity -= 1;
|
|
|
|
break;
|
|
|
|
case 'v': // verbose
|
|
|
|
options.verbosity += 1;
|
|
|
|
break;
|
|
|
|
case 'g': // debug
|
|
|
|
options.code.debug = true;
|
|
|
|
break;
|
2007-04-28 05:40:22 +00:00
|
|
|
case OPT_TRADITIONAL:
|
2002-06-04 05:25:37 +00:00
|
|
|
options.traditional = true;
|
2003-09-20 04:13:32 +00:00
|
|
|
options.advanced = false;
|
2002-06-04 05:25:37 +00:00
|
|
|
options.code.progsversion = PROG_ID_VERSION;
|
|
|
|
break;
|
2007-04-28 05:40:22 +00:00
|
|
|
case OPT_ADVANCED:
|
2003-09-20 04:13:32 +00:00
|
|
|
options.traditional = false;
|
|
|
|
options.advanced = true;
|
|
|
|
options.code.progsversion = PROG_VERSION;
|
|
|
|
break;
|
2003-02-21 22:30:49 +00:00
|
|
|
case 'c':
|
2002-06-21 20:46:56 +00:00
|
|
|
options.compile = true;
|
|
|
|
break;
|
2003-02-21 22:30:49 +00:00
|
|
|
case 'r':
|
2002-07-12 04:50:31 +00:00
|
|
|
options.partial_link = true;
|
|
|
|
break;
|
2003-02-23 23:43:43 +00:00
|
|
|
case 'z':
|
|
|
|
options.gzip = true;
|
|
|
|
break;
|
2002-06-04 05:25:37 +00:00
|
|
|
case 'C':{ // code options
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
|
|
|
|
|
|
|
while (temp) {
|
2004-02-17 00:39:21 +00:00
|
|
|
qboolean flag = true;
|
|
|
|
|
|
|
|
if (!strncasecmp (temp, "no-", 3)) {
|
|
|
|
flag = false;
|
|
|
|
temp += 3;
|
|
|
|
}
|
|
|
|
if (!strcasecmp (temp, "cow")) {
|
|
|
|
options.code.cow = flag;
|
|
|
|
} else if (!(strcasecmp (temp, "cpp"))) {
|
|
|
|
cpp_name = flag ? CPP_NAME : 0;
|
2002-06-04 05:25:37 +00:00
|
|
|
} else if (!(strcasecmp (temp, "debug"))) {
|
2004-02-17 00:39:21 +00:00
|
|
|
options.code.debug = flag;
|
2004-04-27 20:24:37 +00:00
|
|
|
} else if (!(strcasecmp (temp, "fast-float"))) {
|
|
|
|
options.code.fast_float = flag;
|
2007-04-10 13:11:42 +00:00
|
|
|
} else if (!strcasecmp (temp, "help")) {
|
2007-04-10 13:10:53 +00:00
|
|
|
code_usage ();
|
2007-04-10 13:00:21 +00:00
|
|
|
} else if (!(strcasecmp (temp, "local-merging"))) {
|
|
|
|
options.code.local_merging = flag;
|
|
|
|
} else if (!(strcasecmp (temp, "short-circuit"))) {
|
|
|
|
options.code.short_circuit = flag;
|
|
|
|
} else if (!(strcasecmp (temp, "single-cpp"))) {
|
|
|
|
options.single_cpp = flag;
|
2005-06-10 07:31:25 +00:00
|
|
|
} else if (!(strcasecmp (temp, "vector-calls"))) {
|
|
|
|
options.code.vector_calls = flag;
|
2002-06-04 05:25:37 +00:00
|
|
|
} else if (!(strcasecmp (temp, "v6only"))) {
|
2004-02-17 00:39:21 +00:00
|
|
|
if (flag)
|
|
|
|
options.code.progsversion = PROG_ID_VERSION;
|
|
|
|
else
|
|
|
|
options.code.progsversion = PROG_VERSION;
|
2002-06-04 05:25:37 +00:00
|
|
|
}
|
|
|
|
temp = strtok (NULL, ",");
|
|
|
|
}
|
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'W':{ // warning options
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
|
|
|
|
|
|
|
while (temp) {
|
|
|
|
if (!(strcasecmp (temp, "all"))) {
|
|
|
|
options.warnings.cow = true;
|
|
|
|
options.warnings.undefined_function = true;
|
|
|
|
options.warnings.uninited_variable = true;
|
|
|
|
options.warnings.vararg_integer = true;
|
|
|
|
options.warnings.integer_divide = true;
|
2004-02-17 00:39:21 +00:00
|
|
|
options.warnings.interface_check = true;
|
|
|
|
options.warnings.unused = true;
|
|
|
|
options.warnings.executable = true;
|
|
|
|
options.warnings.traditional = true;
|
|
|
|
options.warnings.precedence = true;
|
|
|
|
options.warnings.initializer = true;
|
|
|
|
options.warnings.unimplemented = true;
|
2010-02-20 12:01:49 +00:00
|
|
|
options.warnings.redeclared = true;
|
2002-06-04 05:25:37 +00:00
|
|
|
} else if (!(strcasecmp (temp, "none"))) {
|
|
|
|
options.warnings.cow = false;
|
|
|
|
options.warnings.undefined_function = false;
|
|
|
|
options.warnings.uninited_variable = false;
|
|
|
|
options.warnings.vararg_integer = false;
|
|
|
|
options.warnings.integer_divide = false;
|
2003-07-29 18:31:12 +00:00
|
|
|
options.warnings.interface_check = false;
|
2004-02-17 00:39:21 +00:00
|
|
|
options.warnings.unused = false;
|
|
|
|
options.warnings.executable = false;
|
|
|
|
options.warnings.traditional = false;
|
|
|
|
options.warnings.precedence = false;
|
|
|
|
options.warnings.initializer = false;
|
|
|
|
options.warnings.unimplemented = false;
|
2010-02-20 12:01:49 +00:00
|
|
|
options.warnings.redeclared = false;
|
2004-02-17 00:39:21 +00:00
|
|
|
} else {
|
|
|
|
qboolean flag = true;
|
|
|
|
|
|
|
|
if (!strncasecmp (temp, "no-", 3)) {
|
|
|
|
flag = false;
|
|
|
|
temp += 3;
|
|
|
|
}
|
2007-04-10 13:00:21 +00:00
|
|
|
if (!(strcasecmp (temp, "cow"))) {
|
2004-02-17 00:39:21 +00:00
|
|
|
options.warnings.cow = flag;
|
2007-04-10 13:00:21 +00:00
|
|
|
} else if (!strcasecmp (temp, "error")) {
|
|
|
|
options.warnings.promote = flag;
|
|
|
|
} else if (!strcasecmp (temp, "executable")) {
|
|
|
|
options.warnings.executable = flag;
|
2007-04-10 13:11:42 +00:00
|
|
|
} else if (!strcasecmp (temp, "help")) {
|
2007-04-10 13:10:53 +00:00
|
|
|
warning_usage ();
|
2007-04-10 13:00:21 +00:00
|
|
|
} else if (!strcasecmp (temp, "initializer")) {
|
|
|
|
options.warnings.initializer = flag;
|
2004-02-17 00:39:21 +00:00
|
|
|
} else if (!strcasecmp (temp, "integer-divide")) {
|
|
|
|
options.warnings.integer_divide = flag;
|
|
|
|
} else if (!strcasecmp (temp, "interface-check")) {
|
|
|
|
options.warnings.interface_check = flag;
|
|
|
|
} else if (!strcasecmp (temp, "precedence")) {
|
|
|
|
options.warnings.precedence = flag;
|
2010-02-20 12:01:49 +00:00
|
|
|
} else if (!strcasecmp (temp, "redeclared")) {
|
|
|
|
options.warnings.redeclared = flag;
|
2007-04-10 13:00:21 +00:00
|
|
|
} else if (!strcasecmp (temp, "traditional")) {
|
|
|
|
options.warnings.traditional = flag;
|
|
|
|
} else if (!strcasecmp (temp, "undef-function")) {
|
|
|
|
options.warnings.undefined_function = flag;
|
2004-02-17 00:39:21 +00:00
|
|
|
} else if (!strcasecmp (temp, "unimplemented")) {
|
|
|
|
options.warnings.unimplemented = flag;
|
2007-04-10 13:00:21 +00:00
|
|
|
} else if (!strcasecmp (temp, "unused")) {
|
|
|
|
options.warnings.unused = flag;
|
|
|
|
} else if (!strcasecmp (temp, "uninited-var")) {
|
|
|
|
options.warnings.uninited_variable = flag;
|
|
|
|
} else if (!strcasecmp (temp, "vararg-integer")) {
|
|
|
|
options.warnings.vararg_integer = flag;
|
2004-02-17 00:39:21 +00:00
|
|
|
}
|
2002-06-04 05:25:37 +00:00
|
|
|
}
|
|
|
|
temp = strtok (NULL, ",");
|
2002-06-20 19:29:06 +00:00
|
|
|
}
|
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'N':{ // notice options
|
|
|
|
char *opts = strdup (optarg);
|
|
|
|
char *temp = strtok (opts, ",");
|
|
|
|
|
|
|
|
while (temp) {
|
2007-04-10 13:11:42 +00:00
|
|
|
if (!strcasecmp (temp, "help")) {
|
2007-04-10 13:10:53 +00:00
|
|
|
notice_usage ();
|
|
|
|
} else if (!(strcasecmp (temp, "none"))) {
|
2002-06-20 19:29:06 +00:00
|
|
|
options.notices.silent = true;
|
|
|
|
} else if (!(strcasecmp (temp, "warn"))) {
|
|
|
|
options.notices.promote = true;
|
|
|
|
}
|
|
|
|
temp = strtok (NULL, ",");
|
2002-06-04 05:25:37 +00:00
|
|
|
}
|
|
|
|
free (opts);
|
|
|
|
}
|
|
|
|
break;
|
2007-04-28 05:40:22 +00:00
|
|
|
case OPT_CPP: // --cpp=
|
2002-11-01 18:05:12 +00:00
|
|
|
cpp_name = save_string (optarg);
|
2002-06-04 05:25:37 +00:00
|
|
|
break;
|
|
|
|
case 'S': // save temps
|
|
|
|
options.save_temps = true;
|
|
|
|
break;
|
2004-02-13 04:46:50 +00:00
|
|
|
case 'D': // defines for cpp
|
|
|
|
add_cpp_def (nva ("%s%s", "-D", optarg));
|
2002-06-04 05:25:37 +00:00
|
|
|
break;
|
2004-11-13 13:22:00 +00:00
|
|
|
case 'E': // defines for cpp
|
|
|
|
saw_E = 1;
|
|
|
|
options.preprocess_only = 1;
|
|
|
|
add_cpp_def ("-E");
|
|
|
|
break;
|
2007-04-28 05:40:22 +00:00
|
|
|
case OPT_INCLUDE: // include-file
|
2004-02-13 04:46:50 +00:00
|
|
|
add_cpp_def (nva ("%s", "-include"));
|
|
|
|
add_cpp_def (nva ("%s", optarg));
|
2002-06-04 05:25:37 +00:00
|
|
|
break;
|
2004-02-13 04:46:50 +00:00
|
|
|
case 'I': // includes
|
|
|
|
add_cpp_def (nva ("%s%s", "-I", optarg));
|
|
|
|
break;
|
|
|
|
case 'U': // undefines
|
|
|
|
add_cpp_def (nva ("%s%s", "-U", optarg));
|
2002-06-04 05:25:37 +00:00
|
|
|
break;
|
2002-07-20 05:20:40 +00:00
|
|
|
case 'M':
|
2004-11-13 13:22:00 +00:00
|
|
|
options.preprocess_only = 1;
|
2002-08-13 22:02:07 +00:00
|
|
|
if (optarg) {
|
|
|
|
add_cpp_def (nva ("-M%s", optarg));
|
2004-11-13 13:22:00 +00:00
|
|
|
if (strchr (optarg, 'D'))
|
|
|
|
saw_MD = 1;
|
2002-08-13 22:02:07 +00:00
|
|
|
if (strchr ("FQT", optarg[0]))
|
|
|
|
add_cpp_def (argv[optind++]);
|
|
|
|
} else {
|
|
|
|
options.preprocess_only = 1;
|
|
|
|
add_cpp_def (nva ("-M"));
|
|
|
|
}
|
2002-07-20 05:20:40 +00:00
|
|
|
break;
|
2002-06-04 05:25:37 +00:00
|
|
|
default:
|
|
|
|
usage (1);
|
|
|
|
}
|
|
|
|
}
|
2007-04-06 07:11:38 +00:00
|
|
|
if (!cpp_name)
|
|
|
|
options.single_cpp = 0;
|
2004-11-13 13:22:00 +00:00
|
|
|
if (saw_E && saw_MD) {
|
|
|
|
fprintf (stderr, "%s: cannot use -E and -MD together\n", this_program);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
if (saw_MD)
|
|
|
|
options.preprocess_only = 0;
|
2003-09-20 04:13:32 +00:00
|
|
|
if (!source_files && !options.advanced) {
|
|
|
|
// progs.src mode without --advanced implies --traditional
|
|
|
|
options.traditional = true;
|
|
|
|
options.advanced = false;
|
2005-06-12 11:36:30 +00:00
|
|
|
if (!options.code.progsversion)
|
|
|
|
options.code.progsversion = PROG_ID_VERSION;
|
2004-07-13 19:14:01 +00:00
|
|
|
if (options.code.short_circuit == (qboolean) -1)
|
2003-10-22 08:27:38 +00:00
|
|
|
options.code.short_circuit = false;
|
2007-04-10 13:00:21 +00:00
|
|
|
if (options.code.local_merging == (qboolean) -1)
|
|
|
|
options.code.local_merging = false;
|
2003-09-20 04:13:32 +00:00
|
|
|
}
|
2005-06-12 11:36:30 +00:00
|
|
|
if (!options.code.progsversion)
|
|
|
|
options.code.progsversion = PROG_VERSION;
|
2003-09-20 04:13:32 +00:00
|
|
|
if (!options.traditional) {
|
2003-10-22 08:27:38 +00:00
|
|
|
options.advanced = true;
|
2003-09-20 04:13:32 +00:00
|
|
|
add_cpp_def ("-D__RUAMOKO__=1");
|
|
|
|
add_cpp_def ("-D__RAUMOKO__=1");
|
2004-07-13 19:14:01 +00:00
|
|
|
if (options.code.short_circuit == (qboolean) -1)
|
2003-10-22 08:27:38 +00:00
|
|
|
options.code.short_circuit = true;
|
2007-04-10 13:00:21 +00:00
|
|
|
if (options.code.local_merging == (qboolean) -1)
|
|
|
|
options.code.local_merging = true;
|
2003-09-20 04:13:32 +00:00
|
|
|
}
|
2003-08-24 07:26:02 +00:00
|
|
|
if (options.code.progsversion == PROG_ID_VERSION)
|
|
|
|
add_cpp_def ("-D__VERSION6__=1");
|
2002-11-01 18:05:12 +00:00
|
|
|
|
|
|
|
// add the default paths
|
|
|
|
add_cpp_def (nva ("-I%s", QFCC_INCLUDE_PATH));
|
|
|
|
linker_add_path (QFCC_LIB_PATH);
|
|
|
|
|
2002-08-20 21:13:18 +00:00
|
|
|
if (options.verbosity >= 3)
|
|
|
|
yydebug = 1;
|
2002-06-04 05:25:37 +00:00
|
|
|
return optind;
|
|
|
|
}
|