CC = @CC@
CFLAGS = -Wall @CFLAGS@ @DEFS@
CPPFLAGS = @CPPFLAGS@ @DEFS@ -DSWAPD_DEF_CONFIG=\"$(sysconfdir)/swapd.conf\"
LDFLAGS = @LDFLAGS@ @LIBS@
INSTALL = @INSTALL@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@

prefix = @prefix@
mandir = @mandir@
sysconfdir = @sysconfdir@
datadir = @datadir@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@

BINS = swapd

all: $(BINS)
swapd: swapd.$(OBJEXT) @LIBOBJS@
	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o swapd$(EXEEXT) $(filter %.$(OBJEXT), $^)
swapd.$(OBJEXT): swapd.c compat.h config.h

.PHONY: clean distclean install
clean:
	rm -f *.$(OBJEXT) $(BINS) *~

distclean: clean
	rm -f Makefile config.h config.status config.log swapd.8 swapd.conf.5

install: all
	-$(INSTALL) -d $(sbindir)
	-$(INSTALL) -d $(sysconfdir)
	-$(INSTALL) -d $(mandir)/man8
	-$(INSTALL) -d $(mandir)/man5
	$(INSTALL) -m 755 swapd$(EXEEXT) $(sbindir)/swapd$(EXEEXT)
	$(INSTALL) -m 644 swapd.conf $(sysconfdir)/swapd.conf
	$(INSTALL) -m 644 swapd.8 $(mandir)/man8/swapd.8
	$(INSTALL) -m 644 swapd.conf.5 $(mandir)/man5/swapd.conf.5
