### Path settings
datarootdir = @datarootdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sysconfdir = @sysconfdir@
mandir = @mandir@

### Installation programs and flags
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s
LN_S = @LN_S@
MKDIR = @MKDIR@

### Compiler and link options
CC	= @CC@
CFLAGS	= @CFLAGS@
DEFS	= @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)\"
CPPFLAGS = -I.. -I$(top_srcdir) -I$(srcdir) -I$(top_srcdir)/conserver $(DEFS) @CPPFLAGS@
LDFLAGS	= @LDFLAGS@
LIBS	= @LIBS@
@SET_MAKE@


### Makefile rules - no user-servicable parts below

CONSOLE_OBJS = console.o getpassword.o readconf.o ../conserver/cutil.o
CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h \
	       $(top_srcdir)/conserver/cutil.h \
	       $(top_srcdir)/conserver/version.h \
	       $(srcdir)/getpassword.h $(srcdir)/readconf.h
ALL = console


all: $(ALL)

$(CONSOLE_OBJS): $(CONSOLE_HDRS)

console: $(CONSOLE_OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o console $(CONSOLE_OBJS) $(LIBS)

../conserver/cutil.o:
	( cd ../conserver && $(MAKE) $(MAKE_FLAGS) cutil.o ) || exit 1;

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

clean:
	rm -f *~ *.o $(ALL) core

distclean: clean
	rm -f Makefile

install: console
	$(MKDIR) $(DESTDIR)$(bindir)
	$(INSTALL_PROGRAM) console $(DESTDIR)$(bindir)
	$(MKDIR) $(DESTDIR)$(mandir)/man1
	$(INSTALL) -m 0644 console.man $(DESTDIR)$(mandir)/man1/console.1

.PHONY: clean distclean install
