## -*- mode: makefile -*-
## Makefile for building the libIDL dll with Microsoft C
## Use: nmake -f Makefile.msc install

# Change this to wherever you want to install the DLLs. This directory
# should be in your PATH.
BIN = C:\Bin

# GLib location
GLIB_INCLUDES = -I/Devel/Port/glib
GLIB_LIBPATH = c:\Devel\Port\glib
GLIB_LIB = glib-1.2.lib

# libIDL dll version
LIBIDL_REALVER = @LIBIDL_VERSION@
LIBIDL_LIBVER = @LIBIDL_MAJOR_VERSION@.@LIBIDL_MINOR_VERSION@

# Debug build
LDOPT = /debug:full /debugtype:cv
CCOPT = -Ox
#CCOPT = -Zi # Debug build


################################################################
CC = cl -G5 -GF $(CCOPT) -W3 -D_DLL -nologo
LDFLAGS = /link /nodefaultlib:libc msvcrt.lib /libpath:$(GLIB_LIBPATH) $(LDOPT)
INSTALL = copy
TOUCH = copy Makefile.msc+nul

CFLAGS = -I. $(GLIB_INCLUDES)

all:   libIDL-$(LIBIDL_LIBVER).dll tstidl.exe

install: all
        $(INSTALL) libIDL-$(LIBIDL_LIBVER).dll $(BIN)

libIDL_OBJECTS =				\
	parser.obj				\
	lexer.obj				\
	ns.obj					\
	util.obj

libIDL-$(LIBIDL_LIBVER).dll: $(libIDL_OBJECTS)
        $(CC) $(CFLAGS) -MD -LD -FelibIDL-$(LIBIDL_LIBVER).dll $(libIDL_OBJECTS) $(GLIB_LIB) user32.lib advapi32.lib $(LDFLAGS) /def:libIDL.def

.c.obj:
        $(CC) $(CFLAGS) -GD -c -DPACKAGE=\"libIDL\" -DLIBIDL_VERSION=\"$(LIBIDL_REALVER)\" -DHAVE_CPP_PIPE_STDIN=1 -DCPP_PROGRAM="\"notsupported\"" -DYYTEXT_POINTER=1 -DSTDC_HEADERS=1 -DHAVE_STDDEF_H=1 -DHAVE_WCHAR_H=1 -DYYDEBUG=1 -DIDL_LIBRARY -DG_LOG_DOMAIN=\"libIDL\" $<

tstidl.exe: libIDL-$(LIBIDL_LIBVER).dll tstidl.obj
        $(CC) $(CFLAGS) -MD -Fetstidl.exe tstidl.obj libIDL-$(LIBIDL_LIBVER).lib $(GLIB_LIB) $(LDFLAGS) /map

clean:
	del config.h
	del *.exe
	del *.obj
	del *.dll
	del *.lib
	del *.err
	del *.map
	del *.sym
	del *.exp
	del *.lk1
	del *.mk1
	del *.pdb
	del *.ilk
