#Modify the following to point to your desired installation directories
INDIR=/usr/local/alv/bin
ANDIR=/usr/local/alv/doc/man
FILDIR=/usr/local/alv/filters

#You might want to change this to rasfilter8to1, but ras8to1 is better!
FILTER8TO1=$(BINDIR)/ras8to1

#Sensible values of CFLAGS are -g or -O
#CFLAGS=-g
FLAGS=-O

##########################################################
# You shouldn't need to modify anything below this point #
# Type:                                                  #
# 'make' to make tools merged in place                   #
# 'make install' to make tools merged and install        #
##########################################################

IBS = -lsuntool -lsunwindow -lpixrect -lm 

PROGS = convert dither rasthresh winlev dsp rasregion equalise ffill \
	hist im2ras ras2im ras2lw invert rasval blend rasrange halftone \
	box rasinfo scr2ras winlev8 rasscale transform convolve \
	ras2array array2ras hough palettetool cst rasremap scrload ras8to1 \
	fconvolve

OOLOBJS = convert.o dither.o rasthresh.o winlev.o dsp.o rasregion.o \
	equalise.o ffill.o hist.o im2ras.o ras2im.o ras2lw.o invert.o rasval.o \
	blend.o rasrange.o halftone.o box.o rasinfo.o scr2ras.o winlev8.o \
	rasscale.o transform.o convolve.o ras2array.o array2ras.o hough.o \
	palettetool.o cst.o rasremap.o scrload.o ras8to1.o fconvolve.o

THEROBJS = dynamem.o matrix.o support.o
ALETTEOBJS = p_confirm.o p_init.o p_notif.o p_panel.o p_event.o
BJS = $(TOOLOBJS) $(OTHEROBJS) $(PALETTEOBJS)

ll: alvtools glass

lass: glass.o
	cc $(CFLAGS) -o glass glass.o $(LIBS)

lvtools: $(OBJS) toolmerge.o
	cc $(CFLAGS) -o alvtools toolmerge.o $(OBJS) $(LIBS)

oolmerge.o: toolmerge.c tools.h declarations.h
	cc $(CFLAGS) -c toolmerge.c

onvolve.o: convolve.c defs.h support.c
	cc $(CFLAGS) -DFILTERS_DIR=\"$(FILDIR)\" -c convolve.c

convolve.o: fconvolve.c defs.h support.c
	cc $(CFLAGS) -DFILTERS_DIR=\"$(FILDIR)\" -c fconvolve.c

sp.o: dsp.c defs.h
	cc $(CFLAGS) -DFILTER8TO1=\"$(FILTER8TO1)\" -c dsp.c

lean:
	rm -f *.o *~ core

potless: clean
	rm -f $(LPROGS) glass double half quarter third triple quad MANIFEST alvtools

nstall: all
	install -s alvtools $(BINDIR)
	install -s glass $(BINDIR)
	@for i in ${LPROGS}; do \
		(rm -f $(BINDIR)/$$i; ln -s $(BINDIR)/alvtools $(BINDIR)/$$i); \
	done
	@rm -f $(BINDIR)/double; ln -s $(BINDIR)/alvtools $(BINDIR)/double
	@rm -f $(BINDIR)/half; ln -s $(BINDIR)/alvtools $(BINDIR)/half
	@rm -f $(BINDIR)/quarter; ln -s $(BINDIR)/alvtools $(BINDIR)/quarter
	@rm -f $(BINDIR)/third; ln -s $(BINDIR)/alvtools $(BINDIR)/third
	@rm -f $(BINDIR)/triple; ln -s $(BINDIR)/alvtools $(BINDIR)/triple
	@rm -f $(BINDIR)/quad; ln -s $(BINDIR)/alvtools $(BINDIR)/quad
	@if test ! -d $(MANDIR)/man1; then mkdir $(MANDIR)/man1;fi
	@for i in ../doc/man/man1/*; do \
		(cp $$i $(MANDIR)/man1); \
	done
	@if test ! -d $(MANDIR)/man3; then mkdir $(MANDIR)/man3;fi
	@for i in ../doc/man/man3/*; do \
		(cp $$i $(MANDIR)/man3); \
	done
	@if test ! -d $(MANDIR)/man5; then mkdir $(MANDIR)/man5;fi
	@for i in ../doc/man/man5/*; do \
		(cp $$i $(MANDIR)/man5); \
	done
	@if test ! -d $(FILDIR); then mkdir $(FILDIR);fi
	@for i in ../filters/*; do \
		(cp $$i $(FILDIR)); \
	done
	@echo 'Programs, manual pages and filters installed'
