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

TOPDIR = ..

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@:@srcdir@/DLD-FUNCTIONS:@srcdir@/OPERATORS:@srcdir@/TEMPLATE-INST

include $(TOPDIR)/Makeconf

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

PT_FLAGS = -fexternal-templates -fno-implicit-templates
CXXFLAGS_NO_PT_FLAGS = $(filter-out $(PT_FLAGS), $(ALL_CXXFLAGS))

%.df : %.cc
	@echo making $@ from $<
	@$(CXXCPP) $(CPPFLAGS) $(CXXFLAGS_NO_PT_FLAGS) -DMAKE_BUILTINS $< \
	  | $(srcdir)/mkdefs > $@-t
	@mv $@-t $@

# How to make a .oct file from a .o file:

ifeq ($(ENABLE_DYNAMIC_LINKING), true)
  ifdef CXXPICFLAG
    %.oct : pic/%.o octave$(EXEEXT)
	  $(DL_LD) $(DL_LDFLAGS) -o $@ $< $(OCT_LINK_DEPS)
  else
    %.oct : %.o octave$(EXEEXT)
	  $(DL_LD) $(DL_LDFLAGS) -o $@ $< $(OCT_LINK_DEPS)
  endif
endif


OPT_HANDLERS := DASPK-opts.cc DASRT-opts.cc DASSL-opts.cc \
	LSODE-opts.cc NLEqn-opts.cc ODESSA-opts.cc Quad-opts.cc

DLD_XSRC := balance.cc besselj.cc betainc.cc chol.cc colloc.cc \
	daspk.cc dasrt.cc dassl.cc det.cc eig.cc expm.cc fft.cc fft2.cc \
	fftn.cc fftw_wisdom.cc filter.cc find.cc fsolve.cc gammainc.cc \
	getgrent.cc getpwent.cc getrusage.cc givens.cc hess.cc \
	inv.cc kron.cc lpsolve.cc lsode.cc lu.cc minmax.cc \
	odessa.cc pinv.cc qr.cc quad.cc qz.cc rand.cc schur.cc \
	sort.cc sqrtm.cc svd.cc syl.cc time.cc

DLD_SRC := $(addprefix DLD-FUNCTIONS/, $(DLD_XSRC))

DLD_OBJ := $(patsubst %.cc, %.o, $(DLD_XSRC))

ifeq ($(ENABLE_DYNAMIC_LINKING), true)
  OCT_FILES := $(patsubst %.o, %.oct, $(DLD_OBJ))
  ifdef CXXPICFLAG
    DLD_PICOBJ := $(addprefix pic/, $(DLD_OBJ))
  else
    DLD_PICOBJ := $(DLD_OBJ)
  endif
else
  DLD_STATIC_OBJ := $(DLD_OBJ)
endif

OV_INCLUDES := ov-re-mat.h ov-cx-mat.h ov-ch-mat.h ov-cs-list.h ov-list.h \
	ov-struct.h ov-scalar.h ov-range.h ov-complex.h ov-va-args.h \
	ov-colon.h ov-base.h ov-base-mat.h ov-base-scalar.h \
	ov-streamoff.h ov-str-mat.h ov-bool-mat.h ov-bool.h \
	ov-file.h ov-cell.h ov.h ov-fcn.h ov-builtin.h ov-dld-fcn.h \
	ov-mapper.h ov-usr-fcn.h ov-fcn-handle.h ov-typeinfo.h

PT_INCLUDES := pt.h pt-all.h pt-arg-list.h pt-assign.h pt-binop.h \
        pt-bp.h	pt-cell.h pt-check.h pt-cmd.h pt-colon.h pt-const.h \
	pt-decl.h pt-except.h pt-exp.h pt-fcn-handle.h pt-id.h pt-idx.h \
	pt-jump.h pt-loop.h pt-mat.h pt-misc.h pt-plot.h \
	pt-pr-code.h pt-select.h pt-stmt.h pt-unop.h pt-walk.h \

