#
# ${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 gnome.c stubs.c system.c \
  sys-unix.c sys-std.c \
  X11.c devQuartz.c aqua.c
SOURCES_C_DARWIN = dlfcn-darwin.c
SOURCES = $(SOURCES_C_BASE) @BUILD_DLFCN_DARWIN_TRUE@ $(SOURCES_C_DARWIN)
DEPENDS = $(SOURCES:.c=.d)
OBJECTS = $(SOURCES:.c=.o)
HEADERS = Runix.h devUI.h hpdlfcn.h dlfcn-darwin.h

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

noinst_LIBRARIES = libunix.a
libunix_a_SOURCES = $(SOURCES)
libunix_a_OBJECTS = $(OBJECTS)

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

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) $(noinst_LIBRARIES)
@WANT_R_SHLIB_TRUE@	@$(MAKE) stamp-lo

../include/Rversion.h:
	(cd ../include; $(MAKE) $(@F))

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

stamp-lo: $(libunix_la_OBJECTS)
	@touch $@
libunix.la: stamp-lo
	$(SHLIB_LINK) -o $@ $(libunix_la_LDFLAGS) $(libunix_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:

