#
#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
# OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
#
# Permission is hereby granted to use or copy this program
# for any purpose,  provided the above notices are retained on all copies.
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.


## FIXME: trace_test doesn't work on macosx 10.3
## gcc -g -O2 -o .libs/tracetest trace_test.o  ../.libs/libgc.dylib -lpthread
## ld: Undefined symbols:
## _GC_generate_random_backtrace

# Common libs to _LDADD for all tests.
test_ldadd = $(top_builddir)/libgc.la $(EXTRA_TEST_LIBS)


TESTS += gctest$(EXEEXT)
check_PROGRAMS += gctest
gctest_SOURCES = tests/test.c
gctest_LDADD = $(test_ldadd)
gctest_DEPENDENCIES = $(top_builddir)/libgc.la

TESTS += leaktest$(EXEEXT)
check_PROGRAMS += leaktest
leaktest_SOURCES = tests/leak_test.c
leaktest_LDADD = $(test_ldadd)

TESTS += middletest$(EXEEXT)
check_PROGRAMS += middletest
middletest_SOURCES = tests/middle.c
middletest_LDADD = $(test_ldadd)

TESTS += smashtest$(EXEEXT)
check_PROGRAMS += smashtest
smashtest_SOURCES = tests/smash_test.c
smashtest_LDADD = $(test_ldadd)

TESTS += hugetest$(EXEEXT)
check_PROGRAMS += hugetest
hugetest_SOURCES = tests/huge_test.c
hugetest_LDADD = $(test_ldadd)

TESTS += realloc_test$(EXEEXT)
check_PROGRAMS += realloc_test
realloc_test_SOURCES = tests/realloc_test.c
realloc_test_LDADD = $(test_ldadd)

TESTS += staticrootstest$(EXEEXT)
check_PROGRAMS += staticrootstest
staticrootstest_SOURCES = tests/staticrootstest.c
staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
check_LTLIBRARIES += libstaticrootslib.la
libstaticrootslib_la_SOURCES = tests/staticrootslib.c
libstaticrootslib_la_LIBADD = $(test_ldadd)
libstaticrootslib_la_LDFLAGS = -version-info 1:3:0 -no-undefined -rpath /nowhere
libstaticrootslib_la_DEPENDENCIES = $(top_builddir)/libgc.la

if KEEP_BACK_PTRS
TESTS += tracetest$(EXEEXT)
check_PROGRAMS += tracetest
tracetest_SOURCES = tests/trace_test.c
tracetest_LDADD = $(test_ldadd)
endif

if THREADS
TESTS += threadleaktest$(EXEEXT)
check_PROGRAMS += threadleaktest
threadleaktest_SOURCES = tests/thread_leak_test.c
threadleaktest_LDADD = $(test_ldadd)

TESTS += threadkey_test$(EXEEXT)
check_PROGRAMS += threadkey_test
threadkey_test_SOURCES = tests/threadkey_test.c
threadkey_test_LDADD = $(test_ldadd)

TESTS += initsecondarythread$(EXEEXT)
check_PROGRAMS += initsecondarythread
initsecondarythread_SOURCES = tests/initsecondarythread.c
initsecondarythread_LDADD = $(test_ldadd)
endif

if CPLUSPLUS
TESTS += test_cpp$(EXEEXT)
check_PROGRAMS += test_cpp
test_cpp_SOURCES = tests/test_cpp.cc
if AVOID_CPP_LIB
test_cpp_LDADD = gc_cpp.o $(test_ldadd)
else
test_cpp_LDADD = libgccpp.la $(test_ldadd)
endif
endif
