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

VPATH = ${top_srcdir}/contrib/tool/mlterm-menu

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

LIBEXECDIR = $(DESTDIR)$(libexecdir)
SYSCONFDIR = $(DESTDIR)$(sysconfdir)

LKIK = @LKIK@

CFLAGS = $(CFLAGS_LOCAL) @KIK_CFLAGS@ @CFLAGS@ @CPPFLAGS@ @GTK_CFLAGS@ \
	-DSYSCONFDIR=\"$(sysconfdir)\"

LIBS1 = $(LIBS_LOCAL) @DL_SELF@ @GTK_LIBS@

LIBS2_xlib = $(LKIK)

# mlterm-menu is statically linked with libkik.
# Then it works if installed libkik.dll is compiled with USE_WIN32API or not.
LIBS2_win32 = -mwindows ${top_builddir}/kiklib/src/.libs/libkik.a

LIBS2_quartz = $(LKIK)

LIBS = $(LIBS1) $(LIBS2_@GUI@)

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

PACKAGE = @PACKAGE@
VERSION = @VERSION@

OBJS = mlterm-menu.o

LKIK_DEB=-lkik_deb

all: mlterm-menu

debug:
	$(MAKE) LKIK="$(LKIK_DEB)" all

mlterm-menu: $(OBJS)
	$(LIBTOOL_LINK) $(OBJS) $(CFLAGS) -o mlterm-menu $(LIBS)

.c.o:
	$(CC) $(DEFS) $(CFLAGS) -c $<

install: $(LIBEXECDIR)/mlterm $(SYSCONFDIR)/mlterm
	$(LIBTOOL_INSTALL) -m 755 mlterm-menu $(LIBEXECDIR)/mlterm
	$(INSTALL) -m 644 ${top_srcdir}/contrib/tool/mlterm-menu/menu $(SYSCONFDIR)/mlterm

uninstall:
	rm -f $(LIBEXECDIR)/mlterm/mlterm-menu $(SYSCONFDIR)/mlterm/menu

$(LIBEXECDIR)/mlterm:
	mkdir -p $(LIBEXECDIR)/mlterm

$(SYSCONFDIR)/mlterm:
	mkdir -p $(SYSCONFDIR)/mlterm

clean:
	rm -rf $(OBJS) mlterm-menu mlterm-menu.exe *.core .libs

distclean: clean
	rm -f Makefile
