#-*- Makefile -*-
## remove any .y.c rule
.SUFFIXES:
include ../gnuwin32/MkRules

all: makeMakedeps libmain.a

## there are headers and include files in this directory
CPPFLAGS = -I. -I../include -DHAVE_CONFIG_H -DR_DLL_BUILD $(arch_DEFS)

CSOURCES = \
	CommandLineArgs.c \
	Rdynload.c Renviron.c RNG.c \
	agrep.c altclasses.c altrep.c apply.c arithmetic.c array.c attrib.c \
	bind.c builtin.c \
	character.c coerce.c colors.c complex.c connections.c context.c cum.c \
	dcf.c datetime.c debug.c deparse.c devices.c \
	dotcode.c dounzip.c dstruct.c duplicate.c \
	edit.c engine.c envir.c errors.c eval.c \
	format.c \
	gevents.c gram.c gram-ex.c graphics.c grep.c \
	identical.c inlined.c inspect.c internet.c iosupport.c \
	lapack.c list.c localecharset.c logic.c \
	main.c mapply.c match.c memory.c mkdtemp.c \
	names.c \
	objects.c options.c \
	paste.c patterns.c platform.c plot.c plot3d.c plotmath.c \
	print.c printarray.c printvector.c printutils.c qsort.c \
	radixsort.c random.c raw.c registration.c relop.c rlocale.c \
	saveload.c scan.c seq.c serialize.c sort.c source.c split.c \
	sprintf.c startup.c subassign.c subscript.c subset.c summary.c sysutils.c \
	times.c \
	unique.c util.c \
	version.c \
	g_alab_her.c g_cntrlify.c g_fontdb.c g_her_glyph.c


FSOURCES = xxxpr.f
OBJS = $(CSOURCES:.c=.o) $(FSOURCES:.f=.o)

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

platform-CPPFLAGS = -I../gnuwin32 -I../extra -DPLATFORM_PKGTYPE='"win.binary"'

RNG-CPPFLAGS = -I../nmath
agrep-CPPFLAGS = -I../extra
# array-CPPFLAGS=$(OPENMP) # too slow to be useful.
builtin-CPPFLAGS = -I../gnuwin32

dcf-CPPFLAGS = -I../extra
## gcc warns incorrectly about %a
deparse-CFLAGS = -Wno-format
edit-CPPFLAGS = -I../gnuwin32
memory-CPPFLAGS = $(malloc-DEFS)
printutils-CPPFLAGS = -I../gnuwin32
saveload-CPPFLAGS = -I../extra/xdr
serialize-CPPFLAGS = -I../extra/xdr
sysutils-CPPFLAGS = -I../gnuwin32

connections-CPPFLAGS = -DLZMA_API_STATIC -I"$(EXT_LIBS)"/include
dounzip-CPPFLAGS = -I$(EXT_LIBS)/include
grep-CPPFLAGS = -DPCRE2_STATIC -I../extra -I../gnuwin32 -I"$(EXT_LIBS)"/include
platform-CPPFLAGS += -DPCRE2_STATIC -DLZMA_API_STATIC -I"$(EXT_LIBS)"/include
util-CPPFLAGS = -DLZMA_API_STATIC -I"$(EXT_LIBS)"/include

ifdef USE_ICU
platform-CPPFLAGS += -DUSE_ICU -I"$(ICU_PATH)"/include
util-CPPFLAGS += -DUSE_ICU -I"$(ICU_PATH)"/include
endif

ifdef USE_LIBCURL
connections-CPPFLAGS += -DHAVE_CURL_CURL_H -DHAVE_LIBCURL
platform-CPPFLAGS += -DHAVE_CURL_CURL_H -DHAVE_LIBCURL
endif


libmain.a: $(OBJS)

# Dependencies
DEPS = $(CSOURCES:.c=.d)

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

-include Makedeps
