#
# Makefile.am
#

if COND_GTK_CONFIG
gtk_subdir = gtk
else
gtk_subdir =
endif 

if COND_GL_PKG
gl_subdir = gl
else
gl_subdir = 
endif

if COND_GNET_CONFIG
gnet_subdir = gnet
else
gnet_subdir =
endif

SUBDIRS = $(gtk_subdir) $(gnet_subdir) $(gl_subdir)

SUFFIXES = .m .c

lib_LTLIBRARIES = libcoconut.la

CC=@CC@
OBJC=@OBJC@

CFLAGS 	  += $(GLIB_CFLAGS) $(POPT_CFLAGS) $(XML_CFLAGS) 
OBJCFLAGS  = $(CFLAGS)
LIBS  	   = $(GLIB_LIBS) $(POPT_LIBS) $(XML_LIBS) 
OBJCLIBS   = $(LIBS)
LINK       = $(LIBTOOL) --mode=link $(CC) $(LIBS) $(LDFLAGS) -o $@
OBJCLINK   = $(LIBTOOL) --mode=link $(OBJC) $(LIBS) $(OBJCLIBS) $(LDFLAGS) -o $@

# INCLUDES = -I$(top_srcdir) $(GLIB_CFLAGS) $(POPT_CFLAGS) $(XML_CFLAGS)

libcoconutincludedir = $(includedir)/coconut

if COND_GLIB_CONFIG
glib_headers = \
	casyncfile.h \
	casyncio.h \
	carray.h \
	ceventsystem.h \
	chash.h \
	cidarray.h \
	cidhash.h \
	cidlist.h \
	cidset.h \
	ciostream.h \
	cidstack.h \
	clist.h \
	cset.h \
	cstack.h 
else 
glib_headers =
endif 

if COND_LIBPOPT
popt_headers = \
	coptparser.h 
else 
popt_headers =
endif 

if COND_LIBXML2_CONFIG
libxml_headers = \
	chtmltree.h \
	cxmlalloc.h \
	cxmlfactory.h \
	cxmlnode.h \
	cxmlparser.h \
	cxmltable.h \
	cxmltree.h \
	dxml.h \
	fxml.h \
	txml.h \
	pxmltree.h \
	pxmlparser.h \
	pxmlutil.h
else 
libxml_headers = 
endif 

# if the system does not have obstack in C library, use fobstack.h
if COND_OBSTACK_H
obstack_headers = 
else 
obstack_headers = fobstack.h
endif 

libcoconutinclude_HEADERS = \
	cboolean.h \
	ccmdenv.h \
	ccmdexit.h \
	ccmdnum.h \
	ccmdparser.h \
	ccmdprint.h \
	ccmdtext.h \
	cconststr.h \
	cdate.h \
	cerror.h \
	cexpconst.h \
	cexpfactory.h \
	cexpvar.h \
	cdir.h \
	creal.h \
	cfile.h \
	cindent.h \
	cindtstream.h \
	cint.h \
	clangsystem.h \
	clangscope.h \
	cmemalloc.h \
	cmemory.h \
	cmessage.h \
	cnode.h \
	cobject.h \
	cobstack.h \
	cpagealloc.h \
	cpoint.h \
	crect.h \
	cregexp.h \
	cstring.h \
	csystem.h \
	ctext.h \
	ctoken.h \
	ctree.h \
	cwordlist.h \
	dcmdxml.h \
	dconfig.h \
	dconststr.h \
	dbasic.h \
	derror.h \
	dobject.h \
	flang.h \
	fbasic.h \
	fobject.h \
	fvector.h \
	pallocator.h \
	papplication.h \
	pcommand.h \
	perror.h \
	pgraphics.h \
	plang.h \
	pmath.h \
	pmemory.h \
	pmisc.h \
	pobject.h \
	pset.h \
	pstream.h \
	pstring.h \
	psystem.h \
	ptext.h \
	tbasic.h \
	tcommand.h \
	tglib.h \
	tgraphics.h \
	tlang.h \
	tmath.h \
	tobject.h \
	toptparser.h \
	$(glib_headers) \
	$(obstack_headers) \
	$(popt_headers) \
	$(libxml_headers)

if COND_GLIB_CONFIG
glib_sources = \
	casyncfile.m \
	casyncio.m \
	carray.m \
	ceventsystem.m \
	chash.m \
	cidarray.m \
	cidhash.m \
	cidlist.m \
	cidset.m \
	cidstack.m \
	ciostream.m \
	clist.m \
	cset.m \
	cstack.m 
else 
glib_sources =
endif 

if COND_LIBPOPT
popt_sources = \
	coptparser.m
else 
popt_sources =
endif 

if COND_LIBXML2_CONFIG
libxml_sources = \
	chtmltree.m \
	cxmlalloc.m \
	cxmlfactory.m \
	cxmlnode.m \
	cxmlparser.m \
	cxmltable.m \
	cxmltree.m \
	fxml.m
else 
libxml_sources = 
endif 

# if the system does not have obstack in C library, use fobstack.h
if COND_OBSTACK_BEGIN
obstack_sources=
else 
obstack_sources=fobstack.c
endif 

libcoconut_la_SOURCES = \
	cboolean.m \
	ccmdenv.m \
	ccmdexit.m \
	ccmdnum.m \
	ccmdparser.m \
	ccmdprint.m \
	ccmdtext.m \
	cconststr.m \
	cdate.m \
	cerror.m \
	cexpconst.m \
	cexpfactory.m \
	cexpvar.m \
	cdir.m \
	creal.m \
	cfile.m \
	cindent.m \
	cindtstream.m \
	cint.m \
	clangsystem.m \
	clangscope.m \
	cmemalloc.m \
	cmemory.m \
	cmessage.m \
	cnode.m \
	cobject.m \
	cobstack.m \
	cpagealloc.m \
	cpoint.m \
	crect.m \
	cregexp.m \
	cstring.m  \
	csystem.m \
	ctext.m \
	ctoken.m \
	ctree.m \
	cwordlist.m \
	fbasic.c \
	flang.m \
	fobject.m \
	fvector.c \
	$(glib_sources) \
	$(libxml_sources) \
	$(obstack_sources) \
	$(popt_sources)

libcoconut_la_LDFLAGS = \
  -version-info $(VERSION_INFO) \
  -dynamic

libcoconut_la_LIBADD = $(OBJCLIBS)

