.AUTODEPEND

basepath    = $(BASEPATHCC)
binpath     = $(basepath)\bin
libpath     = $(basepath)\lib
rarpath     = .
incpath     = $(basepath)\include;$(rarpath)

cc    = $(binpath)\bcc32
link  = $(binpath)\ilink32

objpath     = .
guiopt      = -WC -H=$(objpath)\rar.csm

!ifndef RARDLL
!ifndef GUI
guiopt=$(guiopt) -x-
!endif
!ifdef SFX_MODULE
guiopt=$(guiopt) -x-
!endif
!endif

!ifdef DEBUG
optdeb=-Od -k -vi- -DDEBUG
!else
# -O is not safe to use with -pr and int64 return values, so let's turn it off
optdeb=-O1 -O- -k-
#optdeb=-Ob -Oe -Og -Oi -Ol -Om -Op -OS -Ov -Z -Oc
!endif


optunrar=-DUNRAR
linkdest=unrar.exe

!ifdef SFX_MODULE
optunrar=-DUNRAR -DSFX_MODULE
linkdest=sfx.exe
!endif

linkopt = -L$(libpath) -ap -c -v -s -V4.0 -Gn
compopt = -P -c -I$(incpath) -R -v -vi -w-pch -w-par -K -f-\
          -ff- -a4 -pr -RT- $(optdeb) $(guiopt) $(optunrar) -d -w-8072

!ifdef RARDLL
SILENT=true
linkdest=unrar.dll
linkopt=$(linkopt) -Tpd
compopt=$(compopt) -DRARDLL
!else
linkopt=$(linkopt) -Tpe -B:0x400000 
!endif

!ifdef SILENT
compopt=$(compopt) -DSILENT
!endif


rar: $(linkdest)

Dep_SFX= \
   $(objpath)\strlist.obj\
   $(objpath)\strfn.obj\
   $(objpath)\pathfn.obj\
   $(objpath)\cmddata.obj\
   $(objpath)\consio.obj\
   $(objpath)\savepos.obj\
   $(objpath)\smallfn.obj\
   $(objpath)\file.obj\
   $(objpath)\filefn.obj\
   $(objpath)\filcreat.obj\
   $(objpath)\sha1.obj\
   $(objpath)\archive.obj\
   $(objpath)\arcread.obj\
   $(objpath)\unicode.obj\
   $(objpath)\system.obj\
   $(objpath)\isnt.obj\
   $(objpath)\crc.obj\
   $(objpath)\crypt.obj\
   $(objpath)\rijndael.obj\
   $(objpath)\rawread.obj\
   $(objpath)\encname.obj\
   $(objpath)\resource.obj\
   $(objpath)\match.obj\
   $(objpath)\find.obj\
   $(objpath)\timefn.obj\
   $(objpath)\getbits.obj\
   $(objpath)\rarvm.obj\
   $(objpath)\rdwrfn.obj\
   $(objpath)\options.obj\
   $(objpath)\ulinks.obj\
   $(objpath)\errhnd.obj\
   $(objpath)\volume.obj\
   $(objpath)\rs.obj\
   $(objpath)\recvol.obj\
   $(objpath)\extinfo.obj\
   $(objpath)\extract.obj\
   $(objpath)\unpack.obj\
   $(objpath)\rar.obj\
   $(objpath)\global.obj

Dep_Unrar = \
   $(objpath)\filestr.obj\
   $(objpath)\scantree.obj

Dep_Dll = \
   $(objpath)\dll.obj

#Dep_SFXOnly = $(objpath)\rtl.obj

!ifndef GUI
!ifndef SILENT
Dep_Console = \
   $(objpath)\list.obj
!endif
!endif

!ifdef SFX_MODULE
Dep = $(Dep_SFX) $(Dep_SFXOnly)
!else
Dep = $(Dep_SFX) $(Dep_Unrar)
!endif

!ifndef GUI
Dep = $(Dep) $(Dep_Console)
!endif

!ifdef RARDLL
Dep = $(Dep) $(Dep_Dll)
!endif

!ifdef GUI
$(linkdest) : $(Dep)
  echo Done
!else
$(linkdest) : $(Dep)
  $(link) @&&|
 $(linkopt) +
#!ifdef SFX_MODULE
#$(objpath)\dummy.obj+
#$(objpath)\ll.obj+
#$(objpath)\rtl.obj+
#!else
!ifdef RARDLL
$(libpath)\c0d32.obj+
!else
$(libpath)\c0x32.obj+
!endif
#!endif
$(objpath)\strlist.obj+
$(objpath)\strfn.obj+
$(objpath)\pathfn.obj+
$(objpath)\savepos.obj+
$(objpath)\smallfn.obj+
$(objpath)\global.obj+
$(objpath)\file.obj+
$(objpath)\filefn.obj+
$(objpath)\filcreat.obj+
$(objpath)\sha1.obj+
$(objpath)\archive.obj+
$(objpath)\arcread.obj+
$(objpath)\unicode.obj+
$(objpath)\system.obj+
$(objpath)\isnt.obj+
$(objpath)\crc.obj+
$(objpath)\crypt.obj+
$(objpath)\rijndael.obj+
$(objpath)\rawread.obj+
$(objpath)\encname.obj+
$(objpath)\resource.obj+
$(objpath)\match.obj+
$(objpath)\find.obj+
!ifndef SFX_MODULE
$(objpath)\filestr.obj+
$(objpath)\scantree.obj+
!endif
$(objpath)\timefn.obj+
$(objpath)\getbits.obj+
$(objpath)\rarvm.obj+
$(objpath)\rdwrfn.obj+
$(objpath)\consio.obj+
$(objpath)\cmddata.obj+
$(objpath)\options.obj+
$(objpath)\ulinks.obj+
$(objpath)\volume.obj+
$(objpath)\extinfo.obj+
$(objpath)\extract.obj+
$(objpath)\rs.obj+
$(objpath)\recvol.obj+
!ifndef SILENT
!ifndef GUI
$(objpath)\list.obj+
!endif
!endif
!ifdef RARDLL
$(objpath)\dll.obj+
!endif
$(objpath)\errhnd.obj+
$(objpath)\unpack.obj+
$(objpath)\rar.obj
$<,$*
$(libpath)\cw32.lib+
$(libpath)\import32.lib
!ifdef RARDLL
$(rarpath)\dll.def
!else

!endif
|
!endif

$(objpath)\rar.obj :  $(rarpath)\rar.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rar.cpp
|

$(objpath)\strlist.obj :  $(rarpath)\strlist.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\strlist.cpp
|

$(objpath)\strfn.obj :  $(rarpath)\strfn.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\strfn.cpp
|

$(objpath)\pathfn.obj :  $(rarpath)\pathfn.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\pathfn.cpp
|

$(objpath)\savepos.obj :  $(rarpath)\savepos.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\savepos.cpp
|

$(objpath)\smallfn.obj :  $(rarpath)\smallfn.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\smallfn.cpp
|

$(objpath)\global.obj :  $(rarpath)\global.cpp
  $(cc) -q @&&|
 $(compopt) -H- -o$@ $(rarpath)\global.cpp
|

$(objpath)\file.obj :  $(rarpath)\file.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\file.cpp
|

$(objpath)\filefn.obj :  $(rarpath)\filefn.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\filefn.cpp
|

$(objpath)\filestr.obj :  $(rarpath)\filestr.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\filestr.cpp
|

$(objpath)\filcreat.obj :  $(rarpath)\filcreat.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\filcreat.cpp
|

$(objpath)\sha1.obj :  $(rarpath)\sha1.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\sha1.cpp
|

$(objpath)\archive.obj :  $(rarpath)\archive.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\archive.cpp
|

$(objpath)\arcread.obj :  $(rarpath)\arcread.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\arcread.cpp
|

$(objpath)\unicode.obj :  $(rarpath)\unicode.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\unicode.cpp
|

