top_builddir = ../..
top_srcdir = @top_srcdir@
prefix = @prefix@
sysconfdir = @sysconfdir@
exec_prefix = @exec_prefix@
datadir = @datadir@
bindir = @bindir@
libdir = @libdir@
libexecdir = @libexecdir@

CC = @CC@
LIBTOOL = @LIBTOOL@
INSTALL = @INSTALL@

LIBDIR = $(DESTDIR)$(libdir)/mlterm

VPATH = $(top_srcdir)/xwindow/libotl

OBJ = @OT_LAYOUT_OBJ@

LKIK = @LKIK@
LKIK_DEB = -lkik_deb

# XDATADIR is to avoid conflicting with DATADIR structure in w32api/objidl.h.
CFLAGS = $(CFLAGS_LOCAL) @KIK_CFLAGS@ @DEB_CFLAGS@ @GUI_CFLAGS@ @CFLAGS@ @CPPFLAGS@ \
	@OT_LAYOUT_CFLAGS@ -I/usr/local/include

LIBS = $(LIBS_LOCAL) @OT_LAYOUT_LIBS@ $(LKIK) -L/usr/local/lib -R/usr/local/lib

INSTALL_OPT = -m 755

LIBTOOL_CC = $(LIBTOOL) --mode=compile $(CC) $(CFLAGS)
LIBTOOL_LINK = $(LIBTOOL) --mode=link $(CC) @LDFLAGS@
LIBTOOL_INSTALL = $(LIBTOOL) --mode=install $(INSTALL)

all: libotl.la

libotl.la: $(OBJ)
	$(LIBTOOL_LINK) -o libotl.la $(OBJ:.o=.lo) -rpath $(libdir)/mlterm \
	-module -avoid-version @NO_UNDEFINED_FLAG@ $(LIBS)

.SUFFIXES: .c .o

.c.o:
	$(LIBTOOL_CC) -c $<

install : $(LIBDIR)
	$(LIBTOOL_INSTALL) $(INSTALL_OPT) libotl.la $(LIBDIR)

uninstall :
	rm -f $(LIBDIR)/*otl*

$(LIBDIR) :
	mkdir -p $(LIBDIR)

wc :
	find . -name "*.[ch]" -a \! -name "test_*" | xargs wc -l

clean:
	rm -rf libotl.la $(OBJ) $(OBJ:.o=.lo) .libs

distclean: clean
	rm -f Makefile
