build 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #!/bin/bash
  2. # This script is an experiment. It is designed to automate the
  3. # Panda3D build process for Linux or Unix users, or for Windows users
  4. # who have Cygwin installed. If you want to build Panda3D on a
  5. # Windows machine without Cygwin, please refer to the INSTALL document
  6. # instead of attempting to run this script.
  7. # Before you run this script, you must set up your Config.pp file and
  8. # Config.prc files as described in the INSTALL document, and you must
  9. # build and install ppremake (or ppremake.exe), before running this
  10. # script.
  11. # You should ensure that the install bin directory,
  12. # e.g. /usr/local/panda/bin, is on your PATH, and that the install lib
  13. # directory, /usr/local/panda/lib, is on your LD_LIBRARY_PATH (for
  14. # Unix) or your PATH (for Windows). If you are building Python
  15. # interfaces, you should also ensure that /usr/local/panda/lib is on
  16. # your PYTHONPATH.
  17. # Finally, you must have write permission to the /usr/local/panda
  18. # directory hierarchy in order for this script to run successfully.
  19. # As with any automatic process, this script may not work in every
  20. # environment. An effort has been made to make the script as
  21. # trouble-free as possible, but things can always go wrong. If you
  22. # have difficulty running this script, you are encouraged to follow
  23. # the step-by-step instructions in the INSTALL document to build
  24. # Panda3D by hand.
  25. usage="build [\"\"|new|uninstall|install|clean|only|genpy [\"\"|dtool|panda|direct|<relative path>] ]"
  26. usage=$(cat <<-EOS
  27. Usage: ./$(basename $0) [ mode [ module [ package ] ] ]
  28. [Be sure to cd to the panda3d directory first.]
  29. mode ""|new|uninstall|install|clean|only|genpy|--help
  30. module ""|dtool|panda|direct|<relative path>
  31. package one of the */src/* directories.
  32. Examples:
  33. ./build new
  34. ./build install
  35. ./build install panda
  36. ./build clean
  37. ./build clean panda
  38. ./build genpy
  39. ./build only panda express
  40. ./build quick panda express
  41. EOS
  42. )
  43. mode=$1
  44. module=$2
  45. base=$(pwd)
  46. wantGenPy=1
  47. #trap "exit" INT
  48. if [ "$mode" == "--help" ]; then
  49. echo "$usage"
  50. exit
  51. fi
  52. echo -e "\nSetting up build environment\n"
  53. if [ -f ./build_env ]; then
  54. source ./build_env || exit
  55. fi
  56. modules="dtool panda pandatool direct $modules"
  57. if [ "$module" != "" ]; then
  58. modules="$module"
  59. fi
  60. case "$mode" in
  61. ( only )
  62. cd $base/$module || exit
  63. ppremake || exit
  64. make uninstall install || exit
  65. modules_ppremake=""
  66. modules_clean=""
  67. modules_uninstall=""
  68. modules_install=""
  69. ;;
  70. ( quick )
  71. cd $base/$module/src/$3 || exit
  72. make || exit
  73. cd $base/$module || exit
  74. make install || exit
  75. wantGenPy=0
  76. modules_ppremake=""
  77. modules_clean=""
  78. modules_uninstall=""
  79. modules_install=""
  80. ;;
  81. ( new )
  82. # ...build the newest version of the code:
  83. echo -e "\nUpdating cvs\n"
  84. cd "$base" || exit
  85. ./cvs_update || exit
  86. cd "$base" || exit
  87. # This next command is allowed to fail (no || exit):
  88. echo -e "\nBuilding tags file\n"
  89. ctags -nR -h '+.I' --langmap='c:+.I' -h '+.T' --langmap='c:+.T' --fields=fmisS
  90. modules_ppremake=$modules
  91. modules_clean="direct $modules_clean"
  92. modules_uninstall=$modules
  93. modules_install=$modules
  94. ;;
  95. ( ppremake )
  96. wantGenPy=0
  97. modules_ppremake=$modules
  98. modules_clean=""
  99. modules_uninstall=""
  100. modules_install=""
  101. ;;
  102. ( clean )
  103. wantGenPy=0
  104. modules_ppremake=$modules
  105. modules_clean=$modules
  106. modules_uninstall=""
  107. modules_install=""
  108. ;;
  109. ( uninstall )
  110. wantGenPy=0
  111. modules_ppremake=$modules
  112. modules_clean=""
  113. modules_uninstall=$modules
  114. modules_install=""
  115. ;;
  116. ( install )
  117. modules_ppremake=$modules
  118. modules_clean=""
  119. modules_uninstall=$modules
  120. modules_install=$modules
  121. ;;
  122. ( "" )
  123. modules_ppremake=$modules
  124. # Some modules are small enough that we clean them for good measure:
  125. modules_clean="direct $modules_clean"
  126. modules_uninstall=$modules
  127. modules_install=$modules
  128. ;;
  129. ( genpy )
  130. wantGenPy=1
  131. modules_ppremake=""
  132. modules_clean=""
  133. modules_uninstall=""
  134. modules_install=""
  135. ;;
  136. ( * )
  137. echo -e "\nThat mode is not recognized ($mode)"
  138. echo "$usage"
  139. exit 1
  140. ;;
  141. esac
  142. echo " modules_ppremake =$modules_ppremake"
  143. echo " modules_clean =$modules_clean"
  144. echo " modules_uninstall =$modules_uninstall"
  145. echo " modules_install =$modules_install"
  146. for i in $modules_ppremake; do
  147. echo -e "\nStarting Ppremake of $i\n"
  148. cd "$base/$i" || exit
  149. ppremake $ppremake_args || exit
  150. done
  151. for i in $modules_clean; do
  152. echo -e "\nStarting Clean of $i\n"
  153. cd "$base/$i" || exit
  154. make clean || exit
  155. done
  156. for i in $modules_uninstall; do
  157. echo -e "\nStarting Uninstall of $i\n"
  158. cd "$base/$i" || exit
  159. make uninstall || exit
  160. done
  161. for i in $modules_install; do
  162. echo -e "\nStarting Install (build) of $i\n"
  163. cd "$base/$i" || exit
  164. make install || exit
  165. done
  166. cd "$base"
  167. if (($wantGenPy)); then
  168. # Generate Python code:
  169. echo "Generating Python/C++ interface code"
  170. #cd $base || exit
  171. genPyCode || exit
  172. fi
  173. if [ ! -f "$INSTALL_DIR/etc/config.prc" -a -f "$HOME/config.prc" ]; then
  174. echo ""
  175. echo "A .prc file was found at '$HOME/config.prc' creating a hard link from '$INSTALL_DIR/etc/'"
  176. ( cd "$INSTALL_DIR/etc" && ln "$HOME/config.prc" . );
  177. fi
  178. echo "done"