#------------------------------------------------------------------------------
# Makefile for UnZip 5.11 and later                     Greg Roelofs and others
# Version:  Microsoft C (5.x and later)                          11 August 1994
#------------------------------------------------------------------------------

# Users of MSC 6/7 and NMAKE can use the Unix Makefile (target msc_dos),
# if desired.  This makefile works just fine, too, however.  OS/2 users
# can cross-compile using os2/makefile.os2 (target mscdos).  Note that
# there is possibly a bug in MSC 6 which screws up funzip (goes into
# infinite loop? --this has not been confirmed in over a year...).  There
# is definitely a bug (internal compiler error) in MSC 6.00 while com-
# piling explode.c (fixed in 6.0a, 6.0ax, 6.0ax2, 7.*, 8.*).


#    GNU make doesn't like the return value from "rem"
#STRIP=rem
STRIP=echo  Ignore this line.  
#    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).

#    Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
#    should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
#    to the declaration of LOC here:
LOC = $(LOCAL_UNZIP) 

# small model (should work now, but if problems, use L)
MODEL=S

CC = cl		# -Ox does not work for inflate.c
# add -G2(3,4) for 286 (386, 486) and/or -FPi87 for 80x87:
CFLAGS = -nologo -DMSC $(LOC) -Oait -Gs -I.

LD = link
LDFLAGS = /nologo/noi/e/st:0x0c00   # remove /e if you have LZEXE or PKLITE
LDFLAGS2 = ,$*;

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

OBJX = unzip_.obj crypt.obj extract_.obj file_io.obj inflate.obj match.obj\
  msdos_.obj

OBJF = funzip.obj crypt_.obj inflate_.obj


default:        unzip.exe funzip.exe unzipsfx.exe

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

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

crypt_.obj:       crypt.c unzip.h crypt.h zip.h
	$(CC) -c -AS $(CFLAGS) -DFUNZIP -Focrypt_.obj crypt.c

envargs.obj:      envargs.c unzip.h

explode.obj:      explode.c unzip.h

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

extract_.obj:     extract.c unzip.h crypt.h
        $(CC) -c -A$(MODEL) $(CFLAGS) -DSFX -Foextract_.obj extract.c

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

funzip.obj:       funzip.c unzip.h crypt.h tables.h
        $(CC) -c -AS $(CFLAGS) funzip.c

inflate.obj:      inflate.c unzip.h

inflate_.obj:     inflate.c inflate.h unzip.h crypt.h
	$(CC) -c -AS $(CFLAGS) -DFUNZIP -Foinflate_.obj inflate.c

match.obj:        match.c unzip.h

msdos.obj:        msdos/msdos.c unzip.h
        $(CC) -c -A$(MODEL) $(CFLAGS) msdos/msdos.c

msdos_.obj:       msdos/msdos.c unzip.h
        $(CC) -c -A$(MODEL) $(CFLAGS) -DSFX -Fomsdos_.obj msdos/msdos.c

unreduce.obj:     unreduce.c unzip.h

unshrink.obj:     unshrink.c unzip.h

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

unzip_.obj:       unzip.c unzip.h crypt.h version.h
        $(CC) -c -A$(MODEL) $(CFLAGS) -DSFX -Founzip_.obj unzip.c

zipinfo.obj:      zipinfo.c unzip.h


# 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

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

# both makes:
# ----------
funzip.exe:     $(OBJF)
	$(LD) $(LDFLAGS) $(OBJF) $(LDFLAGS2)
	$(STRIP) funzip.exe

unzipsfx.exe:     $(OBJX)
	echo $(OBJX), $@; > unzipsfx.rsp
	$(LD) $(LDFLAGS) @unzipsfx.rsp
	del unzipsfx.rsp
	$(STRIP) unzipsfx.exe
