build_project 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #!/bin/ksh
  2. #
  3. # build_project
  4. #
  5. ########################################################################
  6. # set -x
  7. ##########################################################################
  8. #
  9. # Script setup: THIS NEEDS TO BE FIRST
  10. #
  11. SCRIPTS_DIR="`dirname $0`"
  12. if [ "" = "$SCRIPTS_DIR" ]; then
  13. SCRIPTS_DIR=/project/dt/scripts
  14. fi
  15. ##########################################################################
  16. #
  17. # Script setup:
  18. #
  19. if [ ! -f $SCRIPTS_DIR/script_setup.ksh ]; then
  20. print -u2 "$PRG: File '$SCRIPTS_DIR/script_setup.ksh' NOT found!"
  21. print -u2 "$PRG: Exiting ..."
  22. exit 1
  23. fi
  24. . $SCRIPTS_DIR/script_setup.ksh
  25. PROG_NAME=$0
  26. CDETEST_BUILD_COMMAND=$CDETEST_TOP/admin/BuildTools/master_build/test_build
  27. BOOTSTRAPCFLAGS='BOOTSTRAPCFLAGS=""'
  28. PROJECT=""
  29. BUILD_TYPE="inc"
  30. LOG_DIR="/tmp"
  31. ########################################################################
  32. #
  33. # usage -
  34. #
  35. usage ()
  36. {
  37. cat <<eof
  38. USAGE: $1
  39. {-p | -project} {x11 | motif | cde | cdedoc | cde-test}
  40. [-c | -clean] # Do a clean build; the default is incremental
  41. [{-t | -top} <dir>]
  42. [{-l | -log_dir} <dir>] # Only used with project cde-test
  43. # Default TOP for x11 is '$X_TOP'.
  44. # Default TOP for motif is '$MOTIF_TOP'.
  45. # Default TOP for cde is '$CDE_TOP'.
  46. # Default TOP for cdedoc is '$CDEDOC_TOP'.
  47. # Default TOP for cde-test is '$CDETEST_TOP'.
  48. [-h | -? | -help] # Print usage and exit
  49. eof
  50. }
  51. ########################################################################
  52. #
  53. # Parse command line
  54. #
  55. while [ $# -gt 0 ]; do
  56. case $1 in
  57. -p | -project) PROJECT=$2; shift 2 ;;
  58. -c | -clean) BUILD_TYPE="clean"; shift 1 ;;
  59. -t | -top) TOP=$2; shift 2 ;;
  60. -l | -log_dir) LOG_DIR=$2; shift 2 ;;
  61. -h | -? | -help | *) usage $PROG_NAME;
  62. exit 1;
  63. esac
  64. done
  65. if [ "" = "$PROJECT" ]; then
  66. usage $PROG_NAME
  67. exit 1
  68. fi
  69. ########################################################################
  70. #
  71. # Define OS-specific variables
  72. #
  73. case "`uname -s`" in
  74. SunOS) if [ "4.1.4" = "`uname -r`" ]; then
  75. export PATH=$PATH:/usr/local/bin
  76. else
  77. export PATH=/opt/SUNWspro/bin:/usr/ccs/bin:$PATH:/usr/local/bin
  78. export LM_LICENSE_FILE=/opt/SUNWspro/license_dir/license.dat
  79. fi
  80. ;;
  81. UNIX_System_V) BOOTSTRAPCFLAGS="BOOTSTRAPCFLAGS=-D__uxp__"
  82. export PATH=/usr/ccs/bin:$PATH:/usr/local/bin
  83. print -u1 "$PROG_NAME: Setting $BOOTSTRAPCFLAGS" ;;
  84. UNIX_SV) export PATH=$PATH:/usr/local/bin
  85. print -u1 "$PROG_NAME: Setting $BOOTSTRAPCFLAGS" ;;
  86. IRIX) export PATH=$PATH:/usr/sbin ;;
  87. HP-UX) export PATH=$PATH:/usr/ccs/bin ;;
  88. Linux) export PATH=$PATH:/usr/bin:/usr/local/bin ;;
  89. *) export PATH=$PATH:/usr/local/bin ;;
  90. esac
  91. ########################################################################
  92. #
  93. # Set the cwd
  94. #
  95. if [ "" = "$TOP" ]; then
  96. case $PROJECT in
  97. x | x11) cd $X_TOP ;;
  98. motif) cd $MOTIF_TOP ;;
  99. cde) cd $CDE_TOP ;;
  100. cdedoc) cd $CDEDOC_TOP ;;
  101. cde-test) cd $CDETEST_TOP ;;
  102. *) print -u2 "Exiting ... Project '$PROJECT' is NOT supported!"
  103. exit 1
  104. esac
  105. else
  106. cd $TOP
  107. fi
  108. ########################################################################
  109. #
  110. # Audits
  111. #
  112. if [ $PROJECT != "cde-test" -a ! -f Makefile ]; then
  113. print -u2 "Exiting ... No Makefile is in the '`pwd`' directory!"
  114. exit 1
  115. fi
  116. ########################################################################
  117. #
  118. # Run the build script
  119. #
  120. case $BUILD_TYPE in
  121. clean)
  122. case $PROJECT in
  123. x | x11 | motif)
  124. TARGET=World ;;
  125. cde)
  126. TARGET=World.dev ;;
  127. cdedoc)
  128. TARGET=World.doc ;;
  129. cde-test)
  130. FLAGS="-c -w" ;;
  131. esac
  132. ;;
  133. inc)
  134. case $PROJECT in
  135. x | x11 | motif)
  136. TARGET=Everything ;;
  137. cde)
  138. TARGET=Everything.dev ;;
  139. cdedoc)
  140. TARGET=Everything.doc ;;
  141. cde-test)
  142. FLAGS=-c ;;
  143. esac
  144. ;;
  145. esac
  146. case $PROJECT in
  147. x | x11 | motif | cde | cdedoc)
  148. case "`uname -s`" in
  149. UNIX_SV)
  150. if [ "" = "$TOP" ]; then
  151. make -k BOOTSTRAPCFLAGS="-DSVR4 -Di386" $TARGET
  152. else
  153. make -k BOOTSTRAPCFLAGS="-DSVR4 -Di386" $TARGET TOP=$TOP
  154. fi
  155. ;;
  156. Linux)
  157. if [ "" = "$TOP" ]; then
  158. make -k $TARGET
  159. else
  160. make -k $TARGET TOP=$TOP
  161. fi
  162. ;;
  163. *)
  164. if [ "" = "$TOP" ]; then
  165. make -k "$BOOTSTRAPCFLAGS" $TARGET
  166. else
  167. make -k "$BOOTSTRAPCFLAGS" $TARGET TOP=$TOP
  168. fi
  169. ;;
  170. esac
  171. ;;
  172. cde-test)
  173. $CDETEST_BUILD_COMMAND -build $CDETEST_TOP $FLAGS -log $LOG_DIR ;;
  174. esac