# Makefile for Zip, ZipNote, ZipCloak and ZipSplit
# For Amiga -- Lattice Makefile (lmkfile) for SAS/C 5.10b
# Derived from Zip 1.9 p1 Makefile.
# -John Bush, <J.Bush@MD-B.Prime.COM>

#   - Usage of 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.

# These symbols, when #defined using -D have these effects on compilation:
# AMIGA         - for Amiga target
# AMIGADOS2     - Amiga target; AmigaDOS 2.0 (runs only on 2.x & higher)
# ZMEM		- includes C language versions of memset(), memcpy(), and
#		  memcmp() (util.c).
# DIRENT	- use <sys/dirent.h> and getdents() instead of <sys/dir.h>
#		  and opendir(), etc. (fileio.c).
# NODIR		- used for 3B1, which has neither getdents() nor opendir().
# NDIR		- use "ndir.h" instead of <sys/dir.h> (fileio.c).
# UTIL		- select routines for utilities (note, cloak, and split).
# PROTO		- enable function prototypes.
# RMDIR		- remove directories using a system("rmdir ...") call.
# CONVEX	- for Convex make target.
# AIX		- for AIX make target.
# CRYPT 	- include the encryption code.
# LINUX		- for linux make target.
# NO_MKTEMP     - There is no mktemp() function on your machine.
#
#######################
# MACROBE 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

# NOTE:  Encryption requires separately available CRYPT.C
# Uncomment following two lines for decryption version. (UNTESTED)
# CRYPTF = -DCRYPT
# CRYPTO = crypt.o

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

DEFINES = $(DOSFLAG) $(CRYPTF) -DNO_MKTEMP -DRMDIR -DPROTO
CC = lc
OPT = -O
CFLAGS = $(OPT) -v -mat -cuisf -b0 -j85i86i87i100i $(CDBG) $(DEFINES) 

LD = blink
LDSTART = LIB:c.o
LDFLAGS = LIB LIB:lc.lib+LIB:amiga.lib

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

# default C rules
.c.o:
        $(CC) $(CFLAGS) -o$@ $*.c

# rules for routines containing entries needed by utilities
.c.oo:
        $(CC) $(CFLAGS) -DUTIL -o$*.oo $*.c

# object file macrough lists

HFILES = zip.h ziperr.h tailor.h revision.h

OBJI = deflate.o trees.o bits.o
OBJA = zipfile.o zipup.o fileio.o util.o globals.o filedate.o
OBJU = zipfile.oo zipup.oo fileio.oo util.oo globals.o

OBJZ = zip.o $(OBJA) $(OBJI) $(CRYPTO)

OBJN = zipnote.o  $(OBJU)
OBJC = zipcloak.o $(OBJU) crypt.o
OBJS = zipsplit.o $(OBJU)

#                # still working on these (9/14/92)
ZIPS = zip$(REV) # zipnote$(REV) zipcloak$(REV) zipsplit$(REV) 

all:      $(ZIPS)

zip:      zip$(REV)
zipnote:  zipnote$(REV)
zipcloak: zipcloak$(REV)
zipsplit: zipsplit$(REV)

zip$(REV): $(OBJZ) $(HFILES)
	$(LD) TO Zip$(REV) FROM $(LDSTART) $(OBJZ) $(LDFLAGS) $(LDBG)

zipnote$(REV): $(OBJN) $(HFILES)
	$(LD) TO ZipNote$(REV) FROM $(LDSTART) $(OBJN) $(LDFLAGS) $(LDBG)

zipcloak$(REV): $(OBJC) $(HFILES)
	$(LD) TO ZipCloak$(REV) FROM $(LDSTART) $(OBJC) $(LDFLAGS) $(LDBG)

zipsplit$(REV): $(OBJS) $(HFILES)
	$(LD) TO ZipSplit$(REV) FROM $(LDSTART) $(OBJS) $(LDFLAGS) $(LDBG)

clean:
       -delete $(OBJZ) >nil:
       -delete $(OBJU) >nil:
       -delete zipnote.o zipcloak.o zipsplit.o >nil:

zip.o: zip.c $(HFILES)
zipnote.o: zipnote.c $(HFILES)
zipcloak.o: zipcloak.c $(HFILES)
crypt.o: crypt.c $(HFILES)
zipsplit.o: zipsplit.c $(HFILES)
deflate.o: deflate.c $(HFILES)
trees.o: trees.c $(HFILES)
bits.o: bits.c $(HFILES)
zipfile.o: zipfile.c $(HFILES)
zipup.o: zipup.c $(HFILES)
fileio.o: fileio.c $(HFILES)
util.o: util.c $(HFILES)
globals.o: globals.c $(HFILES)
filedate.o: amiga/filedate.c $(HFILES)

# end of Makefile
