#
# @configure_input@
#

### Identification division.
#

PACKAGE_NAME 	= tile
PACKAGE_VERSION	= 0.8.1

### Environment division.
#
srcdir		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
libdir		= @libdir@
includedir	= @includedir@

TCL_PKGPATH	= $(prefix)/lib
pkglibdir	= $(TCL_PKGPATH)/$(PACKAGE_NAME)$(PACKAGE_VERSION)

EXTRA_DEFINES	=
DEFS		= @DEFS@ $(EXTRA_DEFINES)
LIBS		= @LIBS@
INCLUDES	= -I$(srcdir) @TCL_INCLUDES@ @TK_INCLUDES@ @TK_XINCLUDES@

TCL_STUB_LIB_SPEC	= @TCL_STUB_LIB_SPEC@
TK_STUB_LIB_SPEC	= @TK_STUB_LIB_SPEC@ 
TK_LIB_SPEC		= @TK_LIB_SPEC@ 

PKG_LIBS		= @PKG_LIBS@

CC 		= @CC@
SHLIB_LD	= @SHLIB_LD@
STLIB_LD	= @STLIB_LD@
RANLIB 		= @RANLIB@
WISH_PROG	= @WISH_PROG@
TCLSH_PROG	= @TCLSH_PROG@
INSTALL		= @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@

CFLAGS		= @CFLAGS@
CPPFLAGS	= @CPPFLAGS@
LDFLAGS 	= @LDFLAGS@

OBJEXT		= @OBJEXT@
LIB_PREFIX	= @LIB_PREFIX@
SHLIB_SUFFIX	= @SHLIB_SUFFIX@
STLIB_SUFFIX	= @STLIB_SUFFIX@

# Extra definitions not referenced directly, but that may appear
# inside other susbtitutions inserted by TEA:
#
AR 		= @AR@
LDFLAGS_DEFAULT	= @LDFLAGS_DEFAULT@

### Data division.
#

CLEANFILES	= *.o *.obj $(tile_LIB_FILE) $(tile_STUB_LIB_FILE)

tile_STUB_LIB_FILE	= $(LIB_PREFIX)ttkstub$(STLIB_SUFFIX)
tile_STUB_LIB_OBJS	= ttkStubLib.$(OBJEXT)

tile_LIB_FILE	= $(PACKAGE_NAME)$(SHLIB_SUFFIX)
tile_LIBS	=  \
    $(TCL_STUB_LIB_SPEC) \
    $(TK_STUB_LIB_SPEC) \
    $(PKG_LIBS)

tile_OBJECTS 	= \
    tile.$(OBJEXT) \
    ttkStubInit.$(OBJEXT) \
    tkstate.$(OBJEXT) \
    separator.$(OBJEXT) \
    frame.$(OBJEXT) \
    button.$(OBJEXT) \
    scrollbar.$(OBJEXT) \
    scale.$(OBJEXT) \
    progress.$(OBJEXT) \
    notebook.$(OBJEXT) \
    paned.$(OBJEXT) \
    entry.$(OBJEXT) \
    treeview.$(OBJEXT) tagset.$(OBJEXT) \
    layout.$(OBJEXT) \
    widget.$(OBJEXT) \
    trace.$(OBJEXT) \
    track.$(OBJEXT) \
    blink.$(OBJEXT) \
    scroll.$(OBJEXT) \
    manager.$(OBJEXT) \
    tkElements.$(OBJEXT) \
    label.$(OBJEXT) \
    altTheme.$(OBJEXT) \
    classicTheme.$(OBJEXT) \
    tkTheme.$(OBJEXT) \
    cache.$(OBJEXT) \
    image.$(OBJEXT) \
    clamTheme.$(OBJEXT) \
    @PLATFORM_OBJS@

X11_OBJS	= 
WIN_OBJS	= winTheme.$(OBJEXT) xpTheme.$(OBJEXT) monitor.$(OBJEXT)
MAC_OBJS	= aquaTheme.$(OBJEXT)

WISH_ENV	= TILE_LIBRARY="$(TILE_LIBRARY)" TCLLIBPATH="."
WISH		= $(WISH_ENV) $(WISH_PROG)

### Procedure division.
#

VPATH = @srcdir@:@srcdir@/../win:@srcdir@/../macosx

.PHONY: default all package clean distclean doc install installdirs 
.PHONY: test valgrind vgtest

### Targets section.
#

default:	all
all:		package libraries
install:	install-package install-libraries

package:	$(tile_LIB_FILE)
libraries:	$(tile_STUB_LIB_FILE)

### Build stuff section.
#

.SUFFIXES: .c .@OBJEXT@

.c.@OBJEXT@:
	@echo $<
	@$(CC) -c $(CPPFLAGS) $(DEFS) $(INCLUDES) $(CFLAGS) $< -o $@

$(tile_LIB_FILE): $(tile_OBJECTS)
	-rm -f $@
	$(SHLIB_LD) @SHLIB_LD_OUT@$@ $(tile_OBJECTS) $(LDFLAGS) $(tile_LIBS)

$(tile_STUB_LIB_FILE): $(tile_STUB_LIB_OBJS)
	-rm -f $@
	$(STLIB_LD) @STLIB_LD_OUT@$@ $(tile_STUB_LIB_OBJS)
	$(RANLIB) $@

### Documentation section.
#

### Test stuff section.
#
TILE_LIBRARY	= $(srcdir)/../library
TESTLOAD	= -load "load ./$(tile_LIB_FILE)"
TESTDRIVER	= $(srcdir)/../tests/all.tcl $(TESTLOAD)
TESTFLAGS 	= -verbose e

VALGRIND_OPTS	= --tool=memcheck --leak-check=yes --num-callers=10
VALGRIND	= valgrind $(VALGRIND_OPTS)
VGTESTFLAGS	= -verbose pbe -singleproc true

test ::
	$(WISH) $(TESTDRIVER) $(TESTFLAGS)

vgtest ::
	$(WISH_ENV) $(VALGRIND) $(WISH_PROG) $(TESTDRIVER) $(VGTESTFLAGS) \
	    2>&1 | tee valgrind.log

valgrind ::
	$(WISH_ENV) $(VALGRIND) $(WISH_PROG) $(SCRIPT) 2>&1 | tee valgrind.log

demo ::
	$(WISH) $(srcdir)/../demos/demo.tcl

shell ::
	$(WISH) $(SCRIPT)

gdb:
	$(WISH_ENV) gdb $(WISH_PROG)

### Install stuff section.
#

$(DESTDIR)$(pkglibdir):
	mkdir -p $(DESTDIR)$(pkglibdir)

install-package: package $(DESTDIR)$(pkglibdir)
	$(INSTALL_PROGRAM) $(tile_LIB_FILE) \
	    $(DESTDIR)$(pkglibdir)/$(tile_LIB_FILE)
	$(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir)/pkgIndex.tcl
	for libfile in $(TILE_LIBRARY)/*.tcl ; do \
	    $(INSTALL_DATA) $$libfile $(DESTDIR)$(pkglibdir) ; done

install-libraries: libraries
	mkdir -p $(DESTDIR)$(libdir)
	mkdir -p $(DESTDIR)$(includedir)
	$(INSTALL_DATA) $(tile_STUB_LIB_FILE) $(DESTDIR)$(libdir)
	$(INSTALL_DATA) $(srcdir)/tkTheme.h $(DESTDIR)$(includedir)
	$(INSTALL_DATA) $(srcdir)/ttkDecls.h $(DESTDIR)$(includedir)

### Maintain stuff section.
#

Makefile : $(srcdir)/Makefile.in config.status
	sh config.status

tags ::
	ctags $(srcdir)/*.[ch]


GENSTUBS = $(TCLSH_PROG) $(srcdir)/../tools/genStubs.tcl
genstubs :
	$(GENSTUBS) $(srcdir) $(srcdir)/ttk.decls

### Cleanup section.
#
clean::
	-rm -f $(CLEANFILES)

distclean: clean
	-rm -f Makefile config.cache config.log config.status pkgIndex.tcl

# *EOF*
