# Top-level Makefile rule for automake
#
# Variable conventions:
#
# _h_api            = API headers that will be installed and included in the distribution
# _cppflags         = flags that will be passed to the C/CXX Preprocessor
# _sources          = sources that will be compiled and included in the distribution
# _built_sources    = files that will be autogenerated by the build system and
#                     will be part of the _SOURCES primary
# _built_nosources  = files that are autogenerated but are not part of the
#                     _SOURCES primary
# _cleanfiles       = files that will be removed by the clean target
#
# Sources, headers, flags, etc... should be added to the respective variables
# with the above suffix, e.g, webcore-specific sources should go to
# webcore_sources, gtk port API and WebCoreSupport parts to webkitgtk_sources,
# etc... The only exceptions are the global variables. See Global Variables
# below.
#
# Global Variables
#
# global_cppflags   = CPPFLAGS that apply to JSC, WebCore, and to any
#                     specific port
# global_cflags     = CFLAGS that apply to JSC, WebCore, and to
#                     any specific port
# global_cxxflags   = CXXFLAGS that apply to JSC, WebCore, and to any
#                     specific port

srcdir = @srcdir@
VPATH = @srcdir@

# Directory for autogenerated sources
GENSOURCES := $(top_builddir)/DerivedSources
GENPROGRAMS := $(top_builddir)/Programs

# Script for creating hash tables
CREATE_HASH_TABLE = $(srcdir)/JavaScriptCore/create_hash_table

# Programs to run the WebKitGtk unit tests
GTESTER = gtester
GTESTER_REPORT = gtester-report

# Libraries and support components
bin_PROGRAMS :=
noinst_PROGRAMS :=
noinst_HEADERS :=
lib_LIBRARIES :=
IDL_BINDINGS :=
TEST_PROGS :=
POFILES :=
MOFILES :=
javascriptcore_h_api :=
javascriptcore_cppflags:=
javascriptcore_sources :=
javascriptcore_built_sources :=
javascriptcore_built_nosources :=
javascriptcore_dist :=
webcore_cppflags :=
webcore_sources :=
webcore_libadd :=
webcore_built_sources :=
webcore_built_nosources :=
webcore_dist :=
webcoregtk_cppflags :=
webcoregtk_sources :=
webkitgtk_h_api :=
webkitgtk_sources :=
webkitgtk_cppflags :=
webkitgtk_built_sources :=
webkitgtk_built_nosources :=
webkitgtk_cleanfiles :=
global_cppflags :=
global_cflags :=
global_cxxflags :=
corekit_cflags :=
corekit_cppflags :=

# CFLAGS/CXXFLAGS used by WebCore and WebKit
#
# gtk+.pc already include glib, cairo, freetype and pango CFLAGS
# Don't include them for now to reduce the noise when compiling
# $(GLIB_CFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS)  $(FREETYPE_CFLAGS)
corekit_cflags += \
	-fno-strict-aliasing \
	$(COVERAGE_CFLAGS) \
	$(ENCHANT_CFLAGS) \
	$(GAIL_CFLAGS) \
	$(GEOCLUE_CFLAGS) \
	$(GLIB_CFLAGS) \
	$(GNOMEKEYRING_CFLAGS) \
	$(GSTREAMER_CFLAGS) \
	$(GTK_CFLAGS) \
	$(HILDON_CFLAGS) \
	$(LIBSOUP_CFLAGS) \
	$(LIBXML_CFLAGS) \
	$(LIBXSLT_CFLAGS) \
	$(SQLITE3_CFLAGS) \
	$(UNICODE_CFLAGS) \
	$(XT_CFLAGS)

# When building webcore/webkit, we want WebCore/config.h and NOT
# JavaScriptCore/config.h, hence, it's important that WebCore/ should come first
# before JavaScriptCore in the include path.
corekit_cppflags += \
	$(global_cppflags) \
	$(webcore_cppflags) \
	$(webcoregtk_cppflags) \
	$(javascriptcore_cppflags)

if TARGET_X11
corekit_cppflags += -DXP_UNIX
endif

# Default compiler flags
global_cflags += \
	-Wall -W -Wcast-align -Wchar-subscripts -Wreturn-type \
	-Wformat -Wformat-security -Wno-format-y2k -Wundef \
	-Wmissing-format-attribute -Wpointer-arith -Wwrite-strings \
	-Wno-unused-parameter -Wno-parentheses \
	-fno-exceptions

global_cxxflags += \
	$(global_cflags) \
	$(SYMBOL_VISIBILITY_INLINES) \
	-fno-rtti

# -no-undefined required for building DLLs on Windows
# It breaks the build on other platforms, so we use it conditionally
if OS_WIN32
no_undefined = -no-undefined
endif

if OS_GNU
version_script = -Wl,--version-script,$(srcdir)/autotools/symbols.filter
endif

# Shared libraries
lib_LTLIBRARIES = \
	libwebkit-1.0.la

# Convenience libraries
noinst_LTLIBRARIES = \
	libJavaScriptCore.la \
	libWebCore.la

# JavaScriptCore
javascriptcore_cppflags += \
	-I$(srcdir)/JavaScriptCore/ForwardingHeaders \
	-I$(srcdir)/JavaScriptCore/parser \
	-I$(srcdir)/JavaScriptCore/wtf \
	-I$(top_builddir)/DerivedSources

nodist_EXTRA_libJavaScriptCore_la_SOURCES = \
	$(javascriptcore_built_nosources)

nodist_libJavaScriptCore_la_SOURCES = \
	$(javascriptcore_built_sources)

libJavaScriptCore_ladir = $(prefix)/include/webkit-1.0/JavaScriptCore
libJavaScriptCore_la_HEADERS = $(javascriptcore_h_api)

libJavaScriptCore_la_SOURCES = \
	$(javascriptcore_sources)

libJavaScriptCore_la_LIBADD = \
	$(UNICODE_LIBS) \
	$(GLIB_LIBS) \
	-lpthread

libJavaScriptCore_la_CXXFLAGS = \
	$(global_cxxflags) \
	$(libJavaScriptCore_la_CFLAGS)

libJavaScriptCore_la_CFLAGS = \
	-fstrict-aliasing \
	-O3 \
	$(global_cflags) \
	$(GLIB_CFLAGS) \
	$(UNICODE_CFLAGS)

libJavaScriptCore_la_CPPFLAGS = \
	$(global_cppflags) \
	$(javascriptcore_cppflags)

# WebCore
nodist_EXTRA_libWebCore_la_SOURCES = \
	$(webcore_built_nosources)

nodist_libWebCore_la_SOURCES = \
	$(webcore_built_sources)

libWebCore_la_SOURCES = \
	$(webcore_sources) \
	$(webcoregtk_sources)

libWebCore_la_CXXFLAGS = \
	$(global_cxxflags) \
	$(corekit_cflags)

libWebCore_la_CFLAGS = \
	$(global_cflags) \
	$(corekit_cflags)

libWebCore_la_CPPFLAGS = \
	$(corekit_cppflags)

# WebKit
nodist_libwebkit_1_0_la_SOURCES = \
	$(webkitgtk_built_sources)

libwebkit_1_0_ladir = $(prefix)/include/webkit-1.0/webkit
libwebkit_1_0_la_HEADERS = \
	$(webkitgtk_h_api) \
	WebKit/gtk/webkit/webkitenumtypes.h

libwebkit_1_0_la_SOURCES = \
	$(webkitgtk_sources)

libwebkit_1_0_la_CXXFLAGS = \
	$(global_cxxflags) \
	$(corekit_cflags)

libwebkit_1_0_la_CFLAGS = \
	$(global_cflags) \
	$(corekit_cflags)

libwebkit_1_0_la_CPPFLAGS = \
	$(corekit_cppflags) \
	$(webkitgtk_cppflags) \
	$(HILDON_CPPFLAGS)

libwebkit_1_0_la_LDFLAGS = \
	-version-info @LIBWEBKITGTK_VERSION@ \
	$(version_script) \
	$(no_undefined)

libwebkit_1_0_la_LIBADD = \
	-lpthread \
	libJavaScriptCore.la \
	libWebCore.la \
	libWebCoreJS.la \
	$(webcore_ldflags) \
	$(CAIRO_LIBS) \
	$(COVERAGE_LDFLAGS) \
	$(ENCHANT_LIBS) \
	$(FREETYPE_LIBS) \
	$(GAIL_LIBS) \
	$(GEOCLUE_LIBS) \
	$(GLIB_LIBS) \
	$(GNOMEKEYRING_LIBS) \
	$(GSTREAMER_LIBS) \
	$(GTK_LIBS) \
	$(HILDON_LIBS) \
	$(JPEG_LIBS) \
	$(LIBSOUP_LIBS) \
	$(LIBXML_LIBS) \
	$(LIBXSLT_LIBS) \
	$(PANGO_LIBS) \
	$(PNG_LIBS) \
	$(SQLITE3_LIBS) \
	$(UNICODE_LIBS) \
	$(XT_LIBS)

