###############################################################################
# libbrlapi - A library providing access to braille terminals for applications.
#
# Copyright (C) 2006-2016 by Dave Mielke <dave@mielke.cc>
#
# libbrlapi comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU Lesser General Public License, as published by the Free Software
# Foundation; either version 2.1 of the License, or (at your option) any
# later version. Please see the file LICENSE-LGPL for details.
#
# Web Page: http://brltty.com/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################

include $(SRC_TOP)bindings.mk

TCL_OK = @TCL_OK@
TCLSH = @TCLSH@
TCL_CPPFLAGS = @TCL_CPPFLAGS@
TCL_LIBS = @TCL_LIBS@
TCL_DIR = @TCL_DIR@
TCL_DESTDIR = $(INSTALL_ROOT)

TCL_PKG = $(TCL_DIR)/$(API_NAME)-$(API_RELEASE)
TCL_API = $(LIB_PFX)$(API_NAME)_tcl.$(LIB_EXT)

all: $(TCL_API)

$(TCL_API): bindings.$O $(API_NAME)
	$(MKLIB:<name>=$(API_NAME)) $@ bindings.$O $(TCL_LIBS) $(API_LDFLAGS)

bindings.$O:
	$(CC) $(TCL_CPPFLAGS) $(LIBCFLAGS) -o $@ -c $(SRC_DIR)/bindings.c

mkindex:
	echo >$@ 'pkg_mkIndex $(TCL_DESTDIR)$(TCL_PKG) $(TCL_API)'

clean::
	-rm -f $(TCL_API) mkindex

install: all mkindex
	$(INSTALL_DIRECTORY) $(TCL_DESTDIR)$(TCL_PKG)
	$(INSTALL_PROGRAM) $(TCL_API) $(TCL_DESTDIR)$(TCL_PKG)
	$(TCLSH) ./mkindex

uninstall:
	-rm -f $(TCL_DESTDIR)$(TCL_PKG)/$(TCL_API)
	-rm -f $(TCL_DESTDIR)$(TCL_PKG)/pkgIndex.tcl
	[ ! -d $(TCL_DESTDIR)$(TCL_PKG) ] || rmdir $(TCL_DESTDIR)$(TCL_PKG)

