# Makefile for x2bc command line utility - Microsoft Visual C
#
# Author: 
#   doubleshadow
#
# usage: 
#   nmake all        
#   nmake program    (x2bc and libx2bc)
#   nmake clean      (deletes all files created during compilation)

CPP = cl
LD = link
RC = rc

CPPFLAGS = /MD /O1 /G7 /Wp64 /TP /FD /W3 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /nologo 
RCFLAGS = /d_WIN32

OBJS = main.obj strutils.obj version.obj
LIBRARY = libx2bc.dll
IMPLIB = libx2bc.lib
PROGRAM = x2bc.exe

.cpp.obj::
	$(CPP) $(CPPFLAGS) /c $<

{../common}.cpp.obj::
	$(CPP) $(CPPFLAGS) /c $<

{../x2bc_common}.cpp.obj::
	$(CPP) $(CPPFLAGS) /c $<

x2bc.res: x2bc.rc
	$(RC) $(RCFLAGS) /fo$@ x2bc.rc

$(PROGRAM): library $(OBJS) x2bc.res
	$(LD) $(LDFLAGS) -out:$@ $(OBJS) $(IMPLIB) x2bc.res version.lib

$(IMPLIB):
	cd ../libx2bc
	nmake library
	cd $(MAKEDIR)
	copy ..\libx2bc\libx2bc.lib .\libx2bc.lib

$(LIBRARY):
	cd ../libx2bc
	nmake library
	cd $(MAKEDIR)
	copy ..\libx2bc\libx2bc.dll .\libx2bc.dll
	
version.obj: ../x2bc_common/version.cpp
strutils.obj: ../common/strutils.cpp
main.obj: main.cpp

all: program
rebuild: clean all
program: $(PROGRAM)
library: $(IMPLIB) $(LIBRARY)

clean:
	-del *.obj
	-del x2bc.res
	-del $(IMPLIB)
	-del $(LIBRARY)
	-del $(PROGRAM)
	-del vc70.idb