<?xml version="1.0" ?>
<!--

  This file is part of Bakefile (http://www.bakefile.org)

  Copyright (C) 2003-2008 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: makefile_defs_unix.bkl 1334 2010-02-06 17:08:31Z vaclavslavik $

  This file is common to all formats that share Unix way of writing 
  makefiles (most notably GNU Make and Autoconf formats).

-->
<makefile>
    
    <set var="FORMAT_HAS_MAKE_INSTALL">1</set>
    
    <option name="AR"><default-value>ar</default-value></option>
    <option name="AROPTIONS"><default-value>rcu</default-value></option>
    <option name="RANLIB"><default-value>ranlib</default-value></option>

    <set var="DIRSEP">/</set>

    <set var="OBJEXT">.o</set>
    <set var="LIBEXT" overwrite="0">.a</set>
    <set var="LIBPREFIX" overwrite="0">lib</set>
    <set var="EXEEXT" overwrite="0"></set>
    <set var="DLLEXT" overwrite="0">.so</set>
    <set var="DLLEXT_MODULE" overwrite="0">$(DLLEXT)</set>
    <set var="DLLIMPEXT" overwrite="0">$(DLLEXT)</set>
    <set var="DLLPREFIX" overwrite="0">$(LIBPREFIX)</set>
    <set var="DLLPREFIX_MODULE" overwrite="0">$(DLLPREFIX)</set>
    <set var="PIC_CFLAGS" overwrite="0">-fPIC -DPIC</set>

   <set var="RM">rm -f</set>

    <set var="INSTALL_PROGRAM" overwrite="0">install -c</set>
    <set var="INSTALL_DATA" overwrite="0">$(INSTALL) -m 644</set>
    <set var="INSTALL_DIR" overwrite="0">$(INSTALL) -d</set>

    <set var="UNINSTALL_PROGRAM" overwrite="0">$(RM)</set>
    <set var="UNINSTALL_DATA" overwrite="0">$(RM)</set>
    <set var="UNINSTALL_DIR" overwrite="0">$(RM) -r</set>


    <set var="__DEFINE_ARG">-D</set>
    <set var="__INCLUDE_ARG">-I</set>
    <set var="__LIB_ARG">-l%s</set>
    <set var="__LIBDIR_ARG">-L</set>

    <set var="__DEFAULT_CC">cc</set>
    <set var="__DEFAULT_CXX">c++</set>
    <set var="__DEFAULT_CFLAGS"></set>
    <set var="__DEFAULT_CPPFLAGS"></set>
    <set var="__DEFAULT_CXXFLAGS"></set>
    <set var="__DEFAULT_OBJCFLAGS"></set>
    <set var="__DEFAULT_OBJCXXFLAGS"></set>
    <set var="__DEFAULT_LDFLAGS"></set>
    
    <set var="__LINKER_CC" eval="0">$(CC)</set>
    <set var="__LINKER_CXX" eval="0">$(CXX)</set>

    <set var="CCC" overwrite="0" eval="0">$(CC)</set>
    <set var="CXXC" overwrite="0" eval="0">$(CXX)</set>
    
    <!-- 
    basic compiler/linker flags (they are left almost empty because
    it is configure's job to ensure correct cflags):
    -->
    <set var="__FLAG_EXE_CONSOLE"></set>
    <set var="__FLAG_EXE_GUI" overwrite="0"></set>
    <set var="__FLAG_DEBUG_ON"></set>
    <set var="__FLAG_DEBUG_ON_LINKER"></set>
    <set var="__FLAG_DEBUG_OFF"></set>
    <set var="__FLAG_DEBUG_OFF_LINKER"></set>
    <set var="__FLAG_OPTIMIZE_OFF"></set>
    <set var="__FLAG_OPTIMIZE_SIZE"></set>
    <set var="__FLAG_OPTIMIZE_SPEED"></set>
    <set var="__FLAG_ARCH_I386"></set>
    <set var="__FLAG_ARCH_I486"></set>
    <set var="__FLAG_ARCH_I586"></set>
    <set var="__FLAG_ARCH_I686"></set>
    <set var="__FLAG_USE_PCH"></set>
    <set var="__FLAG_PCH_FILE"></set>
    <set var="__FLAG_SINGLE_THREADING_LD"/>
    <set var="__FLAG_MULTI_THREADING_LD"/>
    <set var="__FLAG_SINGLE_THREADING_CPP"/>
    <set var="__FLAG_MULTI_THREADING_CPP"/>
    <set var="__FLAG_WARNINGS_NO"/>
    <set var="__FLAG_WARNINGS_DEFAULT"/>
    <set var="__FLAG_WARNINGS_MAX"/>
    <set var="__FLAG_RTTI_ON"></set>
    <set var="__FLAG_RTTI_OFF"></set>
    <set var="__FLAG_EXCEPTIONS_ON"></set>    
    <set var="__FLAG_EXCEPTIONS_OFF"></set>

    <!--
     GNU make allows use of $< in non-suffix rules, but some other makes
     (e.g. *BSD one) don't, we have to use full source name (and generate
     larger files). See here for more details:
     https://sourceforge.net/tracker/?func=detail&aid=949940&group_id=83016&atid=568029
     (See makefile_defs_gnu.bkl for GNU-specific code)
     -->
    <if cond="FORMAT not in ['gnu','suncc']">
        <template id="__commands_templ_C">
            <set var="__COMPILE_C_CMD" eval="0">
                $(CCC) -c -o $@ $(__cflags) $(src)
            </set>
        </template>
        <template id="__commands_templ_CXX">
            <set var="__COMPILE_CXX_CMD" eval="0">
                $(CXXC) -c -o $@ $(__cxxflags) $(src)
            </set>
        </template>
        <!-- FIXME: We should allow for a different Objective-C compiler -->
        <template id="__commands_templ_OBJC">
            <set var="__COMPILE_OBJC_CMD" eval="0">
                $(CCC) -c -o $@ $(__objcflags) $(src)
            </set>
        </template>
        <!-- FIXME: We should allow for a different Objective-C++ compiler -->
        <template id="__commands_templ_OBJCXX">
            <set var="__COMPILE_OBJCXX_CMD" eval="0">
                $(CXXC) -c -o $@ $(__objcxxflags) $(src)
            </set>
        </template>
    </if>


    <template id="__commands_templ">
        <!-- arguments to linker in correct order (see
             http://www.bakefile.org/attachment/ticket/182): -->
        <set var="__ldargs" eval="0">
            <if cond="FORMAT!='autoconf'">$(__ldflags_all) $(__ldlibs)</if>
            <if cond="FORMAT=='autoconf'">$(__ldflags_all) $(__ldlibs) $(LIBS)</if>
        </set>

        <set var="__LINK_EXE_CMD" eval="0">
            $(__linker) -o $@ $(__objects_var) $(__ldargs)
        </set>        
        <set var="__LINK_LIB_CMD" eval="0">
            $(RM) $@
            $(AR) $(AROPTIONS) $@ $(__objects_var)
            $(RANLIB) $@
        </set>
        <set var="__LINK_DLL_CMD" eval="0">
            $(__dll_linker) $@ $(__objects_var) $(__ldargs)
        </set>
        <set var="__LINK_MODULE_CMD" eval="0">
            $(__module_linker) $@ $(__objects_var) $(__ldargs)
        </set>
    </template>
    
    <template id="__subproject_templ">
        <set var="__installable">yes</set>
        <set var="__MAKE_SUBPROJECT_CMD" eval="0">
            (cd $(__subdir) &amp;&amp; $(DOLLAR)(MAKE) $(__subtarget))
        </set>
        <set var="__INSTALL_SUBPROJECT_CMD" eval="0">
            (cd $(__subdir) &amp;&amp; $(DOLLAR)(MAKE) install)
        </set>
        <set var="__UNINSTALL_SUBPROJECT_CMD" eval="0">
            (cd $(__subdir) &amp;&amp; $(DOLLAR)(MAKE) uninstall)
        </set>
        <set var="__CLEAN_SUBPROJECT_CMD" eval="0">
            -(cd $(__subdir) &amp;&amp; $(DOLLAR)(MAKE) clean)
        </set>
    </template>

</makefile>
