#-----------------------------------------------------------------------------
# Makefile for UnZip 5.11 and later                           Jean-loup Gailly
# Version:  Turbo C (edit and use makefile.bc for Turbo C++)      10 July 1994
#-----------------------------------------------------------------------------

#    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).

# memory model for UnZip (conflicting reports on whether Turbo C can or
# cannot put strings into far memory; for now assume it can and use small
# model *with* ZipInfo enabled...if fails, either define NO_ZIPINFO or
# use large model)   [GRR 940712:  sigh, no go--inflate fails.  Back to
# large model...]
#MODEL = s
MODEL = l

CC = tcc
LD = $(CC)

UCFLAGS = -m$(MODEL) -O -Z -I. -DFar=
ULDFLAGS = -m$(MODEL)

# funzip is always small-model
FCFLAGS = -ms -O -Z -I.
FLDFLAGS = -ms

LDFLAGS2 =

OBJS = 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

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

OBJF = funzip.obj crypt_.obj inflate_.obj

default:        unzip.exe funzip.exe unzipsfx.exe

clean:
	rem Ignore any errors in the following...
	del *.ob
	del *.obj
	del unzip.exe
	del funzip.exe

.c.obj:
        $(CC) -c $(UCFLAGS) $*.c

crypt.obj:      crypt.c unzip.h crypt.h zip.h

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

envargs.obj:    envargs.c unzip.h

explode.obj:    explode.c unzip.h

extract.obj:    extract.c unzip.h crypt.h

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

file_io.obj:    file_io.c unzip.h crypt.h tables.h

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

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

inflate.obj:    inflate.c inflate.h unzip.h

match.obj:      match.c unzip.h

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

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

unreduce.obj:   unreduce.c unzip.h

unshrink.obj:   unshrink.c unzip.h

unzip.obj:      unzip.c unzip.h crypt.h version.h

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

zipinfo.obj:    zipinfo.c unzip.h


# Turbo Make which cannot deal with the MS-DOS 128 byte limit:
# -----------------------------------------------------------
unzip.exe: $(OBJS)
	rem   Ignore any warnings in the following commands:
	del funzip.ob
	ren funzip.obj *.ob
	del crypt_.ob
	ren crypt_.obj *.ob
	del inflate_.ob
	ren inflate_.obj *.ob
	$(LD) $(ULDFLAGS) -eunzip.exe *.obj
	ren *.ob *.obj
	$(STRIP) unzip.exe

# better makes which know how to deal with 128 char limit on command line:
# -----------------------------------------------------------------------
#unzip.exe:     $(OBJS)
#	$(LD) $(ULDFLAGS) $(OBJS) $(LDFLAGS2)
#	$(STRIP) unzip.exe

# both makes:
# ----------
funzip.exe:     $(OBJF)
	$(LD) $(FLDFLAGS) $(OBJF) $(LDFLAGS2)
	$(STRIP) funzip.exe

unzipsfx.exe:     $(OBJX)
	$(LD) $(ULDFLAGS) $(OBJX) $(LDFLAGS2)
	rename unzip_.exe unzipsfx.exe
	$(STRIP) unzipsfx.exe
