#
# Makefile for octave's scripts directory
#
# John W. Eaton
# jwe@bevo.che.wisc.edu
# University of Wisconsin-Madison
# Department of Chemical Engineering

TOPDIR = ..

script_sub_dir = .

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

include $(TOPDIR)/Makeconf

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

SOURCES =

ALL_M_FILES1 := $(shell find $(srcdir) -name '*.m' -print)
ALL_M_FILES := $(patsubst $(srcdir)/%, %, $(ALL_M_FILES1))

DISTFILES = $(addprefix $(srcdir)/, Makefile.in ChangeLog $(SOURCES) \
	configure.in configure mkinstalldirs mkdoc mkpkgadd gethelp.cc \
	skip-autoheader move-if-change) DOCSTRINGS

SUBDIRS = audio control deprecated elfun finance general geometry image io \
	linear-algebra miscellaneous optimization path pkg plot polynomial \
	quaternion set signal sparse specfun special-matrix startup \
	statistics strings testfun time

DISTSUBDIRS = $(SUBDIRS)

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

all: $(SUBDIRS) DOCSTRINGS
.PHONY: all

$(SUBDIRS):
	$(MAKE) -C $@ all
.PHONY: $(SUBDIRS)

DOCSTRINGS: gethelp$(BUILD_EXEEXT) mkdoc $(ALL_M_FILES)
	$(srcdir)/mkdoc $(srcdir) > $@.t
	mv $@.t $@

gethelp$(BUILD_EXEEXT): gethelp.cc
	$(BUILD_CXX) $(BUILD_CXXFLAGS) -o $@ $^ $(BUILD_LDFLAGS)

install install-strip uninstall clean mostlyclean distclean maintainer-clean::
	@$(subdir-for-command)
.PHONY: install install-strip uninstall
.PHONY: clean mostlyclean distclean maintainer-clean

install install-strip::
	ls -LR $(DESTDIR)$(datadir)/octave > $(DESTDIR)$(datadir)/octave/ls-R
	ls -LR $(DESTDIR)$(libexecdir)/octave > $(DESTDIR)$(libexecdir)/octave/ls-R

uninstall::
	rm -f $(DESTDIR)$(datadir)/octave/ls-R $(DESTDIR)$(libexecdir)/octave/ls-R

tags TAGS:: $(SOURCES)
	$(SUBDIR_FOR_COMMAND)

tags::
	ctags $(SOURCES)

TAGS:: $(SOURCES)
	etags $(SOURCES)

clean distclean maintainer-clean::
	rm -f gethelp$(BUILD_EXEEXT)

distclean maintainer-clean::
	rm -f Makefile config.log config.status DOCSTRINGS
	rm -rf autom4te.cache

maintainer-clean::
	rm -f tags TAGS configure

dist:
	ln $(DISTFILES) ../`cat ../.fname`/scripts
	for dir in $(DISTSUBDIRS); do mkdir ../`cat ../.fname`/scripts/$$dir; $(MAKE) -C $$dir $@; done
.PHONY: dist
