build 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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/wheel/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.conf -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.conf
  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. ./configure --disable-tcl-threads --with-tcllib=${TCLDIR}/lib/libtcl8.4.a --with-tclinc=${TCLDIR}/include/tcl.h > /dev/null 2>configure.temp
  107. #if test "`cat configure.temp`"
  108. #then
  109. # echo "Configure error'd"
  110. # cat configure.temp
  111. #
  112. # exit 1
  113. #fi
  114. #rm -f configure.temp
  115. # make clean, just in case
  116. if [ $clean = "1" ]; then
  117. echo "[*] Cleaning up old binaries/files..."
  118. make clean > /dev/null
  119. fi
  120. # Read the config
  121. echo -n "[*] Compiling with:"
  122. for cnf in `cat $packname | grep -v "^#"`
  123. do
  124. defines="$defines -DS_$cnf"
  125. echo -n "$cnf "
  126. done
  127. echo ""
  128. # Build utils and check we got the bins
  129. echo "[*] Building utils..."
  130. make utils CFLGS="$defines" > /dev/null
  131. if ! test -f stringfix
  132. then
  133. echo "[!] Util build failed"
  134. exit 1
  135. fi
  136. if [ $leaf = "1" ]; then
  137. # Build leaf and check
  138. echo "[*] Building ${d}leaf..."
  139. make ${d}leaf CFLGS="$defines" > /dev/null
  140. if ! test -f leaf
  141. then
  142. echo "[!] ${d}leaf build failed"
  143. exit 1
  144. fi
  145. fi
  146. if [ $hub = "1" ]; then
  147. # Build hub and check
  148. echo "[*] Building ${d}hub..."
  149. make ${d}hub CFLGS="$defines" > /dev/null
  150. if ! test -f hub
  151. then
  152. echo "[!] ${d}hub build failed"
  153. exit 1
  154. fi
  155. fi
  156. # Wrap it nicely up into an archive
  157. echo "[*] Packaging..."
  158. packname=`basename $packname .conf`
  159. if [ $all = "1" ]; then
  160. fls="leaf hub"
  161. elif [ $leaf = "1" ]; then
  162. fls="leaf"
  163. elif [ $hub = "1" ]; then
  164. fls="hub"
  165. fi
  166. for bin in $fls
  167. do
  168. mv -f $bin $bin.$os.$numver
  169. done
  170. tar -zcf $packname.$os.$numver.tgz *.$os.$numver
  171. rm -f *.$os.$numver
  172. echo "Binaries are now in '$packname.$os.$numver.tgz'."
  173. exit 0