#
# Makefile for octave's scripts/image directory
#
# John W. Eaton
# jwe@che.utexas.edu
# Department of Chemical Engineering
# The University of Texas at Austin

TOPDIR = ../..

script_sub_dir = image

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@

include $(TOPDIR)/Makeconf

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

SOURCES = *.m octtopnm.c
IMAGES = *.img

DISTFILES = Makefile.in $(SOURCES) $(IMAGES)

FCN_FILES = $(wildcard $(srcdir)/*.m)
FCN_FILES_NO_DIR = $(notdir $(FCN_FILES))

IMAGE_FILES = $(wildcard $(srcdir)/*.img)
IMAGE_FILES_NO_DIR = $(notdir $(IMAGE_FILES))

all: octtopnm
.PHONY: all

octtopnm: octtopnm.o
	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) octtopnm.o -o octtopnm

install:
	$(top_srcdir)/mkinstalldirs $(fcnfiledir)/$(script_sub_dir)
	for f in $(FCN_FILES_NO_DIR) ; do \
	  rm -f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
	  $(INSTALL_DATA) $(srcdir)/$$f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
	done
	$(top_srcdir)/mkinstalldirs $(imagedir)
	for f in $(IMAGE_FILES_NO_DIR) ; do \
	  rm -f $(imagedir)/$$f ; \
	  $(INSTALL_DATA) $(srcdir)/$$f $(imagedir)/$$f ; \
	done
	$(top_srcdir)/mkinstalldirs $(archlibdir)
	$(INSTALL_PROGRAM) octtopnm $(archlibdir)/octtopnm
.PHONY: install

uninstall:
	for f in $(FCN_FILES_NO_DIR) ; \
	  do rm -f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
	done
	for f in $(IMAGE_FILES_NO_DIR) ; \
	  do rm -f $(imagedir)/$$f ; \
	done
	rm -f $(archlibdir)/octtopnm
.PHONY: uninstall

clean:
	rm -f octtopnm.o octtopnm
.PHONY: clean

tags: $(SOURCES)
	ctags $(SOURCES)

TAGS: $(SOURCES)
	etags $(SOURCES)

mostlyclean: clean
.PHONY: mostlyclean

distclean: clean
	rm -f Makefile
.PHONY: distclean

realclean: distclean
	rm -f tags TAGS
.PHONY: realclean

local-dist:
	ln $(DISTFILES) ../../`cat ../../.fname`/scripts/image
.PHONY: local-dist

dist:
	ln $(DISTFILES) ../../`cat ../../.fname`/scripts/image
.PHONY: dist
