#
# Makefile
#

#SUFFIXES = .m .c
#VPATH = .:coconut

INCLUDES = -I$(top_builddir) 

if COND_GL_PKG
G_CFLAGS = $(GL_CFLAGS)
G_LIBS = $(GL_LIBS)
else
if COND_GTK_CONFIG
G_CFLAGS = $(GTK_CFLAGS)
G_LIBS   = $(GTK_LIBS)
else
if COND_GLIB_CONFIG
G_CFLAGS = $(GLIB_CFLAGS)
G_LIBS   = $(GLIB_LIBS)
endif
endif
endif

if COND_GNET_CONFIG
GNET_CFLAGS = $(GNET_CFLAGS)
GNET_CLIBS = $(GNET_CLIBS)
else
GNET_CFLAGS = 
GNET_CLIBS = 
endif

CFLAGS	  = @CFLAGS@ $(G_CFLAGS) $(POPT_CFLAGS) $(XML_CFLAGS) $(GNET_CFLAGS) 
OBJCFLAGS = $(CFLAGS)

if COND_GTK_CONFIG
GTK_TESTS= ./gtk-test.sh
else
GTK_TESTS=
endif

if COND_GL_PKG
GL_TESTS= ./gl-test.sh
else
GL_TESTS=
endif

# TESTS= ../script/test-and-compare $(GTK_TESTS) $(GL_TESTS)
TESTS= ../script/test-and-compare 

../script/test-and-compare : dummy
	chmod +x ../script/test-and-compare

./gtk-test.sh : dummy
	chmod +x ./gtk-test.sh

dummy:

if COND_GL_PKG
COCONUT_GL_LIBS = \
  $(top_builddir)/coconut/gl/libcoconut_gl.la 
else
COCONUT_GL_LIBS = 
endif

if COND_GTK_CONFIG
COCONUT_GTK_LIBS = \
  $(top_builddir)/coconut/gtk/libcoconut_gtk.la 
else
COCONUT_GTK_LIBS = 
endif

if COND_GLIB_CONFIG
COCONUT_GNET_LIBS = \
  $(top_builddir)/coconut/gnet/libcoconut_gnet.la
else
COCONUT_GNET_LIBS = 
endif

COCONUT_LIBS = \
   $(top_builddir)/coconut/libcoconut.la \
   $(G_LIBS) $(POPT_LIBS) $(XML_LIBS) $(GNET_LIBS) $(OBJCLIBS)

ALL_LIBS  = \
  $(COCONUT_GNET_LIBS) \
  $(COCONUT_GL_LIBS) \
  $(COCONUT_GTK_LIBS) \
  $(COCONUT_LIBS) 

#OBJCLINK  = $(LIBTOOL) --mode=link @OBJC@ -o $@ 

if COND_GLIB_CONFIG
noinst_glib_programs = \
  casyncfile-test1.out \
  casyncfile-test2.out \
  carray-test.out \
  cdate-test.out \
  chash-test.out \
  cidarray-test.out \
  cidhash-test.out \
  cidlist-test.out \
  cidset-test.out \
  cidstack-test.out \
  clist-test.out \
  cset-test.out \
  cstack-test.out 
else
noinst_glib_programs = 
endif

if COND_LIBXML2_CONFIG
noinst_libxml_programs = \
  ccmdparser-test1.out \
  ccmdparser-test2.out \
  chtmltree-test.out \
  cxmlalloc-test.out \
  cxmlfactory-test.out \
  cxmlfactory-test2.out \
  cxmlnode-test.out \
  cxmlparser-test.out \
  cxmltable-test.out \
  cxmltree-test.out \
  cxmltree-test2.out \
  cxmltree-test3.out \
  cxmltree-test4.out
else
noinst_libxml_programs = 
endif

if COND_LIBPOPT
noinst_popt_programs = \
  coptparser-test.out
else
noinst_popt_programs = 
endif

if COND_GTK_CONFIG
noinst_gtk_programs = \
  carrow-test.gui_out \
  cbutton-test.gui_out \
  ccalendar-test.gui_out \
  ccheckbutton-test.gui_out \
  ccontainer-test.gui_out \
  cframe-test.gui_out \
  cguiparser-test1.gui_out \
  cguiparser-test2.gui_out \
  clabel-test.gui_out \
  cradiobutton-test.gui_out \
  cseparator-test.gui_out \
  ctextview-test.gui_out \
  cwindow-test.gui_out
