# HELLO tutorial makefile

#    nmake -f mvcpp600.mak dos32       (makes the DOS TNT extender hello tutorials)
#    nmake -f mscpp400.mak winnt       (makes all the Windows hello tutorials)
#    nmake -f mscpp400.mak win32       (makes all the Windows hello tutorials)

# Be sure to set the LIB and INCLUDE environment variables for Zinc, e.g.:
#    set INCLUDE=.;C:\ZINC\INCLUDE;C:\MSVC\INCLUDE
#    set LIB=.;C:\ZINC\LIB\MVCPP100;C:\MSVC\LIB

# ----- DOS TNT Extender options --------------------------------------------
# for debug:    add -Zi to CPP_OPTS
#               and -CV to LINK_OPTS
D32_CPP=cl
D32_LINK=link
D32_CPP_OPTS=-c -DDOS386 -D$(FONT) -nologo
D32_LINK_OPTS=
D32_OBJS=

# --- Use the next line for UI_GRAPHICS_DISPLAY ---
D32_LIBS=dosx32.lib dos32.lib d32_zil.lib d32_gfx.lib ms_32gfx.lib oldnames.lib
# --- Use the next line for UI_MSC_DISPLAY ---
#D32_LIBS=dosx32.lib dos32.lib tntapi.lib d32_zil.lib d32_msc.lib oldnames.lib

.cpp.o32:
	$(D32_CPP) $(D32_CPP_OPTS) -Fo$*.o32 $<

# ----- Windows NT compiler options -----------------------------------------
# for debug:    add /Zi to CPP_OPTS
#               add /DEBUG:MAPPED,FULL /DEBUGTYPE:CV to LINK_OPTS
WNT_CPP=cl
WNT_LINK=link
WNT_LIBRARIAN=lib

WNT_CPP_OPTS= -MT -c -W3 -D_X86_=1 -DWIN32
WNT_LINK_OPTS=-align:0x1000 -subsystem:windows -entry:WinMainCRTStartup
WNT_CON_LINK_OPTS=-align:0x1000 -subsystem:console -entry:mainCRTStartup
WNT_LIB_OPTS=/machine:i386 /subsystem:WINDOWS

WNT_OBJS=
WNT_LIBS=libcmt.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib wnt_zil.lib oldnames.lib 
WNT_CON_LIBS=libcmt.lib kernel32.lib wnt_zil.lib oldnames.lib

.cpp.obn:
	$(WNT_CPP) $(WNT_CPP_OPTS) -Fo$*.obn $<

# ----- Windows 32 bit compiler options -------------------------------------
# for debug:    add /Zi to CPP_OPTS
#               add /DEBUG:MAPPED,FULL /DEBUGTYPE:CV to LINK_OPTS
W32_CPP=cl
W32_LINK=link
W32_LIBRARIAN=lib

W32_CPP_OPTS= -MT -c -W3 -D_X86_=1 -DWIN32
W32_LINK_OPTS=-align:0x1000 -subsystem:windows -entry:WinMainCRTStartup
W32_LIB_OPTS=/machine:i386 /subsystem:WINDOWS

W32_OBJS=
W32_LIBS=libcmt.lib kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib w32_zil.lib oldnames.lib 

.cpp.ob9:
	$(W32_CPP) $(W32_CPP_OPTS) -Fo$*.ob9 $<

# ----- Usage --------------------------------------------------------------
usage:
	@echo ...........
	@echo ...........
	@echo To make this Zinc tutorial for Visual C++ type:
	@echo nmake -f mvcpp600.mak dos32
	@echo nmake -f mvcpp600.mak winnt
	@echo nmake -f mvcpp600.mak win32
	@echo ...........
	@echo ...........

# ----- Clean ---------------------------------------------------------------
clean:
	z_clean

# ----- DOS 32 bit TNT Extender ---------------------------------------------
dos32: hello132.exe hello232.exe hello332.exe hellog32.exe

hello132.exe: hello1.o32
	$(D32_LINK) @msvc32.lnk $(D32_LINK_OPTS) -out:hello132.exe $(D32_OBJS) hello1.o32 $(D32_LIBS)

hello232.exe: hello2.o32
	$(D32_LINK) @msvc32.lnk $(D32_LINK_OPTS) -out:hello232.exe $(D32_OBJS) hello2.o32 $(D32_LIBS)

hello332.exe: hello3.o32 hello.o32
	$(D32_LINK) @msvc32.lnk $(D32_LINK_OPTS) -out:hello332.exe $(D32_OBJS) hello3.o32 hello.o32 $(D32_LIBS)

hellog32.exe: hellog.o32
	$(D32_LINK) @msvc32.lnk $(D32_LINK_OPTS) -out:hellog32.exe $(D32_OBJS) hellog.o32 $(D32_LIBS)

# ----- Windows NT ----------------------------------------------------------
winnt: nhello1.exe nhello2.exe nhello3.exe nhellog.exe

nhello1.exe: hello1.obn 
	$(WNT_LINK) $(WNT_LINK_OPTS) -out:nhello1.exe $(WNT_OBJS) hello1.obn  $(WNT_LIBS)

nhello2.exe: hello2.obn
	$(WNT_LINK) $(WNT_LINK_OPTS) -out:nhello2.exe $(WNT_OBJS) hello2.obn $(WNT_LIBS)

nhello3.exe: hello3.obn hello.obn
	$(WNT_LINK) $(WNT_LINK_OPTS) -out:nhello3.exe $(WNT_OBJS) hello3.obn hello.obn $(WNT_LIBS)

nhellog.exe: hellog.obn
	$(WNT_LINK) $(WNT_LINK_OPTS) -out:nhellog.exe $(WNT_OBJS) hellog.obn $(WNT_LIBS)

# ----- 32 bit Windows ------------------------------------------------------
win32: 9hello1.exe 9hello2.exe 9hello3.exe 9hellog.exe

9hello1.exe: hello1.ob9
	$(W32_LINK) $(W32_LINK_OPTS) -out:9hello1.exe $(W32_OBJS) hello1.ob9 $(W32_LIBS)

9hello2.exe: hello2.ob9
	$(W32_LINK) $(W32_LINK_OPTS) -out:9hello2.exe $(W32_OBJS) hello2.ob9 $(W32_LIBS)

9hello3.exe: hello3.ob9 hello.ob9
	$(W32_LINK) $(W32_LINK_OPTS) -out:9hello3.exe $(W32_OBJS) hello3.ob9 hello.ob9 $(W32_LIBS)

9hellog.exe: hellog.ob9
	$(W32_LINK) $(W32_LINK_OPTS) -out:9hellog.exe $(W32_OBJS) hellog.ob9 $(W32_LIBS)
