# Ports collection makefile for:	click
# Date created:        3 Nov 2001
# Whom:                gnn
#
# $FreeBSD: ports/net/click/Makefile,v 1.15 2006/11/05 09:51:31 bms Exp $
#

# XXX: TODO: fix kernel module

PORTNAME=	click
PORTVERSION=	1.5.0
CATEGORIES=	net
MASTER_SITES=	http://www.read.cs.ucla.edu/click/

MAINTAINER=	bms@FreeBSD.org
COMMENT=	The Click Modular Router

USE_PERL5_BUILD=yes
GNU_CONFIGURE=	yes
USE_GMAKE=	yes

SRC_BASE?=	/usr/src
INC_BASE?=	/usr/include

CONFIGURE_ARGS+=	--disable-linuxmodule
CONFIGURE_ARGS+=	--enable-nanotimestamp

MANCOMPRESSED=	no
INFO=	click
MAN1=	click.1 click-align.1 click-combine.1 click-devirtualize.1 \
	click-fastclassifier.1 click-flatten.1 click-install.1 \
	click-mkmindriver.1 click-pretty.1 click-uncombine.1 click-undead.1 \
	click-uninstall.1 click-xform.1 testie.1
MAN5=	click.5
MAN7=	elementdoc.7
MAN8=	click.o.8
MANN=	FTPPortMapper.n ARPFaker.n ARPPrint.n ARPQuerier.n ARPResponder.n \
	elements-click.n ChangeUID.n \
	EnsureEther.n EtherEncap.n EtherMirror.n HostEtherFilter.n \
	CheckARPHeader.n DirectIPLookup.n \
	RFC2507Comp.n RFC2507Decomp.n \
	CheckICMPHeader.n ICMPError.n ICMPPingResponder.n ICMPPingRewriter.n \
	ICMPRewriter.n CheckIPHeader.n CheckIPHeader2.n \
	DecIPTTL.n FixIPSrc.n FromSocket.n GetIPAddress.n ICMPPingEncap.n \
	ICMPPingSource.n IPAddrRewriter.n IPAddrPairRewriter.n IPClassifier.n \
	IPEncap.n IPFilter.n IPFragmenter.n IPGWOptions.n IPInputCombo.n \
	IPNameInfo.n \
	IPMirror.n IPOutputCombo.n IPPrint.n IPRateMonitor.n IPRewriterPatterns.n \
	KernelTun.n LinearIPLookup.n LinkUnqueue.n \
	MarkIPCE.n MarkIPHeader.n Message.n MixedQueue.n NotifierQueue.n \
	PaintSwitch.n PortInfo.n RIPSend.n RandomSwitch.n RangeIPLookup.n \
	RoundRobinIPMapper.n SetAnnoByte.n SetIPAddress.n SetIPChecksum.n SetIPDSCP.n \
	SetRandIPAddress.n SetUDPChecksum.n SimpleQueue.n StoreData.n \
	StoreIPAddress.n StripIPHeader.n ToSocket.n UnstripIPHeader.n \
	Socket.n Script.n Truncate.n \
	AddressInfo.n Align.n AlignmentInfo.n AverageCounter.n \
	BandwidthMeter.n BandwidthShaper.n Burster.n BandwidthRatedSplitter.n \
	BandwidthRatedUnqueue.n CheckCRC32.n CheckLength.n CheckPaint.n \
	Classifier.n CompareBlock.n Counter.n DelayShaper.n DelayUnqueue.n \
	Discard.n DiscardNoFree.n DriverManager.n DropBroadcasts.n DRRSched.n \
	Error.n FrontDropQueue.n HashSwitch.n Idle.n \
	InfiniteSource.n Meter.n MSQueue.n Null.n PushNull.n PullNull.n \
	Null1.n \
	Paint.n PaintTee.n PokeHandlers.n Print.n PrioSched.n \
	PullSwitch.n Queue.n QuitWatcher.n \
	RandomBitErrors.n RandomSource.n RatedSource.n \
	RatedSplitter.n RatedUnqueue.n RED.n RoundRobinSched.n \
	RoundRobinSwitch.n ScheduleInfo.n SetCRC32.n SetTimestamp.n Shaper.n \
	SourceIPHashMapper.n SortedIPLookup.n \
	SpinlockAcquire.n SpinlockInfo.n SpinlockRelease.n StaticPullSwitch.n \
	StaticSwitch.n StrideSched.n StrideSwitch.n Strip.n Suppressor.n \
	Switch.n Tee.n PullTee.n TimedSink.n TimedSource.n Unqueue.n \
	Unqueue2.n Unstrip.n CheckTCPHeader.n CheckUDPHeader.n \
	DynamicUDPIPEncap.n IPRewriter.n SetTCPChecksum.n TCPRewriter.n \
	UDPIPEncap.n ChatterSocket.n ControlSocket.n FromDevice.u.n \
	FromDump.n KernelTap.n KernelHandlerProxy.n \
	ToDevice.u.n ToDump.n elements.n AdaptiveRED.n IPReassembler.n \
	IPRouteTable.n StaticIPLookup.n LinuxIPLookup.n RadixIPLookup.n \
	RandomSample.n SetPacketType.n StripToNetworkHeader.n ProgressBar.n

CONFDIR=	${PREFIX}/etc/click/conf

OPTIONS=								\
	 XML		 "Enable XML support with expat" Off		\
	 USERCLICK	 "Build user-space Click" On			\
	 KERNEL_MODULE	 "Build BSD kernel module (BROKEN)" Off		\
	 ANALYSIS_ELEMS	 "Build network analysis elements" Off		\
	 ETHERSWITCH_ELEMS "Build etherswitch elements" Off		\
	 GRID_ELEMS	 "Build Grid elements (see FAQ)" Off		\
	 IPSEC_ELEMS	 "Build IPSEC elements" Off			\
	 LOCAL_ELEMS	 "Build local elements" Off			\
	 WIFI_ELEMS	 "Build Wi-Fi elements" Off			\
	 IPV6_ELEMS	 "Build IPv6 elements (EXPERIMENTAL)" Off	\
	 NS_ELEMS	 "Build NS elements (EXPERIMENTAL)" Off		\
	 RADIO_ELEMS	 "Build radio elements (EXPERIMENTAL)" Off

.include <bsd.port.pre.mk>

.if ${ARCH} == "alpha"
BROKEN=		does not compile on alpha 4.x
.endif

.if defined(WITH_XML)
CONFIGURE_ARGS+=	--with-expat=${LOCALBASE}
LIB_DEPENDS=		expat.6:${PORTSDIR}/textproc/expat2
PLIST_SUB+=		XMLCLICK=""
.else
PLIST_SUB+=		XMLCLICK="@comment "
.endif

.if !defined(WITH_USERCLICK)
CONFIGURE_ARGS+=	--disable-userlevel
#.else
#MANN+=			IPFlowRawSockets.n
.endif

.if defined(WITH_KERNEL_MODULE)
.if !exists(${SRC_BASE}/sys/Makefile)
IGNORE=		kernel source files required
.endif
CONFIGURE_ARGS+=	--enable-bsdmodule				\
			--with-freebsd=${SRC_BASE}/sys,${INC_BASE}
.else
CONFIGURE_ARGS+=	--disable-bsdmodule
.endif

.if defined(WITH_ANALYSIS_ELEMS)
CONFIGURE_ARGS+=	--enable-analysis
MANN+=		AggregateFilter.n TimeSortedSched.n TimeRange.n \
		FromTcpdump.n ToIPFlowDumps.n AggregateLast.n \
		SimPacketAnalyzer.n AggregatePaint.n \
		FromNetFlowSummaryDump.n AggregateFirst.n AggregateCounter.n \
		FromDAGDump.n StoreTimestamp.n AggregateIPFlows.n \
		SetTimestampDelta.n FromCapDump.n AggregateIP.n \
		TimestampAccum.n AnonymizeIPAddr.n AggregateLength.n \
		FromIPSummaryDump.n ToIPSummaryDump.n AggregateIPAddrPair.n \
		AggregatePacketCounter.n TimeFilter.n
.endif

.if defined(WITH_ETHERSWITCH_ELEMS)
CONFIGURE_ARGS+=	--enable-etherswitch
MANN+=			EtherSwitch.n ListenEtherSwitch.n
.endif

.if defined(WITH_GRID_ELEMS)
CONFIGURE_ARGS+=	--enable-grid
MANN+=		ACKResponder.n ACKResponder2.n ACKRetrySender.n \
		ACKRetrySender2.n AiroInfo.n BottleneckMetric.n \
		CheckGridHeader.n DSDVRouteTable.n DSRArpTable.n \
		DSRRouteTable.n E2ELossMetric.n ETX2Metric.n ETXMetric.n \
		EstimateRouterRegion.n FilterByGridHops.n FilterByRange.n \
		FixDstLoc.n FixSrcLoc.n FloodingLocQuerier.n FromNLANRDump.n \
		GridEncap.n GridGatewayInfo.n GridHeaderInfo.n \
		GridLocationInfo.n GridLocationInfo2.n GridLogger.n \
		GridProbeHandler.n GridProbeReplyReceiver.n \
		GridProbeSender.n GridProxy.n GridRouteTable.n GridTxError.n \
		HopcountMetric.n IncrementSeqNo.n LIRMetric.n LinkStat.n \
		LinkTable.n LinkTestReceiver.n LinkTester.n LinkTracker.n \
		LocFromFile.n LocQueryResponder.n LocationTable.n \
		LookupGeographicGridRoute.n LookupLocalGridRoute.n \
		LookupLocalGridRoute2.n MovementSimulator.n PEP.n \
		PacketLogger.n PacketLogger2.n PingPong.n PrintGrid.n \
		SendGridHello.n SendGridLRHello.n SetGridChecksum.n \
		SimpleLocQuerier.n ThresholdMetric.n UpdateGridRoutes.n \
		YarvisMetric.n
.endif

.if defined(WITH_IPSEC_ELEMS)
CONFIGURE_ARGS+=	--enable-ipsec
MANN+=			IPsecAuthSHA1.n IPsecDES.n IPsecESPUnencap.n \
			IPsecESPEncap.n
.endif

.if defined(WITH_LOCAL_ELEMS)
CONFIGURE_ARGS+=	--enable-local
.endif

.if defined(WITH_WIFI_ELEMS)
CONFIGURE_ARGS+=	--enable-wifi
MANN+=		FilterPhyErr.n AssociationResponder.n FilterFailures.n \
		ReadAnno.n PacketStore.n AvailableRates.n \
		AssociationRequester.n OpenAuthResponder.n \
		OpenAuthRequeser.n Prism2Encap.n ProbeResponder.n \
		AutoRateFallback.n ProbeTXRate.n ARPTable.n WepEncap.n \
		WepDecap.n WifiDecap.n FilterTX.n EtherCount.n \
		RadiotapDecap.n RadiotapEncap.n WifiFragment.n \
		BeaconSource.n BeaconTracker.n BeaconScanner.n RXStats.n \
		WirelessInfo.n PrintTXFeedback.n SetTXRate.n SetTXPower.n \
		Prism2Decap.n WifiEncap.n WifiDefrag.n MadwifiRate.n \
		PrintWifi.n WifiSeq.n PushAnno.n WifiDupeFilter.n \
		ExtraEncap.n ExtraDecap.n AthdescDecap.n AthdescEncap.n
.endif

#
# The following Click elements are marked experimental as of 1.5.0.
#

.if defined(WITH_IPV6_ELEMS)
CONFIGURE_ARGS+=	--enable-ipv6
.endif

.if defined(WITH_NS_ELEMS)
CONFIGURE_ARGS+=	--enable-nsclick
MANN+=			ToSimTrace.n ToSimDevice.u.n FromSimDevice.u.n \
			EraseIPPayload.n
PLIST_SUB+=		NSCLICK=""
.else
PLIST_SUB+=		NSCLICK="@comment "
.endif

.if defined(WITH_RADIO_ELEMS)
CONFIGURE_ARGS+=	--enable-radio
MANN+=			RadioSim.n
.endif

post-install:
	cd ${PREFIX}/bin && ${STRIP_CMD} click click-align click-check \
	  click-combine click-uncombine click-devirtualize click-fastclassifier \
	  click-flatten click-mkmindriver click-undead click-xform
	@${MKDIR} ${CONFDIR}
	${INSTALL_DATA} ${WRKSRC}/conf/*.click ${CONFDIR}
	@${MKDIR} ${CONFDIR}/wifi
	${INSTALL_DATA} ${WRKSRC}/conf/wifi/*.click ${CONFDIR}/wifi
	@${ECHO_CMD}
	@${ECHO_CMD} "----------------------------------------------------"
	@${ECHO_CMD} "Install complete, to try it out do the following:"
	@${ECHO_CMD} "cd ${PREFIX}/etc/click/conf"
	@${ECHO_CMD} "click test.click"
	@${ECHO_CMD} "You should see some output.  Now go read the papers and manual."
	@${ECHO_CMD} "----------------------------------------------------"
	@${ECHO_CMD}

.include <bsd.port.post.mk>


syntax highlighted by Code2HTML, v. 0.9.1