### 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 = c2n
MANPAGES = c2n.1
SRCS = c2n.c decode.c encode.c oric_d.c oric_e.c
HDRS = $(SRCS:.c=.h)
OBJS = $(SRCS:.c=.o)
LIBS = -lm

all: depend $(TARGET)

clean:
	$(RM) $(OBJS)

reallyclean: clean
	$(RM) $(TARGET)

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

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

depend: $(SRCS) $(HDRS)
	$(CC) -MM $(SRCS) > depend

$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(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;' > $@

include depend
