top_builddir = ../..
top_srcdir = @top_srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@

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

VPATH = ${top_srcdir}/inputmethod/kbd

IM_KBD_OBJ = im_kbd.o

CFLAGS = $(CFLAGS_LOCAL) 		\
	 @POBL_CFLAGS@			\
	 @MEF_CFLAGS@			\
	 @DEB_CFLAGS@			\
	 @X_CFLAGS@			\
	 @GUI_CFLAGS@			\
	 @WAYLAND_CFLAGS@		\
	 @SDL2_CFLAGS@			\
	 @TRUECOLOR_CFLAGS@		\
	 @CFLAGS@			\
	 @CPPFLAGS@			\
	 -I$(top_srcdir)/vtemu		\
	 -I${top_srcdir}/uitoolkit	\
	 -I/usr/local/include

LIBS = $(LIBS_LOCAL) @LPOBL@ @LMEF@

TARGET_xlib = libim@TRUECOLOR_TAG@-kbd.la
TARGET_fb = libim@TRUECOLOR_TAG@-kbd-fb.la
TARGET_console = $(TARGET_fb)
TARGET_win32 = $(TARGET_xlib)
TARGET_quartz = $(TARGET_xlib)
TARGET_beos = $(TARGET_xlib)
TARGET_wayland = libim@TRUECOLOR_TAG@-kbd-wl.la
TARGET_sdl2 = libim@TRUECOLOR_TAG@-kbd-sdl2.la

TARGET = $(TARGET_@GUI@)

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

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

.SUFFIXES: .o .c

all: $(TARGET)

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

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

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

install: $(LIBDIR)
	$(LIBTOOL_INSTALL) $(TARGET) $(LIBDIR)

uninstall:
	rm -f $(LIBDIR)/*im*-kbd*

clean:
	rm -rf $(IM_KBD_OBJ) $(IM_KBD_OBJ:.o=.lo) *im*-kbd* *.core .libs

distclean: clean
	rm -f Makefile