INCLUDES := Cell.h base-list.h c-file-ptr-stream.h comment-list.h \
	defun-dld.h defun-int.h defun.h dirfns.h dynamic-ld.h \
	error.h file-io.h fn-cache.h gripes.h help.h input.h \
	lex.h load-save.h ls-hdf5.h ls-mat-ascii.h ls-mat4.h \
	ls-mat5.h ls-oct-ascii.h ls-oct-binary.h ls-utils.h \
	oct-fstrm.h oct-hist.h oct-iostrm.h oct-map.h oct-obj.h \
	oct-prcstrm.h oct-procbuf.h oct-stdstrm.h oct-stream.h \
	oct-strstrm.h oct-lvalue.h oct.h octave.h ops.h pager.h \
	parse.h pr-output.h procstream.h sighandlers.h siglist.h \
	symtab.h sysdep.h token.h toplev.h unwind-prot.h utils.h \
	variables.h version.h xdiv.h xpow.h $(OV_INCLUDES) $(PT_INCLUDES)

TI_XSRC := Array-oc.cc Array-os.cc Array-sym.cc Array-tc.cc

TI_SRC := $(addprefix TEMPLATE-INST/, $(TI_XSRC))

OP_XSRC := op-b-b.cc op-b-bm.cc op-bm-b.cc op-bm-bm.cc \
	op-cell.cc op-chm.cc op-cm-cm.cc op-cm-cs.cc op-cm-m.cc \
	op-cm-s.cc op-cs-cm.cc op-cs-cs.cc op-cs-m.cc \
	op-cs-s.cc op-fil-b.cc op-fil-bm.cc op-fil-cm.cc \
	op-fil-cs.cc op-fil-m.cc op-fil-s.cc op-fil-lis.cc \
	op-fil-rec.cc op-fil-str.cc op-list.cc op-m-cm.cc \
	op-m-cs.cc op-m-m.cc op-m-s.cc op-range.cc op-s-cm.cc \
	op-s-cs.cc op-s-m.cc op-s-s.cc op-str-m.cc \
	op-str-s.cc op-str-str.cc op-streamoff.cc op-fcn-handle.cc

OP_SRC := $(addprefix OPERATORS/, $(OP_XSRC))

OV_SRC := ov-base.cc ov-base-mat.cc ov-base-scalar.cc ov-ch-mat.cc \
	ov-cs-list.cc ov-list.cc ov-re-mat.cc ov-cx-mat.cc \
	ov-range.cc ov-scalar.cc ov-complex.cc ov-str-mat.cc \
	ov-streamoff.cc ov-struct.cc ov-va-args.cc \
	ov-colon.cc ov-bool-mat.cc ov-bool.cc ov-file.cc ov-cell.cc \
	ov.cc ov-fcn.cc ov-builtin.cc ov-dld-fcn.cc ov-mapper.cc \
	ov-usr-fcn.cc ov-fcn-handle.cc ov-typeinfo.cc

PT_SRC := pt.cc pt-arg-list.cc pt-assign.cc pt-bp.cc pt-binop.cc \
	pt-cell.cc pt-check.cc pt-cmd.cc pt-colon.cc pt-const.cc \
	pt-decl.cc pt-except.cc pt-exp.cc pt-fcn-handle.cc pt-id.cc \
	pt-idx.cc pt-jump.cc pt-loop.cc pt-mat.cc pt-misc.cc \
	pt-plot.cc pt-pr-code.cc pt-select.cc pt-stmt.cc pt-unop.cc

DIST_SRC := Cell.cc c-file-ptr-stream.cc comment-list.cc \
	cutils.c data.cc debug.cc defaults.cc defun.cc dirfns.cc \
	dynamic-ld.cc error.cc file-io.cc fn-cache.cc gripes.cc \
	help.cc input.cc lex.l load-save.cc ls-hdf5.cc \
	ls-mat-ascii.cc ls-mat4.cc ls-mat5.cc ls-oct-ascii.cc \
	ls-oct-binary.cc ls-utils.cc main.c mappers.cc matherr.c \
	oct-fstrm.cc oct-hist.cc oct-iostrm.cc oct-map.cc \
	oct-obj.cc oct-prcstrm.cc oct-procbuf.cc oct-stdstrm.cc \
	oct-stream.cc oct-strstrm.cc oct-lvalue.cc pager.cc \
	parse.y pr-output.cc procstream.cc sighandlers.cc \
	siglist.c strcasecmp.c strncase.c strfns.cc symtab.cc \
	syscalls.cc sysdep.cc token.cc toplev.cc \
	unwind-prot.cc utils.cc variables.cc xdiv.cc xpow.cc \
	$(OV_SRC) \
	$(PT_SRC)

