#WINXP_TARGETING=1

CC=cl.exe
!ifdef DEBUG
CFLAGS=/nologo /I. /W4 /Wall /wd4710 /wd4711 /Oi /MT /GZ /Zi \
       /DDEBUG /D_CRT_SECURE_NO_WARNINGS /DHAVE_CONFIG_H
!else
CFLAGS=/nologo /I. /W4 /Wall /wd4710 /wd4711 /O2 /MT \
       /D_CRT_SECURE_NO_WARNINGS /DHAVE_CONFIG_H
!endif
# Place /Wall *after* /W<n>. /W<n> after /Wall will adjust the effect of /Wall.
# /wd4710, 'function' : function not inlined
# /wd4711, function 'function' selected for inline expansion
!ifdef WINXP_TARGETING
CFLAGS=$(CFLAGS) /I"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include" \
       /D_USING_V110_SDK71_
!endif

LDFLAGS=/NOLOGO
!ifdef WINXP_TARGETING
LDFLAGS=$(LDFLAGS) /SUBSYSTEM:CONSOLE,5.01 \
        /LIBPATH:"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib"
!endif

DEFAULT_BUILD=1

# If the user passed anything, we are not a default build.

!ifdef LIBIEEE1284
DEFAULT_BUILD=0
!else
!ifdef RAWIO
DEFAULT_BUILD=0
!endif
!endif

!if $(DEFAULT_BUILD)==1
# Put default build options here

RAWIO=1

!endif # DEFAULT_BUILD = 1

# Now for backend-specific defs

!ifdef LIBIEEE1284
CFLAGS=$(CFLAGS) /DCD64_USE_LIBIEEE1284
LDFLAGS=$(LDFLAGS) ieee1284.lib
!endif

!ifdef RAWIO
CFLAGS=$(CFLAGS) /DCD64_USE_RAWIO
!endif

default: all

all: cd64.lib cd64.dll

# libcd64 stuff

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

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

cd64.lib: cd64lib.obj cd64io.obj
	lib.exe $** $(LDFLAGS) /OUT:$@

cd64.dll: cd64lib.obj cd64io.obj
	link.exe $** $(LDFLAGS) /DLL /DEF:cd64.def /IMPLIB:cd64dll.lib /OUT:$@

clean:
	del *.obj
	del *.exp
	del *.lib
	del *.dll
	del *.pdb
