# Copyright 2014 Jeffrey Kegler
# This file is part of Marpa::R2.  Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser
# General Public License along with Marpa::R2.  If not, see
# http://www.gnu.org/licenses/.

# Build static and dynamic libraries of Marpa, using a config.h generated with Marpa::R2::Build_Me

#
# You should execute this Makefile in the libmarpa_dist directory like this:
# nmake -f Makefile.win32
#

CC = cl
CFLAGS = /c /Gy /DWIN32 /MD
LD = link
CP = copy
CPFLAGS = /Y
RM = del
MT = mt
RM_FLAGS = /Q
MARPA_DEF = win32\marpa.def
MARPA_OBJS = marpa.obj marpa_ami.obj marpa_obs.obj marpa_avl.obj
MARPA_DLL = libmarpa.dll

LDFLAGS = /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB:"LIBCMTD.LIB" /DLL /DEF:$(MARPA_DEF) /VERSION:%%MARPA_VERSION%%

.c.obj:
        $(CC) $(CFLAGS) /Fo$@ $<

all: $(MARPA_DLL)

$(MARPA_DLL): config.h $(MARPA_OBJS)
        $(LD) $(LDFLAGS) /OUT:$@ $(MARPA_OBJS)
        if exist $(MARPA_DLL).manifest mt -nologo -manifest $(MARPA_DLL).manifest -outputresource:$(MARPA_DLL);2

config.h:
        perl win32\do_config_h.pl --cc="$(CC)" --ccflags="$(CFLAGS)" --obj_ext=".obj"

clean:
        $(RM) $(RM_FLAGS) *.obj
        $(RM) $(RM_FLAGS) *.exp

distclean: clean
        $(RM) $(RM_FLAGS) *.dll
        $(RM) $(RM_FLAGS) *.lib

mrproper: distclean