SOURCES := $(DIST_SRC) $(OP_SRC) $(TI_SRC)

OBJECTS_4 := $(notdir $(SOURCES))
OBJECTS_3 := $(patsubst %.l, %.o, $(OBJECTS_4))
OBJECTS_2 := $(patsubst %.y, %.o, $(OBJECTS_3))
OBJECTS_1 := $(patsubst %.c, %.o, $(OBJECTS_2))
OBJECTS := $(patsubst %.cc, %.o, $(OBJECTS_1)) octave.o builtins.o ops.o

ifeq ($(SHARED_LIBS), true)
  ifdef CXXPICFLAG
    PICOBJ := $(addprefix pic/, $(OBJECTS))
  else
    PICOBJ := $(OBJECTS)
  endif
endif

# Ugh.

DEP_5 := $(SOURCES) $(DLD_SRC) builtins.cc ops.cc octave.cc main.c
DEP_4 := $(notdir $(DEP_5))
DEP_3 := $(patsubst %.l, %.cc, $(DEP_4))
DEP_2 := $(patsubst %.y, %.cc, $(DEP_3))
DEP_1 := $(patsubst %.c, %.d, $(DEP_2))
MAKEDEPS := $(patsubst %.cc, %.d, $(DEP_1))

# Some stupid egreps don't like empty elements in alternation patterns,
# so we have to repeat ourselves because some stupid egreps don't like
# empty elements in alternation patterns.

DEFUN_PATTERN = "^[ \t]*DEF(CONSTFUN|CMD|UN|UN_DLD|UN_TEXT|UN_MAPPER)[ \t]*\\("

DLD_DEF_FILES := $(patsubst %.cc, %.df, $(DLD_XSRC))

DEF_4 := $(addprefix $(srcdir)/, $(SOURCES))
DEF_3 := $(notdir $(shell egrep -l $(DEFUN_PATTERN) $(DEF_4)))
DEF_2 := $(patsubst %.y, %.df, $(DEF_3))
DEF_1 := $(patsubst %.l, %.df, $(DEF_2))
DEF_FILES := $(patsubst %.cc, %.df, $(DEF_1)) $(DLD_DEF_FILES)

DEFVAR_PATTERN = "^[ \t]*DEF(VAR|CONS(T|TX))[ \t]*\\("

VAR_5 := $(SOURCES) $(DLD_SRC)
VAR_4 := $(addprefix $(srcdir)/, $(VAR_5))
VAR_3 := $(notdir $(shell egrep -l $(DEFVAR_PATTERN) $(VAR_4)))
VAR_2 := $(patsubst %.y, %, $(VAR_3))
VAR_1 := $(patsubst %.l, %, $(VAR_2))
VAR_FILES := $(patsubst %.cc, %, $(VAR_1))

DOC_FILES := $(sort $(DEF_FILES) $(patsubst %, %.df, $(VAR_FILES)))

OCTAVE_LFLAGS = -L$(TOPDIR)/liboctave -L$(TOPDIR)/libcruft \
  -L$(TOPDIR)/src $(RLD_FLAG)

OCTAVE_LIBS = $(LIBOCTINTERP) $(LIBOCTAVE) \
  $(SPECIAL_MATH_LIB) $(LIBCRUFT) \
  $(LIBPLPLOT) $(LIBGLOB) $(LIBDLFCN)

OCTINTERP_LINK_DEPS = \
  -L../liboctave $(LIBOCTAVE) -L../libcruft $(LIBCRUFT) $(LIBS) $(FLIBS)

OCT_LINK_DEPS = \
  -L../libcruft $(LIBCRUFT) -L../liboctave $(LIBOCTAVE) \
  -L. $(LIBOCTINTERP) $(BLAS_LIBS) $(FFTW_LIBS) $(LIBS) $(FLIBS)

DISTFILES = Makefile.in ChangeLog mkdefs mkops mkgendoc \
	DOCSTRINGS mkbuiltins mk-oct-links \
	defaults.h.in oct-conf.h.in octave.gperf oct-gperf.h \
	octave.cc parse.cc lex.cc y.tab.h \
	$(INCLUDES) $(DIST_SRC) $(OPT_HANDLERS)

