# Makfile for pngslice
# Makefile
#
# This is a sort of reusable Makefile for C programs
# using gengetopt. You'll need to change $(NAME) and 
# $(OBJ) of course, but probably the "check" target too
#
# J. J. Green 2002
# $Id: Makefile.in,v 1.21 2008/09/26 21:20:06 jjg Exp $

# macros

NAME    =  pngslice

PIXELS  = 10

OBJ     = main.o tmask.o options.o 
GGO_OUT = options.c options.h 

RUBBISH = $(NAME) $(OBJ) slices/test.*.* test.html *~
AUTOGEN = $(GGO_OUT)

CFLAGS      = -DHAVE_CONFIG_H -g -O2 -Wall

LIBS        = -lpng 

prefix      = /usr/local
exec_prefix = ${prefix}
datarootdir = ${prefix}/share
bindir      = ${exec_prefix}/bin
mandir      = ${datarootdir}/man
GGO         = /usr/bin/gengetopt

INSTALL  = /usr/bin/install -c
INSTDIR  = $(INSTALL) -d 
INSTEXEC = ${INSTALL} 
INSTDATA = ${INSTALL} -m 644 

# phoney targets

default : all 

all : $(NAME)

clean : 
	$(RM) $(RUBBISH)

veryclean : clean

autogenclean :
	$(RM) $(AUTOGEN)

check : test.html

install : $(NAME) $(NAME)
	$(INSTEXEC) $(NAME) $(bindir)/$(NAME) 
	$(INSTDATA) $(NAME).1  $(mandir)/man1/$(NAME).1 

bt : backtrace

backtrace : $(NAME) bt.gdb
	gdb -x bt.gdb ./$(NAME)

debug : $(NAME) debug.gdb
	gdb -x debug.gdb ./$(NAME)

.PHONEY : default all clean veryclean check install backtrace bt debug

# real targets

$(NAME) : $(OBJ)
	$(CC) $(OBJ) $(LIBS) -o $(NAME)

ifdef GGO

$(GGO_OUT) : options.ggo
	$(GGO) -u -i options.ggo -f options -F options

endif

slices/test.sliced.html : $(NAME) test.png
	./$(NAME) -bslices/test -v -m0.2/0.6 -t51/51/51 -p$(PIXELS) test.png

test.html : test.pre.html slices/test.sliced.html test.post.html
	cat test.pre.html slices/test.sliced.html test.post.html > test.html

.PRECIOUS : main.c options.ggo.in $(NAME).1 Makefile.in

# dependancies

main.o: config.h options.h
options.o:

