# $Id: Portfile 90640 2012-03-11 17:35:45Z afb@macports.org $

PortSystem 1.0

name		libfetch
version		7.4.0-RELEASE
revision	1
categories	net
maintainers	afb
description	FreeBSD file fetching library
long_description	These functions implement a high-level library for retrieving and \
			uploading files using Uniform Resource Locators (URLs).
platforms	darwin freebsd
license		BSD
use_bzip2	yes
homepage	http://www.freebsd.org/
master_sites	macports
checksums	md5 8c489dddaea84ef17a5c6addc11ac1c3 \
		sha1 8464fb158f349546cb3bb390c59bbfc8d13be637 \
		rmd160 8ee8e717049876f1636ad4f456d89fdb3ff44823
variant universal {}
build.type	bsd
build.env	CC=${configure.cc} \
		CFLAGS="${configure.cppflags} ${configure.cflags} [get_canonical_archflags]" \
		LDFLAGS="${configure.ldflags} [get_canonical_archflags]"
build.args	-DMK_INET6_SUPPORT -DMK_OPENSSL
worksrcdir	${name}
use_configure	no
set libver	5
destroot	{
		xinstall -m 644 -c ${worksrcpath}/fetch.h ${destroot}${prefix}/include
		xinstall -m 644 -c ${worksrcpath}/fetch.3 ${destroot}${prefix}/share/man/man3 }

depends_lib	port:openssl
depends_build	bin:bsdmake:bsdmake
patchfiles	patch-common.c patch-http.c

platform darwin {
	patchfiles-append	patch-Makefile patch-common.h
	post-build {
		# need to add libdir, do it afterwards instead of messing with make
		system "install_name_tool -id ${prefix}/lib/libfetch.${libver}.dylib \
			${worksrcpath}/libfetch.${libver}.dylib"
	}
	pre-destroot {
		xinstall -m 644 -c ${worksrcpath}/libfetch.${libver}.dylib \
			${destroot}${prefix}/lib
		ln -sf libfetch.${libver}.dylib ${destroot}${prefix}/lib/libfetch.dylib
	}
}

platform freebsd {
	pre-destroot {
		xinstall -m 644 -c ${worksrcpath}/libfetch.so.${libver} \
			${destroot}${prefix}/lib
		ln -sf libfetch.so.${libver} ${destroot}${prefix}/lib/libfetch.so
	}
}
