#
# ${R_HOME}/src/modules/lapack/Makefile

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

top_builddir = ../../..
subdir = src/modules/lapack
R_HOME = $(top_builddir)

include $(top_builddir)/Makeconf

SOURCES_C = Lapack.c
SOURCES_F = double.f @COMPILE_DOUBLE_COMPLEX_FALSE@ cmplx.f

SOURCES_BLAS_BASE = blas2.f
SOURCES_BLAS_DOUBLE_COMPLEX = cmplxblas.f
SOURCES_BLAS = blas2.f @COMPILE_DOUBLE_COMPLEX_FALSE@ cmplxblas.f

DEPENDS = $(SOURCES_C:.c=.d)
OBJECTS = $(SOURCES_C:.c=.lo) $(SOURCES_F:.f=.lo) \
  @USE_EXTERNAL_BLAS_FALSE@ $(SOURCES_BLAS:.f=.lo)
HEADERS = Lapack.h

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = \
	README Makefile.in Makefile.mac Makefile.win \
	dllversion.rc $(HEADERS) $(SOURCES_C) \
	double.f cmplx.f blas2.f cmplxblas.f lapack.mcp.hqx

## FIXME:
## Change to `lapack.la' when using libtool for shlibs.
## Remove when using automake ... also fix install then.
lapack_la = lapack$(SHLIB_EXT)
## </FIXME>
Rexecmodulesdir_LTLIBRARIES = $(lapack_la)
lapack_la_SOURCES = $(SOURCES)
lapack_la_OBJECTS = $(OBJECTS)
@USE_LIBTOOL_TRUE@lapack_la_LDFLAGS = -avoid-version -rpath $(Rexecmodulesdir) -module
lapack_la_LIBADD = $(LIBR)

all: Makefile Makedeps R

Makefile: $(srcdir)/Makefile.in \
  $(top_builddir)/config.status \
  $(SOURCES)
	@cd $(top_builddir) && \
	  CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
	  $(SHELL) ./config.status

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

R: Makefile
	@$(MAKE) Makedeps
	@$(MAKE) $(Rexecmodulesdir_LTLIBRARIES)

$(lapack_la): $(lapack_la_OBJECTS) $(lapack_la_DEPENDENCIES)
	$(SHLIB_LINK) -o $@ $(lapack_la_LDFLAGS) $(lapack_la_OBJECTS) $(lapack_la_LIBADD) @BLAS_LIBS@ $(FLIBS) $(LIBS)
## FIXME: Not sure of we want to do this ...
	@$(MAKE) rhome=`cd $(top_builddir); pwd` install
## </FIXME>

install: installdirs
@USE_LIBTOOL_FALSE@	@$(top_srcdir)/tools/copy-if-change $(lapack_la) $(Rexecmodulesdir)/lapack$(SHLIB_EXT)
@USE_LIBTOOL_TRUE@	@$(LIBTOOL) --mode=install $(INSTALL) $(lapack_la) $(Rexecmodulesdir)
installdirs:
	@$(MKINSTALLDIRS) $(Rexecmodulesdir)
install-strip:
	$(MAKE) INSTALL_PROGRAM="${INSTALL_PROGRAM} -s" install
uninstall:
	@rm -f $(Rexecmodulesdir)/lapack$(SHLIB_EXT)

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

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:

