# Makefile for octave's scripts directory
#
# Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
#               2003, 2004, 2005, 2006, 2007 John W. Eaton
#
# This file is part of Octave.
# 
# Octave 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 3 of the License, or (at
# your option) any later version.
# 
# Octave 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 Octave; see the file COPYING.  If not, see
# <http://www.gnu.org/licenses/>.

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 deprecated elfun general geometry image io \
	linear-algebra miscellaneous optimization path pkg plot polynomial \
	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

check-m-sources:
	@$(subdir-for-command)
.PHONY: check-m-sources
