###########################################################################
#    This file is part of morph.                                       #
#    Copyright (C) 1999  Oliver Knill                                     #
#                                                                         #
#    This program is free software; you can redistribute it and/or modify #
#    it under the terms of the GNU General Public License as published by #
#    the Free Software Foundation; either version 2 of the License, or    #
#    (at your option) any later version.                                  #
#                                                                         #
#    This program is distributed in the hope that it will be useful,      #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of       # 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
#    GNU General Public License for more details.                         #
#                                                                         #
#    You should have received a copy of the GNU General Public License    #
#    along with this program; if not, write to the Free Software          #
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            #
#                                                                         #
###########################################################################
#                                                                         #
# Makefile for ppmmorph                                                   #
#                                                                         #
###########################################################################

SHELL   = /bin/sh
PROGRAM	= ppmmorph
RM	= rm -f
CC	= gcc

prefix	= /usr/local
bindir	= $(prefix)/bin
mandir	= $(prefix)/man
man1dir	= $(mandir)/man1
cat1dir	= $(mandir)/cat1
docdir	= $(prefix)/doc
chidoc	= $(docdir)/morph-$(VERSION) 

#DEBUG	= -DDEBUG -g -Wall -ansi -pedantic 
#DEBUG	= -O2 -Wall
DEBUG   = -O3  -Wno-unused-result 

CFLAGS	= $(DEBUG) $(CONFIG)
LIBS	= -lm

DOCS	= COPYING README
VERSION	= 0.6

SRCS	= ppmmorph.c 
INCS	= ppmmorph.h
OBJS	= ppmmorph.o 

all:	$(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)

.c.o:
	$(CC) $(CFLAGS) -c $*.c

clean:
	$(RM) $(OBJS) $(PROGRAM) 
	touch test.ppm; rm *.ppm

install:	install-bin install-man install-doc

install-bin:	$(PROGRAM)
	install -s -c -m 755 $(PROGRAM) $(bindir)

install-man:	ppmmorph.1.gz
	install -c -m 644 ppmmorph.1.gz $(man1dir)

install-doc:	$(DOCS)
	install -d $(chidoc)
	install -c -m 644 $(DOCS) $(chidoc)

uninstall:
	-$(RM) $(bindir)/$(PROGRAM)
	-$(RM) $(man1dir)/morph.1
	-$(RM) $(cat1dir)/morph.1
	-$(RM) -r $(chidoc)                
test:
	convert shield.png test.ppm; ./ppmmorph -0.1 test.ppm >out.ppm
	convert out.ppm deformed_shield.png; rm out.ppm; rm test.ppm;
