# Makefile for unzip30

# "make vaxbsd" -- makes unzip on a VAX 11-780 BSD 4.3 in current directory
# "make"	-- uses environment variable SYSTEM to set the type
#		   system to compile for.
# "make wombat" -- Chokes and dies if you haven't added the specifics
#		   for your Wombat 68000 (or whatever) to the systems list.
#
# CFLAGS are flags for the C compiler.  LDFLAGS are flags for the loader.
#
# My host (a VAX 11-780 running BSD 4.3) is hereafter referred to as
# "my host."
#
# My host's /usr/include/sys/param.h defines BSD for me.
# You may have to add "-DBSD" to the list of CFLAGS for your system.
#
# You MAY need to define "-DNOTINT16" if the program produces crc errors
# during a "-t" run or extraction.  (This involves structure alignment.)
# It won't HURT to define "-dNOTINT16" anyway .. but if you don't need it,
# why add to the program size, complexity, etc.?
#
# If your host is "big-endian" (as in the 68000 family) and does NOT order
# its integers and long integers in Intel fashion (low .. high), you should
# define "-DHIGH_LOW".  This insures key structure values will be "swapped"
# low end for high end.
# Some mainframes DO require this.
#
# Some systems have a shell-defined "$MAKE" (my host did not).  If not,
# use "make" instead of the "$MAKE" or "$(MAKE)" in your system's makerule.
# Or try adding the following line to your .login file:
#   setenv MAKE "make"
# (It didn't help on my host.)
#
# zmemcpy has been added to the list of required files for some systems.
# memcpy() is a normal C function that works just fine in Turbo C
# and some Unix systems, but has a problem in others (producing CRC errors).
#
# You can try a compile without zmemcpy.c, and if it works .. fine.
# (To do this, you may have to remove zmemcpy.o from your system's list
# of required OBJS files, and the "-DZMEM" from the list of CFLAGS defines.)
#
# Else use the included zmemcpy.c.
# (Again, you may have to add zmemcpy.o to your system's list of required
# OBJS files, and the "-DZMEM" to the list of CFLAGS defines.)

# To test, insure your zip file includes some LARGE members.  Many systems
# ran just fine with zip file members <512 bytes, but failed with larger ones.
#

# Defaults most systems use
CFLAGS = -O -DUNIX

CC=cc

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

# Defaults everybody uses
OBJS = unzip.o crc32.o match.o ascebc.o mapname.o
SRCS = unzip.c crc32.c match.c ascebc.c mapname.c

# You'll need these also if you include "-DZMEM" in your CFLAGS
ZMEMS = zmemset.o zmemcpy.o

# list of supported systems in this version
SYSTEMS	=xenix386 ultrix sun3 sun4 encore stellar convex vaxbsd next vaxsysV

# The below will try to use your shell variable "SYSTEM"
# as the type system to use (e.g., if you command:
# make <no parameters>
# at the command line).

default:
	if test -z "$(SYSTEM)";\
	then make ERROR;\
	else make $(SYSTEM);\
	fi

ERROR:
	@echo "Must make one of $(SYSTEMS)"
	@echo "or set shell variable SYSTEM to a legal value"
	exit 1

unzip: $(OBJS)
	cc $(LDFLAGS) -o unzip $(OBJS)

unzip.o: unzip.c

crc32.o: crc32.c

match.o: match.c

ascebc.o: ascebc.c

zmemcpy.o: zmemcpy.c

zmemset.o: zmemset.c

mapname.o: mapname.c
#
# these are the makerules for various systems
# TABS ARE REQUIRED FOR SOME VERSIONS OF make!
# DO NOT DE-TABIFY THIS FILE!
# Example:
# wombat:^I# wombat 68000
#        ^this is an ASCII 9 tab char, NOT a bunch of spaces!
#^I$(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DZMEM" \
#^IOBJS="$(OBJS) $(ZMEMS)"
#^these indentations are an ASCII 9 tab char!

xenix386:	# Xenix/386 (tested on 2.3.1)
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DZMEM" \
	OBJS="$(OBJS) $(ZMEMS)"

vaxsysV:	# from Forrest Gehrke
encore:		# Multimax
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DZMEM" \
	OBJS="$(OBJS) $(ZMEMS)"

stellar:	# gs-2000
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DZMEM" \
	OBJS="$(OBJS) $(ZMEMS)"

sun3:		# 68020, SunOS 4.0.3
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DHIGH_LOW -DZMEM" \
	OBJS="$(OBJS) $(ZMEMS)"

sun4:		# Sun 4/110, SunOS 4.0.3c
		# v2.0g Removed -DHIGH_LOW (my mistake) David Kirschbaum
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DZMEM" \
	OBJS="$(OBJS) $(ZMEMS)"

convex:		# C200/C400
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16 -DZMEM" \
	OBJS="$(OBJS) $(ZMEMS)"

# My Vax doesn't know anything about "$(MAKE)".
# I tried adding 'setenv MAKE "make" to my .login
# but it still wouldn't.  Unix wizards, to the rescue!

ultrix:		# per Greg Flint
vaxbsd:		# VAX 11-780, BSD 4.3	David Kirschbaum
#	$(MAKE) unzip
	make unzip

#From Mark Adler, madler@tybalt.caltech.edu:
#  I used "make stellar" on the NeXT and the resulting unzip
#  worked fine on all my zip test files.  Not willing to leave
#  well enough alone, I tried it without the zmem* routines by
#  adding the following to the Makefile:

next:		# 68030 BSD 4.3+Mach
	$(MAKE) unzip CFLAGS="$(CFLAGS) -DNOTINT16" \
	OBJS="$(OBJS)"

#  and using "make next".  This also worked fine, and presumably
#  is faster since the native memcpy and memset routines are
#  optimized assembler.


