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

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

top_builddir = ../..
subdir = src/extra

include $(top_builddir)/Makeconf

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = Makefile.in

SUBDIRS = blas bzip2 pcre xdr zlib @USE_NLS_TRUE@ intl
SUBDIRS_WITH_NO_BUILD = graphapp trio @USE_NLS_FALSE@ intl

RBLAS =@BLAS_SHLIB_TRUE@ blas
LIBBZ2 =@BUILD_BZLIB_TRUE@ bzip2
LIBPCRE =@BUILD_PCRE_TRUE@ pcre
LIBZ =@BUILD_ZLIB_TRUE@ zlib
LIBXDR =@BUILD_XDR_TRUE@ xdr
LIBINTL =@BUILD_LIBINTL_TRUE@ intl
EXTRA_LIBS = $(RBLAS) $(LIBBZ2) $(LIBPCRE) $(LIBZ) $(LIBXDR) $(LIBINTL)

all: Makefile R

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

R: Makefile
	@list='$(EXTRA_LIBS)'; for d in $${list}; do \
	  (cd $${d} && $(MAKE) $@) || exit 1; \
	done

mostlyclean: clean
clean:
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@) || exit 1; \
	done
distclean: clean
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@) || exit 1; \
	done
	-@rm -f Makefile
maintainer-clean: distclean

install install-strip:
	@for d in $(SUBDIRS); do \
	  (cd $${d} && $(MAKE) $@) || exit 1; \
	done

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
	@for d in $(SUBDIRS); do \
	  test -d $(distdir)/$${d} \
	    || mkdir $(distdir)/$${d} \
	    || exit 1; \
	  chmod 755 $(distdir)/$${d}; \
	  (cd $${d} && $(MAKE) distdir) \
	    || exit 1; \
	done
	@for d in $(SUBDIRS_WITH_NO_BUILD); do \
	  ((cd $(srcdir); $(TAR) -c -f - $(DISTDIR_TAR_EXCLUDE) $${d}) \
	      | (cd $(distdir); $(TAR) -x -f -)) \
	    || exit 1; \
	done