Conscript 3.4 KB

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