ifeq ($(SHARED_LIBS), true)
  BINDISTLIBS = src/liboctinterp
  BINDISTFILES = octave $(OCT_FILES) liboctinterp.$(SHLEXT_VER)
else
  BINDISTFILES = octave $(OCT_FILES)
endif

all: octave$(EXEEXT) stamp-oct-links DOCSTRINGS
.PHONY: all

objects: $(OBJECTS)

XERBLA = ../libcruft/blas-xtra/xerbla.o
ifdef FPICFLAG
  PIC_XERBLA = ../libcruft/blas-xtra/pic/xerbla.o
else
  PIC_XERBLA = $(XERBLA)
endif

ifeq ($(SHARED_LIBS), true)
  ifeq ($(STATIC_LIBS), true)
    LIBRARIES = liboctinterp.$(LIBEXT) liboctinterp.$(SHLEXT_VER)
  else
    LIBRARIES = liboctinterp.$(SHLEXT_VER)
  endif
else
  ifeq ($(STATIC_LIBS), true)
    LIBRARIES = liboctinterp.$(LIBEXT)
  else
    ## This is not going to work, but hey, you asked for it...
    LIBRARIES =
  endif
endif

libraries: $(LIBRARIES)
.PHONY: libraries

liboctinterp.$(LIBEXT): $(OBJECTS) $(XERBLA)
	rm -f $@
	$(TEMPLATE_AR) $(TEMPLATE_ARFLAGS) $@ $^
	$(RANLIB) $@

liboctinterp.$(SHLEXT_VER): liboctinterp.$(SHLEXT)
	rm -f $@
	$(LN_S) $< $@

liboctinterp.$(SHLEXT): $(PICOBJ) $(PIC_XERBLA)
	rm -f $@
	$(SH_LD) $(SH_LDFLAGS) $(SONAME_FLAGS) -o $@ $^ $(OCTINTERP_LINK_DEPS)

stamp-oct-links: $(OCT_FILES)
	if [ -n "$(OCT_FILES)" ]; then \
	  $(srcdir)/mk-oct-links . $(DLD_DEF_FILES); \
	fi
	touch stamp-oct-links

stamp-prereq: defaults.h oct-conf.h oct-gperf.h parse.cc lex.cc $(OPT_HANDLERS)
	touch stamp-prereq

octave$(EXEEXT): stamp-prereq $(LIBRARIES) main.o $(DLD_STATIC_OBJ)
	$(LD_CXX) $(CPPFLAGS) $(ALL_CXXFLAGS) $(RDYNAMIC_FLAG) \
	$(ALL_LDFLAGS) -o $@ \
	main.o $(DLD_STATIC_OBJ) \
	$(OCTAVE_LFLAGS) \
	$(OCTAVE_LIBS) \
	$(LEXLIB) $(BLAS_LIBS) $(FFTW_LIBS) $(LIBS) $(FLIBS)

stmp-pic: pic
	@if [ -f stmp-pic ]; then \
	  true; \
	else \
	  echo "touch stmp-pic"; \
	  touch stmp-pic; \
	fi

pic:
	@if [ -d pic ]; then \
	  true; \
	else \
	  echo "mkdir pic"; \
	  mkdir pic; \
	fi

$(PICOBJ): stmp-pic

builtins.cc: $(DEF_FILES) mkbuiltins
	@echo making $@
	@echo DEF_FILES = $(DEF_FILES)
	@echo VAR_FILES = $(VAR_FILES)
	@echo $(DEF_FILES) > def-files
	@echo $(VAR_FILES) > var-files
	@$(srcdir)/mkbuiltins def-files var-files > $@-t
	@$(top_srcdir)/move-if-change $@-t $@

DOCSTRINGS: gendoc$(BUILD_EXEEXT)
	./gendoc > $@-t
	mv $@-t $@

doc-files: $(DOC_FILES)
	@echo making $@
	@echo DOC_FILES = $(DOC_FILES)
	@echo $(DOC_FILES) > $@-t
	@mv $@-t $@

gendoc.cc: doc-files mkgendoc
	@echo making $@
	@$(srcdir)/mkgendoc doc-files > $@-t
	@$(top_srcdir)/move-if-change $@-t $@

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