else
noinst_gtk_programs =
endif

if COND_GL_PKG
noinst_gl_programs = \
  cglfactory-test.gui_out 
else
noinst_gl_programs = 
endif

if COND_GNET_CONFIG
noinst_gnet_programs = \
  cnetstream-test.out
# casyncnet-test.out
else
noinst_gnet_programs =
endif

noinst_PROGRAMS = \
  simple.out \
  inline-test.out \
  longjmp-test.out \
  macro-test.out \
  mem-test.out \
  message-test.out \
  cboolean-test.out \
  ccmdenv-test.out \
  ccmdexit-test.out \
  ccmdnum-test.out \
  ccmdprint-test.out \
  ccmdtext-test.out \
  cconststr-test.out \
  cdir-test.out \
  cexpconst-test.out \
  cexpvar-test.out \
  creal-test.out \
  cfile-test.out \
  cindent-test.out \
  cindtstream-test.out \
  cint-test.out \
  clangsystem-test.out \
  clangscope-test.out \
  cmemalloc-test.out \
  cmemory-test.out \
  cmessage-test.out \
  cnode-test.out \
  cobject-test.out \
  cobstack-test.out \
  cpagealloc-test.out \
  cpoint-test.out \
  crect-test.out \
  cregexp-test.out \
  csystem-test.out \
  csystem-test2.out \
  cstring-test.out \
  ctext-test.out \
  ctoken-test.out \
  ctree-test.out \
  cwordlist-test.out \
  fvector-test.out \
  $(noinst_glib_programs) \
  $(noinst_libxml_programs) \
  $(noinst_popt_programs) \
  $(noinst_gtk_programs) \
  $(noinst_gl_programs) \
  $(noinst_gnet_programs) 

CLEANFILES = *.out *.gui_out *.o *.result

simple_out_SOURCES = simple.m
simple_out_LDADD = $(COCONUT_LIBS)
longjmp_test_out_SOURCES = longjmp-test.m
longjmp_test_out_LDADD = $(COCONUT_LIBS)
macro_test_out_SOURCES = macro-test.m
macro_test_out_LDADD = $(COCONUT_LIBS)
mem_test_out_SOURCES = mem-test.m
mem_test_out_LDADD = $(COCONUT_LIBS)
message_test_out_SOURCES = message-test.m
message_test_out_LDADD = $(COCONUT_LIBS)

casyncfile_test1_out_SOURCES = casyncfile-test1.m
casyncfile_test1_out_LDADD = $(ALL_LIBS)
casyncfile_test2_out_SOURCES = casyncfile-test2.m
casyncfile_test2_out_LDADD = $(ALL_LIBS)
carray_test_out_SOURCES = carray-test.m
carray_test_out_LDADD = $(ALL_LIBS)
cboolean_test_out_SOURCES = cboolean-test.m
cboolean_test_out_LDADD = $(COCONUT_LIBS)
cconststr_test_out_SOURCES = cconststr-test.m
cconststr_test_out_LDADD = $(COCONUT_LIBS)
ccmdenv_test_out_SOURCES = ccmdenv-test.m
ccmdenv_test_out_LDADD = $(COCONUT_LIBS)
ccmdexit_test_out_SOURCES = ccmdexit-test.m
ccmdexit_test_out_LDADD = $(COCONUT_LIBS)
ccmdnum_test_out_SOURCES = ccmdnum-test.m
ccmdnum_test_out_LDADD = $(COCONUT_LIBS)
ccmdprint_test_out_SOURCES = ccmdprint-test.m
ccmdprint_test_out_LDADD = $(COCONUT_LIBS)
ccmdparser_test1_out_SOURCES = ccmdparser-test1.m
ccmdparser_test1_out_LDADD = $(COCONUT_LIBS)
ccmdparser_test2_out_SOURCES = ccmdparser-test2.m
ccmdparser_test2_out_LDADD = $(COCONUT_LIBS)
ccmdtext_test_out_SOURCES = ccmdtext-test.m
ccmdtext_test_out_LDADD = $(COCONUT_LIBS)
cdate_test_out_SOURCES = cdate-test.m
cdate_test_out_LDADD = $(COCONUT_LIBS)
cdir_test_out_SOURCES = cdir-test.m
cdir_test_out_LDADD = $(COCONUT_LIBS)
cexpconst_test_out_SOURCES = cexpconst-test.m
cexpconst_test_out_LDADD = $(COCONUT_LIBS)
cexpvar_test_out_SOURCES = cexpvar-test.m
cexpvar_test_out_LDADD = $(COCONUT_LIBS)
creal_test_out_SOURCES = creal-test.m
creal_test_out_LDADD = $(COCONUT_LIBS)
cfile_test_out_SOURCES = cfile-test.m
cfile_test_out_LDADD = $(ALL_LIBS)
chash_test_out_SOURCES = chash-test.m
chash_test_out_LDADD = $(ALL_LIBS)
cidarray_test_out_SOURCES = cidarray-test.m
cidarray_test_out_LDADD = $(ALL_LIBS)
cidhash_test_out_SOURCES = cidhash-test.m
cidhash_test_out_LDADD = $(ALL_LIBS)
cidlist_test_out_SOURCES = cidlist-test.m
cidlist_test_out_LDADD = $(ALL_LIBS)
cidset_test_out_SOURCES = cidset-test.m
cidset_test_out_LDADD = $(ALL_LIBS)
cidstack_test_out_SOURCES = cidstack-test.m
cidstack_test_out_LDADD = $(ALL_LIBS)
cindent_test_out_SOURCES = cindent-test.m
cindent_test_out_LDADD = $(ALL_LIBS)
cindtstream_test_out_SOURCES = cindtstream-test.m
cindtstream_test_out_LDADD = $(ALL_LIBS)
cint_test_out_SOURCES = cint-test.m
cint_test_out_LDADD = $(COCONUT_LIBS)
clist_test_out_SOURCES = clist-test.m
clist_test_out_LDADD = $(ALL_LIBS)
clangsystem_test_out_SOURCES = clangsystem-test.m
clangsystem_test_out_LDADD = $(COCONUT_LIBS)
clangscope_test_out_SOURCES = clangscope-test.m
clangscope_test_out_LDADD = $(COCONUT_LIBS)
cmemalloc_test_out_SOURCES = cmemalloc-test.m
cmemalloc_test_out_LDADD = $(COCONUT_LIBS)
cmemory_test_out_SOURCES = cmemory-test.m
cmemory_test_out_LDADD = $(COCONUT_LIBS)
cmessage_test_out_SOURCES = cmessage-test.m
cmessage_test_out_LDADD = $(COCONUT_LIBS)
cnode_test_out_SOURCES = cnode-test.m
cnode_test_out_LDADD = $(COCONUT_LIBS)
cobject_test_out_SOURCES = cobject-test.m
cobject_test_out_LDADD = $(COCONUT_LIBS)
cobstack_test_out_SOURCES = cobstack-test.m
cobstack_test_out_LDADD = $(COCONUT_LIBS)
coptparser_test_out_SOURCES = coptparser-test.m
coptparser_test_out_LDADD = $(COCONUT_LIBS)
cpagealloc_test_out_SOURCES = cpagealloc-test.m
cpagealloc_test_out_LDADD = $(COCONUT_LIBS)
cpoint_test_out_SOURCES = cpoint-test.m
cpoint_test_out_LDADD = $(COCONUT_LIBS)
crect_test_out_SOURCES = crect-test.m
crect_test_out_LDADD = $(COCONUT_LIBS)
cregexp_test_out_SOURCES = cregexp-test.m
cregexp_test_out_LDADD = $(COCONUT_LIBS)
cset_test_out_SOURCES = cset-test.m
cset_test_out_LDADD = $(ALL_LIBS)
csystem_test_out_SOURCES = csystem-test.m
csystem_test_out_LDADD = $(COCONUT_LIBS)
csystem_test2_out_SOURCES = csystem-test2.m
csystem_test2_out_LDADD = $(COCONUT_LIBS)
cstack_test_out_SOURCES = cstack-test.m
cstack_test_out_LDADD = $(COCONUT_LIBS)
cstring_test_out_SOURCES = cstring-test.m
cstring_test_out_LDADD = $(COCONUT_LIBS)
ctext_test_out_SOURCES = ctext-test.m
ctext_test_out_LDADD = $(COCONUT_LIBS)
ctoken_test_out_SOURCES = ctoken-test.m
ctoken_test_out_LDADD = $(COCONUT_LIBS)
ctree_test_out_SOURCES = ctree-test.m
ctree_test_out_LDADD = $(COCONUT_LIBS)
cwordlist_test_out_SOURCES = cwordlist-test.m
cwordlist_test_out_LDADD = $(COCONUT_LIBS)
chtmltree_test_out_SOURCES = chtmltree-test.m
chtmltree_test_out_LDADD = $(COCONUT_LIBS)
cxmlalloc_test_out_SOURCES = cxmlalloc-test.m
cxmlalloc_test_out_LDADD = $(ALL_LIBS)
cxmlfactory_test_out_SOURCES = cxmlfactory-test.m
cxmlfactory_test_out_LDADD = $(ALL_LIBS)
cxmlfactory_test2_out_SOURCES = cxmlfactory-test2.m
cxmlfactory_test2_out_LDADD = $(ALL_LIBS)
cxmlnode_test_out_SOURCES = cxmlnode-test.m
cxmlnode_test_out_LDADD = $(ALL_LIBS)
cxmlparser_test_out_SOURCES = cxmlparser-test.m
cxmlparser_test_out_LDADD = $(ALL_LIBS)
cxmltable_test_out_SOURCES = cxmltable-test.m
cxmltable_test_out_LDADD = $(ALL_LIBS)
cxmltree_test_out_SOURCES = cxmltree-test.m
cxmltree_test_out_LDADD = $(ALL_LIBS)
cxmltree_test2_out_SOURCES = cxmltree-test2.m
cxmltree_test2_out_LDADD = $(ALL_LIBS)
cxmltree_test3_out_SOURCES = cxmltree-test3.m
cxmltree_test3_out_LDADD = $(ALL_LIBS)
cxmltree_test4_out_SOURCES = cxmltree-test4.m
cxmltree_test4_out_LDADD = $(ALL_LIBS)
fvector_test_out_SOURCES = fvector-test.c
fvector_test_out_LDADD = $(COCONUT_LIBS)

inline_test_out_SOURCES = inline-test.c
inline_test_out_LDADD = $(COCONUT_LIBS)

cnetstream_test_out_SOURCES = cnetstream-test.m
cnetstream_test_out_LDADD = $(ALL_LIBS)
# casyncnet_test_out_SOURCES = casyncnet-test.m
# casyncnet_test_out_LDADD = $(ALL_LIBS)

carrow_test_gui_out_SOURCES = carrow-test.m
carrow_test_gui_out_LDADD = $(ALL_LIBS)
cbutton_test_gui_out_SOURCES = cbutton-test.m
cbutton_test_gui_out_LDADD = $(ALL_LIBS)
ccalendar_test_gui_out_SOURCES = ccalendar-test.m
ccalendar_test_gui_out_LDADD = $(ALL_LIBS)
ccheckbutton_test_gui_out_SOURCES = ccheckbutton-test.m
ccheckbutton_test_gui_out_LDADD = $(ALL_LIBS)
ccontainer_test_gui_out_SOURCES = ccontainer-test.m
ccontainer_test_gui_out_LDADD = $(ALL_LIBS)
cframe_test_gui_out_SOURCES = cframe-test.m
cframe_test_gui_out_LDADD = $(ALL_LIBS)
cglfactory_test_gui_out_SOURCES = cglfactory-test.m
cglfactory_test_gui_out_LDADD = $(ALL_LIBS)
cguiparser_test1_gui_out_SOURCES = cguiparser-test1.m
cguiparser_test1_gui_out_LDADD = $(ALL_LIBS)
cguiparser_test2_gui_out_SOURCES = cguiparser-test2.m
cguiparser_test2_gui_out_LDADD = $(ALL_LIBS)
clabel_test_gui_out_SOURCES = clabel-test.m
clabel_test_gui_out_LDADD = $(ALL_LIBS)
cradiobutton_test_gui_out_SOURCES = cradiobutton-test.m
cradiobutton_test_gui_out_LDADD = $(ALL_LIBS)
cseparator_test_gui_out_SOURCES = cseparator-test.m
cseparator_test_gui_out_LDADD = $(ALL_LIBS)
ctextview_test_gui_out_SOURCES = ctextview-test.m
ctextview_test_gui_out_LDADD = $(ALL_LIBS)
cwindow_test_gui_out_SOURCES = cwindow-test.m
cwindow_test_gui_out_LDADD = $(ALL_LIBS)

