# Library makefile for the Simply Powerful Toolkit (SPTK).
# Copyright 2000 by Alexey Parshin.
# Copyright 2005 Ilya A. Volynets <ilya@total-knowledge.com>
AM_CXXFLAGS    = -O3 -Wall -I. -I$(top_srcdir) -I$(top_builddir) @FLTK_CXXFLAGS@ @DEBUGFLAG@
AM_LDFLAGS= -L$(top_builddir)
################################################################

SPTK_TESTS = \
    datetime \
    exceptions \
    registry \
    smtp_connect \
    unique_instance \
    net/http_connect \
    net/imap_connect \
    xml/xml_test1 \
    xml/xml_test2 \
    thread_test \
    thread_rwlock \
    thread_onexit \
    server_test \
    client_test \
    datasources/directory_ds \
    datasources/imap_ds 

SPTK_TEST_CPPFILES = \
    datetime.cpp \
    exceptions.cpp \
    registry.cpp \
    smtp_connect.cpp \
    unique_instance.cpp \
    net/http_connect.cpp \
    net/imap_connect.cpp \
    xml/xml_test1.cpp \
    xml/xml_test2.cpp \
    thread_test.cpp \
    thread_rwlock.cpp \
    thread_onexit.cpp \
    server_test.cpp \
    client_test.cpp \
    datasources/directory_ds.cpp \
    datasources/imap_ds.cpp


if BUILD_EXCEL
    AM_LDFLAGS+=-lspxl3
    SPTK_TESTS+=xls_read xls_write
    SPTK_TEST_CPPFILES+=xls_read.cpp xls_write.cpp
endif

if USE_FLTK
    AM_LDFLAGS+=-lsptk3
    SPTK_TESTS+=    ceditor_test check_buttons \
		    cgroup_test combo_test cscroll_test \
		    dialog_test font_combo list_view \
		    radio_buttons tree_view \
		    dialogs/file_dialogs calendar_test \
		    splitter tabs_test
    SPTK_TEST_CPPFILES+=ceditor_test.cpp check_buttons.cpp \
			cgroup_test.cpp combo_test.cpp cscroll_test.cpp \
			dialog_test.cpp font_combo.cpp list_view.cpp \
			radio_buttons.cpp tree_view.cpp \
			dialogs/file_dialogs.cpp calendar_test.cpp \
			splitter.cpp tabs_test.cpp
if USE_ODBC
    SPTK_TESTS+=sptk_test db_list_view
    SPTK_TEST_CPPFILES+=sptk_test.cpp db_list_view.cpp
endif
endif

if USE_ODBC
    AM_LDFLAGS+=-lspdb3
    SPTK_TESTS+=odbc_test odbc_test2 odbc_test3
    SPTK_TEST_CPPFILES+=odbc_test.cpp odbc_test2.cpp odbc_test3.cpp
endif
if USE_ASPELL
    SPTK_TESTS+=spell_checker
    SPTK_TEST_CPPFILES+=spell_checker.cpp
endif

AM_LDFLAGS+=-lsputil3 @ODBC_LIBS@ @FLTK_LDFLAGS@ @ASPELL_LIBS@ -lpthread @DEBUGFLAG@ $(all_libraries)

MOSTLYCLEANFILES=$(patsubst %.cpp, %.o, $(SPTK_TEST_CPPFILES)) $(SPTK_TESTS)

#################### PERVERSION BEGIN ###################

EXTRA_PROGRAMS=perversion
perversion_SOURCES=perversion.cpp

all: $(SPTK_TESTS)

$(SPTK_TESTS): %: $(srcdir)/%.cpp
	mkdir -p `dirname $@`
	$(CXXCOMPILE) -c $< -o $@.o
	$(CXXLINK) $@.o -o $@
