#
#  Makefile for Waterloo TCP sample applications
#
#  Borland (real-mode) & High-C/Pharlap (prot-mode)
#  executables. Use `makefile.dj' to make djgpp executables.
#

.AUTODEPEND
.SWAP

#
# Uncomment to enable profiling for Metaware High-C
# Copy this file from your Metaware installation and
# make if read-only.
#
# MW_PROF = mwprof.obj

MODEL  = l
CFLAGS = -m$(MODEL) -v -ls -f87 -I..\inc -I..\src -L ..\lib\wattcpb$(MODEL).lib
#CFLAGS = -DMAKE_TSR $(CFLAGS)

PROGS  = ping.exe    popdump.exe rexec.exe   tcpinfo.exe cookie.exe  \
         daytime.exe dayserv.exe finger.exe  host.exe    lpq.exe     \
         lpr.exe     ntime.exe   ph.exe      stat.exe    htget.exe   \
         revip.exe   tcptalk.exe uname.exe   whois.exe   tcpport.exe \
       # blather.exe lister.exe  tracert.exe vlsm.exe

PROGS32 = ping.exp    popdump.exp rexec.exp   tcpinfo.exp cookie.exp  \
          daytime.exp dayserv.exp finger.exp  host.exp    lpq.exp     \
          lpr.exp     ntime.exp   ph.exp      stat.exp    htget.exp   \
          revip.exp   tracert.exp tcptalk.exp uname.exp   vlsm.exp    \
          whois.exp   blather.exp lister.exp  ident.exp


all:  $(PROGS)
      @echo Real-mode binaries done

flat: $(PROGS32)
      @echo Protected-mode (PharLap) binaries done

$(PROGS32): 386link.arg

tcptalk.exp: 386link.arg
      hc386 -g -c -w3 -I..\inc $*.c
      386link $*.obj -exe $*.exp -lib conio @386link.arg

.c.exe:
      bcc $(CFLAGS) $*.c

.c.exp:
      hc386 -g -c -w3 -I..\inc $*.c
      386link $(MW_PROF) $*.obj -exe $*.exp @386link.arg

386link.arg: makefile
      copy &&|
        -lib hc386,hc387,hcna       # MetaWare High-C libraries
        -lib dosx32                 # PharLap DOSX API library
        -lib ..\lib\wattcphf        # Waterloo TCP/IP for MetaWare/PharLap
        -lib exc_hc                 # Exception handler library
        -offset 1000h               # start at 4kB (trap 0-pointer access)
        -stack 50000                # allocate stack
        -386                        # 386 (or later) processor target
        -twocase                    # case sensitive link
        -nostub                     # don't prepend a stub
        -unprivileged               # run at ring 3
        -fullwarn                   # give all warnings
        -maxdata 0                  # limit data to what we use (no heap)
        -fullseg                    # Make segment listing
!if $d(MW_PROF)
        -realbreak end_real         # profiler uses real-code
        -cvsymbols                  # CodeView symbol format
!else
        -symbols                    # -symbols (386debug) or -cvsymbols (Mdb)
!endif
        -publist both               # map-list by name and address
        -purge none *
        -mapnames 30
        -mapwidth 132
        -pack                       # pack BSS segment
| $<

clean:
        @del *.obj
        @del *.map
love:
        @echo not war!
