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

pkg = tools

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

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

SOURCES_C = text.c init.c Rmd5.c md5.c signals.c install.c getfmts.c http.c \
  gramLatex.c gramRd.c pdscan.c Rsha256.c sha256.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

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

ifdef RUN_BISON
gramRd.c: gramRd.y
	bison gramRd.y
	$(SED) -e "s/gramRd.tab.c/gramRd.c/" gramRd.tab.c > gramRd.c
	$(RM) gramRd.tab.c

gramLatex.c: gramLatex.y
	bison gramLatex.y
	$(SED) -e "s/gramLatex.tab.c/gramLatex.c/" gramLatex.tab.c > gramLatex.c
	$(RM) gramLatex.tab.c
endif

-include Makedeps
