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

VPATH = ${top_srcdir}/tool/mlmenu

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

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

CFLAGS = $(CFLAGS_LOCAL) @CFLAGS@ @CPPFLAGS@ @X_CFLAGS@ -DSYSCONFDIR=\"$(sysconfdir)\"
LIBS = $(LIBS_LOCAL) @X_LIBS@ -lX11 @X_EXTRA_LIBS@
#LIBS = $(LIBS_LOCAL) @X_LIBS@ @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@

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

PACKAGE = @PACKAGE@
VERSION = @VERSION@

OBJS = main.o

all: mlmenu

mlmenu: $(OBJS)
	$(LIBTOOL_LINK) $(OBJS) $(CFLAGS) -o mlmenu $(LIBS)

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

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

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

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

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

distclean: clean
	rm -f Makefile
