Conscript (3467B)
1 # cgame building 2 # builds the cgame for vanilla Q3 and TA 3 4 # there are slight differences between Q3 and TA build: 5 # -DMISSIONPACK 6 # TA has cg_newdraw.c and ../ui/ui_shared.c 7 # the config is passed in the imported variable TARGET_DIR 8 9 # qvm building against native: 10 # only native has cg_syscalls.c 11 # only qvm has ../game/bg_lib.c 12 # qvm uses a custom cg_syscalls.asm with equ stubs 13 14 Import qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK ); 15 16 $env = new cons( 17 # the code has the very bad habit of doing things like #include "../ui/ui_shared.h" 18 # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix 19 CPPPATH => '#cgame:#game:#q3_ui', 20 CC => $CC, 21 CXX => $CXX, 22 LINK => $LINK, 23 ENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} }, 24 CFLAGS => $BASE_CFLAGS . '-fPIC', 25 LDFLAGS => '-shared -ldl -lm' 26 ); 27 28 # for TA, use -DMISSIONPACK 29 %ta_env_hash = $env->copy( 30 CPPPATH => '#cgame:#game:#ui' 31 ); 32 $ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $ta_env_hash{CFLAGS}; 33 $ta_env = new cons(%ta_env_hash); 34 35 # qvm building 36 # we heavily customize the cons environment 37 $vm_env = new cons( 38 # the code has the very bad habit of doing things like #include "../ui/ui_shared.h" 39 # this seems to confuse the dependency analysis, explicit toplevel includes seem to fix 40 CPPPATH => '#cgame:#game:#q3_ui', 41 CC => 'q3lcc', 42 CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>', 43 SUFOBJ => '.asm', 44 LINK => 'q3asm', 45 CFLAGS => '-DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g', 46 # need to know where to find the compiler tools 47 ENV => { PATH => $ENV{PATH} . ":./qvmtools", }, 48 ); 49 50 # TA qvm building 51 %vm_ta_env_hash = $vm_env->copy( 52 CPPPATH => '#cgame:#game:#ui' 53 ); 54 $vm_ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $vm_ta_env_hash{CFLAGS}; 55 $vm_ta_env = new cons(%vm_ta_env_hash); 56 57 # the file with vmMain function MUST be the first one of the list 58 @FILES = qw( 59 cg_main.c 60 ../game/bg_misc.c 61 ../game/bg_pmove.c 62 ../game/bg_slidemove.c 63 ../game/q_math.c 64 ../game/q_shared.c 65 cg_consolecmds.c 66 cg_draw.c 67 cg_drawtools.c 68 cg_effects.c 69 cg_ents.c 70 cg_event.c 71 cg_info.c 72 cg_localents.c 73 cg_marks.c 74 cg_players.c 75 cg_playerstate.c 76 cg_predict.c 77 cg_scoreboard.c 78 cg_servercmds.c 79 cg_snapshot.c 80 cg_view.c 81 cg_weapons.c 82 ); 83 $FILESREF = \@FILES; 84 85 # only in .so 86 # (VM uses a custom .asm with equ stubs) 87 @SO_FILES = qw( 88 cg_syscalls.c 89 ); 90 $SO_FILESREF = \@SO_FILES; 91 92 # only for VM 93 @VM_FILES = qw( 94 ../game/bg_lib.c 95 cg_syscalls.asm 96 ); 97 $VM_FILESREF = \@VM_FILES; 98 99 # common additionals for TA 100 @TA_FILES = qw( 101 cg_newdraw.c 102 ../ui/ui_shared.c 103 ); 104 $TA_FILESREF = \@TA_FILES; 105 106 # FIXME CPU string 107 if ($TARGET_DIR eq 'Q3') 108 { 109 if ($NO_SO eq 0) 110 { 111 Program $env 'cgamei386.so', @$FILESREF, @$SO_FILESREF; 112 Install $env $INSTALL_DIR, 'cgamei386.so'; 113 } 114 if ($NO_VM eq 0) 115 { 116 Depends $vm_env 'cgame.qvm', '#qvmtools/q3lcc'; 117 Depends $vm_env 'cgame.qvm', '#qvmtools/q3asm'; 118 Program $vm_env 'cgame.qvm', @$FILESREF, @$VM_FILESREF; 119 Install $vm_env $INSTALL_DIR . '/vm', 'cgame.qvm'; 120 } 121 } 122 else 123 { 124 if ($NO_SO eq 0) 125 { 126 Program $ta_env 'cgamei386.so', 127 @$FILESREF, @$SO_FILESREF, @$TA_FILESREF; 128 Install $ta_env $INSTALL_DIR, 'cgamei386.so'; 129 } 130 if ($NO_VM eq 0) 131 { 132 Depends $vm_env 'cgame.qvm', '#qvmtools/q3lcc'; 133 Depends $vm_env 'cgame.qvm', '#qvmtools/q3asm'; 134 Program $vm_ta_env 'cgame.qvm', 135 @$FILESREF, @$VM_FILESREF, @$TA_FILESREF; 136 Install $vm_ta_env $INSTALL_DIR . '/vm', 'cgame.qvm'; 137 } 138 }