build 2.9 KB

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