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

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

VPATH = ${top_srcdir}/scrollbar/sample

_SAMPLE_OBJ_xlib = x_sample_sb_view.o x_transparent_sample_sb_view.o x_sample_sb_view_lib.o
_SAMPLE_OBJ_win32 = x_sample_sb_view_win32.o x_sample_sb_view_lib_win32.o
SAMPLE_OBJ = $(_SAMPLE_OBJ_@GUI@)

_TARGETS_xlib = libsample.la
_TARGETS_win32 = libsample.la
TARGETS = $(_TARGETS_@GUI@)

CFLAGS = $(CFLAGS_LOCAL) -I$(top_srcdir)/xwindow @CFLAGS@ @CPPFLAGS@ @X_CFLAGS@ \
	@GUI_CFLAGS@ -I/usr/include

_LIBS_xlib = @X_LIBS@ -lX11 @X_EXTRA_LIBS@
#_LIBS = @X_LIBS@ @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@
_LIBS_win32 = -mwindows
LIBS = $(_LIBS_@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: $(TARGETS)

libsample.la: $(SAMPLE_OBJ)
	$(LIBTOOL_LINK) -o libsample.la $(SAMPLE_OBJ:.o=.lo) -rpath $(LIBDIR) \
	-module -avoid-version @NO_UNDEFINED_FLAG@ $(LIBS)

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

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

install: $(LIBDIR)
	$(LIBTOOL_INSTALL) $(TARGETS) $(LIBDIR)

uninstall:
	rm -f $(LIBDIR)/*sample*.*

clean:
	rm -rf $(SAMPLE_OBJ) $(SAMPLE_OBJ:.o=.lo) libsample*.la *.core .libs

distclean: clean
	rm -f Makefile