#
# Extra checks and flags
global_cppflags += \
	-DBUILDING_CAIRO__=1 \
	-DBUILDING_GTK__=1 \
	-DWTF_CHANGES

if USE_ICU_UNICODE
global_cppflags += \
	-DWTF_USE_ICU_UNICODE=1
endif

if USE_GLIB_UNICODE
# https://bugs.webkit.org/show_bug.cgi?id=15914
# In patch 1/4 we are compiling a hybrid version of GLib WTF Unicode
# functionality mixed with ICU-based text codecs and TextBreakIterator.
# For the transition, introducing an interim HYBRID macro.
# This macro is required for compiling WTF with GLib Unicode backend,
# but at the same time keeping ICU dependency for codecs and break iterator.
# It will be removed with patch 3/4 of the above bug.
global_cppflags += \
	-DWTF_USE_GLIB_UNICODE=1 \
	-DWTF_USE_GLIB_ICU_UNICODE_HYBRID=1
endif

if !ENABLE_FAST_MALLOC
global_cppflags += \
	-DUSE_SYSTEM_MALLOC
endif

if !ENABLE_DEBUG
global_cppflags += -DNDEBUG
global_cflags += $(SYMBOL_VISIBILITY)

else
webcoregtk_cppflags += \
	-DG_DISABLE_DEPRECATED \
	-DGDK_PIXBUF_DISABLE_DEPRECATED \
	-DGDK_DISABLE_DEPRECATED \
	-DGTK_DISABLE_DEPRECATED \
	-DPANGO_DISABLE_DEPRECATED

# Might be useful in the future
#	-DGDK_MULTIHEAD_SAFE \
#	-DGTK_MULTIHEAD_SAFE
endif

if ENABLE_COVERAGE
global_cppflags += \
	-DGCC_GENERATE_TEST_COVERAGE_FILES \
	-DGCC_INSTRUMENT_PROGRAM_FLOW_ARCS
endif

webkitgtk_h_api += \
	WebKit/gtk/webkit/webkit.h \
	WebKit/gtk/webkit/webkitdefines.h \
	WebKit/gtk/webkit/webkitdownload.h \
	WebKit/gtk/webkit/webkiterror.h \
	WebKit/gtk/webkit/webkitnetworkrequest.h \
	WebKit/gtk/webkit/webkitsoupauthdialog.h \
	WebKit/gtk/webkit/webkitversion.h \
	WebKit/gtk/webkit/webkitwebbackforwardlist.h \
	WebKit/gtk/webkit/webkitwebframe.h \
	WebKit/gtk/webkit/webkitwebhistoryitem.h \
	WebKit/gtk/webkit/webkitwebinspector.h \
	WebKit/gtk/webkit/webkitwebnavigationaction.h \
	WebKit/gtk/webkit/webkitwebpolicydecision.h \
	WebKit/gtk/webkit/webkitwebsettings.h \
	WebKit/gtk/webkit/webkitwebwindowfeatures.h \
	WebKit/gtk/webkit/webkitwebview.h

webkitgtk_built_sources += \
	DerivedSources/webkitenumtypes.cpp \
	DerivedSources/webkitmarshal.cpp \
	DerivedSources/webkitmarshal.h \
	WebKit/gtk/webkit/webkitenumtypes.h

