# Makefile for UnZip(SFX) and fUnZip for Borland C++ 2.x/3.0 and Turbo C++ 1.0
# Version: 5.12 and later        Alvin Koh, Jim Knoble, Christian Spieler, etc.
#
# Last revised:  11 Aug 94


# for Borland C++ uncomment this and comment out the tcc line:
CC = bcc

# for Turbo C++ uncomment this and comment out the bcc line:
#CC = tcc

#TASM = tasm	# not used

#UNMODEL = s     # small model for UnZip and ZipInfo, now that strings moved
UNMODEL = l     # large model for UnZip (M. Lawler/BC 4.0:  _text > 64K w/ "s")
FUMODEL = s     # always use small model for fUnZip

#    GNU make doesn't like the return value from "rem"
#STRIP=rem
STRIP=echo  Ignore this line.  
#    If you don't have LZEXE or PKLITE, get one of them. Then define:
#STRIP=lzexe
#    or
#STRIP=pklite
#    This makes a big difference in .exe size (and possibly load time).


#    Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
#    should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
#    to the declaration of LOC here:
LOC = $(LOCAL_UNZIP)


# compiler flags

CFLAGS = -O -ff- -k- -P-.C -I. $(LOC)
UNFLAGS = -m$(UNMODEL) $(CFLAGS)
FUFLAGS = -m$(FUMODEL) $(CFLAGS) -K -d
LDFLAGS = -lxncd -l-P          # for bcc
#LDFLAGS = -lxncd		# for tcc

# implicit rules

.c.obj:
	$(CC) -c $(UNFLAGS) {$< }

# list macros

unzip_dependencies = \
	unzip.obj \
	crypt.obj \
	envargs.obj \
	explode.obj \
	extract.obj \
	file_io.obj \
	inflate.obj \
	match.obj \
	unreduce.obj \
	unshrink.obj \
	zipinfo.obj \
	msdos.obj

funzip_dependencies = \
	funzip.obj \
	crypt_.obj \
	inflate_.obj

unzipsfx_dependencies = \
	unzip_.obj \
	crypt.obj \
	extract_.obj \
	file_io.obj \
	inflate.obj \
	match.obj \
	msdos_.obj

# explicit rules

all:    unzip.exe funzip.exe unzipsfx.exe

unzip.exe:      $(unzip_dependencies)
	$(CC) -m$(UNMODEL) $(LDFLAGS) -eunzip.exe @&&|
unzip.obj
crypt.obj
envargs.obj
explode.obj
extract.obj
file_io.obj
inflate.obj
match.obj
unreduce.obj
unshrink.obj
zipinfo.obj
msdos.obj
|
	$(STRIP) unzip.exe

funzip.exe:    $(funzip_dependencies)
	$(CC) -m$(FUMODEL) $(LDFLAGS) -efunzip.exe @&&|
funzip.obj
crypt_.obj
inflate_.obj
|
	$(STRIP) funzip.exe

unzipsfx.exe:      $(unzipsfx_dependencies)
	$(CC) -m$(UNMODEL) $(LDFLAGS) -eunzipsfx.exe @&&|
unzip_.obj
crypt.obj
extract_.obj
file_io.obj
inflate.obj
match.obj
msdos_.obj
|
	$(STRIP) unzipsfx.exe

# individual file dependencies

crypt.obj:      crypt.c unzip.h zip.h crypt.h
envargs.obj:    envargs.c unzip.h
explode.obj:    explode.c unzip.h
extract.obj:    extract.c unzip.h crypt.h
file_io.obj:    file_io.c unzip.h crypt.h tables.h
inflate.obj:    inflate.c inflate.h unzip.h
match.obj:      match.c unzip.h
unreduce.obj:   unreduce.c unzip.h
unshrink.obj:   unshrink.c unzip.h
unzip.obj:      unzip.c unzip.h crypt.h version.h
zipinfo.obj:    zipinfo.c unzip.h

msdos.obj:      msdos/msdos.c unzip.h
	$(CC) -c $(UNFLAGS) msdos/msdos.c

funzip.obj:     funzip.c unzip.h crypt.h tables.h
	$(CC) -c $(FUFLAGS) funzip.c

crypt_.obj:     crypt.c unzip.h zip.h crypt.h
	$(CC) -c $(FUFLAGS) -DFUNZIP -ocrypt_.obj crypt.c

inflate_.obj:   inflate.c inflate.h unzip.h crypt.h
	$(CC) -c $(FUFLAGS) -DFUNZIP -oinflate_.obj inflate.c

unzip_.obj:     unzip.c unzip.h crypt.h version.h
	$(CC) -c $(UNFLAGS) -DSFX -ounzip_.obj unzip.c

extract_.obj:   extract.c unzip.h crypt.h
	$(CC) -c $(UNFLAGS) -DSFX -oextract_.obj extract.c

msdos_.obj:     msdos/msdos.c unzip.h
	$(CC) -c $(UNFLAGS) -DSFX -omsdos_.obj msdos/msdos.c
