History

more consistent command line handling

bellard committed 24 years ago

Commit a50e58e1 parent 61a15991 file · +46 −17Browse files

Unified · Split

tcc.c+46−17
@@ -61,6 +61,10 @@ · 60 unmodified lines
61#define CONFIG_TCC_PREFIX "/usr/local"61#define CONFIG_TCC_PREFIX "/usr/local"
62#endif62#endif
63 63
64/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
65 executables or dlls */
66#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
67
64/* amount of virtual memory associated to a section (currently, we do68/* amount of virtual memory associated to a section (currently, we do
65 not realloc them) */69 not realloc them) */
66#define SECTION_VSIZE (1024 * 1024)70#define SECTION_VSIZE (1024 * 1024)
@@ -7617,26 +7621,37 @@ void tcc_add_file(TCCState *s, const char *filename) · 7550 unmodified lines
7617void help(void)7621void help(void)
7618{7622{
7619 printf("tcc version 0.9.8 - Tiny C Compiler - Copyright (C) 2001, 2002 Fabrice Bellard\n" 7623 printf("tcc version 0.9.8 - Tiny C Compiler - Copyright (C) 2001, 2002 Fabrice Bellard\n"
7620 "usage: tcc [-Idir] [-Dsym[=val]] [-Usym] [-llib] [-g] [-b]\n"7624 "usage: tcc [-c] [-o outfile] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n"
7621 " [-i infile] [-bench] infile [infile_args...]\n"7625 " [-g] [-b] [-llib] [-shared] [-static]\n"
7626 " [--] infile1 [infile2... --] [infile_args...]\n"
7622 "\n"7627 "\n"
7623 "-Idir : add include path 'dir'\n"7628 "General options:\n"
7624 "-Dsym[=val] : define 'sym' with value 'val'\n"7629 " -c compile only - generate an object file\n"
7625 "-Usym : undefine 'sym'\n"7630 " -i infile compile infile\n"
7626 "-llib : link with dynamic library 'lib'\n"7631 " -o outfile set output filename (NOT WORKING YET)\n"
7627 "-g : generate runtime debug info\n"7632 " -bench output compilation statistics\n"
7633 " -- allows multiples input files if no -o option given. Also\n"
7634 " separate input files from runtime arguments\n"
7635 "Preprocessor options:\n"
7636 " -Idir add include path 'dir'\n"
7637 " -Dsym[=val] define 'sym' with value 'val'\n"
7638 " -Usym undefine 'sym'\n"
7639 "C compiler options:\n"
7640 " -g generate runtime debug info\n"
7628#ifdef CONFIG_TCC_BCHECK7641#ifdef CONFIG_TCC_BCHECK
7629 "-b : compile with built-in memory and bounds checker (implies -g)\n"7642 " -b compile with built-in memory and bounds checker (implies -g)\n"
7630#endif7643#endif
7631 "-i infile : compile infile\n"7644 "Linker options:\n"
7632 "-bench : output compilation statistics\n"7645 " -llib link with dynamic library 'lib'\n"
7646 " -shared generate a shared library (NOT WORKING YET)\n"
7647 " -static static linking (NOT WORKING YET)\n"
7633 );7648 );
7634}7649}
7635 7650
7636int main(int argc, char **argv)7651int main(int argc, char **argv)
7637{7652{
7638 char *r, *outfile;7653 char *r, *outfile;
7639 int optind, file_type;7654 int optind, file_type, multiple_files;
7640 TCCState *s;7655 TCCState *s;
7641 7656
7642 s = tcc_new();7657 s = tcc_new();
@@ -7644,6 +7659,7 @@ int main(int argc, char **argv) · 1 unmodified line
7644 7659
7645 optind = 1;7660 optind = 1;
7646 outfile = NULL;7661 outfile = NULL;
7662 multiple_files = 0;
7647 while (1) {7663 while (1) {
7648 if (optind >= argc) {7664 if (optind >= argc) {
7649 show_help:7665 show_help:
@@ -7654,7 +7670,10 @@ int main(int argc, char **argv) · 4 unmodified lines
7654 if (r[0] != '-')7670 if (r[0] != '-')
7655 break;7671 break;
7656 optind++;7672 optind++;
7657 if (r[1] == 'I') {7673 if (r[1] == '-') {
7674 /* '--' enables multiple files input */
7675 multiple_files = 1;
7676 } else if (r[1] == 'I') {
7658 if (tcc_add_include_path(s, r + 2) < 0)7677 if (tcc_add_include_path(s, r + 2) < 0)
7659 error("too many include paths");7678 error("too many include paths");
7660 } else if (r[1] == 'D') {7679 } else if (r[1] == 'D') {
@@ -7672,10 +7691,6 @@ int main(int argc, char **argv) · 11 unmodified lines
7672 char buf[1024];7691 char buf[1024];
7673 snprintf(buf, sizeof(buf), "lib%s.so", r + 2);7692 snprintf(buf, sizeof(buf), "lib%s.so", r + 2);
7674 tcc_add_dll(s, buf);7693 tcc_add_dll(s, buf);
7675 } else if (r[1] == 'i') {
7676 if (optind >= argc)
7677 goto show_help;
7678 tcc_add_file(s, argv[optind++]);
7679 } else if (!strcmp(r + 1, "bench")) {7694 } else if (!strcmp(r + 1, "bench")) {
7680 do_bench = 1;7695 do_bench = 1;
7681#ifdef CONFIG_TCC_BCHECK7696#ifdef CONFIG_TCC_BCHECK
@@ -7713,6 +7728,7 @@ int main(int argc, char **argv) · 31 unmodified lines
7713 /* the following options are only for testing, so not7728 /* the following options are only for testing, so not
7714 documented */7729 documented */
7715 if (r[1] == 'c') {7730 if (r[1] == 'c') {
7731 multiple_files = 1;
7716 file_type = TCC_FILE_OBJ;7732 file_type = TCC_FILE_OBJ;
7717 } else if (!strcmp(r + 1, "static")) {7733 } else if (!strcmp(r + 1, "static")) {
7718 static_link = 1;7734 static_link = 1;
@@ -7721,13 +7737,26 @@ int main(int argc, char **argv) · 2 unmodified lines
7721 } else if (r[1] == 'o') {7737 } else if (r[1] == 'o') {
7722 if (optind >= argc)7738 if (optind >= argc)
7723 goto show_help;7739 goto show_help;
7740 multiple_files = 1;
7724 outfile = argv[optind++];7741 outfile = argv[optind++];
7725 } else {7742 } else {
7726 error("invalid option -- '%s'", r);7743 error("invalid option -- '%s'", r);
7727 }7744 }
7728 }7745 }
7729 7746
7730 tcc_add_file(s, argv[optind]);7747 tcc_add_file(s, argv[optind]);
7748 if (multiple_files) {
7749 while ((optind + 1) < argc) {
7750 optind++;
7751 r = argv[optind];
7752 if (r[0] == '-') {
7753 if (r[1] != '-')
7754 error("'--' expected");
7755 break;
7756 }
7757 tcc_add_file(s, r);
7758 }
7759 }
7731 7760
7732 if (do_bench) {7761 if (do_bench) {
7733 printf("total: %d idents, %d lines, %d bytes\n", 7762 printf("total: %d idents, %d lines, %d bytes\n",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t