SubDir HAIKU_TOP src kits network libnetapi ;

UsePrivateHeaders net shared ;

UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ]
	: true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;

local sslSources ;
if $(HAIKU_OPENSSL_ENABLED) {
	SubDirC++Flags -DOPENSSL_ENABLED ;
	SubDirSysHdrs $(HAIKU_OPENSSL_HEADERS) ;
	sslSources = SSL.cpp ;
	Includes [ FGristFiles $(sslSources) SecureSocket.cpp ]
		: $(HAIKU_OPENSSL_HEADERS_DEPENDENCY) ;
		# Dependency needed to trigger downloading/unzipping the package before
		# compiling the files.
	SetupFeatureObjectsDir ssl ;
} else {
	SetupFeatureObjectsDir no-ssl ;
}

SharedLibrary libbnetapi.so :
	init.cpp
	DynamicBuffer.cpp
	NetEndpoint.cpp
	NetAddress.cpp
	NetBuffer.cpp
	NetDebug.cpp

	$(sslSources)

	NetworkAddress.cpp
	NetworkAddressResolver.cpp
	NetworkCookie.cpp
	NetworkCookieJar.cpp
	NetworkDevice.cpp
	NetworkInterface.cpp
	NetworkRoster.cpp

	AbstractSocket.cpp
	DatagramSocket.cpp
	Socket.cpp
	SecureSocket.cpp

	# TODO: The HTTP stuff should all go into an add-on. It needs linking
	# against libcrypto.so and only the add-on should link against it.
	# Building of the commented out files has not been completely tested after
	# integrating the code from the GSoC 2010 "Services Kit" project and doing
	# some renaming of types, constants and methods.
#	HttpAuthentication.cpp
#	HttpHeaders.cpp
#	HttpForm.cpp
	HttpTime.cpp

	Url.cpp
	UrlContext.cpp
#	UrlProtocol.cpp
#	UrlProtocolAsynchronousListener.cpp
#	UrlProtocolDispatchingListener.cpp
#	UrlProtocolHttp.cpp # TODO: -> add-on, See above.
#	UrlProtocolListener.cpp
#	UrlRequest.cpp
#	UrlResult.cpp
#	UrlSynchronousRequest.cpp

	:
	be $(TARGET_NETWORK_LIBS) $(TARGET_LIBSUPC++) $(HAIKU_OPENSSL_LIBS)
	libshared.a
;
