# @configure_input@
#
# Common configuration rules for all of octave's Makefiles.
#
# John W. Eaton
# jwe@bevo.che.wisc.edu
# University of Wisconsin-Madison
# Department of Chemical Engineering
 
SHELL = /bin/sh

#### Start of system configuration section. ####

LEX = @LEX@
LFLAGS = @LFLAGS@
LEXLIB = @LEXLIB@

YACC = @YACC@
YFLAGS = -dv

AR = @AR@
ARFLAGS = @ARFLAGS@ 

RANLIB = @RANLIB@

LN_S = @LN_S@

RUNTEST = @RUNTEST@

DEFAULT_PAGER = @DEFAULT_PAGER@

WITH_DL = @WITH_DL@
WITH_SHL = @WITH_SHL@

WITH_DYNAMIC_LINKING = @WITH_DYNAMIC_LINKING@

OCTAVE_LITE = @OCTAVE_LITE@

SHARED_LIBS = @SHARED_LIBS@
SHLEXT = @SHLEXT@

# Fortran to C translator and associated flags.

F2C = @F2C@
F2CFLAGS = @F2CFLAGS@

# Fortran compiler flags.

FC = @FC@
F77 = @F77@
FFLAGS = @FFLAGS@
FPICFLAG = @FPICFLAG@
FUGLY = @FUGLY@
ALL_FFLAGS = $(FUGLY) $(FFLAGS)

# cc and associated flags.

DLFCN_INCFLAGS = @DLFCN_INCFLAGS@

# Clean up INCFLAGS a bit if we are not compiling in a separate
# directory.
ifeq ($(srcdir),.)
  TMP_IF_1 = -I. -I../src
else
  TMP_IF_1 = -I. -I$(srcdir) -I../src
endif
ifeq ($(TOPDIR),$(top_srcdir))
  TMP_IF_2 = -I$(TOPDIR) -I$(TOPDIR)/liboctave -I$(TOPDIR)/src \
	-I$(TOPDIR)/glob
else
  TMP_IF_2 = -I$(TOPDIR) -I$(TOPDIR)/liboctave -I$(TOPDIR)/src \
	-I$(TOPDIR)/glob -I$(top_srcdir) -I$(top_srcdir)/liboctave \
	-I$(top_srcdir)/src -I$(top_srcdir)/glob
endif
INCFLAGS = $(TMP_IF_1) $(TMP_IF_2) $(DLFCN_INCFLAGS)

LIBFLAGS = -L$(TOPDIR)

DEFS = @DEFS@

UGLY_DEFS = @UGLY_DEFS@

CC = @CC@
CC_VERSION = @CC_VERSION@
CFLAGS = @CFLAGS@
CPICFLAG = @CPICFLAG@
GCC_IEEE_FP_FLAG = @GCC_IEEE_FP_FLAG@
ALL_CFLAGS = $(INCFLAGS) $(DEFS) $(GCC_IEEE_FP_FLAG) $(CFLAGS)
BUG_CFLAGS = $(DEFS) $(GCC_IEEE_FP_FLAG) $(CFLAGS)


CXX = @CXX@
CXX_VERSION = @CXX_VERSION@
CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CXXPICFLAG = @CXXPICFLAG@
NO_IMPLICIT_TEMPLATES = @NO_IMPLICIT_TEMPLATES@
HOST_CXXFLAGS = @HOST_CXXFLAGS@
ALL_CXXFLAGS = $(INCFLAGS) $(DEFS) $(HOST_CXXFLAGS) \
	$(NO_IMPLICIT_TEMPLATES) $(GCC_IEEE_FP_FLAG) $(CXXFLAGS)
UGLY_ALL_CXXFLAGS = $(INCFLAGS) $(UGLY_DEFS) $(HOST_CXXFLAGS) \
	$(NO_IMPLICIT_TEMPLATES) $(GCC_IEEE_FP_FLAG) $(CXXFLAGS)
BUG_CXXFLAGS = $(DEFS) $(HOST_CXXFLAGS) $(NO_IMPLICIT_TEMPLATES) \
	$(GCC_IEEE_FP_FLAG) $(CXXFLAGS)

CPPFLAGS = @CPPFLAGS@

LDFLAGS = @LDFLAGS@
LD_STATIC_FLAG = @LD_STATIC_FLAG@
ALL_LDFLAGS = $(LIBFLAGS) $(GCC_IEEE_FP_FLAG) $(LD_STATIC_FLAG) $(LDFLAGS)

RLD_FLAG = @RLD_FLAG@

FLIBS = @FLIBS@
FLIB_LIST = @FLIB_LIST@
FLIB_PATH = @FLIB_PATH@

CXXLIBS = @CXXLIBS@
CXXLIB_LIST = @CXXLIB_LIST@
CXXLIB_PATH = @CXXLIB_PATH@

TERMLIBS = @TERMLIBS@
LIBPLPLOT = @LIBPLPLOT@
LIBDLFCN = @LIBDLFCN@

SH_FLIBS = @SH_FLIBS@
SH_TERMLIBS = @SH_TERMLIBS@
SH_LIBS = @SH_LIBS@

# The arguments passed to configure.
config_opts = @config_opts@

# A shell command to extract the version number from version.h.
getversion = sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*$$/\1/' -e q

# The version number.  TOPDIR is something like `.' or `..' or `../..'
# and gets us back up to the top level of the source tree.
version := $(shell $(getversion) $(srcdir)/$(TOPDIR)/src/version.h)

# ==================== Where To Install Things ====================

# The default location for installation.  Everything is placed in
# subdirectories of this directory.  The default values for many of
# the variables below are expressed in terms of this one, so you may
# not need to change them.  This defaults to /usr/local.
prefix = @prefix@

# Like `prefix', but used for architecture-specific files.
exec_prefix = @exec_prefix@

# Where to install Octave and other binaries that people will want to
# run directly.
bindir = @bindir@

# Where to install architecture-independent data files.  ${fcnfiledir}
# and ${localfcnfiledir} are subdirectories of this.
datadir = @datadir@

# Where to install and expect libraries like libcruft.a, liboctave.a,
# and libreadline.a and other architecture-dependent data.  The
# directory ${archlibdir} is a subdirectory of this.  
libdir = @libdir@

# Where to install and expect executable programs to be run by Octave
# rather than directly by users.
libexecdir = @libexecdir@

# The prefix for Octave's include file directory.  The default is
# ${prefix}/include
includedir = @includedir@

# Where to install Octave's include files.  The default is
# ${includedir}/octave-${version}
octincludedir = @octincludedir@

# Where to install Octave's man pages, and what extension they should
# have.  The default is ${prefix}/man/man1
mandir = @mandir@
man1dir = @man1dir@
man1ext = @man1ext@

# Where to install and expect the info files describing Octave..
infodir = @infodir@

# ==================== Octave-specific directories ====================

# These variables hold the values Octave will actually use.  They are
# based on the values of the standard Make variables above.

# Where to install the function file distributed with
# Octave.  This includes the Octave version, so that the
# function files for different versions of Octave will install
# themselves in separate directories.
fcnfiledir = @fcnfiledir@

# Directories Octave should search for function files specific
# to this site (i.e. customizations), before consulting
# ${fcnfiledir}.  This should be a colon-separated list of
# directories.
localfcnfiledir = @localfcnfiledir@
localfcnfilepath = @localfcnfilepath@

# Where to put executables to be run by Octave rather than
# the user.  This path usually includes the Octave version
# and configuration name, so that multiple configurations
# for multiple versions of Octave may be installed at once.
archlibdir = @archlibdir@

# Where to put object files that will by dynamically loaded.
# This path usually includes the Octave version and configuration
# name, so that multiple configurations for multiple versions of
# Octave may be installed at once. 
octfiledir = @octfiledir@

# Directories Octave should search for object files that will be
# dynamically loaded and that are specific to this site
# (i.e. customizations), before consulting ${octfiledir}.  This should
# be a colon-separated list of directories.
localoctfiledir = @localoctfiledir@
localoctfilepath = @localoctfilepath@

