##
## ${R_HOME}/src/appl/Makefile

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

top_builddir = ../..
subdir = src/appl

include $(top_builddir)/Makeconf

## <NOTE>
## All functions/subroutines to be called via .C() or .Fortran() must
## also have an entry in the appropriate table/array in
## @file{../main/registration.c} in order to be registered with the
## symbol lookup mechanism, i.e., 'pre-dyn.loaded'.
## </NOTE>

SOURCES_C = \
	approx.c \
	bakslv.c bandwidths.c binning.c \
	chull.c cpoly.c cumsum.c \
	fft.c fmin.c integrate.c interv.c \
	lbfgsb.c loglin.c lowess.c \
	machar.c maxcol.c massdist.c \
	pretty.c \
	rcont.c rowsum.c \
	splines.c stem.c strsignif.c \
	tabulate.c \
	uncmin.c \
	zeroin.c
SOURCES_F = \
	ch2inv.f chol.f \
	dchdc.f dpbfa.f dpbsl.f dpoco.f dpodi.f dpofa.f dposl.f dqrdc.f \
	dqrdc2.f dqrls.f dqrsl.f dqrutl.f dsvdc.f dtrco.f dtrsl.f \
	eigen.f \
	lminfl.f
DEPENDS = $(SOURCES_C:.c=.d)
OBJECTS = $(SOURCES_C:.c=.o) $(SOURCES_F:.f=.o) \
  @USE_EXTERNAL_BLAS_FALSE@ blas.o @COMPILE_DOUBLE_COMPLEX_FALSE@ zgemm.o
HEADERS =

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = COPYRIGHT COPYRIGHT.ftn README lowess.doc \
	Makefile.in Makefile.win \
	$(HEADERS) \
	$(SOURCES_C) \
	$(SOURCES_F) \
	blas.f zgemm.f

noinst_LIBRARIES = libappl.a
libappl_a_SOURCES = $(SOURCES)
libappl_a_OBJECTS = $(OBJECTS)

## <FIXME>
## We most likely will not want a separate shared library.
## If we have a final decision, remove libappl.la target.
noinst_LTLIBRARIES = libappl.la
## </FIXME>
libappl_la_SOURCES = $(SOURCES)
libappl_la_OBJECTS = $(OBJECTS:.o=.lo)
@USE_LIBTOOL_TRUE@libappl_la_LDFLAGS = -avoid-version -rpath "$(Rexeclibdir)"

all: Makefile Makedeps R

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(SOURCES_C)
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

Makedeps: Makefile $(DEPENDS)
	@cat $(DEPENDS) >> Makefile
	@touch $@

R: Makefile
	@$(MAKE) Makedeps
@WANT_R_SHLIB_FALSE@	@$(MAKE) $(noinst_LIBRARIES)
@WANT_R_SHLIB_TRUE@	@$(MAKE) stamp-lo

libappl.a: $(libappl_a_OBJECTS)
	rm -f $@
	$(AR) cr $@ $(libappl_a_OBJECTS)
	$(RANLIB) $@

stamp-lo: $(libappl_la_OBJECTS)
	@touch $@
libappl.la: stamp-lo
	$(SHLIB_LINK) -o $@ $(libappl_la_LDFLAGS) $(libappl_la_OBJECTS)

mostlyclean: clean
clean:
	@-rm -rf .libs _libs
	@-rm -f Makedeps *.d *.o *.a *.lo *.la stamp-lo
distclean: clean
	@-rm -f Makefile
maintainer-clean: distclean

install install-strip uninstall TAGS info dvi check:

distdir: $(DISTFILES)
	@for f in $(DISTFILES); do \
	  test -f $(distdir)/$${f} \
	    || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
	    || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
	done

## Automagically generated dependencies:

