### User-configurable section begins

# Installation directory prefix for Debian GNU/Linux
DESTDIR =
# Installation directory prefix for other systems
PREFIX = $(DESTDIR)/usr
#PREFIX = $(DESTDIR)/usr/local

# Where to put binaries on 'make install'?
BINDIR = $(PREFIX)/bin
# Where to put manual pages on 'make installman'?
MANDIR = $(PREFIX)/share/man/man1

## Installation commands
RM = rm -f
INSTALLDIR = install -d
INSTALLDATA = install -m 444
INSTALLBIN = install

## C compiler and its options
#CC = gcc
#CFLAGS = -Wall -ansi -pedantic -O3 -fomit-frame-pointer

### User-configurable section ends

TARGET = faucet
MANPAGES = faucet.1
SRCS = faucet.c
OBJS = $(SRCS:.c=.o)

all: $(TARGET)

clean:
	$(RM) $(OBJS)

reallyclean: clean
	$(RM) $(TARGET)

install: $(TARGET)
	$(INSTALLDIR) $(BINDIR)
	$(INSTALLBIN) $(TARGET) $(BINDIR)

installman: $(MANPAGES)
	$(INSTALLDIR) $(MANDIR)
	$(INSTALLDATA) $(MANPAGES) $(MANDIR)

$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)

.phony: all clean reallyclean install installman

.SUFFIXES:
.SUFFIXES: .o .c .1 .dvi .pdf .txt

.c.o:
	$(CC) $(CFLAGS) -c $< -o $@
.1.dvi:
	groff -man -Tdvi $< > $@
.dvi.pdf:
	dvipdfm $<
.1.txt:
	groff -man -Tlatin1 $< | sed -e 's/.//g;' > $@
