# -*- makefile-gmake -*-

# to prepare for building Macaulay2 under cygwin:

# install these cygwin packages:
#    mingw64-x86_64-gcc-fortran
#    mingw64-x86_64-gcc-g++
#    mingw64-x86_64-pthreads
#    mingw64-x86_64-zlib
# (setup's log file is here: /var/log/setup.log)

# also install these libraries manually, as shown:

# ncurses
#   ftp.gnu.org -- ncurses-5.9.tar.gz
#   ./configure --prefix=$HOME/local/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-term-driver --enable-sp-funcs --disable-shared CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++

# libxml2
#   ftp://xmlsoft.org/libxml2/libxml2-sources-2.9.0.tar.gz
#   ./configure --without-python --prefix=$HOME/local/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-shared CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++

# cpp search path:
#   find /usr/lib/gcc/x86_64-w64-mingw32/4.5.3/include /usr/lib/gcc/x86_64-w64-mingw32/4.5.3/include-fixed /usr/x86_64-w64-mingw32/sys-root/mingw/include

# ld search path:
#   find /usr/lib/gcc/x86_64-w64-mingw32/4.5.3 /usr/x86_64-w64-mingw32/lib64 /usr/x86_64-w64-mingw32/lib /usr/x86_64-w64-mingw32/sys-root/mingw/lib

# binary/text mode options
#   /usr/x86_64-w64-mingw32/sys-root/mingw/lib/binmode.o
#   /usr/x86_64-w64-mingw32/sys-root/mingw/lib/txtmode.o
#   and see the use of _setmode in M2lib.c

# The compiler needs to know whether a function is coming from a dynamic
# library, in which case it is declared with "__attribute__ ((dllimport))" and
# the name is prefixed with __imp__ instead of with _ .  The variable
# LIBXML_STATIC is used by the libxml include files to decide whether to add
# the attribute.

export CC =

# get the libraries needed for running the programs
# consider also adding this to your path so you can run makefiles other than through this one
export PATH := /usr/x86_64-w64-mingw32/sys-root/mingw/bin:$(PATH)

DIRECTORY = mingw
CONFIGOPTIONS += --host=x86_64-w64-mingw32
CPPFLAGS="-I$(HOME)/local/x86_64-w64-mingw32/include -I$(HOME)/local/x86_64-w64-mingw32/include/libxml2 -DLIBXML_STATIC"
LDFLAGS="-L$(HOME)/local/x86_64-w64-mingw32/lib"
CONFIGOPTIONS += --with-issue=mingw64

ifeq ($(DEBUG),yes)
   INSTALLOPTIONS += prefix=/none
   CONFIGOPTIONS += --enable-debug --disable-optimize
   DIRECTORY := $(DIRECTORY).debug
endif

include Makefile.include
# Local Variables:
# compile-command: "time make -f Makefile.mingw DEBUG=no "
# End:
