# Makefile for Zip, ZipCloak, ZipNote and ZipSplit for
# Borland C++ for Windows 95/NT
# By E-Yen Tan. Last updated on 8 November 1997
# Includes ideas by Cosmin Truta <cosmint@cs.ubbcluj.ro>, Dec 1997.

# To use, do "make -fwin32\makefile.bor"

# Add -DNO_ASM to LOC, remove -DASM_CRC from LOC, and comment out
# the ASMOBJS definition if you do not have tasm32.

# Optional nonstandard preprocessor flags (as -DMEDIUM_MEM or -DNO_ASM)
# should be added to the environment via "set LOCAL_ZIP=-DFOO" or added
# to the declaration of LOC here:
LOC = -DASM_CRC $(LOCAL_ZIP)

# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 4

# Uncomment the following macro to use the optimized assembler
# routines in Zip:
#ASMOBJS = match32.obj crc_i386.obj

ASCPUFLAG = __$(CPU_TYP)86

VPATH=.;win32
CC = bcc32
# If you have bcc32i, you should define:
#CC = bcc32i
# This compiler generates a faster code.
# Note: due to an inconsistency in 'malloc.h', bcc32i version 5.0 displays
#       a warning "Redefinition of 'alloca' is not identical",
#       which you can ignore.
# Although, I did not disable this warning, because, generally speaking,
# it concerns correct C coding. [comment by: Cosmin Truta]

CFLAGS=-w -w-aus -w-ccc -w-par -w-sig -O2 -I. -DWIN32 -DMSDOS $(LOC)
UTILFLAGS=-DUTIL $(CFLAGS) -o

AS=tasm32
ASFLAGS=-ml -t -m2 -D$(ASCPUFLAG) $(LOC)

LD=$(CC)
LDFLAGS=

# ------------- Used by install rule
# set BIN to the directory you want to install the executables to
BIN = c:\util

# variables
OBJZ1 = zip.obj crypt.obj ttyio.obj zipfile.obj zipup.obj fileio.obj util.obj \
	crc32.obj crctab.obj globals.obj
OBJZ2 = deflate.obj trees.obj $(ASMOBJS)
OBJZS = win32zip.obj win32.obj nt.obj
OBJZ  = $(OBJZ1) $(OBJZ2) $(OBJZS)

OBJU  = zipfile_.obj fileio_.obj util_.obj globals.obj win32_.obj
OBJN  = zipnote.obj $(OBJU)
OBJC  = zipcloak.obj crctab.obj crypt_.obj ttyio.obj $(OBJU)
OBJS  = zipsplit.obj $(OBJU)

ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h

ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe

zips: $(ZIPS)

zip.obj:        zip.c $(ZIP_H) revision.h crypt.h ttyio.h
	$(CC) -c $(CFLAGS) $*.c

zipfile.obj:    zipfile.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

zipup.obj:      zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h
	$(CC) -c $(CFLAGS) $*.c

fileio.obj:     fileio.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

util.obj:       util.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

globals.obj:    globals.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

deflate.obj:    deflate.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

trees.obj:      trees.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

crc32.obj:      crc32.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

crctab.obj:     crctab.c $(ZIP_H)
	$(CC) -c $(CFLAGS) $*.c

crypt.obj:      crypt.c $(ZIP_H) crypt.h ttyio.h
	$(CC) -c $(CFLAGS) $*.c

ttyio.obj:      ttyio.c $(ZIP_H) crypt.h ttyio.h
	$(CC) -c $(CFLAGS) $*.c

win32zip.obj:   win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h
    $(CC) -c $(CFLAGS) win32/$*.c

win32.obj:      win32/win32.c $(ZIP_H) win32/win32zip.h
    $(CC) -c $(CFLAGS) win32/$*.c

nt.obj:         win32/nt.c $(ZIP_H) win32/nt.h
    $(CC) -c $(CFLAGS) win32/$*.c

zipcloak.obj:   zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h
	$(CC) -c $(CFLAGS) $*.c

zipnote.obj:    zipnote.c $(ZIP_H) revision.h
	$(CC) -c $(CFLAGS) $*.c

zipsplit.obj:   zipsplit.c $(ZIP_H) revision.h
	$(CC) -c $(CFLAGS) $*.c

zipfile_.obj:   zipfile.c $(ZIP_H)
	$(CC) -c $(UTILFLAGS)$* zipfile.c

fileio_.obj:    fileio.c $(ZIP_H)
	$(CC) -c $(UTILFLAGS)$* fileio.c

util_.obj:      util.c $(ZIP_H)
	$(CC) -c $(UTILFLAGS)$* util.c

crypt_.obj:     crypt.c $(ZIP_H) crypt.h ttyio.h
	$(CC) -c $(UTILFLAGS)$* crypt.c

win32_.obj:     win32/win32.c $(ZIP_H) win32/win32zip.h
	$(CC) -c $(UTILFLAGS)$* win32/win32.c

crc_i386.obj:   win32/crc_i386.asm
    $(AS) $(ASFLAGS) win32\crc_i386.asm ;

match32.obj:    win32/match32.asm
    $(AS) $(ASFLAGS) win32\match32.asm

# we must cut the command line to fit in the MS/DOS 128 byte limit:
zip.exe: $(OBJZ)
	echo $(OBJZ1) > zip.rsp
	echo $(OBJZ2) >> zip.rsp
	echo $(OBJZS) >> zip.rsp
	$(LD) $(LDFLAGS) @zip.rsp
	del zip.rsp

zipcloak.exe: $(OBJC)
	echo $(OBJC) > zipc.rsp
	$(LD) $(LDFLAGS) @zipc.rsp
	del zipc.rsp

zipnote.exe: $(OBJN)
	echo $(OBJN) > zipn.rsp
	$(LD) $(LDFLAGS) @zipn.rsp
	del zipn.rsp

zipsplit.exe: $(OBJS)
	echo $(OBJS) > zips.rsp
	$(LD) $(LDFLAGS) @zips.rsp
	del zips.rsp

install:        $(ZIPS)
	copy /b *.exe $(BIN)

clean:
	del *.obj
	del *.exe
