# File:         makewat.env
# Purpose:      Watcom environments for wxWindows makefiles.
# Author:       Julian Smart and others
#
# The main things to change are:
#
#   WATCOM:    set to where the compiler is installed
#   WXDIR:     set to where the wxWindows is installed
#   MODE:      set to windows [16 bit windows], nt [win32s], or win386 [32-bit non-WIN32]

FINAL=0
WATCOMDIR=$(%WATCOM)
#.EXTENSIONS: .exe .obj .c .cc .cpp .res .rc .def

# Set this to win386 if compiling under WIN386 mode, or
# to windows for normal 16-bit Windows, nt if compiling for WIN32s/NT
MODE= nt # windows

WXDIR = c:\wx
WXINC = $(WXDIR)\include\msw
WXBASEINC = $(WXDIR)\include\base

# Suffixes
OBJSUFF=obj
SRCSUFF=cpp

DEBUG=0

!ifneq NOPRECOMP 1
PRECOMP     = /fh=$(WXDIR)\src\msw\watcom.pch
!endif

RC = wrc

!ifeq MODE win386

##### WIN386 OPTIONS

# Set LEVEL to 386 if using 32-bit compilation
LEVEL       = 386
CCC         = wpp$(LEVEL)
CC         =  wcc$(LEVEL)
OS_TARGET   = win386
MODEL       =
LINKOPTION  = win386
BINDCOMMAND = wbind
WATLIBDIR = $(WATCOMDIR)\lib386\win
MINDATA     = option mindata=100K
MAXDATA     = option maxdata=100K
STACK       = option stack=64k
EXTRALIBS   = $(WXDIR)\contrib\ctl3d\ctl3d32.obj 
IFLAGS      = -i=$(WXINC) -i=$(WXBASEINC) -i=$(WXDIR)\contrib\fafa -i=$(%watcom)\h;$(%watcom)\h\win
RESFLAGS1   = -r -bt=windows /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
RESFLAGS2   = -R $(name) /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
DEBUGINFO   = debug all

#CPPFLAGS    = /zw /w1 /zq /d2 /d__WIN386__ /zt4 $(MODEL) /d__WINDOWS__
CPPFLAGS    = /zw /w1 /zq /d1 /d__WIN386__ $(MODEL) $(PRECOMP) /d__WINDOWS__ $(EXTRACPPFLAGS)

!endif
#### END WIN386 MODE

!ifeq MODE windows

##### 16-BIT WINDOWS OPTIONS

# Set LEVEL to 386 if using 32-bit compilation
LEVEL       =
CCC         = wpp$(LEVEL)
CC          = wcc$(LEVEL)
OS_TARGET   = windows
MODEL       =/ml
LINKOPTION  = windows
BINDCOMMAND = echo
WATLIBDIR = $(WATCOMDIR)\lib286\win
MINDATA     =
MAXDATA     =
STACK       =
EXTRALIBS=$(WATLIBDIR)\shell.lib $(WATLIBDIR)\ddeml.lib $(WATLIBDIR)\ctl3d.lib $(WATLIBDIR)\commdlg.lib $(WATLIBDIR)\mmsystem.lib
IFLAGS      = -i=$(WXINC) -i=$(WXBASEINC) -i=$(WXDIR)\contrib\fafa 
RESFLAGS1   = -r -bt=windows -i=$(WXINC) -i=$(WXDIR)\contrib\fafa 
RESFLAGS2   = -R
DEBUGINFO   = debug all

#-i=$(WXDIR)\contrib\itsybits

# Note: I've added the data threshold (/zt4) for 16-bit operation,
# or we get link failure (TEXT segment overflow). Is this OK for
# 32-bit mode also? -- JACS
# An alternative might be /zc (put string literals in code segment).
#CPPFLAGS    = /zw /w1 /zq /d1 /zt4 $(MODEL) /d__WINDOWS__
CPPFLAGS    = /zw /w2 /zq /d1 $(MODEL) $(PRECOMP) /d__WINDOWS__ $(EXTRACPPFLAGS)

!endif
#### END WINDOWS MODE

!ifeq MODE nt

##### NT OPTIONS

LEVEL       = 386
CCC         = wpp$(LEVEL)
CC         =  wcc$(LEVEL)
OS_TARGET   = nt_win
MODEL       =
# If you use win95, assumptions will be made about Win95 icon format etc.
# so nt_win is probably better for simultaneous Win32s/Win95/NT operation.
LINKOPTION  = nt_win # win95
BINDCOMMAND = wrc
WATLIBDIR   = $(WATCOMDIR)\lib386\nt
MINDATA     =
MAXDATA     =
STACK       = option stack=64k
EXTRALIBS   = $(WATLIBDIR)\ctl3d32.lib $(WATLIBDIR)\odbc32.lib
IFLAGS      = -i=$(WXINC) -i=$(WXBASEINC) -i=$(WXDIR)\contrib\fafa -i=$(%watcom)\h;$(%watcom)\h\nt
RESFLAGS1   = -r -bt=nt /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
RESFLAGS2   = -R $(name) /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa
DEBUGINFO   = debug all # Linking: comment out if operating in a non-debuggable environment

#-i=$(WXDIR)\contrib\itsybits

# Here are some possible optimization flags:
# /5r  Pentium timings
# /fp5 /fpi87 Inline 80x87 instructions optimized for Pentium: coprocessor must be present
# /ox  Standard optimizations
# /or  Reordering for Pentium timings (included in /ox)
# The Watcom-recommended flags for optimum Pentium speed are:
# /oneatx /zp4 /5 /fpi87 /fp5

OPTFLAGS=/ox /5r # /DDEBUG=1

# /d1 for line numbers only: anything else produces an enormous wx32.lib
CPPFLAGS    = /bt=nt /w1 /D__WIN32__ /zq $(OPTFLAGS) $(MODEL) $(PRECOMP) /d1 /d__WINDOWS__ $(EXTRACPPFLAGS)

!endif
#### END NT MODE

.cpp.obj: # $< # .AUTODEPEND
    *$(CCC) $(CPPFLAGS) $(IFLAGS) $<

#    %create tmp.lbc
#    @%append tmp.lbc $(CPPFLAGS) $(IFLAGS) $<
#    echo $<
#    $(CCC) @tmp.lbc

.c.obj: # $< # .AUTODEPEND
    *$(CC) $(CPPFLAGS) $(IFLAGS) $<

# This doesn't work for wcc
#    %create tmp.lbc
#    @%append tmp.lbc $(CPPFLAGS) $(IFLAGS) $<
#    echo $<
#    $(CC) @tmp.lbc

dummy:  .SYMBOLIC
    @echo Please give a target for wxWin makefiles: the usual one is 'all'.

erasepch:   .SYMBOLIC
    -erase $(WXDIR)\src\msw\watcom.pch
