SubDir HAIKU_TOP src tests servers app ;

SetSubDirSupportedPlatforms libbe_test ;

# No need to define any of those targets, when not building for libbe_test
if $(TARGET_PLATFORM) = libbe_test {

UseLibraryHeaders agg png zlib ;
UsePrivateHeaders app graphics input interface shared storage ;
UsePrivateHeaders [ FDirName graphics common ] ;

# headers/build/private/kernel is needed for safemode.h and syscalls.h.
# headers/private/kernel for the util/* stuff.
UseHeaders [ FDirName $(HAIKU_TOP) headers build private kernel ] : true ;
UsePrivateHeaders kernel ;

local appServerDir = [ FDirName $(HAIKU_TOP) src servers app ] ;

UseHeaders [ FDirName $(appServerDir) drawing ] ;
UseHeaders [ FDirName $(appServerDir) drawing Painter ] ;
UseHeaders [ FDirName $(appServerDir) drawing Painter drawing_modes ] ;
UseHeaders [ FDirName $(appServerDir) drawing Painter font_support ] ;
UseFreeTypeHeaders ;

# This overrides the definitions in private/servers/app/ServerConfig.h
local defines = [ FDefines TEST_MODE=1 ] ;
	# USE_DIRECT_WINDOW_TEST_MODE=1

SubDirCcFlags $(defines) ; #-finstrument-functions ; #-fcheck-memory-usage -D_NO_INLINE_ASM ;
SubDirC++Flags $(defines) ; #-finstrument-functions ; #-fcheck-memory-usage -D_NO_INLINE_ASM ;

SEARCH_SOURCE += $(appServerDir) ;
SEARCH_SOURCE += [ FDirName $(appServerDir) drawing ] ;
SEARCH_SOURCE += [ FDirName $(appServerDir) drawing Painter ] ;

SharedLibrary libhwinterface.so :
	BBitmapBuffer.cpp
	DWindowBuffer.cpp
	HWInterface.cpp
	RGBColor.cpp
	UpdateQueue.cpp

	: libtestappserver.so
;


# The reason for this is that libhwinterfaceimpl.so needs to link against
# libbe *first*, but simply adding it to the library list would add it to
# LINKLIBS which is always appended after NEEDLIBS in the command line.
LINKFLAGS on libhwinterfaceimpl.so ?= $(LINKFLAGS) ;
LINKFLAGS on libhwinterfaceimpl.so += -lbe ;

SharedLibrary libhwinterfaceimpl.so :
	ViewHWInterface.cpp
	DWindowHWInterface.cpp
	MultiLocker.cpp

#	trace.c
	: libhwinterface.so
;

SharedLibrary libtestappserver.so :
	Angle.cpp
	ClientMemoryAllocator.cpp
	CursorData.cpp
	CursorManager.cpp
	CursorSet.cpp
	DesktopSettings.cpp
	DirectWindowInfo.cpp
	DrawState.cpp
	FontCache.cpp
	FontCacheEntry.cpp
	FontEngine.cpp
	FontFamily.cpp
	FontManager.cpp
	FontStyle.cpp
	GlobalSubpixelSettings.cpp
	HashTable.cpp
	IntPoint.cpp
	IntRect.cpp
	MultiLocker.cpp
	Overlay.cpp
	RGBColor.cpp
	ServerBitmap.cpp
	ServerCursor.cpp
	ServerFont.cpp
	SystemPalette.cpp

	# drawing
	PatternHandler.cpp

#	trace.c

	# libraries
	: be libpainter.a libtextencoding.so libfreetype.so libshared.a
;

AddResources test_app_server : app_server.rdef ;

Server test_app_server :
	# Misc. Sources
	Decorator.cpp
	ProfileMessageSupport.cpp
	EventDispatcher.cpp
	EventStream.cpp
	MessageLooper.cpp

	# Manager Classes
	BitmapManager.cpp
	DecorManager.cpp
	InputManager.cpp
	ScreenManager.cpp

	AppServer.cpp
	Desktop.cpp

	ServerApp.cpp
	ServerWindow.cpp

	# DrawingEngine Classes
#	AccelerantBuffer.cpp
#	AccelerantHWInterface.cpp
	BitmapBuffer.cpp
	BitmapDrawingEngine.cpp
	drawing_support.cpp
	DrawingEngine.cpp
	MallocBuffer.cpp

	VirtualScreen.cpp
	BitmapHWInterface.cpp
	DefaultDecorator.cpp
	OffscreenServerWindow.cpp
	OffscreenWindow.cpp
	RegionPool.cpp
	Screen.cpp
	ScreenConfigurations.cpp
	ServerPicture.cpp
	View.cpp
	Window.cpp
	WindowList.cpp
	Workspace.cpp
	WorkspacesView.cpp

	# libraries
	:
	z libtestappserver.so libpainter.a be
	libhwinterface.so libhwinterfaceimpl.so
	libagg.a libfreetype.so libtextencoding.so
	$(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++)
;

# install in the test dir
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_LIB_DIR)
	: libtestappserver.so libbe_test.so
	  libhwinterface.so libhwinterfaceimpl.so libfreetype.so
	  libtextencoding.so
	: tests!apps ;

HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : test_app_server
	: tests!apps ;

} # if $(TARGET_PLATFORM) = libbe_test

SubInclude HAIKU_TOP src tests servers app archived_view ;
SubInclude HAIKU_TOP src tests servers app async_drawing ;
SubInclude HAIKU_TOP src tests servers app avoid_focus ;
SubInclude HAIKU_TOP src tests servers app benchmark ;
SubInclude HAIKU_TOP src tests servers app bitmap_bounds ;
SubInclude HAIKU_TOP src tests servers app bitmap_drawing ;
SubInclude HAIKU_TOP src tests servers app code_to_name ;
SubInclude HAIKU_TOP src tests servers app constrain_clipping_region ;
SubInclude HAIKU_TOP src tests servers app copy_bits ;
SubInclude HAIKU_TOP src tests servers app cursor_test ;
SubInclude HAIKU_TOP src tests servers app desktop_window ;
SubInclude HAIKU_TOP src tests servers app draw_after_children ;
SubInclude HAIKU_TOP src tests servers app draw_string_offsets ;
SubInclude HAIKU_TOP src tests servers app drawing_debugger ;
SubInclude HAIKU_TOP src tests servers app drawing_modes ;
SubInclude HAIKU_TOP src tests servers app event_mask ;
SubInclude HAIKU_TOP src tests servers app find_view ;
SubInclude HAIKU_TOP src tests servers app following ;
SubInclude HAIKU_TOP src tests servers app hide_and_show ;
SubInclude HAIKU_TOP src tests servers app idle_test ;
SubInclude HAIKU_TOP src tests servers app lagging_get_mouse ;
SubInclude HAIKU_TOP src tests servers app lock_focus ;
SubInclude HAIKU_TOP src tests servers app look_and_feel ;
SubInclude HAIKU_TOP src tests servers app menu_crash ;
SubInclude HAIKU_TOP src tests servers app no_pointer_history ;
SubInclude HAIKU_TOP src tests servers app painter ;
SubInclude HAIKU_TOP src tests servers app playground ;
SubInclude HAIKU_TOP src tests servers app regularapps ;
SubInclude HAIKU_TOP src tests servers app resize_limits ;
SubInclude HAIKU_TOP src tests servers app scrollbar ;
SubInclude HAIKU_TOP src tests servers app scrolling ;
SubInclude HAIKU_TOP src tests servers app shape_test ;
SubInclude HAIKU_TOP src tests servers app statusbar ;
SubInclude HAIKU_TOP src tests servers app stress_test ;
SubInclude HAIKU_TOP src tests servers app textview ;
SubInclude HAIKU_TOP src tests servers app view_state ;
SubInclude HAIKU_TOP src tests servers app view_transit ;
SubInclude HAIKU_TOP src tests servers app window_creation ;
SubInclude HAIKU_TOP src tests servers app window_invalidation ;
SubInclude HAIKU_TOP src tests servers app workspace_activated ;
SubInclude HAIKU_TOP src tests servers app workspace_switcher ;
