#===========================================================================
# Makefile for UnZip, ZipInfo & fUnZip:  AMIGA SAS/C Version 6.x
# Version:  5.1                                                  9 July 1993
#===========================================================================
# John Bush <john.bush@east.sun.com>                last modified:  6 Feb 94
#---------------------------------------------------------------------------

#####################
# MACRO DEFINITIONS #
#####################

# Compiler and loader debug flags.  Uncomment as needed.  Recomment when done.
# 
# CDBG = DEBUG=L DEF=DEBUG
# LDBG = ADDSYM
# LMAP = MAP AMIGA/UNZIP.MAP

# Compiler definitions
#
CC = sc
#
OPT = OPT OPTINL OPTINLOCAL OPTTIME OPTCOMP=5 OPTDEP=5 OPTRDEP=5
#
# Choose one DATAOPTS & SASLIB.  NOTE!  only DATA=FAR is known to work!
#
DATAOPTS = DATA=FAR         # link with SCNB.lib
SASLIB = scnb
# DATAOPTS = DATA=FAR SINT  # link with SCSNB.lib  [not working yet!]
# SASLIB = scsnb
# DATAOPTS = DATA=NEAR      # link with SC.lib
# SASLIB = sc
#
CDEFINES = DEF=AMIGA DEF=PROTO
COPTIONS = $(DATAOPTS) NOSTKCHK STRMERGE CPU=ANY CODE=NEAR NMINC UNSCHAR
COPTIONS = $(COPTIONS) ERRORREXX NOERRORCONSOLE NOICONS
#
CFLAGS = $(CDEFINES) $(COPTIONS) $(CDBG) $(OPT)

# Linker definitions
#  See SASLIB definition above
#
LD = slink
LDFLAGS =  FROM LIB:c.o
LDFLAGS2 = NOICONS $(LDBG) $(LMAP)
LIBFLAGS = LIB LIB:$(SASLIB).lib+LIB:amiga.lib

# UnZip Objects
#
OBJS1 = unzip.o crypt.o envargs.o explode.o extract.o file_io.o
OBJS2 = inflate.o match.o unreduce.o unshrink.o zipinfo.o
OBJSA = amiga.o
OBJS  = $(OBJS1) $(OBJS2) $(OBJSA)
LOBJS = $(OBJS)

# fUnZip Objects
OBJF = funzip.o crypt_f.o inflate_f.o

# Output targets
UNZIPS = unzip funzip

# Temp filename for object lists to load using linker "WITH" command.
OBJLIST = ram:OBJLIST.TMP

#######################################
# DEFAULT TARGET AND PROCESSING RULES #
#######################################

all: $(UNZIPS)

.c.o :
        $(CC) $(CFLAGS) OBJNAME=$@ $*.c


#########################
# Final output targets. #
#########################

# NOTE:  When generating MAP files, don't make "all" because only the last 
#        map generated will be the one that remains after this is finished.
#        Or, put specific MAP statements in below for each.  

unzip:  $(OBJS)
        echo "$(OBJS)" >$(OBJLIST)
        $(LD) TO UnZip $(LDFLAGS) WITH $(OBJLIST) $(LIBFLAGS) $(LDFLAGS2)

funzip: $(OBJF)
        echo "$(OBJF)" >$(OBJLIST)
        $(LD) TO fUnZip $(LDFLAGS) WITH $(OBJLIST) $(LIBFLAGS) $(LDFLAGS2)

clean:
        -delete >nil: $(OBJS1)
        -delete >nil: $(OBJS2)
        -delete >nil: $(OBJSA)
        -delete >nil: $(OBJF)

spotless: clean
        -delete >nil: UnZip FunZip

# special rules for crypt binary used in FunZip
#
crypt_f.o:     crypt.c unzip.h zip.h crypt.h
                $(CC) DEF=FUNZIP $(CFLAGS) OBJNAME=crypt_f.o crypt.c

inflate_f.o:   inflate.c inflate.h unzip.h crypt.h
                $(CC) DEF=FUNZIP $(CFLAGS) OBJNAME=inflate_f.o inflate.c

# objects common to all revisions/ports:
#
crypt.o:        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 tables.h
funzip.o:       funzip.c unzip.h crypt.h tables.h
inflate.o:      inflate.c inflate.h unzip.h
match.o:        match.c unzip.h
shared.o:       shared.c unzip.h
unreduce.o:     unreduce.c unzip.h
unshrink.o:     unshrink.c unzip.h
unzip.o:        unzip.c unzip.h
zipinfo.o:      zipinfo.c unzip.h


# objects specific to Amiga
amiga.o:        amiga/amiga.c amiga/amiga.h