webkitgtk_sources += \
	WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp \
	WebKit/gtk/WebCoreSupport/ChromeClientGtk.h \
	WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp \
	WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h \
	WebKit/gtk/WebCoreSupport/DragClientGtk.cpp \
	WebKit/gtk/WebCoreSupport/DragClientGtk.h \
	WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp \
	WebKit/gtk/WebCoreSupport/EditorClientGtk.h \
	WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp \
	WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h \
	WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp \
	WebKit/gtk/WebCoreSupport/InspectorClientGtk.h \
	WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp \
	WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h \
	WebKit/gtk/webkit/webkitdownload.cpp \
	WebKit/gtk/webkit/webkiterror.cpp \
	WebKit/gtk/webkit/webkitnetworkrequest.cpp \
	WebKit/gtk/webkit/webkitprivate.cpp \
	WebKit/gtk/webkit/webkitprivate.h \
	WebKit/gtk/webkit/webkitsoupauthdialog.c \
	WebKit/gtk/webkit/webkitversion.cpp \
	WebKit/gtk/webkit/webkitwebbackforwardlist.cpp \
	WebKit/gtk/webkit/webkitwebframe.cpp \
	WebKit/gtk/webkit/webkitwebhistoryitem.cpp \
	WebKit/gtk/webkit/webkitwebinspector.cpp \
	WebKit/gtk/webkit/webkitwebnavigationaction.cpp \
	WebKit/gtk/webkit/webkitwebpolicydecision.cpp \
	WebKit/gtk/webkit/webkitwebsettings.cpp \
	WebKit/gtk/webkit/webkitwebview.cpp \
	WebKit/gtk/webkit/webkitwebwindowfeatures.cpp

webkitgtk_cppflags += \
	-DBUILDING_WEBKIT \
	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
	-DDATA_DIR=\"${datadir}\" \
	-I$(srcdir)/WebKit/gtk \
	-I$(srcdir)/WebKit/gtk/WebCoreSupport \
	-I$(srcdir)/WebKit/gtk/webkit \
	-I$(top_builddir)/WebKit/gtk/webkit

if USE_GNOMEKEYRING
webkitgtk_cppflags += \
	-DWTF_USE_GNOMEKEYRING=1
endif

webkitgtk_cleanfiles += \
	$(top_builddir)/WebKit/gtk/docs/version.xml \
	$(top_builddir)/WebKit/gtk/docs/GNUmakefile \
	$(top_builddir)/Programs/GtkLauncher \
	$(top_builddir)/WebKit/gtk/webkit-1.0.pc \
	$(top_builddir)/WebKit/gtk/webkit/webkitenumtypes.h \
	$(top_builddir)/WebKit/gtk/webkit/webkitversion.h

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = WebKit/gtk/webkit-1.0.pc

stamp_files := \
	stamp-webkitmarshal.cpp \
	stamp-webkitmarshal.h \
	stamp-webkitenumtypes.cpp \
	stamp-webkitenumtypes.h

WEBKIT_MARSHAL = $(GENSOURCES)/webkitmarshal
WEBKIT_MARSHAL_LIST = $(top_srcdir)/WebKit/gtk/webkitmarshal.list

$(WEBKIT_MARSHAL).cpp: stamp-webkitmarshal.cpp
	@true

$(WEBKIT_MARSHAL).h: stamp-webkitmarshal.h
	@true

stamp-webkitmarshal.cpp: $(WEBKIT_MARSHAL_LIST)
	echo "extern \"C\" {" > $(WEBKIT_MARSHAL).cpp && \
	$(GLIB_GENMARSHAL) --prefix=webkit_marshal $(WEBKIT_MARSHAL_LIST) --body >> $(WEBKIT_MARSHAL).cpp && echo '}' >> $(WEBKIT_MARSHAL).cpp && \
	echo timestamp > $(@F)

stamp-webkitmarshal.h: $(WEBKIT_MARSHAL_LIST)
	$(GLIB_GENMARSHAL) --prefix=webkit_marshal $(WEBKIT_MARSHAL_LIST) --header > $(WEBKIT_MARSHAL).h && \
	echo timestamp > $(@F)

WebKit/gtk/webkit/webkitenumtypes.h: stamp-webkitenumtypes.h
	@true
stamp-webkitenumtypes.h: $(webkitgtk_h_api) GNUmakefile
	(cd $(srcdir) \
	&& glib-mkenums \
			--fhead "#ifndef WEBKIT_ENUM_TYPES_H\n" \
			--fhead "#define WEBKIT_ENUM_TYPES_H\n\n" \
			--fhead "#include <glib-object.h>\n\n" \
			--fhead "#include <webkit/webkitdefines.h>\n\n" \
			--fhead "G_BEGIN_DECLS\n\n" \
			--ftail "G_END_DECLS\n\n" \
			--ftail "#endif\n" \
			--fprod "#include <@filename@>\n\n" \
			--eprod "#define WEBKIT_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n\n" \
			--eprod "WEBKIT_API GType\n@enum_name@_get_type(void);\n\n" \
		$(webkitgtk_h_api) | \
		sed 's,WebKit/gtk/,,' | \
		sed 's,web_kit,webkit,' | \
		sed 's,WEBKIT_TYPE_KIT,WEBKIT_TYPE,' \
		) > xgen-gth \
	&& (cmp -s xgen-gth WebKit/gtk/webkit/webkitenumtypes.h || cp xgen-gth WebKit/gtk/webkit/webkitenumtypes.h) \
	&& rm -f xgen-gth \
	&& echo timestamp > $(@F)

DerivedSources/webkitenumtypes.cpp: $(webkitgtk_h_api) GNUmakefile
	(cd $(srcdir) \
	&& glib-mkenums \
			--fhead "#include <config.h>\n" \
			--fhead "#include <glib-object.h>\n" \
			--fhead "#include \"$(top_builddir)/WebKit/gtk/webkit/webkitenumtypes.h\"\n\n" \
			--fhead "extern \"C\" {\n\n" \
			--fprod "\n/* enumerations from \"@filename@\" */" \
			--vhead "static const G@Type@Value _@enum_name@_values[] = {" \
			--vprod "    { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
			--vtail "    { 0, NULL, NULL }\n};\n\n" \
			--vtail "GType @enum_name@_get_type(void)\n{\n" \
			--vtail "    static GType type = 0;\n\n" \
			--vtail "    if (!type)\n" \
			--vtail "        type = g_@type@_register_static(\"@EnumName@\", _@enum_name@_values);\n\n" \
			--vtail "    return type;\n}\n\n" \
			--ftail "}\n" \
		$(webkitgtk_h_api) | \
		sed 's,web_kit,webkit,' \
		) > xgen-gtc \
	&& cp xgen-gtc $@ \
	&& rm -f xgen-gtc

# Files that will be distributed
EXTRA_DIST = \
	$(srcdir)/gtk-doc.make \
	WebKit/LICENSE \
	$(javascriptcore_dist) \
	$(webcore_dist) \
	$(srcdir)/autotools/symbols.filter \
	$(srcdir)/WebKit/gtk/ChangeLog \
	$(srcdir)/WebKit/gtk/NEWS \
	$(srcdir)/WebKit/gtk/webkitmarshal.list \
	$(srcdir)/WebKit/gtk/docs/GNUmakefile.* \
	$(srcdir)/WebKit/gtk/docs/webkitenvironment.xml \
	$(srcdir)/WebKit/gtk/docs/webkitgtk-docs.sgml \
	$(srcdir)/WebKit/gtk/docs/webkitgtk-sections.txt \
	$(srcdir)/WebKit/gtk/docs/version.xml.in \
	$(srcdir)/WebKit/gtk/po/* \
	$(srcdir)/WebKit/gtk/resources/*

# extra resource files
resourcesdir = ${datadir}/webkit-1.0/resources
dist_resources_DATA = \
	$(shell ls $(srcdir)/WebKit/gtk/resources/*.html)

# END WEBKIT GTK+

# Files that will be cleaned
MAINTAINERCLEANFILES := $(stamp_files) $(BUILT_SOURCES) doltcompile doltlibtool
DISTCLEANFILES := $(stamp_files) $(BUILT_SOURCES) doltcompile doltlibtool
CLEANFILES := $(stamp_files) $(BUILT_SOURCES)

# Include module makefiles
include JavaScriptCore/GNUmakefile.am
include WebCore/GNUmakefile.am
include WebKitTools/GNUmakefile.am
include WebKit/gtk/po/GNUmakefile.am

# Build unit tests
noinst_PROGRAMS += $(TEST_PROGS)

webkit_tests_cflags = \
	-fno-strict-aliasing \
	-I$(srcdir)/JavaScriptCore/ForwardingHeaders \
	-I$(srcdir)/WebKit/gtk \
	-I$(top_builddir)/WebKit/gtk \
	$(global_cflags) \
	$(GLIB_CFLAGS) \
	$(GTK_CFLAGS) \
	$(LIBSOUP_CFLAGS)

webkit_tests_ldadd = \
	libwebkit-1.0.la \
	$(GTK_LIBS)	\
	$(GLIB_LIBS) \
	$(LIBSOUP_LIBS)

webkit_tests_ldflags = \
	-no-install \
	-no-fast-install

TEST_PROGS += Programs/unittests/testhttpbackend \
	Programs/unittests/testloading \
	Programs/unittests/testnetworkrequest \
	Programs/unittests/testwebframe \
	Programs/unittests/testwebbackforwardlist \
	Programs/unittests/testwebhistoryitem \
	Programs/unittests/testdownload \
	Programs/unittests/testatk \
	Programs/unittests/testwebsettings

# Add additional tests here
Programs_unittests_testhttpbackend_SOURCES = WebKit/gtk/tests/testhttpbackend.c
Programs_unittests_testhttpbackend_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testhttpbackend_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testhttpbackend_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testloading_SOURCES = WebKit/gtk/tests/testloading.c
Programs_unittests_testloading_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testloading_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testloading_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testnetworkrequest_SOURCES = WebKit/gtk/tests/testnetworkrequest.c
Programs_unittests_testnetworkrequest_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testnetworkrequest_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testnetworkrequest_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testwebframe_SOURCES = WebKit/gtk/tests/testwebframe.c
Programs_unittests_testwebframe_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testwebframe_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testwebframe_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testwebbackforwardlist_SOURCES = WebKit/gtk/tests/testwebbackforwardlist.c
Programs_unittests_testwebbackforwardlist_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testwebbackforwardlist_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testwebbackforwardlist_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testwebhistoryitem_SOURCES = WebKit/gtk/tests/testwebhistoryitem.c
Programs_unittests_testwebhistoryitem_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testwebhistoryitem_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testwebhistoryitem_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testdownload_SOURCES = WebKit/gtk/tests/testdownload.c
Programs_unittests_testdownload_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testdownload_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testdownload_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testatk_SOURCES = WebKit/gtk/tests/testatk.c
Programs_unittests_testatk_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testatk_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testatk_LDFLAGS = $(webkit_tests_ldflags)

Programs_unittests_testwebsettings_SOURCES = WebKit/gtk/tests/testwebsettings.c
Programs_unittests_testwebsettings_CFLAGS = $(webkit_tests_cflags)
Programs_unittests_testwebsettings_LDADD = $(webkit_tests_ldadd)
Programs_unittests_testwebsettings_LDFLAGS = $(webkit_tests_ldflags)

# Autogenerated sources
BUILT_SOURCES := \
	$(javascriptcore_built_sources) \
	$(javascriptcore_built_nosources) \
	$(webcore_built_sources) \
	$(webcore_built_nosources) \
	$(webkitgtk_built_sources) \
	$(webkitgtk_built_nosources)

# Project-wide clean rules
CLEANFILES += \
	$(webkitgtk_cleanfiles)

MAINTAINERCLEANFILES += \
	$(srcdir)/aconfig.h.in \
	$(srcdir)/autotools/config.* \
	$(srcdir)/autotools/compile \
	$(srcdir)/autotools/depcomp \
	$(srcdir)/autotools/install-sh \
	$(srcdir)/autotools/missing \
	$(srcdir)/configure \
	$(srcdir)/GNUmakefile.in \
	$(srcdir)/INSTALL \
	$(srcdir)/README \
	$(top_builddir)/config.*

# Older automake versions (1.7) place Plo files in a different place so we need
# to create the output directory manually.
all-local: stamp-po
	$(mkdir_p) $(top_builddir)/$(DEPDIR)/DerivedSources

# remove built sources and program directories
clean-local:
	-rm -rf $(GENPROGRAMS)

maintainer-clean-local: distclean-local

distclean-local:
	-rm -rf $(GENSOURCES) $(GENPROGRAMS)

install-data-local: po-install-data-local

installdirs-data-local: po-installdirs-data-local

uninstall-local: po-uninstall-local

# Run all tests in cwd
# FIXME: we should run this under xvfb
test: $(TEST_PROGS)
	$(GTESTER) --verbose $(TEST_PROGS);

# test-report: run tests in cwd and generate report
# full-report: run tests in cwd with -m perf and -m slow and generate report
# perf-report: run tests in cwd with -m perf and generate report
test-report full-report perf-report: $(TEST_PROGS)
	@ case $@ in \
	  test-report) test_options="-k";; \
	  full-report) test_options="-k -m=perf";; \
	  perf-report) test_options="-k -m=perf -m=slow";; \
	  esac ; \
	  $(GTESTER) --verbose $$test_options -o test-report.xml $(TEST_PROGS); \
	  $(GTESTER_REPORT) test-report.xml > test-report.html ;

.PHONY: test test-report perf-report full-report
check-local: test