#!/bin/sh #add in 'cont' support for NOT using make clean. #change this to 0 to not clean previously compiled files (faster/for dev) clean=0 #### DO NOT EDIT BELOW THIS LINE ##### # Awk out the version from source ver=`cat src/main.c 2>&1 | grep "char" | awk '/egg_version/ {print $4}' | sed -e 's/\"//g' | sed -e 's/\;//g'` numver=`cat src/main.c 2>&1 | grep "int" | awk '/egg_numver =/ {print $4}' | sed -e 's/\;//g'` if test -z "$ver" then ver="?.?.?" fi echo "*** wraith v${ver}/${numver} builder ***" echo "" debug=0 all=0 hub=0 leaf=0 #if test $# -lt 1; then if test -z "$1"; then echo "Usage: $0 -d all|leaf|hub" echo " -d: Builds a debug package." # echo " -c: Does not erase previously compiled files unless *necessary* (faster)" echo "" exit 1 elif [ $1 = "all" ]; then all=1 elif [ $1 = "leaf" ]; then leaf=1 elif [ $1 = "hub" ]; then hub=1 elif [ $1 = "-d" ]; then debug=1 test=" " if ! test $# -lt 2; then if [ $2 = "all" ]; then all=1 elif [ $2 = "leaf" ]; then leaf=1 elif [ $2 = "hub" ]; then hub=1 else all=1 fi else all=1 fi else all=1 fi d="" if [ $debug = "1" ]; then d="d" fi if [ $all = "1" ]; then leaf=1 hub=1 fi packname=wraith ############# CHECK FOR pack/ FILES ################# # Figure what bins we're making case `uname` in Linux) os=Linux;; FreeBSD) case `uname -r` in 5*) os=FreeBSD5;; 4*) os=FreeBSD4;; 3*) os=FreeBSD3;; esac;; OpenBSD) os=OpenBSD;; esac if test -z $os then echo "[!] Automated packaging disabled, `uname` isn't recognized" fi echo "[*] Building pack for $os" # Run ./configure, then verify it's ok echo "[*] Configuring..." umask 077 >/dev/null TCLDIR=`cat pack/conf.h 2>&1 | grep "//" | awk '/TCLDIR/ {print $2}' | sed -e 's/\"//g'` if test -z ${TCLDIR} then echo "[*] Searching for TCL in default dirs (edit $packname to change)" ./configure --silent --disable-tcl-threads --enable-ipv6 else echo "[*] Searching for TCL in: $TCLDIR" ./configure --silent --disable-tcl-threads --enable-ipv6 --with-tcllib=${TCLDIR}/lib/libtcl8.4.a --with-tclinc=${TCLDIR}/include/tcl.h fi # make clean, just in case if [ $clean = "1" ]; then echo "[*] Cleaning up old binaries/files..." make clean > /dev/null fi if [ $leaf = "1" ]; then # Build leaf and check echo "[*] Building ${d}leaf..." make ${d}leaf -s if ! test -f leaf then echo "[!] ${d}leaf build failed" exit 1 fi fi if [ $hub = "1" ]; then # Build hub and check echo "[*] Building ${d}hub..." make ${d}hub -s if ! test -f hub then echo "[!] ${d}hub build failed" exit 1 fi fi # Wrap it nicely up into an archive echo "[*] Packaging..." packname=`basename $packname .cfg` if [ $all = "1" ]; then fls="leaf hub" elif [ $leaf = "1" ]; then fls="leaf" elif [ $hub = "1" ]; then fls="hub" fi for bin in $fls do mv -f $bin $bin.$os.$numver done tar -zcf $packname.$os.$numver.tgz *.$os.$numver rm -f *.$os.$numver echo "Binaries are now in '$packname.$os.$numver.tgz'." exit 0