build 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #!/bin/sh
  2. # Awk out the version from source
  3. ver="?.?.?"
  4. ver=`grep "char" src/main.c | awk '/egg_version/ {print $4}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
  5. numver=`grep "int" src/main.c | awk '/egg_numver =/ {print $4}' | sed -e 's/\;//g'`
  6. PACKNAME=`grep "PACKNAME " pack/pack.cfg | awk '/PACKNAME/ {print $2}'`
  7. echo "*** wraith v${ver}/${numver} builder ***"
  8. usage()
  9. {
  10. echo "Usage: $0 [-d] [-c] [-t dir] type"
  11. echo " -c - Cleans up old binaries/files before compile (default: off)"
  12. echo " -d - Builds a debug package. (default: off)"
  13. echo " -t dir - Where to search for TCL libraries. (usually not needed)"
  14. echo " type - One of the following: all, leaf, hub."
  15. }
  16. debug=0
  17. all=0
  18. hub=0
  19. leaf=0
  20. clean=0
  21. type=
  22. tcldir=
  23. while getopts t:cdh opt ; do
  24. case "$opt" in
  25. c) clean=1 ;;
  26. d) debug=1 ;;
  27. t) tcldir="$OPTARG" ;;
  28. h) usage; exit 0 ;;
  29. *) usage; exit 1 ;;
  30. esac
  31. done
  32. shift $(($OPTIND - 1))
  33. if test -z "$1"; then
  34. usage
  35. exit 1
  36. else
  37. if [ $1 = "all" ]; then
  38. all=1
  39. elif [ $1 = "leaf" ]; then
  40. leaf=1
  41. type="leaf"
  42. elif [ $1 = "hub" ]; then
  43. hub=1
  44. type="hub"
  45. else
  46. all=1
  47. # usage
  48. # exit 1
  49. fi
  50. fi
  51. if [ $debug = "1" ]; then
  52. d="d"
  53. else
  54. d=""
  55. fi
  56. if [ $all = "1" ]; then
  57. type="all"
  58. leaf=1
  59. hub=1
  60. fi
  61. ############# CHECK FOR pack/ FILES #################
  62. # Figure what bins we're making
  63. case `uname` in
  64. Linux) os=Linux;;
  65. FreeBSD) case `uname -r` in
  66. 5*) os=FreeBSD5;;
  67. 4*) os=FreeBSD4;;
  68. 3*) os=FreeBSD3;;
  69. esac;;
  70. OpenBSD) os=OpenBSD;;
  71. esac
  72. if test -z $os
  73. then
  74. echo "[!] Automated packaging disabled, `uname` isn't recognized"
  75. fi
  76. echo "[*] Building ${PACKNAME}::${type} for $os"
  77. # Run ./configure, then verify it's ok
  78. echo "[*] Configuring..."
  79. umask 077 >/dev/null
  80. if test -z "$tcldir"; then
  81. echo "[*] Searching for TCL in default paths (use '-t dir' to change)"
  82. ./configure --silent --disable-tcl-threads
  83. else
  84. echo "[*] Searching for TCL in: $tcldir"
  85. ./configure --silent --disable-tcl-threads --with-tcllib=${tcldir}/lib/libtcl8.4.a --with-tclinc=${tcldir}/include/tcl.h
  86. fi
  87. # make clean, just in case
  88. if [ $clean = "1" ]; then
  89. echo "[*] Cleaning up old binaries/files..."
  90. make clean > /dev/null
  91. fi
  92. _leaf()
  93. {
  94. if [ $leaf = "1" ]; then
  95. # Build leaf and check
  96. echo "[*] Building ${d}leaf..."
  97. make ${d}leaf -s
  98. if ! test -f leaf
  99. then
  100. echo "[!] ${d}leaf build failed"
  101. exit 1
  102. fi
  103. fi
  104. }
  105. _hub()
  106. {
  107. if [ $hub = "1" ]; then
  108. # Build hub and check
  109. echo "[*] Building ${d}hub..."
  110. make ${d}hub -s
  111. if ! test -f hub
  112. then
  113. echo "[!] ${d}hub build failed"
  114. exit 1
  115. fi
  116. fi
  117. }
  118. if [ -f stamp.hub ]; then
  119. _hub
  120. _leaf
  121. else
  122. _leaf
  123. _hub
  124. fi
  125. # Wrap it nicely up into an archive
  126. echo "[*] Packaging..."
  127. if [ $all = "1" ]; then
  128. fls="leaf hub"
  129. elif [ $leaf = "1" ]; then
  130. fls="leaf"
  131. elif [ $hub = "1" ]; then
  132. fls="hub"
  133. fi
  134. if test -n "$d"; then
  135. d="-debug"
  136. fi
  137. for bin in $fls
  138. do
  139. mv -f $bin $bin.$os.$numver${d}
  140. done
  141. tar -zcf ${PACKNAME}.$os.$numver${d}.tgz *.$os.$numver${d}
  142. rm -f *$os.$numver${d}
  143. echo "Binaries are now in '${PACKNAME}.$os.$numver${d}.tgz'."
  144. exit 0