$(objpath)\system.obj :  $(rarpath)\system.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\system.cpp
|

$(objpath)\isnt.obj :  $(rarpath)\isnt.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\isnt.cpp
|

$(objpath)\crc.obj :  $(rarpath)\crc.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\crc.cpp
|

$(objpath)\crypt.obj :  $(rarpath)\crypt.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\crypt.cpp
|

$(objpath)\rijndael.obj :  $(rarpath)\rijndael.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rijndael.cpp
|

$(objpath)\rawread.obj :  $(rarpath)\rawread.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rawread.cpp
|

$(objpath)\rawwrite.obj :  $(rarpath)\rawwrite.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rawwrite.cpp
|

$(objpath)\encname.obj :  $(rarpath)\encname.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\encname.cpp
|

$(objpath)\resource.obj :  $(rarpath)\resource.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\resource.cpp
|

$(objpath)\match.obj :  $(rarpath)\match.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\match.cpp
|

$(objpath)\find.obj :  $(rarpath)\find.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\find.cpp
|

$(objpath)\scantree.obj :  $(rarpath)\scantree.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\scantree.cpp
|

$(objpath)\timefn.obj :  $(rarpath)\timefn.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\timefn.cpp
|

$(objpath)\getbits.obj :  $(rarpath)\getbits.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\getbits.cpp
|

$(objpath)\rarvm.obj :  $(rarpath)\rarvm.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rarvm.cpp
|

$(objpath)\putbits.obj :  $(rarpath)\putbits.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\putbits.cpp
|

$(objpath)\pack.obj :  $(rarpath)\pack.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\pack.cpp
|

$(objpath)\packbord.obj :  $(rarpath)\packbord.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\packbord.cpp
|

$(objpath)\packanlz.obj :  $(rarpath)\packanlz.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\packanlz.cpp
|

$(objpath)\cblock.obj :  $(rarpath)\cblock.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\cblock.cpp
|

$(objpath)\add.obj :  $(rarpath)\add.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\add.cpp
|

$(objpath)\addlist.obj :  $(rarpath)\addlist.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\addlist.cpp
|

$(objpath)\procarc.obj :  $(rarpath)\procarc.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\procarc.cpp
|

$(objpath)\sfx.obj :  $(rarpath)\sfx.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\sfx.cpp
|

$(objpath)\comment.obj :  $(rarpath)\comment.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\comment.cpp
|

$(objpath)\rs.obj :  $(rarpath)\rs.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rs.cpp
|

$(objpath)\recvol.obj :  $(rarpath)\recvol.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\recvol.cpp
|

$(objpath)\repair.obj :  $(rarpath)\repair.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\repair.cpp
|

$(objpath)\rdwrfn.obj :  $(rarpath)\rdwrfn.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rdwrfn.cpp
|

$(objpath)\consio.obj :  $(rarpath)\consio.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\consio.cpp
|

$(objpath)\cmddata.obj :  $(rarpath)\cmddata.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\cmddata.cpp
|

$(objpath)\options.obj :  $(rarpath)\options.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\options.cpp
|

$(objpath)\ulinks.obj :  $(rarpath)\ulinks.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\ulinks.cpp
|

$(objpath)\errhnd.obj :  $(rarpath)\errhnd.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\errhnd.cpp
|

$(objpath)\volume.obj :  $(rarpath)\volume.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\volume.cpp
|

$(objpath)\extinfo.obj :  $(rarpath)\extinfo.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\extinfo.cpp
|


$(objpath)\extract.obj :  $(rarpath)\extract.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\extract.cpp
|

$(objpath)\list.obj :  $(rarpath)\list.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\list.cpp
|

$(objpath)\rtl.obj :  $(rarpath)\rtl.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\rtl.cpp
|

$(objpath)\unpack.obj :  $(rarpath)\unpack.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\unpack.cpp
|

$(objpath)\dll.obj :  $(rarpath)\dll.cpp
  $(cc) -q @&&|
 $(compopt) -o$@ $(rarpath)\dll.cpp
|