#-*- Makefile -*-
#
# ${R_HOME}/src/library/utils/src/Makefile.win

pkg = utils

srcdir = .
top_srcdir = ../../../..

top_builddir = ../../../..
subdir = src/library/$(pkg)/src
R_HOME = $(top_builddir)

SOURCES_C = init.c io.c size.c sock.c stubs.c utils.c hashtab.c \
  windows/dataentry.c windows/dialogs.c windows/registry.c \
  windows/util.c windows/widgets.c

DEPENDS = $(SOURCES_C:.c=.d)
OBJECTS = $(SOURCES_C:.c=.o) ../../../gnuwin32/dllversion.o

SHLIB = $(pkg).dll
RESFLAGS = -I $(R_HOME)/include

PKG_CPPFLAGS = -I$(R_HOME)/src/include -DHAVE_CONFIG_H \
  -I$(R_HOME)/src/main -I$(R_HOME)/src/gnuwin32 -I$(R_HOME)/src/extra \
  -I$(R_HOME)/src/library/grDevices/src

PKG_LIBS = -lRgraphapp -lversion

ifndef USE_PKG_CONFIG
  PKG_CPPFLAGS += -DLZMA_API_STATIC -I"$(EXT_LIBS)/include"
  PKG_LIBS += -L"$(EXT_LIBS)"/lib$(R_ARCH) -llzma
else
  PKG_CPPFLAGS += $(shell $(PKG_CONFIG) --cflags liblzma)
  PKG_LIBS += $(shell $(PKG_CONFIG) --libs liblzma)
endif

all: makeMakedeps shlib

shlib: $(SHLIB)
	@mkdir -p $(top_builddir)/library/$(pkg)/libs$(R_ARCH)
	@cp $(SHLIB) $(top_builddir)/library/$(pkg)/libs$(R_ARCH)

include $(R_HOME)/etc${R_ARCH}/Makeconf
include $(top_srcdir)/share/make/winshlib.mk

mostlyclean distclean: clean
clean:
	@-rm -f Makedeps *.d *.o $(SHLIB)


makeMakedeps: $(DEPENDS)
	@$(RM) Makedeps
	-@cat $(DEPENDS) > Makedeps


-include Makedeps
