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

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

top_builddir = ../..
subdir = src/include

include $(top_builddir)/Makeconf

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

SUBDIRS = R_ext

## API(1): for .C() and .Call() writers, ...:
SRC_HEADERS = R.h S.h Rdefines.h Rgraphics.h Rinternals.h Rmath.h
## Partially included by these, but not part of the API per se.
R_EXT_HEADERS = \
	Applic.h Arith.h Boolean.h Complex.h Constants.h Error.h \
	Linpack.h Mathlib.h Memory.h Print.h PrtUtil.h R-ftp-http.h \
	RS.h Random.h RConverters.h Rdynload.h Utils.h eventloop.h 
## API(2) {these are built, system-dependently}:
OBJ_HEADERS = Rconfig.h Rversion.h

## Non-API internal ones:
INT_HEADERS = Defn.h Rdevices.h Errormsg.h Fileio.h Graphics.h \
	IOStuff.h Internal.h Parse.h Print.h Rconnections.h Startup.h 

DISTFILES = Makefile.in README $(INT_HEADERS) $(SRC_HEADERS) \
	config.h.in stamp-h.in

all: Makefile R

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

R: Makefile $(OBJ_HEADERS)
	@$(MAKE) rhome=$(top_builddir) install

config.h: stamp-h
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
	@cd $(top_builddir) && \
	  CONFIG_FILES= CONFIG_HEADERS=$(subdir)/config.h \
	  $(SHELL) ./config.status
	@echo timestamp > $@ 2> /dev/null
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/stamp-h.in
$(srcdir)/stamp-h.in: @MAINTAINER_MODE_TRUE@ $(top_srcdir)/configure.in $(top_srcdir)/acconfig.h $(top_srcdir)/aclocal.m4
	@cd $(top_srcdir) && $(AUTOHEADER)
	@echo timestamp > $@ 2> /dev/null
Rconfig.h: $(top_srcdir)/VERSION config.h
	@$(top_srcdir)/tools/GETCONFIG > $@
Rversion.h: $(top_srcdir)/VERSION $(top_srcdir)/date-stamp
	@$(top_srcdir)/tools/GETVERSION > $@

install: installdirs
	@for f in $(SRC_HEADERS); do \
	  $(INSTALL_DATA) $(srcdir)/$${f} $(rhome)/include; \
	done
	@for f in $(R_EXT_HEADERS); do \
	  $(INSTALL_DATA) $(srcdir)/R_ext/$${f} \
	    $(rhome)/include/R_ext; \
	done
	@for f in $(OBJ_HEADERS); do \
	  $(INSTALL_DATA) $${f} $(rhome)/include; \
	done
installdirs:
	@$(MKINSTALLDIRS) $(rhome)/include
	@$(MKINSTALLDIRS) $(rhome)/include/R_ext
install-strip:
	$(MAKE) INSTALL_PROGRAM="${INSTALL_PROGRAM} -s" install
uninstall:
	@rm -rf $(rhome)/include

mostlyclean: clean
clean:
	@rm -f $(OBJ_HEADERS) FFDecl.h FFTab.h
distclean: clean
	@rm -f Makefile config.h stamp-h
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
	@for d in $(SUBDIRS); do \
	  if test -d $(srcdir)/$${d}; then \
	    ((cd $(srcdir); $(TAR) -c -f - --exclude=CVS $${d}) \
	        | (cd $(distdir); $(TAR) -x -f -)) \
	      || exit 1; \
	  fi; \
	done