#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*            Xavier Leroy, projet Cristal, INRIA Rocquencourt            *
#*                                                                        *
#*   Copyright 1999 Institut National de Recherche en Informatique et     *
#*     en Automatique.                                                    *
#*                                                                        *
#*   All rights reserved.  This file is distributed under the terms of    *
#*   the GNU Lesser General Public License version 2.1, with the          *
#*   special exception on linking described in the file LICENSE.          *
#*                                                                        *
#**************************************************************************

# Configuration for Windows, Mingw compiler

######### General configuration

PREFIX=C:/ocamlmgw64

### Remove this to disable compiling ocamldebug
WITH_DEBUGGER=ocamldebugger

### Remove this to disable compiling ocamldoc
WITH_OCAMLDOC=ocamldoc

### Where to install the binaries
BINDIR=$(PREFIX)/bin

### Where to install the standard library
LIBDIR=$(PREFIX)/lib/ocaml

### Where to install the stub DLLs
STUBLIBDIR=$(LIBDIR)/stublibs

### Where to install the info files
DISTRIB=$(PREFIX)

### Where to install the man pages
MANDIR=$(PREFIX)/man

########## Toolchain and OS dependencies

TOOLCHAIN=mingw

### Toolchain prefix
TARGET=x86_64-w64-mingw32
HOST=$(TARGET)

TOOLPREF=$(TARGET)-

CCOMPTYPE=cc
O=o
A=a
S=s
SO=s.o
EXE=.exe
EMPTY=
OUTPUTEXE=-o $(EMPTY)
EXT_DLL=.dll
EXT_OBJ=.$(O)
OUTPUTOBJ=-o $(EMPTY)
EXT_LIB=.$(A)
EXT_ASM=.$(S)
PROGRAMS_MAN_SECTION=1
LIBRARIES_MAN_SECTION=3
HASHBANGSCRIPTS=false
PTHREAD_LINK=
PTHREAD_CAML_LINK=
X11_INCLUDES=
X11_LINK=
RPATH=
SUPPORTS_SHARED_LIBRARIES=true
SHAREDLIB_CFLAGS=
MKSHAREDLIBRPATH=
ASM=$(TOOLPREF)as
ASPP=$(TOOLPREF)gcc -c
ASPPPROFFLAGS=
PROFILING=false
DYNLINKOPTS=
CC_PROFILE=
SYSTHREAD_SUPPORT=true
EXTRALIBS=
NATDYNLINK=true
NATDYNLINKOPTS=
CMXS=cmxs
RUNTIMED=false
ASM_CFI_SUPPORTED=false
WITH_FRAME_POINTERS=false
UNIX_OR_WIN32=win32
UNIXLIB=win32unix
GRAPHLIB=win32graph
FLAMBDA=false
WITH_FLAMBDA_INVARIANTS=false
WITH_PROFINFO=false
WITH_SPACETIME=false
ENABLE_CALL_COUNTS=false
LIBUNWIND_AVAILABLE=false
LIBUNWIND_LINK_FLAGS=
PROFINFO_WIDTH=0
FORCE_SAFE_STRING=false
DEFAULT_SAFE_STRING=true
WINDOWS_UNICODE=1
AFL_INSTRUMENT=false
AWK=gawk
CC_HAS_DEBUG_PREFIX_MAP=false
AS_HAS_DEBUG_PREFIX_MAP=false

########## Configuration for the bytecode compiler

### Which C compiler to use for the bytecode interpreter.
CC=$(TOOLPREF)gcc
OC_CFLAGS=-O -mms-bitfields -Wall -Wno-unused -fno-tree-vrp
# -fno-tree-vrp is here to try to work around the Skylake/Kaby lake bug,
# and only works on GCC 4.2 and later.
OC_CPPFLAGS=-DCAML_NAME_SPACE -DUNICODE -D_UNICODE \
  -DWINDOWS_UNICODE=$(WINDOWS_UNICODE)
OCAMLC_CFLAGS=-O -mms-bitfields

OC_LDFLAGS=-municode

### Libraries needed
BYTECCLIBS=-lws2_32 -lversion
NATIVECCLIBS=-lws2_32 -lversion

### How to invoke the C preprocessor
CPP=cpp

### Flexlink
FLEXLINK_CMD=flexlink
FLEXDLL_CHAIN=mingw64
# FLEXLINK_FLAGS must be safe to insert in an OCaml string
#   (see ocamlmklibconfig.ml in tools/Makefile)
FLEXLINK_FLAGS=-chain $(FLEXDLL_CHAIN) -stack 33554432
FLEXLINK=$(FLEXLINK_CMD) $(FLEXLINK_FLAGS)
FLEXDIR:=$(shell $(FLEXLINK) -where 2>/dev/null)
ifeq ($(FLEXDIR),)
IFLEXDIR=-I"../flexdll"
else
IFLEXDIR=-I"$(FLEXDIR)"
endif
# MKDLL, MKEXE and MKMAINDLL must ultimately be equivalent to
#   $(FLEXLINK_CMD) $(FLEXLINK_FLAGS) [-exe|-maindll]
# or OCAML_FLEXLINK overriding will not work (see utils/config.mlp)
MKDLL=$(FLEXLINK)
MKEXE=$(MKEXE_ANSI) $(if $(OC_LDFLAGS),-link "$(OC_LDFLAGS)")
MKEXEDEBUGFLAG=-g
MKMAINDLL=$(FLEXLINK) -maindll

### Native command to build ocamlrun.exe without flexlink
MKEXE_BOOT=$(CC) $(OC_CFLAGS) $(OC_LDFLAGS) $(OUTPUTEXE)$(1) $(2)

### Native command to build an ANSI executable
MKEXE_ANSI=$(FLEXLINK) -exe

### How to build a static library
MKLIB=rm -f $(1) && $(TOOLPREF)ar rcs $(1) $(2)

### Canonicalize the name of a system library
SYSLIB=-l$(1)

### The ranlib command
RANLIB=$(TOOLPREF)ranlib
RANLIBCMD=$(TOOLPREF)ranlib

### The ar command
ARCMD=$(TOOLPREF)ar

############# Configuration for the native-code compiler

### Name of architecture for the native-code compiler
ARCH=amd64
ARCH64=true

### Name of architecture model for the native-code compiler.
MODEL=default

### Name of operating system family for the native-code compiler.
SYSTEM=mingw64

OCAMLOPT_CFLAGS=-O -mms-bitfields

### Build partially-linked object file
PACKLD=$(TOOLPREF)ld -r -o # must have a space after '-o'

### Set to "true" to install ".byte" executables (ocamlc.byte, etc.)
INSTALL_BYTECODE_PROGRAMS=true

############# Configuration for the contributed libraries

OTHERLIBRARIES=win32unix str win32graph dynlink bigarray systhreads

############# for the testsuite makefiles
OTOPDIR=$(WINTOPDIR)
CTOPDIR=$(TOPDIR)
CYGPATH=cygpath -m
DIFF=/usr/bin/diff -q --strip-trailing-cr
SET_LD_PATH=PATH="$(PATH):$(LD_PATH)"
MAX_TESTSUITE_DIR_RETRIES=1
FLAT_FLOAT_ARRAY=true
