#------------------------------------------------------------------------------
# Makefile for UnZip 5.x and ZipInfo 1.x                Greg Roelofs and others
# Version:  Microsoft C 5.x / Turbo C                           15 October 1992
#------------------------------------------------------------------------------

# Comment/uncomment appropriate sections for your compiler.  Users of MSC 6
# and NMAKE can use the main Makefile (target msc_dos).  Note that there is
# possibly a bug in MSC 6 which screws up funzip (goes into infinite loop?).


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

STRIP=rem
#    If you don't have LZEXE or PKLITE, get one of them. Then define:
#STRIP=lzexe
#    or
#STRIP=pklite
#    and remove /e from LDFLAGS.  This makes a big difference in
#    .exe size (and possibly load time).


# MSC 5.x-7.x for MS-DOS:
# ----------------------
CC = cl				# -Ox does not work for inflate.c
CFLAGS = -AS -Oait -Gs		# add -G2 (G3, G4) and/or -FPi87 for 80x86/80x87
LD = link
LDFLAGS = /NOI/e/st:0x1000	# remove /e if you have LZEXE or PKLITE
LDFLAGS2 = ,$*;

# Turbo C 2.0 for MS-DOS:
# ----------------------
## tcc is usually configured with -I and -L set appropriately...
#INCL = #-Ic:\turboc\include
#LIBS = c:\turboc\lib\cs.lib	# or \tc\lib\cs.lib, or ... (truly necessary?)
#CC = tcc
#CFLAGS = -ms -O -Z $(INCL)	# add -1 for 80286 instructions
#LD = tlink
#LDFLAGS = /c/x
#LDFLAGS2 = $(LIBS)


OBJS1 = unzip.obj crypt.obj envargs.obj explode.obj extract.obj file_io.obj
OBJS2 = inflate.obj mapname.obj match.obj misc.obj unreduce.obj unshrink.obj
OBJS3 = msdos.obj
OBJS = $(OBJS1) $(OBJS2) $(OBJS3)

OBJZ = zipinfo.obj envargs.obj match.obj

OBJF = funzip.obj inflate.obj


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

default:        unzip.exe zipinfo.exe funzip.exe

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

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

envargs.obj:    envargs.c unzip.h

explode.obj:    explode.c unzip.h

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

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

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

inflate.obj:    inflate.c unzip.h

mapname.obj:    mapname.c unzip.h

match.obj:      match.c unzip.h

misc.obj:       misc.c unzip.h

unreduce.obj:   unreduce.c unzip.h

unshrink.obj:   unshrink.c unzip.h

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

zipinfo.obj:    zipinfo.c unzip.h file_io.c misc.c



# DOS/MS make:
# -----------
unzip.exe:      $(OBJS)
	echo $(OBJS1)+ > unzip.rsp
	echo $(OBJS2)+ >> unzip.rsp
	echo $(OBJS3); >> unzip.rsp
	$(LD) $(LDFLAGS) @unzip.rsp
	del unzip.rsp
	$(STRIP) unzip.exe

# DOS/Borland tmake:   (is there a way to do this using the OBJS macros?)
# -----------------
#unzip.exe:     $(OBJS)
#	echo \tc\lib\c0s.obj+ > unzip.rsp
#	echo unzip+          >> unzip.rsp
#	echo crypt+          >> unzip.rsp
#	echo envargs+        >> unzip.rsp
#	echo explode+        >> unzip.rsp
#	echo extract+        >> unzip.rsp
#	echo file_io+        >> unzip.rsp
#	echo inflate+        >> unzip.rsp
#	echo mapname+        >> unzip.rsp
#	echo match+          >> unzip.rsp
#	echo misc+           >> unzip.rsp
#	echo unreduce+       >> unzip.rsp
#	echo unshrink+       >> unzip.rsp
#	echo msdos           >> unzip.rsp
#	echo $(LDFLAGS)      >> unzip.rsp
#	echo unzip.exe       >> unzip.rsp
##	echo $(LDFLAGS2)     >> unzip.rsp   # is this line (cs.lib) necessary?
#	$(LD) @unzip.rsp
#	del unzip.rsp
#	$(STRIP) unzip.exe

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



# Both makes:
# ----------
zipinfo.exe:    $(OBJZ)
	$(LD) $(LDFLAGS) $(OBJZ) $(LDFLAGS2)
	$(STRIP) zipinfo.exe

funzip.exe:     $(OBJF)
	$(LD) $(LDFLAGS) $(OBJF) $(LDFLAGS2)
	$(STRIP) funzip.exe
