# Makefile for UnZip 5.x using SAS/C 5.10a
#   last revised:  11 Sep 92
#
# Updated to AmigaDOS 1.3 & 2.04, SAS/C 5.10b
# August 1992  (John Bush <J.Bush@MD-B.Prime.COM>)
#   - Selected unix equivalent routines via USTUFF variable to
#     reduce runfile size when not called.
#   - Re-did compiler options, and invented the AMIGADOS2 switch.
#   - Removed dependency on "-DUNIX", now require -DAMIGA
# Sept 6-7, 1992 (J.Bush)
#   - Incorporated filedate.c
#   - stat() and utime() elimintated
#   - Added DBG macros
#   - Removed useless $(O) and $(EXE) macros
#   - Created REV and DOSFLAG macros.
#        REV selects suffix for executable.
#        DOSFLAG can be "-DAMIGADOS2" for version 2.x, or
#                       "-DAMIGA" for version 1.3.x compatibility.
#        These flags can be overridden on the LMK command line.  Eg:
#
#     To Make for 1.3, "lmk -f amiga/lmkfile REV=_1.3 DOSFLAG=-DAMIGA
#     To Make for 2.x, "lmk -f amiga/lmkfile REV=_2.0 DOSFLAG=-DAMIGADOS2
#     See "MakeScript" AmigaDOS script.
#
# NOTE:  decryption (full versions of crypt.c, crypt.h) is not yet
#   supported.  In particular, code to prevent password echoing is
#   desirable, and even if echoing is allowed, the echo-related pre-
#   processor stuff in crypt.c is almost certain to cause compiler
#   warnings/errors.
#
#####################
# MACRO DEFINITIONS #
#####################

# OPTIONS:  reorganize comments depending upon selection

# Suffix for executable -- (_1.3 or _2.0 or whatever you want)
REV = _1.3
# REV = _2.0

# Dos flag -- set to -DAMIGADOS2 2.x systems (w/v.36 ROM and above).
# Set to -DAMIGA only on 1.3 systems (w/less than v.36 ROM).
DOSFLAG = -DAMIGA
# DOSFLAG = -DAMIGADOS2

CC = lc
OPT = -O
CFLAGS = $(OPT) $(DOSFLAG) -DPROTO -v -mat -cuisf -b0  -j85i86i87i100i
LD = blink
LDFLAGS =  FROM LIB:c.o
LDFLAGS2 = LIB LIB:lc.lib+LIB:amiga.lib

# Compiler and loader debug flags.  Swap comments as req'd.
# Do not set when building production version.
# CDBG = -d3
# LDBG = ADDSYM

#UnZip Objects
OBJS = unzip.o crypt.o envargs.o explode.o extract.o file_io.o inflate.o \
       mapname.o match.o misc.o unreduce.o unshrink.o filedate.o

#ZipInfo Objects
IOBS = zipinfo.o envargs.o match.o misc.ozi   # misc.ozi: compiled w/ -DZIPINFO

#FUnZip Objects
FOBS = funzip.o crypt.ofu inflate.o           # crypt.ofu: compiled w/ -DFUNZIP

###############################################
# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
###############################################

all: unzip funzip zipinfo

unzip: unzip$(REV)

.c.o :
        $(CC) -o$@ $(CFLAGS) $(CDBG) $*.c

.c.ozi :
        $(CC) -o$*.ozi -DZIPINFO $(CFLAGS) $(CDBG) $*.c

.c.ofu :
        $(CC) -o$*.ofu -DFUNZIP $(CFLAGS) $(CDBG) $*.c

unzip$(REV):    $(OBJS)
        $(LD) TO UnZip$(REV) $(LDFLAGS) $(OBJS) $(LDFLAGS2) $(LDBG)

funzip:   $(FOBS)
        $(LD) TO FUnZip $(LDFLAGS) $(FOBS) $(LDFLAGS2)

zipinfo:  $(IOBS)
        $(LD) TO ZipInfo $(LDFLAGS) $(IOBS) $(LDFLAGS2)

clean:
        -delete $(OBJS)
        -delete $(FOBS)
        -delete $(IOBS)

# objects common to all revisions/ports:
crypt.o:        crypt.c unzip.h zip.h crypt.h
crypt.ofu:      crypt.c unzip.h zip.h crypt.h
envargs.o:      envargs.c unzip.h
explode.o:      explode.c unzip.h
extract.o:      extract.c unzip.h crypt.h
file_io.o:      file_io.c unzip.h crypt.h
funzip.o:       funzip.c unzip.h crypt.h
inflate.o:      inflate.c unzip.h
mapname.o:      mapname.c unzip.h
match.o:        match.c unzip.h
misc.o:         misc.c unzip.h
misc.ozi:       misc.c unzip.h
unreduce.o:     unreduce.c unzip.h
unshrink.o:     unshrink.c unzip.h
unzip.o:        unzip.c unzip.h crypt.h
zipinfo.o:      zipinfo.c unzip.h


# objects specific to Amiga
filedate.o:     amiga/filedate.c        # only used if AMIGADOS2 not defined
