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

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

VPATH = ${top_srcdir}/inputmethod/m17nlib

IM_M17NLIB_OBJ = im_m17nlib.o

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

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

TARGET_xlib = libim@TRUECOLOR_TAG@-m17nlib.la
TARGET_fb = libim@TRUECOLOR_TAG@-m17nlib-fb.la
TARGET_console = libim@TRUECOLOR_TAG@-m17nlib-fb.la
TARGET_wayland = libim@TRUECOLOR_TAG@-m17nlib-wl.la
TARGET_sdl2 = libim@TRUECOLOR_TAG@-m17nlib-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_M17NLIB_OBJ)
	$(LIBTOOL_LINK) -o $(TARGET) $(IM_M17NLIB_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*-m17nlib*

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

distclean: clean
	rm -f Makefile

