@#
@#  This file is part of Bakefile (http://www.bakefile.org)
@#
@#  Copyright (C) 2003-2007 Vaclav Slavik
@#
@#  Permission is hereby granted, free of charge, to any person obtaining a
@#  copy of this software and associated documentation files (the "Software"),
@#  to deal in the Software without restriction, including without limitation
@#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
@#  and/or sell copies of the Software, and to permit persons to whom the
@#  Software is furnished to do so, subject to the following conditions:
@#
@#  The above copyright notice and this permission notice shall be included in
@#  all copies or substantial portions of the Software.
@#
@#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
@#  DEALINGS IN THE SOFTWARE.
@#
@#  $Id: watcom.empy 1280 2009-01-04 21:34:52Z vaclavslavik $
@#
@{
# helper functions:
def makeCondBegin(c):
    s = ''
    for e in c.exprs:
        s += '!ifeq %s %s\n' % (e.option.name, e.value)
    return s.strip()
def makeCondEnd(c):
    s = ''
    for e in range(0,len(c.exprs)):
        s += '!endif\n'
    return s.strip()
}@
@empy.include(os.path.join(RULESDIR, '_hdr_makefile.empy'))
@[if OPTIONS_FILE != '']!include @OPTIONS_FILE
@[end if]@
@[if OPTIONS_FILE == '']@
@empy.include(os.path.join(RULESDIR, 'watcom-opts.empy'))
@[end if]@

# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------

# Speed up compilation a bit:
!ifdef __LOADDLL__
!  loaddll wcc      wccd
!  loaddll wccaxp   wccdaxp
!  loaddll wcc386   wccd386
!  loaddll wpp      wppdi86
!  loaddll wppaxp   wppdaxp
!  loaddll wpp386   wppd386
! if $(__VERSION__) >= 1280
!  loaddll wlink    wlinkd
! else
!  loaddll wlink    wlink
! endif
!  loaddll wlib     wlibd
!endif

# We need these variables in some bakefile-made rules:
WATCOM_CWD = $+ $(%cdrive):$(%cwd) $-

### Conditionally set variables: ###

@[for c in cond_vars]@
@c.name =
@[for v in c.values]@
@makeCondBegin(v.cond)
@utils.wrapLongLine('%s = ' % c.name, v.value, ' &', variable=c.name)
@makeCondEnd(v.cond)
@[end for]@
@[end for]@

### Variables: ###

@[for v in make_vars]@
@utils.wrapLongLine('%s = ' % v.name, v.value, ' &', variable=v.name)
@[end for]@

@[if BUILDDIR != '.']
all : @BUILDDIR
@BUILDDIR :
@\t-if not exist @BUILDDIR mkdir @BUILDDIR
@[end if]@

### Targets: ###
@[for t in targets]
@[if t.cond != None]@makeCondBegin(t.cond)
@[end if]@
@t.__targetdir@t.__targetname : @[if t.__is_phony=='1'].SYMBOLIC@[end if] @t.__deps
@[for cmd in t.__command.splitlines()]@
@(cmd.strip()=='|' ? '|' : '\t'+cmd.strip())
@[end for]@
@[if t.cond != None]@makeCondEnd(t.cond)
@[end if]@
@[end for]@

@[for f in fragments]
@f.content
@[end for]@
