build 3.7 KB

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