### 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 -c -m 444
INSTALLBIN = install -c

## C compiler and its options
#CC = gcc
#CFLAGS = -Wall -ansi -pedantic -O6 -fomit-frame-pointer
#LDFLAGS = -s
#DEFINES =
#INCLUDES =

### User-configurable section ends

TARGETS = photomolo jpegcom exifiron
MANPAGES = photomolo.1 jpegcom.1 exifiron.1
HDRS = scale.h tree.h info.h spec.h html.h
SRCS = photomolo.c $(HDRS:.h=.c)
OBJS = $(SRCS:.c=.o)
LIBS = -ljpeg#-mmx

all: depend $(TARGETS)

clean:
	$(RM) $(OBJS) jpegcom.o exifiron.o

reallyclean: clean
	$(RM) $(TARGETS)

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

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

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

jpegcom: jpegcom.o
	$(CC) $(LDFLAGS) -o $@ jpegcom.o

exifiron: exifiron.o
	$(CC) $(LDFLAGS) -o $@ exifiron.o $(LIBS)

photomolo: $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

.phony: all clean reallyclean install installman

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

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

include depend
