Unified · Split
| @@ -61,6 +61,10 @@ · 60 unmodified lines | ||
| 61 | 61 | #define CONFIG_TCC_PREFIX "/usr/local" |
| 62 | 62 | #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 | 68 | /* amount of virtual memory associated to a section (currently, we do |
| 65 | 69 | not realloc them) */ |
| 66 | 70 | #define SECTION_VSIZE (1024 * 1024) |
| @@ -7617,26 +7621,37 @@ void tcc_add_file(TCCState *s, const char *filename) · 7550 unmodified lines | ||
| 7617 | 7621 | void help(void) |
| 7618 | 7622 | { |
| 7619 | 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" | |
| 7621 | − " [-i infile] [-bench] infile [infile_args...]\n" | |
| 7624 | + "usage: tcc [-c] [-o outfile] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n" | |
| 7625 | + " [-g] [-b] [-llib] [-shared] [-static]\n" | |
| 7626 | + " [--] infile1 [infile2... --] [infile_args...]\n" | |
| 7622 | 7627 | "\n" |
| 7623 | − "-Idir : add include path 'dir'\n" | |
| 7624 | − "-Dsym[=val] : define 'sym' with value 'val'\n" | |
| 7625 | − "-Usym : undefine 'sym'\n" | |
| 7626 | − "-llib : link with dynamic library 'lib'\n" | |
| 7627 | − "-g : generate runtime debug info\n" | |
| 7628 | + "General options:\n" | |
| 7629 | + " -c compile only - generate an object file\n" | |
| 7630 | + " -i infile compile infile\n" | |
| 7631 | + " -o outfile set output filename (NOT WORKING YET)\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 | 7641 | #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 | 7643 | #endif |
| 7631 | − "-i infile : compile infile\n" | |
| 7632 | − "-bench : output compilation statistics\n" | |
| 7644 | + "Linker options:\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 | |
| 7636 | 7651 | int main(int argc, char **argv) |
| 7637 | 7652 | { |
| 7638 | 7653 | char *r, *outfile; |
| 7639 | − int optind, file_type; | |
| 7654 | + int optind, file_type, multiple_files; | |
| 7640 | 7655 | TCCState *s; |
| 7641 | 7656 | |
| 7642 | 7657 | s = tcc_new(); |
| @@ -7644,6 +7659,7 @@ int main(int argc, char **argv) · 1 unmodified line | ||
| 7644 | 7659 | |
| 7645 | 7660 | optind = 1; |
| 7646 | 7661 | outfile = NULL; |
| 7662 | + multiple_files = 0; | |
| 7647 | 7663 | while (1) { |
| 7648 | 7664 | if (optind >= argc) { |
| 7649 | 7665 | show_help: |
| @@ -7654,7 +7670,10 @@ int main(int argc, char **argv) · 4 unmodified lines | ||
| 7654 | 7670 | if (r[0] != '-') |
| 7655 | 7671 | break; |
| 7656 | 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 | 7677 | if (tcc_add_include_path(s, r + 2) < 0) |
| 7659 | 7678 | error("too many include paths"); |
| 7660 | 7679 | } else if (r[1] == 'D') { |
| @@ -7672,10 +7691,6 @@ int main(int argc, char **argv) · 11 unmodified lines | ||
| 7672 | 7691 | char buf[1024]; |
| 7673 | 7692 | snprintf(buf, sizeof(buf), "lib%s.so", r + 2); |
| 7674 | 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 | 7694 | } else if (!strcmp(r + 1, "bench")) { |
| 7680 | 7695 | do_bench = 1; |
| 7681 | 7696 | #ifdef CONFIG_TCC_BCHECK |
| @@ -7713,6 +7728,7 @@ int main(int argc, char **argv) · 31 unmodified lines | ||
| 7713 | 7728 | /* the following options are only for testing, so not |
| 7714 | 7729 | documented */ |
| 7715 | 7730 | if (r[1] == 'c') { |
| 7731 | + multiple_files = 1; | |
| 7716 | 7732 | file_type = TCC_FILE_OBJ; |
| 7717 | 7733 | } else if (!strcmp(r + 1, "static")) { |
| 7718 | 7734 | static_link = 1; |
| @@ -7721,13 +7737,26 @@ int main(int argc, char **argv) · 2 unmodified lines | ||
| 7721 | 7737 | } else if (r[1] == 'o') { |
| 7722 | 7738 | if (optind >= argc) |
| 7723 | 7739 | goto show_help; |
| 7740 | + multiple_files = 1; | |
| 7724 | 7741 | outfile = argv[optind++]; |
| 7725 | 7742 | } else { |
| 7726 | 7743 | error("invalid option -- '%s'", r); |
| 7727 | 7744 | } |
| 7728 | 7745 | } |
| 7729 | − | |
| 7746 | + | |
| 7730 | 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 | 7761 | if (do_bench) { |
| 7733 | 7762 | printf("total: %d idents, %d lines, %d bytes\n", |