ops.cc: $(OP_SRC) mkops
	@echo making $@ from $(OP_SRC)
	@$(srcdir)/mkops $(OP_SRC) > $@-t
	@$(top_srcdir)/move-if-change $@-t $@

stamp-liboctave-prereq:
	$(MAKE) -C ../liboctave stamp-prereq
	touch stamp-liboctave-prereq

$(DEF_FILES): stamp-liboctave-prereq mkdefs defun-int.h defun-dld.h defun.h defaults.h oct-conf.h

$(MAKEDEPS): stamp-liboctave-prereq defaults.h oct-gperf.h oct-conf.h

@bsd_gcc_kluge_targets_frag@

check: all
.PHONY: check

install: install-bin install-oct install-lib install-inc
.PHONY: install

install-strip:
	$(MAKE) INSTALL_PROGRAM="$(INSTALL_PROGRAM) -s" install
.PHONY: install-strip

install-bin:
	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
	rm -f $(DESTDIR)$(bindir)/octave$(EXEEXT)
	$(INSTALL_PROGRAM) octave$(EXEEXT) $(DESTDIR)$(bindir)/octave-$(version)$(EXEEXT)
	$(LN_S) octave-$(version)$(EXEEXT) $(DESTDIR)$(bindir)/octave$(EXEEXT)
.PHONY: install-bin

install-oct:
	if [ -n "$(OCT_FILES)" ]; then \
	  $(top_srcdir)/mkinstalldirs $(DESTDIR)$(octfiledir); \
	  xfiles="$(OCT_FILES)"; \
	  for f in $$xfiles; do \
	    $(INSTALL_PROGRAM) $$f $(DESTDIR)$(octfiledir)/$$f; \
	  done; \
	  $(srcdir)/mk-oct-links $(DESTDIR)$(octfiledir) $(DLD_DEF_FILES); \
	fi
.PHONY: install-oct

install-lib:
	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(octlibdir)
	if $(STATIC_LIBS); then \
	  rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(LIBEXT); \
	  $(INSTALL_DATA) liboctinterp.$(LIBEXT) \
	    $(DESTDIR)$(octlibdir)/liboctinterp.$(LIBEXT); \
	  $(RANLIB) $(DESTDIR)$(octlibdir)/liboctinterp.$(LIBEXT); \
	fi
	if $(SHARED_LIBS); then \
	  rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLEXT_VER); \
	  $(INSTALL) liboctinterp.$(SHLLIB) \
	    $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB_VER); \
	  rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB); \
	  $(LN_S) liboctinterp.$(SHLLIB_VER) $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB); \
	  if  test x$(SHLBIN) != x ; then \
	    rm -f $(DESTDIR)$(bindir)/liboctinterp.$(SHLBIN); \
	    $(INSTALL_PROGRAM) \
	      liboctinterp.$(SHLBIN) $(DESTDIR)$(bindir)/liboctinterp.$(SHLBIN); \
	  fi; \
	fi
.PHONY: install-lib

install-inc:
	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(octincludedir)/octave
	for f in $(INCLUDES); do \
	  rm -f $(DESTDIR)$(octincludedir)/octave/$$f; \
	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(octincludedir)/octave/$$f; \
	done
	for f in defaults.h oct-conf.h oct-gperf.h; do \
	  rm -f $(DESTDIR)$(octincludedir)/octave/$$f; \
	  if [ -f $$f ]; then \
	    $(INSTALL_DATA) $$f $(DESTDIR)$(octincludedir)/octave/$$f ; \
	  else \
	    $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(octincludedir)/octave/$$f ; \
	  fi ; \
	done
.PHONY: install-inc

uninstall:
	rm -f $(DESTDIR)$(bindir)/octave$(EXEEXT)
	rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(LIBEXT)
	rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB)
	rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB_VER)
	if test x$(SHLBIN) != x ; then \
	  rm -f $(DESTDIR)$(bindir)/liboctinterp.$(SHLBIN); \
	  rm -f $(DESTDIR)$(bindir)/liboctinterp.$(SHLBIN_VER); \
	fi
	for f in $(INCLUDES) defaults.h oct-conf.h; do \
	  rm -f $(DESTDIR)$(octincludedir)/octave/$$f; \
	done
.PHONY: uninstall

tags: $(SOURCES) $(DLD_SRC)
	ctags $(SOURCES) $(DLD_SRC)

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

clean:
	rm -f *.$(LIBEXT) *.o *.d *.df *.oct pic/*.o stmp-pic gendoc$(EXEEXT)
	rm -f builtins.cc ops.cc defaults.h oct-conf.h def-files var-files
	-rmdir pic
	if $(SHARED_LIBS); then rm -f *.$(SHLEXT_VER) *.$(SHLEXT); fi
.PHONY: clean

mostlyclean: clean
.PHONY: mostlyclean

distclean: clean
	rm -f Makefile octave$(EXEEXT) .fname so_locations
	rm -f stamp-prereq stamp-liboctave-prereq stamp-oct-links
	rm -f doc-files gendoc.cc DOCSTRINGS
.PHONY: distclean

maintainer-clean: distclean
	rm -f tags TAGS y.tab.c y.tab.h y.output yy.lex.c lex.cc parse.cc
	rm -f oct-gperf.h $(OPT_HANDLERS)
.PHONY: maintainer-clean

dist: parse.cc lex.cc oct-gperf.h
	ln $(DISTFILES) ../`cat ../.fname`/src
	for f in DLD-FUNCTIONS OPERATORS TEMPLATE-INST; do \
	  if [ -d ../`cat ../.fname`/src/$$f ]; then \
	    true; \
	  else \
	    mkdir ../`cat ../.fname`/src/$$f; \
	  fi; \
	done
	ln $(DLD_SRC) ../`cat ../.fname`/src/DLD-FUNCTIONS
	ln $(OP_SRC) ../`cat ../.fname`/src/OPERATORS
	ln $(TI_SRC) ../`cat ../.fname`/src/TEMPLATE-INST
	rm -f parse.cc lex.cc y.tab.h y.output yy.lex.c
	rm -f oct-gperf.h defaults.h oct-conf.h *.d *.df builtins.cc
.PHONY: dist

conf-dist:
	ln octave.cc Makefile.in ../`cat ../.fname`/src
.PHONY: conf-dist

bin-dist:
	if [ -n "$(BINDISTFILES)" ]; then \
	  ln $(BINDISTFILES) ../`cat ../.fname`/src; \
	fi
	if [ -n "$(OCT_FILES)" ]; then \
	  $(srcdir)/mk-oct-links -p $(octfiledir) \
	    $(addprefix $(srcdir)/, $(DLD_SRC)) \
	    > ../`cat ../.fname`/src/links-to-make; \
	fi
	if [ -n "$(BINDISTLIBS)" ]; then \
	  echo $(BINDISTLIBS) >> ../`cat ../.fname`/LIBRARIES; \
	fi
.PHONY: bin-dist

# Special rules -- these files need special things to be defined.

$(OPT_HANDLERS) : %.cc : $(top_srcdir)/liboctave/%.in $(top_srcdir)/mk-opts.pl
	@echo making $@ from $<
	@perl $(top_srcdir)/mk-opts.pl --opt-handler-fcns $< > $@-t
	@$(top_srcdir)/move-if-change $@-t $@

parse.cc : parse.y
	@echo "expect 11 shift/reduce conflicts"
	$(YACC) $(YFLAGS) $<
	@$(top_srcdir)/move-if-change y.tab.c $(@F)

lex.cc : lex.l
	$(LEX) $(LFLAGS) $< > $(@F)

defaults.h: defaults.h.in ../Makeconf Makefile
	@$(do-subst-default-vals)

oct-conf.h: oct-conf.h.in ../Makeconf Makefile
	@$(do-subst-config-vals)

oct-gperf.h: octave.gperf
	@echo "making $@ from $<"
	@$(GPERF) -t -C -D -E -G -L ANSI-C \
               -H octave_kw_hash -N octave_kw_lookup \
	  $< | $(SED) 's,lookup\[,gperf_lookup[,' > $@-t
	@$(top_srcdir)/move-if-change $@-t $@

check: all
.PHONY: check

# If missing, GNU make attempts to create them in the reverse of the
# order in which they are listed here.  We rely on that fact to ensure
# that defaults.h is created before trying to create the .d files.
# Hmm.  I wonder if we can count on that...

ifndef omit_deps
-include $(MAKEDEPS) stamp-prereq
endif
