#
# ${R_HOME}/src/library/grDevices/src/cairo/Makefile

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

top_builddir = ../../../../..
subdir = src/library/grDevices/src/cairo
R_HOME = $(top_builddir)

pkg = grDevices

## Although this is in a package,
## it uses the top-level Makeconf and not etc/Makeconf
include $(top_builddir)/Makeconf

## need to find bitmap.h
ALL_CPPFLAGS = $(R_XTRA_CPPFLAGS) @CAIRO_CPPFLAGS@ \
  -I$(top_srcdir)/src/modules/X11 $(CPPFLAGS) $(DEFS)
ALL_CFLAGS = $(ALL_CFLAGS_LO)

## the X11 module is not made at all if BUILD_X11 is false.
SOURCES = cairoBM.c
DEPENDS = $(SOURCES:.c=.d)
OBJECTS = $(SOURCES:.c=.o) $(top_builddir)/src/modules/X11/rbitmap.o

cairo_la = cairo$(SHLIB_EXT)
## This order has to be consistent with the other use of rbitmap.o
## AIX needs LIBM
cairo_la_LIBADD = @BITMAP_LIBS@ @CAIRO_LIBS@ $(LIBR) $(LIBM) @DYLIB_UNDEFINED_ALLOWED_FALSE@ $(LIBINTL)

all: Makedeps
	@$(MAKE) R

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

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

R: Makefile
	@$(MAKE) $(cairo_la)
	@$(MKINSTALLDIRS) $(top_builddir)/library/$(pkg)/libs@R_ARCH@
	@cp $(cairo_la) $(top_builddir)/library/$(pkg)/libs@R_ARCH@

$(top_builddir)/src/modules/X11/rbitmap.o:
	(cd $(top_builddir)/src/modules/X11; $(MAKE) rbitmap.o)

$(cairo_la): $(OBJECTS)
	$(SHLIB_LINK) -o $@ $(OBJECTS) $(cairo_la_LIBADD)

mostlyclean: clean
clean:
	@-rm -Rf .libs _libs Makedeps *.d *.o $(cairo_la)
distclean: clean
	@-rm -f Makefile
maintainer-clean: distclean

## Automagically generated dependencies:
