# Win32 Makefile for Moscow ML dynamically loadable regex library

# The runtime system must be compiled with support for dynamic libraries.
# The GNU REGEX persistent hashtables must be installed.

# Where to find REGEX header file and compiled library

REGEXDIR=regex-0.12

CC=cl
OPTS= /nologo /LD /MT /W1 /GB /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS"
#OPTS= /nologo /LD /MTd /W1 /GB /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"

CFLAGS= -Dunix $(OPTS) /I ..\..\runtime /I $(REGEXDIR)
LIBS= $(REGEXDIR)\regex.lib ..\..\runtime\camlrt.lib

!include ..\..\Makedefs.w32

MOSMLHOME=$(HOME)\mosml
MOSMLTOOLS=camlrunm $(MOSMLHOME)\tools
MOSMLC=mosmlc -c
MOSMLL=mosmlc
MOSMLLEX=mosmllex
MOSMLYACC=mosmlyac

all: libmregex.so
    @echo "Now execute 'nmake install'"

install:
    copy /b libmregex.so $(BINDIR)\libmregex.so
    @echo
    @echo "Then execute 'mosml testregex.sml' to try regexp matching"

libmregex.so: $(REGEXDIR)\regex.lib mregex.obj
    $(CC) $(CFLAGS) /Felibmregex.so mregex.obj $(LIBS) /link /subsystem:console

$(REGEXDIR)\regex.lib:
    cd $(REGEXDIR)
    nmake -f regex.mak CFG="regex - Win32 Release"
    cd ..

test:
    mosml testregex.sml

clean:
    cd regex-0.12
    nmake -f regex.mak CFG="regex - Win32 Release" CLEAN
    cd ..
    -del *.so
    -del *.exp
    -del *.lib
    -del *.obj

depend: 
    del Makefile.bak
    mv Makefile Makefile.bak
    $(MOSMLTOOLS)\cutdeps < Makefile.bak > Makefile
    $(MOSMLTOOLS)\mosmldep >> Makefile

mregex.obj: mregex.c

### EVERYTHING THAT GOES BEYOND THIS COMMENT WILL BE ERASED WITHOUT WARNING
### DO NOT DELETE THIS LINE
