build 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. #### 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.conf"
  22. echo " -d: Builds a debug package."
  23. echo ""
  24. exit 1
  25. elif [ $1 = "all" ]; then
  26. all=1
  27. elif [ $1 = "leaf" ]; then
  28. leaf=1
  29. elif [ $1 = "hub" ]; then
  30. hub=1
  31. elif [ $1 = "-d" ]; then
  32. debug=1
  33. test=" "
  34. if ! test $# -lt 2; then
  35. if [ $2 = "all" ]; then
  36. all=1
  37. elif [ $2 = "leaf" ]; then
  38. leaf=1
  39. elif [ $2 = "hub" ]; then
  40. hub=1
  41. else
  42. all=1
  43. pack=$2
  44. fi
  45. else
  46. all=1
  47. fi
  48. else
  49. all=1
  50. pack=$1
  51. fi
  52. d=""
  53. if [ $debug = "1" ]; then
  54. d="d"
  55. fi
  56. if ! test $pack
  57. then
  58. if [ $debug = "1" ]; then
  59. pack=$3
  60. else
  61. pack=$2
  62. fi
  63. fi
  64. if [ $all = "1" ]; then
  65. leaf=1
  66. hub=1
  67. fi
  68. if test $pack
  69. then
  70. packname=$pack
  71. else
  72. packname=default
  73. fi
  74. # Verify we got the config file
  75. origpack=$packname
  76. if ! test -f $packname; then
  77. packname=$packname.conf
  78. fi
  79. if ! test -f $packname; then
  80. echo "[!] Can't find pack configuration file $origpack"
  81. exit 1
  82. else
  83. echo "[*] Using pack configuration file: $packname"
  84. fi
  85. # Figure what bins we're making
  86. case `uname` in
  87. Linux) os=Linux;;
  88. FreeBSD) case `uname -r` in
  89. 5*) os=FreeBSD5;;
  90. 4*) os=FreeBSD4;;
  91. 3*) os=FreeBSD3;;
  92. esac;;
  93. OpenBSD) os=OpenBSD;;
  94. esac
  95. if test -z $os
  96. then
  97. echo "[!] Automated packaging disabled, `uname` isn't recognized"
  98. fi
  99. echo "[*] Building pack for $os"
  100. # Run ./configure, then verify it's ok
  101. echo "[*] Configuring..."
  102. umask 077 >/dev/null
  103. ./configure --disable-tcl-threads --with-tcllib=${TCLDIR}/lib/libtcl8.4.a --with-tclinc=${TCLDIR}/include/tcl.h > /dev/null 2>configure.temp
  104. #if test "`cat configure.temp`"
  105. #then
  106. # echo "Configure error'd"
  107. # cat configure.temp
  108. #
  109. # exit 1
  110. #fi
  111. #rm -f configure.temp
  112. # make clean, just in case
  113. echo "[*] Cleaning up old binaries..."
  114. make clean > /dev/null
  115. # Read the config
  116. echo -n "[*] Compiling with:"
  117. for cnf in `cat $packname | grep -v "^#"`
  118. do
  119. defines="$defines -DS_$cnf"
  120. echo -n "$cnf "
  121. done
  122. echo ""
  123. # Build utils and check we got the bins
  124. echo "[*] Building utils..."
  125. make utils CFLGS="$defines" > /dev/null
  126. if ! test -f stringfix
  127. then
  128. echo "[!] Util build failed"
  129. exit 1
  130. fi
  131. if [ $leaf = "1" ]; then
  132. # Build leaf and check
  133. echo "[*] Building ${d}leaf..."
  134. make ${d}leaf CFLGS="$defines" > /dev/null
  135. if ! test -f leaf
  136. then
  137. echo "[!] ${d}leaf build failed"
  138. exit 1
  139. fi
  140. fi
  141. if [ $hub = "1" ]; then
  142. # Build hub and check
  143. echo "[*] Building ${d}hub..."
  144. make ${d}hub CFLGS="$defines" > /dev/null
  145. if ! test -f hub
  146. then
  147. echo "[!] ${d}hub build failed"
  148. exit 1
  149. fi
  150. fi
  151. # Wrap it nicely up into an archive
  152. echo "[*] Packaging..."
  153. packname=`basename $packname .conf`
  154. if [ $all = "1" ]; then
  155. fls="leaf hub"
  156. elif [ $leaf = "1" ]; then
  157. fls="leaf"
  158. elif [ $hub = "1" ]; then
  159. fls="hub"
  160. fi
  161. for bin in $fls
  162. do
  163. mv -f $bin $bin.$os.$numver
  164. done
  165. tar -zcf $packname.$os.$numver.tgz *.$os.$numver
  166. rm -f *.$os.$numver
  167. echo "Binaries are now in '$packname.$os.$numver.tgz'."
  168. exit 0