summaryrefslogtreecommitdiff
blob: 76b22438687eba6fd17950525391df81f74deb4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/tcng/tcng-9i.ebuild,v 1.10 2006/01/29 19:46:00 cryos Exp $

inherit eutils

DESCRIPTION="Traffic Control Next Generation"
HOMEPAGE="http://tcng.sourceforge.net/"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="debug doc tcsim"

# perl because stuff is written in it
# iproute,linux-atm as the output needs that
# os-headers as it compiles stuff with them
# gcc/binutils as it compiles stuff
DEPEND_COMMON="dev-lang/perl
	sys-apps/iproute2
	net-dialup/linux-atm
	virtual/os-headers
	sys-devel/gcc
	sys-devel/binutils"

DEPEND="doc? ( virtual/ghostscript virtual/tetex media-gfx/transfig )
	sys-devel/make
	dev-util/yacc
	sys-devel/flex
	${DEPEND_COMMON}"
RDEPEND="sys-devel/gcc
	tcsim? ( sci-visualization/gnuplot )
	sys-apps/grep
	sys-apps/sed
	sys-apps/gawk
	sys-apps/coreutils
	${DEPEND_COMMON}"

IPROUTE_PN="iproute"
IPROUTE_PV="20010824"
IPROUTE_DEBIAN_PATCH_PV="11"
IPROUTE_P="${IPROUTE_PN}-${IPROUTE_PV}"
IPROUTE_DEBIAN_PATCH="${IPROUTE_P/-/_}-${IPROUTE_DEBIAN_PATCH_PV}.diff.gz"
IPROUTE_SRCFILE="iproute2-2.4.7-now-ss${IPROUTE_PV/20}.tar.gz"

# we also need a vanilla kernel source to use with this
KERNEL_PN=linux
KERNEL_PV=2.4.23
KERNEL_P=${KERNEL_PN}-${KERNEL_PV}

# note this project does NOT use the SF mirroring system
SRC_URI="http://tcng.sourceforge.net/dist/${P}.tar.gz
	tcsim? ( ftp://ftp.inr.ac.ru/ip-routing/${IPROUTE_SRCFILE}
	mirror://debian/pool/main/i/iproute/${IPROUTE_DEBIAN_PATCH}
	mirror://kernel/linux/kernel/v2.4/${KERNEL_P}.tar.bz2 )"

S=${WORKDIR}/tcng
IPROUTE_S=${WORKDIR}/${IPROUTE_P}
KERNEL_S=${WORKDIR}/${KERNEL_P}

src_unpack() {
	# unpack tcng
	unpack ${P}.tar.gz || die "failed to unpack tcng"
	epatch ${FILESDIR}/${P}-fixes.patch
	epatch ${FILESDIR}/${P}-gentoo.patch

	if use tcsim; then
		# unpack kernel
		unpack ${KERNEL_P}.tar.bz2 || die "failed to unpack kernel"
		ln -s ${KERNEL_S} ${S}/tcsim/linux || die "failed to unpack kernel"

		# unpack iproute
		unpack ${IPROUTE_SRCFILE} || die "failed to unpack iproute"
		mv iproute2 iproute-20010824 || die "failed to unpack iproute"
		epatch ${DISTDIR}/${IPROUTE_DEBIAN_PATCH}
		# this is needed for tcsim
		rm ${IPROUTE_S}/include-glibc/bits/socket.h || die "failed to unpack iproute"
		cp -f ${IPROUTE_S}/include-glibc/socketbits.h ${IPROUTE_S}/include-glibc/bits/socket.h || die "failed to unpack iproute"
		ln -s ${IPROUTE_S} ${S}/tcsim/iproute2 || die "failed to unpack iproute"
	fi
}

src_compile() {
	local myconf
	if use tcsim; then
		myconf="${myconf} --with-tcsim"
		myconf="${myconf} --kernel ${KERNEL_S}"
		myconf="${myconf} --iproute2 ${IPROUTE_S}"
	else
		myconf="${myconf} --no-tcsim"
	fi

	# i know this is before install stage, but the build needs it
	dodir /usr/bin

	# configure is NONSTANDARD
	./configure \
		--install-directory /usr \
		--no-manual \
		${myconf} \
		|| die "configure failed"

	# if we aren't debugging, an extra optimization is available
	use debug || CFLAGS="${CFLAGS} -D__NO_STRING_INLINES"
	# upstream package uses CFLAGS var for it's own uses
	sed -i Common.make -e "s/^\(CC_OPTS=\)\(.*\)/\1${CFLAGS} #\2/"
	unset CFLAGS
	emake || die
	cd ${S}/doc
	make tcng.txt
	use doc && make tcng.pdf
}

src_install() {
	dodir /usr
	dodir /usr/bin

	#For localization.sh to work corectly
	#TCNG INSTALL/TOPDIR has to be /usr, instead of /var/tmp/portage/tcng-xx/image/usr...
	sed 's:^\(INSTALL_DIR=\)\(.*\):\1$(DESTDIR)\2:g' -i ${S}/Makefile
	einstall DESTDIR=${D} TCNG_INSTALL_CWD=/usr install-tcc || die "make install-tcc failed"
	if use tcsim; then
		einstall DESTDIR=${D} TCNG_INSTALL_CWD=/usr install-tcsim || die "make install-tcsim failed"
	fi

	# lots of doc stuff
	dodoc CHANGES COPYING.GPL COPYING.LGPL README TODO VERSION tcc/PARAMETERS
	dodoc doc/tcng.txt doc/README.tccext
	newdoc doc/README README.doc
	if use doc; then
		dodoc doc/tcng.ps doc/tcng.pdf
	fi
	if use tcsim; then
		newdoc tcsim/BUGS BUGS.tcsim
		newdoc tcsim/README README.tcsim
	fi
}