# Makefile for Zip, ZipCloak, ZipNote and ZipSplit for
# Turbo C 2.0. (Thanks to Andrew Cadach <kadach@isi.itfs.nsk.su>)

# To use, do "make -fmakefile.tc"

# WARNING: the small model is not supported. You must use the large model.
# Add -DSMALL_MEM or -DMEDIUM_MEM to CFLAGS if you wish to reduce the memory
# requirements. Add -DNO_ASM to CFLAGS and remove match.obj from OBJI if
# you do not have tasm.

# ------------- Turbo C 2.0 -------------
MODEL=-ml
CFLAGS=-w -w-eff -w-def -w-sig -w-cln -a -d -G -O -Z $(MODEL) $(CRFLAG)
UTILFLAGS=-DUTIL $(CFLAGS) -o
CC=tcc
LD=tcc
LDFLAGS=$(MODEL)
AS=tasm
ASFLAGS=-ml -t -DDYN_ALLOC -DSS_NEQ_DS -D__LARGE__

# ------------- Common declarations:
STRIP=rem
#    If you don't have lzexe, get it (by ftp on wuarchive.wustl.edu
#    in /mirrors/msdos/filutl/lzexe91e.zip). Then define:
#STRIP=lzexe
#    Or if you've registered PKLITE, then define:
#STRIP=pklite
#    This makes a big difference in .exe size (and possibly load time)

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

# variables
OBJZ = zip.obj zipfile.obj zipup.obj fileio.obj util.obj globals.obj crypt.obj

OBJI = deflate.obj trees.obj bits.obj match.obj
# remove match.obj if you do not have tasm

OBJU = _zipfile.obj _zipup.obj _fileio.obj _util.obj globals.obj
OBJN = _zipnote.obj  $(OBJU)
OBJC = _zipcloak.obj $(OBJU) _crypt.obj
OBJS = _zipsplit.obj $(OBJU)

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

zips:	$(ZIPS)

zip.obj:	zip.h ziperr.h tailor.h revision.h zip.c
	$(CC) -c $(CFLAGS) $*.c

zipfile.obj:	zip.h ziperr.h tailor.h zipfile.c
	$(CC) -c $(CFLAGS) $*.c

zipup.obj:	zip.h ziperr.h tailor.h revision.h zipup.c
	$(CC) -c $(CFLAGS) $*.c

fileio.obj:	zip.h ziperr.h tailor.h fileio.c
	$(CC) -c $(CFLAGS) $*.c

util.obj:	zip.h ziperr.h tailor.h util.c
	$(CC) -c $(CFLAGS) $*.c

globals.obj:	zip.h ziperr.h tailor.h globals.c
	$(CC) -c $(CFLAGS) $*.c

deflate.obj:	zip.h ziperr.h tailor.h deflate.c
	$(CC) -c $(CFLAGS) $*.c

trees.obj:	zip.h ziperr.h tailor.h trees.c
	$(CC) -c $(CFLAGS) $*.c

bits.obj:	zip.h ziperr.h tailor.h bits.c
	$(CC) -c $(CFLAGS) $*.c

crypt.obj:	zip.h ziperr.h tailor.h crypt.c
	$(CC) -c $(CFLAGS) $*.c

_zipcloak.obj:	zip.h ziperr.h tailor.h revision.h zipcloak.c
	$(CC) -c $(UTILFLAGS)$* zipcloak.c

_zipnote.obj:	zip.h ziperr.h tailor.h revision.h zipnote.c
	$(CC) -c $(UTILFLAGS)$* zipnote.c

_zipsplit.obj:	zipsplit.c zip.h ziperr.h tailor.h revision.h
	$(CC) -c $(UTILFLAGS)$* zipsplit.c

_zipfile.obj:	zipfile.c zip.h ziperr.h tailor.h
	$(CC) -c $(UTILFLAGS)$* zipfile.c

_zipup.obj:	zipup.c zip.h ziperr.h tailor.h
	$(CC) -c $(UTILFLAGS)$* zipup.c

_fileio.obj:	fileio.c zip.h ziperr.h tailor.h
	$(CC) -c $(UTILFLAGS)$* fileio.c

_util.obj:	util.c zip.h ziperr.h tailor.h
	$(CC) -c $(UTILFLAGS)$* util.c

_crypt.obj:	crypt.c zip.h ziperr.h tailor.h
	$(CC) -c $(UTILFLAGS)$* crypt.c

match.obj:	msdos\match.asm
	$(AS) $(ASFLAGS) msdos\match;

# make sure the command line fits in the MS/DOS 128 byte limit:
zip.exe: $(OBJZ) $(OBJI)
	rem   ignore any warnings in the following renaming commands:
	ren _*.obj _*.ob
	$(LD) $(LDFLAGS) -ezip.exe *.obj
	ren _*.ob _*.obj
	$(STRIP) zip.exe

zipcloak.exe: $(OBJC)
	$(LD) $(LDFLAGS) -ezipcloak.exe $(OBJC)
	$(STRIP) zipcloak.exe

zipnote.exe: $(OBJN)
	$(LD) $(LDFLAGS) -ezipnote.exe $(OBJN)
	$(STRIP) zipnote.exe

zipsplit.exe: $(OBJS)
	$(LD) $(LDFLAGS) -ezipsplit.exe $(OBJS)
	$(STRIP) zipsplit.exe

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

clean:
	del *.obj
	del *.exe
