# Make all FORTRAN/TK examples
# wmake [all] [calc] [edit] [example] [example_ratfor] [clean] [rc_bin=rc16] [os=OS2|WIN]
# if "os" is omitted, they will be compiled for the platform running on
# if "calc", "edit", "example" or "example_ratfor" is specified, just these
# targets will be compiled; if all targets are omitted (or you use "all"), all
# targets except example_ratfor will be compiled
# symbolic target "clean" deletes all obj/exe/res files
# if "rc_bin" is defined, the given resource compiler will be used
# (e.g. rc16 16-bit compiler under OS/2)
# "fortrantk.lib" must be in the examples\ directory

!ifndef os
!ifdef __OS2__
os = OS2
!else ifdef __NT__
os = WIN
!endif
!endif

!ifeq os OS2
os_spec     = __OS2__
sys_spec    = OS2V2
syswin_spec = OS2V2_PM
bin_spec    = BINOS2

!ifndef rc_bin
rc_bin      = rc
!endif
rcfile      = ftkicon_os2.rc
resfile     = ftkicon_os2.res

!       else ifeq os WIN

os_spec     = __WIN__
sys_spec    = NT
syswin_spec = NT_WIN
bin_spec    = BINWIN

rc_bin      = wrc
rcfile      = ftkicon_win.rc
resfile     = ftkicon_win.res
!endif

ratfor      = ratfor77

all : calc edit example .SYMBOLIC

calc : $(bin_spec)\calc.exe .SYMBOLIC
$(bin_spec)\calc.exe : calc.for fortrantk.lib ..\$(resfile)
        wfl386 $[. fortrantk.lib -FE=$^@ &
               -BM -DEF=$(os_spec) -L=$(syswin_spec)
        $(rc_bin) ..\$(resfile) $^@

edit : $(bin_spec)\edit.exe .SYMBOLIC
$(bin_spec)\edit.exe : edit.for fortrantk.lib ..\$(resfile)
        wfl386 $[. fortrantk.lib -FE=$^@ &
               -BM -DEF=$(os_spec) -L=$(syswin_spec)
        $(rc_bin) ..\$(resfile) $^@

example : $(bin_spec)\example.exe .SYMBOLIC
$(bin_spec)\example.exe : example.for fortrantk.lib ..\$(resfile)
        wfl386 $[. fortrantk.lib -FE=$^@ &
               -BM -DEF=$(os_spec) -L=$(sys_spec)
        $(rc_bin) ..\$(resfile) $^@

example_ratfor : $(bin_spec)\example_ratfor.exe .SYMBOLIC
$(bin_spec)\example_ratfor.exe : example_ratfor.for fortrantk.lib ..\$(resfile)
        wfl386 $[. fortrantk.lib -FE=$^@ &
               -BM -DEF=$(os_spec) -L=$(sys_spec)
        $(rc_bin) ..\$(resfile) $^@
example_ratfor.for : example_ratfor.r
        $(ratfor) -o $^@ $[.

..\$(resfile) : ..\$(rcfile)
        cd..
        $(rc_bin) -r $(rcfile)
        cd examples

clean : .SYMBOLIC
        if exist ..\$(resfile) del ..\$(resfile)
        if exist *.obj del *.obj
        if exist $(bin_spec)\*.exe del $(bin_spec)\*.exe
        if exist example_ratfor.for del example_ratfor.for

