SUMMARY="Library bits of the samba network filesystem"
DESCRIPTION="
Samba is an Open Source/Free Software suite that provides seamless file and \
print services to SMB/CIFS clients. Samba is freely available, unlike other \
SMB/CIFS implementations, and allows for interoperability between Linux/Unix \
servers and Windows-based clients. Samba is software that can be run on a \
platform other than Microsoft Windows, for example, UNIX, Linux, IBM System \
390, OpenVMS, and other operating systems. Samba uses the TCP/IP protocol that \
is installed on the host server. When correctly configured, it allows that \
host to interact with a Microsoft Windows client or server as if it is a \
Windows file and print server."
HOMEPAGE="http://www.samba.org/"
COPYRIGHT="1992-2015 Anrew Tridgell and the Samba Team"
LICENSE="GNU GPL v3"

SOURCE_URI="http://ftp.samba.org/pub/samba/samba-$portVersion.tar.gz"

CHECKSUM_SHA256="8f2c8a7f2bd89b0dfd228ed917815852f7c625b2bc0936304ac3ed63aaf83751"

REVISION="1"
ARCHITECTURES="x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"
DISABLE_SOURCE_PACKAGE=yes

PATCHES="samba-3.6.23.patchset"

GLOBAL_WRITABLE_FILES="
	settings/samba directory keep-old
	"

PROVIDES="
	samba$secondaryArchSuffix = $portVersion
	cmd:eventlogadm$secondaryArchSuffix = $portVersion
	cmd:findsmb$secondaryArchSuffix = $portVersion
	cmd:net$secondaryArchSuffix = $portVersion
	cmd:nmbd$secondaryArchSuffix = $portVersion
	cmd:nmblookup$secondaryArchSuffix = $portVersion
	cmd:ntlm_auth$secondaryArchSuffix = $portVersion
	cmd:pdbedit$secondaryArchSuffix = $portVersion
	cmd:profiles$secondaryArchSuffix = $portVersion
	cmd:rpcclient$secondaryArchSuffix = $portVersion
	cmd:sharesec$secondaryArchSuffix = $portVersion
	cmd:smbcacls$secondaryArchSuffix = $portVersion
	cmd:smbclient$secondaryArchSuffix = $portVersion
	cmd:smbcontrol$secondaryArchSuffix = $portVersion
	cmd:smbcquotas$secondaryArchSuffix = $portVersion
	cmd:smbd$secondaryArchSuffix = $portVersion
	cmd:smbget$secondaryArchSuffix = $portVersion
	cmd:smbpasswd$secondaryArchSuffix = $portVersion
	cmd:smbspool$secondaryArchSuffix = $portVersion
	cmd:smbstatus$secondaryArchSuffix = $portVersion
	cmd:smbta_util$secondaryArchSuffix = $portVersion
	cmd:smbtar$secondaryArchSuffix = $portVersion
	cmd:smbtree$secondaryArchSuffix = $portVersion
#	cmd:swat$secondaryArchSuffix = $portVersion
	cmd:tdbbackup$secondaryArchSuffix = $portVersion
	cmd:tdbdump$secondaryArchSuffix = $portVersion
	cmd:tdbrestore$secondaryArchSuffix = $portVersion
	cmd:testparm$secondaryArchSuffix = $portVersion
	cmd:tdbtool$secondaryArchSuffix = $portVersion
	lib:libnetapi$secondaryArchSuffix = $portVersion
	lib:libsmbclient$secondaryArchSuffix = $portVersion
	lib:libsmbsharemodes$secondaryArchSuffix = $portVersion
	lib:libtalloc$secondaryArchSuffix = $portVersion
	lib:libtdb$secondaryArchSuffix = $portVersion
	lib:libtevent$secondaryArchSuffix = $portVersion
	"

REQUIRES="
	haiku
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:autoconf
	cmd:find	
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix	
	cmd:libtoolize
	cmd:make	
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	cmd:which
	"

BUILD()
{
	cd source3
	sed -i 's/| \*qnx\*/| \*qnx\* | haiku\*/g' configure
	LDFLAGS="-lnetwork -lbnetapi" CFLAGS="-D_BSD_SOURCE" runConfigure ./configure --disable-swat \
							--with-configdir=$settingsDir/samba \
							--with-privatedir=$settingsDir/samba \
							--with-localedir=$dataRootDir/locale \
							--with-logfilebase=sharedStateDir/log
	sed -i 's/-lpthread//g' Makefile
	sed -i 's/-lc//g' Makefile
	make $jobArgs
}


INSTALL()
{
	cd source3
	make $jobArgs install

	# move headers to the correct location
	mkdir -p $(dirname $includeDir)
	mv $prefix/include $includeDir

	# copy sample config file
	cp ../testdata/samba3/smb.conf $settingsDir/samba

	prepareInstalledDevelLibs libnetapi \
						libsmbclient \
						libsmbsharemodes \
						libtalloc \
						libtdb \
						libtevent

	packageEntries devel $developDir
}


PROVIDES_devel="
	samba${secondaryArchSuffix}_devel = $portVersion
	devel:libsmbclient$secondaryArchSuffix = $portVersion
	devel:libnetapi$secondaryArchSuffix = $portVersion compat >= 0
	devel:libsmbsharemodes$secondaryArchSuffix = $portVersion compat >= 0
	devel:libtalloc$secondaryArchSuffix = $portVersion compat >= 2
	devel:libtdb$secondaryArchSuffix = $portVersion compat >= 1
	devel:libtevent$secondaryArchSuffix = $portVersion compat >= 0
"


REQUIRES_devel="
	samba$secondaryArchSuffix == $portVersion base
"
