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

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

top_builddir = ../..
subdir = src/unix

include $(top_builddir)/Makeconf

ALL_CPPFLAGS = $(R_XTRA_CPPFLAGS) $(X_CFLAGS) $(CPPFLAGS) $(DEFS)

SOURCES_C_BASE = dynload.c edit.c stubs.c system.c sys-unix.c sys-std.c \
  X11.c aqua.c
SOURCES = $(SOURCES_C_BASE)
DEPENDS = $(SOURCES:.c=.d)
OBJECTS = $(SOURCES:.c=.o)
HEADERS = Runix.h hpdlfcn.h

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = \
  Makefile.in $(SOURCES_C_BASE) Rembedded.c \
  $(HEADERS) hpdlfcn.c system.txt

@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO)

all: Makefile Makedeps R

Makefile: $(srcdir)/Makefile.in \
  $(top_builddir)/config.status \
  ../include/Rversion.h \
  $(SOURCES)
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

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

R: Makefile
	@$(MAKE) Makedeps
@WANT_R_SHLIB_FALSE@	@$(MAKE) libunix.a
@WANT_R_SHLIB_TRUE@	@$(MAKE) stamp-lo

## is this portable?
../include/Rversion.h:
	(cd ../include; $(MAKE) $(@F))

libunix.a: $(OBJECTS)
	rm -rf $@
	$(AR) cr $@ $(OBJECTS)
	$(RANLIB) $@

stamp-lo: $(OBJECTS) Rembedded.o
	@touch $@

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:

