#! /bin/bash

# Define parameters
VERS=1.0.8
SRC="src/tcludp-${VERS}.tar.gz"
SRCURL="http://sourceforge.net/projects/tcludp/files/tcludp/${VERS}/tcludp-${VERS}.tar.gz/download"
BUILDDIR="tcludp-${VERS}"
export VERS SRC SRCURL BUILDDIR

# Load common functions
source ../common.sh

# Do not build if the "tcl" platform has been requested
not_platforms 'tcl'

# Download source
download_src

# Build package
(
	rm -rf build
	mkdir -p "${PLATDIR}" >/dev/null 2>/dev/null
	mkdir build

	cd build/ || exit 1

	gzip -dc "../${SRC}" | tar -xf -
	cd "${BUILDDIR}" || exit 1

	bash ./configure --enable-shared --enable-threads --with-tcl="${TCLCONFIGDIR}" --prefix="${PLATDIR}" --libdir="${PLATDIR}" --bindir="${PLATDIR}" ${CONFIGUREEXTRA}

	${MAKE:-make} || exit 1

	${MAKE:-make} install-binaries PKG_DIR='' || exit 1

	rm -f "${PLATDIR}"/*.a
) || exit 1

# Create metadata
../create_teapot "${PLATDIR}/teapot.txt" "udp" "${VERS}" "${SRCURL}" "${PLATFORM}" "Tcl 8.4" "The TclUDP package provides Tcl with UDP sockets on Windows and UNIX-like systems.  It supports multicast and binary data."

exit 0
