SHELL = /bin/sh

VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..

sane_prefix = @SANE_PREFIX@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
configdir = ${sysconfdir}/sane.d
sanedatadir = ${datadir}/sane

MKDIR = $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

CC = @CC@
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include \
	@INCLUDES@ @GTK_CFLAGS@
DEFS        = @DEFS@
CPPFLAGS    = @CPPFLAGS@
CFLAGS      = @CFLAGS@ @SANE_CFLAGS@
LDFLAGS     = @LDFLAGS@ @SANE_LDFLAGS@
LIBS        = @LIBS@ @SANE_LIBS@
GTK_LIBS    = @GTK_LIBS@
GTK_CFLAGS  = @GTK_CFLAGS@
GIMP_LIBS   = @GIMP_LIBS@

BINPROGS = @BINPROGS@

COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(GTK_CFLAGS)
LINK = $(CC) $(LDFLAGS) -o $@

@SET_MAKE@

PROGRAMS = $(BINPROGS)
LIBLIB = ../lib/liblib.a
LIBSANEI = ../sanei/libsanei.a

XSCAN_OBJS = xscanimage.o progress.o preview.o preferences.o gtkglue.o
XCAM_OBJS = xcam.o preferences.o gtkglue.o

.c.o:
	$(COMPILE) $<

all: $(PROGRAMS)

install: $(PROGRAMS)
	$(MKDIR) $(bindir) $(datadir)
	@for program in $(BINPROGS); do \
	  $(INSTALL_PROGRAM) $${program} \
	    $(bindir)/$${program}; \
	done
	$(INSTALL_DATA) $(srcdir)/sane-style.rc $(datadir)/sane-style.rc

xscanimage: $(XSCAN_OBJS) $(LIBSANEI) $(LIBLIB)
	$(LINK) $(XSCAN_OBJS) $(LIBSANEI) \
		$(LIBLIB) $(GIMP_LIBS) $(GTK_LIBS) $(LIBS)

xcam: $(XCAM_OBJS) $(LIBSANEI) $(LIBLIB)
	$(LINK) $(XCAM_OBJS) $(LIBSANEI) \
		$(LIBLIB) $(GTK_LIBS) $(LIBS)

clean:
	rm -f *.o *~ .*~ *.bak
	rm -rf .libs

distclean: clean
	rm -f Makefile $(PROGRAMS)

depend:
	makedepend $(INCLUDES) *.c

.PHONY: all install depend clean distclean
