build 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #!/bin/sh
  2. #add in 'cont' support for NOT using make clean.
  3. #change this to 0 to not clean previously compiled files (faster/for dev)
  4. clean=1
  5. #### DO NOT EDIT BELOW THIS LINE #####
  6. # Awk out the version from source
  7. ver=`cat src/main.c 2>&1 | grep "char" | awk '/egg_version/ {print $4}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
  8. numver=`cat src/main.c 2>&1 | grep "int" | awk '/egg_numver =/ {print $4}' | sed -e 's/\;//g'`
  9. if test -z "$ver"
  10. then
  11. ver="?.?.?"
  12. fi
  13. echo "*** wraith v${ver}/${numver} builder ***"
  14. echo ""
  15. debug=0
  16. all=0
  17. hub=0
  18. leaf=0
  19. #if test $# -lt 1; then
  20. if test -z "$1"; then
  21. echo "Usage: $0 -d all|leaf|hub pack.cfg -c"
  22. echo " -d: Builds a debug package."
  23. # echo " -c: Does not erase previously compiled files unless *necessary* (faster)"
  24. echo ""
  25. exit 1
  26. elif [ $1 = "all" ]; then
  27. all=1
  28. elif [ $1 = "leaf" ]; then
  29. leaf=1
  30. elif [ $1 = "hub" ]; then
  31. hub=1
  32. elif [ $1 = "-d" ]; then
  33. debug=1
  34. test=" "
  35. if ! test $# -lt 2; then
  36. if [ $2 = "all" ]; then
  37. all=1
  38. elif [ $2 = "leaf" ]; then
  39. leaf=1
  40. elif [ $2 = "hub" ]; then
  41. hub=1
  42. else
  43. all=1
  44. pack=$2
  45. fi
  46. else
  47. all=1
  48. fi
  49. else
  50. all=1
  51. pack=$1
  52. fi
  53. d=""
  54. if [ $debug = "1" ]; then
  55. d="d"
  56. fi
  57. if ! test $pack
  58. then
  59. if [ $debug = "1" ]; then
  60. pack=$3
  61. else
  62. pack=$2
  63. fi
  64. fi
  65. if [ $all = "1" ]; then
  66. leaf=1
  67. hub=1
  68. fi
  69. if test $pack
  70. then
  71. packname=$pack
  72. else
  73. packname=default
  74. fi
  75. # Verify we got the config file
  76. origpack=$packname
  77. if ! test -f $packname; then
  78. packname=$packname.cfg
  79. fi
  80. if ! test -f $packname; then
  81. echo "[!] Can't find pack configuration file $origpack"
  82. exit 1
  83. else
  84. echo "[*] Using pack configuration file: $packname"
  85. fi
  86. # Figure what bins we're making
  87. case `uname` in
  88. Linux) os=Linux;;
  89. FreeBSD) case `uname -r` in
  90. 5*) os=FreeBSD5;;
  91. 4*) os=FreeBSD4;;
  92. 3*) os=FreeBSD3;;
  93. esac;;
  94. OpenBSD) os=OpenBSD;;
  95. esac
  96. if test -z $os
  97. then
  98. echo "[!] Automated packaging disabled, `uname` isn't recognized"
  99. fi
  100. echo "[*] Building pack for $os"
  101. # Run ./configure, then verify it's ok
  102. echo "[*] Configuring..."
  103. umask 077 >/dev/null
  104. TCLDIR=`cat $packname | grep "^\/"`
  105. if test -z ${TCLDIR}
  106. then
  107. echo "[*] Searching for TCL in default dirs (edit $packname to change)"
  108. ./configure --disable-tcl-threads > /dev/null 2>configure.temp
  109. else
  110. echo "[*] Searching for TCL in: $TCLDIR"
  111. ./configure --disable-tcl-threads --with-tcllib=${TCLDIR}/lib/libtcl8.4.a --with-tclinc=${TCLDIR}/include/tcl.h > /dev/null 2>configure.temp
  112. fi
  113. #if test "`cat configure.temp`"
  114. #then
  115. # echo "Configure error'd"
  116. # cat configure.temp
  117. #
  118. # exit 1
  119. #fi
  120. #rm -f configure.temp
  121. # make clean, just in case
  122. if [ $clean = "1" ]; then
  123. echo "[*] Cleaning up old binaries/files..."
  124. make clean > /dev/null
  125. fi
  126. # Read the config
  127. echo -n "[*] Compiling with:"
  128. for cnf in `cat $packname | grep -v "^#" | grep -v "^\/"`
  129. do
  130. defines="$defines -DS_$cnf"
  131. echo -n "$cnf "
  132. done
  133. echo ""
  134. # Build utils and check we got the bins
  135. echo "[*] Building utils..."
  136. make utils CFLGS="$defines" > /dev/null
  137. if ! test -f stringfix
  138. then
  139. echo "[!] Util build failed"
  140. exit 1
  141. fi
  142. if [ $leaf = "1" ]; then
  143. # Build leaf and check
  144. echo "[*] Building ${d}leaf..."
  145. make ${d}leaf CFLGS="$defines" > /dev/null
  146. if ! test -f leaf
  147. then
  148. echo "[!] ${d}leaf build failed"
  149. exit 1
  150. fi
  151. fi
  152. if [ $hub = "1" ]; then
  153. # Build hub and check
  154. echo "[*] Building ${d}hub..."
  155. make ${d}hub CFLGS="$defines" > /dev/null
  156. if ! test -f hub
  157. then
  158. echo "[!] ${d}hub build failed"
  159. exit 1
  160. fi
  161. fi
  162. # Wrap it nicely up into an archive
  163. echo "[*] Packaging..."
  164. packname=`basename $packname .cfg`
  165. if [ $all = "1" ]; then
  166. fls="leaf hub"
  167. elif [ $leaf = "1" ]; then
  168. fls="leaf"
  169. elif [ $hub = "1" ]; then
  170. fls="hub"
  171. fi
  172. for bin in $fls
  173. do
  174. mv -f $bin $bin.$os.$numver
  175. done
  176. tar -zcf $packname.$os.$numver.tgz *.$os.$numver
  177. rm -f *.$os.$numver
  178. echo "Binaries are now in '$packname.$os.$numver.tgz'."
  179. exit 0