#-*- Makefile -*-
include ../../gnuwin32/MkRules

MODULE = internet
all: makeMakedeps ../../../modules$(R_ARCH)/internet.dll

CSOURCES = internet.c libcurl.c nanoftp.c nanohttp.c sockconn.c Rsock.c sock.c Rhttpd.c

CPPFLAGS = -I../../include -I../../extra/graphapp -DHAVE_CONFIG_H

EXTRA_LIBS = -lwininet -lws2_32

ifdef USE_LIBCURL
libcurl-CPPFLAGS += -DHAVE_CURL_CURL_H -DCURL_STATICLIB -I"$(CURL_PATH)"/include
EXTRA_LIBS += -L"$(CURL_PATH)"/lib$(R_ARCH) $(CURL_LIBS)
endif


../../../modules$(R_ARCH)/internet.dll: internet.o libcurl.o nanoftp.o nanohttp.o sockconn.o Rhttpd.o Rsock.o sock.o dllversion.o
	@$(MKDIR) -p ../../../modules$(R_ARCH)
	@$(ECHO) "EXPORTS" > internet.def
	@$(ECHO) " R_init_internet" >> internet.def
	$(DLL) -shared  -o $@ $^ internet.def -L../../../$(IMPDIR) -lR -lRgraphapp $(EXTRA_LIBS)
	@$(RM) internet.def

clean:
	@$(RM) Makedeps *.d *.o *.def *.dll

# Dependencies
dllversion.o: ../../include/Rversion.h
DEPS = $(CSOURCES:.c=.d)


makeMakedeps: $(DEPS)
	@$(RM) Makedeps
	@cat $(DEPS) >> Makedeps

-include Makedeps
