linux.c (2360B)
1 /* x86s running Linux */ 2 3 #include <string.h> 4 5 static char rcsid[] = "Dummy rcsid"; 6 7 /* 8 TTimo - 10-18-2001 9 our binaries are named q3lcc q3rcc and q3cpp 10 removed hardcoded paths 11 removed __linux__ preprocessor define (confuses the preprocessor, we are doing bytecode!) 12 */ 13 14 #ifndef LCCDIR 15 #define LCCDIR "" 16 //#define LCCDIR "/usr/local/lib/lcc/" 17 #endif 18 19 char *suffixes[] = { ".c", ".i", ".asm", ".o", ".out", 0 }; 20 char inputs[256] = ""; 21 // TTimo experimental: do not compile with the __linux__ define, we are doing bytecode! 22 char *cpp[] = { LCCDIR "q3cpp", 23 "-U__GNUC__", "-D_POSIX_SOURCE", "-D__STDC__=1", "-D__STRICT_ANSI__", 24 "-Dunix", "-Di386", "-Dlinux", 25 "-D__unix__", "-D__i386__", "-D__signed__=signed", 26 "$1", "$2", "$3", 0 }; 27 char *include[] = {"-I" LCCDIR "include", "-I" LCCDIR "gcc/include", "-I/usr/include", 28 "-I" SYSTEM "include", 0 }; 29 char *com[] = {LCCDIR "q3rcc", "-target=x86/linux", "$1", "$2", "$3", 0 }; 30 char *as[] = { "/usr/bin/as", "-o", "$3", "$1", "$2", 0 }; 31 // NOTE TTimo I don't think we have any use with the native linkage 32 // our target is always bytecode.. 33 char *ld[] = { 34 /* 0 */ "/usr/bin/ld", "-m", "elf_i386", "-dynamic-linker", 35 /* 4 */ "/lib/ld-linux.so.2", "-o", "$3", 36 /* 7 */ "/usr/lib/crt1.o", "/usr/lib/crti.o", 37 /* 9 */ SYSTEM "crtbegin.o", 38 "$1", "$2", 39 /* 12 */ "-L" LCCDIR, 40 /* 13 */ "-llcc", 41 /* 14 */ "-L" LCCDIR "/gcc", "-lgcc", "-lc", "-lm", 42 /* 18 */ "", 43 /* 19 */ SYSTEM "crtend.o", "/usr/lib/crtn.o", 44 /* 20 */ "-L" SYSTEM, 45 0 }; 46 47 extern char *concat(char *, char *); 48 49 int option(char *arg) { 50 if (strncmp(arg, "-lccdir=", 8) == 0) { 51 cpp[0] = concat(&arg[8], "/gcc/cpp"); 52 include[0] = concat("-I", concat(&arg[8], "/include")); 53 include[1] = concat("-I", concat(&arg[8], "/gcc/include")); 54 ld[9] = concat(&arg[8], "/gcc/crtbegin.o"); 55 ld[12] = concat("-L", &arg[8]); 56 ld[14] = concat("-L", concat(&arg[8], "/gcc")); 57 ld[19] = concat(&arg[8], "/gcc/crtend.o"); 58 com[0] = concat(&arg[8], "/rcc"); 59 } else if (strcmp(arg, "-p") == 0 || strcmp(arg, "-pg") == 0) { 60 ld[7] = "/usr/lib/gcrt1.o"; 61 ld[18] = "-lgmon"; 62 } else if (strcmp(arg, "-b") == 0) 63 ; 64 else if (strcmp(arg, "-g") == 0) 65 ; 66 else if (strncmp(arg, "-ld=", 4) == 0) 67 ld[0] = &arg[4]; 68 else if (strcmp(arg, "-static") == 0) { 69 ld[3] = "-static"; 70 ld[4] = ""; 71 } else 72 return 0; 73 return 1; 74 }