# Where Octave will search to find its function files.  Before
# changing this, check to see if your purpose wouldn't
# better be served by changing localfcnfilepath.  This
# should be a colon-separated list of directories.
fcnfilepath = @fcnfilepath@

# Where Octave will search to find image files.es.
imagedir = @imagedir@
imagepath = @imagepath@

# The type of computer we are running on.
target_host_type = @target_host_type@

# The following pattern rules and the substitution functions require
# GNU make.  If you don't have it, get it!

# Rules for making object files from Fortran source.
#
# If we are using f2c there will be a command for the `%.c : %.f'
# pattern and no command for the `%.o : %.f' pattern, so that make
# will not invoke the fortran compiler by mistake.
#
# If we are not using f2c, it should be ok to have an empty rule for
# the pattern `%.c : %.f', but we don't want to replace make's default
# rule for making object from Fortran source files, so there should be
# no pattern or command for that.

@f77_rules_frag@

# How to make .o files:

%.o : %.c
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<

%.o : %.cc
	$(CXX) -c $(CPPFLAGS) $(ALL_CXXFLAGS) $<

pic/%.o : %.c
	$(CC) -c $(CPPFLAGS) $(CPICFLAG) $(ALL_CFLAGS) $< -o $@

pic/%.o : %.cc
	$(CXX) -c $(CPPFLAGS) $(CXXPICFLAG) $(ALL_CXXFLAGS) $< -o $@

# Here is a rule for generating dependencies for .cc files:

%.d : %.cc
	@echo making $@ from $<
	@rm -f $@
	@-if test "$(srcdir)" = "." ; then \
	  $(CXX) -MM $(CPPFLAGS) $(ALL_CXXFLAGS) $< | \
	    sed -e 's,$*\.o,pic/& & $@,g' > $@.tmp ; \
	else \
	  $(CXX) -MM $(CPPFLAGS) $(ALL_CXXFLAGS) $< | \
	    sed -e 's,$*\.o,pic/& & $@,g' -e 's,$(srcdir)/,,g' > $@.tmp ; \
	fi
	@mv $@.tmp $@

# And one for .c files.too:

%.d : %.c
	@echo making $@ from $<
	@rm -f $@
	@-if test "$(srcdir)" = "." ; then \
	  $(CC) -MM $(CPPFLAGS) $(ALL_CFLAGS) $< | \
	    sed -e 's,$*\.o,pic/& & $@,g' > $@.tmp ; \
	else \
	  $(CC) -MM $(CPPFLAGS) $(ALL_CFLAGS) $< | \
	    sed -e 's,$*\.o,pic/& & $@,g' -e 's,$(srcdir)/,,g' > $@.tmp ; \
	fi
	@mv $@.tmp $@

define do-subdir-for-command
echo making $@ in $d; cd $d; $(MAKE) $@; cd ..;
endef

define subdir-for-command
$(foreach d, $(SUBDIRS), $(do-subdir-for-command))
endef

