####################################################################
###
###  makefile
###
###  Makefile for the Windows Sockets Wormhole project.
###
###  If CPU is undefined, then assume we're building for DOS
###  Windows 3.1. Otherwise, CPU should be either i386 or MIPS
###  (case sensitive!).
###
####################################################################

!IF "$(CPU)" != ""
OS  = NT
ENV = WIN32
!ELSE   # CPU == ""
OS  = DOS
ENV = WIN16
!ENDIF  # CPU != "


###
###  Include the target dependent makefile options.
###

!include <$(OS)$(ENV).MAK>


###
###  Define a few collections to simplify things a bit.
###

INCL = wormcons.h wormdata.h wormhole.h wormproc.h wormtype.h
OBJ0 = client.obj dialogs.obj frame.obj globals.obj
OBJ1 = init.obj server.obj utility.obj wormhole.obj


###
###  Standard targets.
###

all: wormhole.exe

clean:
    -del *.obj
    -del *.res
    -del *.exe
!IFDEF CPUTYPE
    -del wormhole.rbj
!ENDIF  # CPUTYPE


###
###  General build rule.
###

.c.obj:
    $(cc) $(cflags) $(cdebug) $(cvars) -DSTRICT $*.c


###
###  The guts.
###

wormhole.res: wormhole.rc wormhole.dlg client.ico frame.ico server.ico $(INCL)
    rc $(rcvars) -r -fo $*.res $*.rc
!IFDEF CPUTYPE
    cvtres -$(CPU) $*.res -o $*.rbj
!ENDIF  # CPUTYPE

client.obj: client.c $(INCL)

dialogs.obj: dialogs.c $(INCL)

frame.obj: frame.c $(INCL)

globals.obj: globals.c $(INCL)

init.obj: init.c $(INCL)

server.obj: server.c $(INCL)

utility.obj: utility.c $(INCL)

wormhole.obj: wormhole.c $(INCL)


###
###  There are enough differences in the linker options
###  that they are handled separately.
###

wormhole.exe: $(OBJ0) $(OBJ1) wormhole.res wormhole.def
!IFDEF CPUTYPE
    $(link) @<<
$(ldebug)
$(guiflags)
-out:wormhole.exe
$(OBJ0)
$(OBJ1)
$(guilibs) wsock32.lib shell32.lib
wormhole.rbj
<<
!ELSE   # !CPUTYPE
    $(link) @<<
$(ldebug) $(guiflags) +
$(OBJ0) +
$(OBJ1)
wormhole.exe

$(guilibs) winsock.lib shell.lib
wormhole.def
<<
    rc wormhole.res
!ENDIF  # CPUTYPE

