# Makefile for Microsoft Visual C++
# usage: Make
#

CC=cl
DEFS = -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE \
-D_CRT_OBSOLETE_NO_DEPRECATE -D_SECURE_SCL=0

CFLAGS= -DWIN32 -MD -O2 -D_FILE_OFFSET_BITS=64 -nologo $(DEFS)

OBJS= blocksort.obj  \
      huffman.obj    \
      crctable.obj   \
      randtable.obj  \
      compress.obj   \
      decompress.obj \
      bzlib.obj

all: libbz2.lib bzip2.exe

bzip2.exe: libbz2.lib
	$(CC) $(CFLAGS) -Febzip2.exe bzip2.c libbz2.lib setargv.obj
	$(CC) $(CFLAGS) -Febzip2recover.exe bzip2recover.c

lib: libbz2.lib
libbz2.lib: $(OBJS)
	lib -out:$@ $(OBJS)

test: bzip2.exe
	cat words1
	./bzip2 -1  < sample1.ref > sample1.rb2
	./bzip2 -2  < sample2.ref > sample2.rb2
	./bzip2 -3  < sample3.ref > sample3.rb2
	./bzip2 -d  < sample1.bz2 > sample1.tst
	./bzip2 -d  < sample2.bz2 > sample2.tst
	./bzip2 -ds < sample3.bz2 > sample3.tst
	echo "All six of the fc's should find no differences."
	echo "If fc finds an error on sample3.bz2, this could be"
	echo "because WinZip's 'TAR file smart CR/LF conversion'"
	echo "is too clever for its own good.  Disable this option."
	echo "The correct size for sample3.ref is 120,244.  If it"
	echo "is 150,251, WinZip has messed it up."
	fc sample1.bz2 sample1.rb2 
	fc sample2.bz2 sample2.rb2
	fc sample3.bz2 sample3.rb2
	fc sample1.tst sample1.ref
	fc sample2.tst sample2.ref
	fc sample3.tst sample3.ref



clean:
	rm -f *.obj *~
	rm -f libbz2.lib 
	rm -f bzip2.exe
	rm -f bzip2recover.exe
	rm -f sample1.rb2 
	rm -f sample2.rb2 
	rm -f sample3.rb2
	rm -f sample1.tst 
	rm -f sample2.tst
	rm -f sample3.tst

.c.obj: 
	$(CC) $(CFLAGS) -c $<
