DLOPEN=1
#USE_ZLIB=1
#WINXP_TARGETING=1

CC=cl.exe
CFLAGS=/nologo /I. /W4 /Wall /wd4710 /wd4711 /O2 /MT /DDLL \
       /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /DHAVE_CONFIG_H
# 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 DLOPEN
CFLAGS=$(CFLAGS) /DDLOPEN
!endif
!ifdef WINXP_TARGETING
CFLAGS=$(CFLAGS) /I"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include" \
       /D_USING_V110_SDK71_
!endif

LIBNAME=discmage
FULLLIBNAME=$(LIBNAME).dll

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

OBJECTS=libdm_misc.obj dllinit.obj misc.obj misc_wav.obj format/format.obj \
        format/cdi.obj format/nero.obj format/cue.obj format/toc.obj \
        format/other.obj
!ifdef USE_ZLIB
LDFLAGS=$(LDFLAGS) zdll.lib
OBJECTS=$(OBJECTS) map.obj misc_z.obj unzip.obj
!endif


all: $(FULLLIBNAME)


clean:
	del $(FULLLIBNAME)
	del $(LIBNAME).lib
	del *.obj
	del format\*.obj
	del $(LIBNAME).exp


distclean: clean
	del config.h


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


$(FULLLIBNAME): $(OBJECTS)
	link.exe $(OBJECTS) $(LDFLAGS) /OUT:$(FULLLIBNAME)
# link.exe automatically creates the import library. "/IMPLIB:filename.lib"
#  could be used to give the import library another name
#	lib.exe $(OBJECTS) $(LDFLAGS) /OUT:$(LIBNAME).lib

install:

uninstall:


# Dependencies

MISC_Z_H_DEPS=misc_z.h unzip.h
MISC_H_DEPS=misc.h $(MISC_Z_H_DEPS) getopt.h

libdm_misc.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
              format/format.h misc_wav.h
dllinit.obj: config.h libdiscmage.h
misc.obj: config.h $(MISC_Z_H_DEPS) $(MISC_H_DEPS)
misc_wav.obj: config.h $(MISC_H_DEPS) misc_wav.h
format/format.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
                 format/format.h format/cdi.h format/cue.h format/nero.h \
                 format/other.h format/toc.h
format/cdi.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
              format/format.h
format/nero.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
               format/format.h
format/cue.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
              format/format.h
format/toc.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
              format/format.h
format/other.obj: config.h $(MISC_H_DEPS) libdiscmage.h libdm_misc.h \
                format/format.h
map.obj: config.h map.h
misc_z.obj: config.h $(MISC_Z_H_DEPS) $(MISC_H_DEPS) map.h unzip.h
unzip.obj: config.h unzip.h