define do-subst-config-vals
echo "making $@ from $<"
sed < $< > $@.tmp \
  -e "s;%VERSION%;\"${version}\";" \
  -e "s;%config_opts%;\"${config_opts}\";" \
  -e "s;%TARGET_HOST_TYPE%;\"${target_host_type}\";" \
  -e "s;%F77%;\"${F77}\";" \
  -e "s;%FFLAGS%;\"${FFLAGS}\";" \
  -e "s;%FPICFLAG%;\"${FPICFLAG}\";" \
  -e "s;%F2C%;\"${F2C}\";" \
  -e "s;%F2CFLAGS%;\"${F2CFLAGS}\";" \
  -e "s;%FLIBS%;\"${FLIBS}\";" \
  -e "s;%CPPFLAGS%;\"${CPPFLAGS}\";" \
  -e "s;%INCFLAGS%;\"-I${includedir} -I${octincludedir}\";" \
  -e "s;%CC%;\"${CC}\";" \
  -e "s;%CC_VERSION%;\"${CC_VERSION}\";" \
  -e "s;%CFLAGS%;\"${BUG_CFLAGS}\";" \
  -e "s;%CPICFLAG%;\"${CPICFLAG}\";" \
  -e "s;%CXX%;\"${CXX}\";" \
  -e "s;%CXX_VERSION%;\"${CXX_VERSION}\";" \
  -e "s;%CXXFLAGS%;\"${CXXFLAGS}\";" \
  -e "s;%CXXPICFLAG%;\"${CXXPICFLAG}\";" \
  -e "s;%BUG_CXXFLAGS%;\"${BUG_CXXFLAGS}\";" \
  -e "s;%HOST_CXXFLAGS%;\"${HOST_CXXFLAGS}\";" \
  -e "s;%NO_IMPLICIT_TEMPLATES%;\"${NO_IMPLICIT_TEMPLATES}\";" \
  -e "s;%GCC_IEEE_FP_FLAG%;\"${GCC_IEEE_FP_FLAG}\";" \
  -e "s;%LDFLAGS%;\"${LDFLAGS}\";" \
  -e "s;%LIBFLAGS%;\"-L${libdir}\";" \
  -e "s;%RLD_FLAG%;\"${RLD_FLAG}\";" \
  -e "s;%CXXLIBS%;\"${CXXLIBS}\";" \
  -e "s;%TERMLIBS%;\"${TERMLIBS}\";" \
  -e "s;%LIBS%;\"${LIBS}\";" \
  -e "s;%LEXLIB%;\"${LEXLIB}\";" \
  -e "s;%LIBPLPLOT%;\"${LIBPLPLOT}\";" \
  -e "s;%LIBDLFCN%;\"${LIBDLFCN}\";" \
  -e "s;%DEFS%;\"${UGLY_DEFS}\";"
$(top_srcdir)/move-if-change $@.tmp $@
endef

define do-subst-default-vals
echo "making $@ from $<"
sed < $< > $@.tmp \
  -e "s;%DEFAULT_PAGER%;\"${DEFAULT_PAGER}\";" \
  -e "s;%OCTAVE_PREFIX%;\"${prefix}\";" \
  -e "s;%OCTAVE_EXEC_PREFIX%;\"${exec_prefix}\";" \
  -e "s;%OCTAVE_DATADIR%;\"${datadir}\";" \
  -e "s;%OCTAVE_BINDIR%;\"${bindir}\";" \
  -e "s;%OCTAVE_LIBDIR%;\"${libdir}\";" \
  -e "s;%OCTAVE_INFODIR%;\"${infodir}\";" \
  -e "s;%OCTAVE_FCNFILEDIR%;\"${fcnfiledir}\";" \
  -e "s;%OCTAVE_LOCALFCNFILEDIR%;\"${localfcnfiledir}\";" \
  -e "s;%OCTAVE_LOCALFCNFILEPATH%;\"${localfcnfilepath}\";" \
  -e "s;%OCTAVE_ARCHLIBDIR%;\"${archlibdir}\";" \
  -e "s;%OCTAVE_OCTFILEDIR%;\"${octfiledir}\";" \
  -e "s;%OCTAVE_LOCALOCTFILEPATH%;\"${localoctfilepath}\";" \
  -e "s;%OCTAVE_FCNFILEPATH%;\"${fcnfilepath}\";" \
  -e "s;%OCTAVE_IMAGEPATH%;\"${imagepath}\";" \
  -e "s;%TARGET_HOST_TYPE%;\"${target_host_type}\";" \
  -e "s;%FLIB_LIST%;\"${FLIB_LIST}\";" \
  -e "s;%FLIB_PATH%;\"${FLIB_PATH}\";" \
  -e "s;%CXXLIB_LIST%;\"${CXXLIB_LIST}\";" \
  -e "s;%CXXLIB_PATH%;\"${CXXLIB_PATH}\";"
$(top_srcdir)/move-if-change $@.tmp $@
endef
