build 3.3 KB

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