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)/uitoolkit/libotl

OBJ = @OT_LAYOUT_OBJ@

LPOBL = @LPOBL@
LPOBL_DEB = -lpobl_deb

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

CFLAGS_beos = @FONTCONFIG_CFLAGS@

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

LIBS_win32 = -mwindows
LIBS_beos = @FONTCONFIG_LIBS@

TARGET_win32 = libotl-win32.la
TARGET_xlib = libotl.la
TARGET_quartz = libotl-quartz.la
TARGET_fb = libotl.la
TARGET_console = libotl.la
TARGET_wayland = libotl.la
TARGET_sdl2 = libotl.la
TARGET_beos = libotl.la

TARGET = $(TARGET_@GUI@)

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

all: $(TARGET)

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

.SUFFIXES: .c .o

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

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

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

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

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

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

distclean: clean
	rm -f Makefile
