<?xml?>

<gwbuild>

  <project name="aqhome" version="0.0.17" so_current="0" so_age="0" so_revision="17" write_config_h="TRUE">
    <setVar name="package">$(project_name)</setVar>
    <setVar name="version">
      $(project_vmajor).$(project_vminor).$(project_vpatchlevel)
    </setVar>
    <define name="PACKAGE" value="$(package)"  quoted="TRUE" />



    <!-- version -->
    <setVar name="AQHOME_VERSION_MAJOR">$(project_vmajor)</setVar>
    <setVar name="AQHOME_VERSION_MINOR">$(project_vminor)</setVar>
    <setVar name="AQHOME_VERSION_PATCHLEVEL">$(project_vpatchlevel)</setVar>
    <setVar name="AQHOME_VERSION_BUILD">$(project_vbuild)</setVar>
    <setVar name="AQHOME_VERSION_TAG">$(project_vtag)</setVar>
    <setVar name="AQHOME_SO_CURRENT">$(project_so_current)</setVar>
    <setVar name="AQHOME_SO_REVISION">$(project_so_revision)</setVar>
    <setVar name="AQHOME_SO_AGE">$(project_so_age)</setVar>
    <setVar name="AQHOME_SO_EFFECTIVE">$(project_so_effective)</setVar>
    <setVar name="AQHOME_VERSION_STRING">
      $(project_vmajor).$(project_vminor).$(project_vpatchlevel)
    </setVar>
    <setVar name="AQHOME_VERSION_FULL_STRING">
      $(project_vmajor).$(project_vminor).$(project_vpatchlevel).$(project_vbuild)$(project_vtag)
    </setVar>
    <define name="AQHOME_VERSION_STRING" value="$(AQHOME_VERSION_STRING)" quoted="TRUE" />



    <!-- prefix handling -->
    <option id="prefix" type="string">
      <default>/usr/local</default>
    </option>
    <setVar name="prefix">$(option_prefix)</setVar>
    <setVar name="exec_prefix">$(option_prefix)/bin</setVar>
    <setVar name="sysconfdir">$(option_prefix)/etc</setVar>
    <setVar name="bindir">$(option_prefix)/bin</setVar>
    <setVar name="sbindir">$(option_prefix)/sbin</setVar>
    <setVar name="libdir">$(option_prefix)/lib</setVar>
    <setVar name="includedir">$(option_prefix)/include</setVar>
    <setVar name="datarootdir">$(option_prefix)/share</setVar>
    <setVar name="datadir">$(option_prefix)/share</setVar>
    <setVar name="rtdatadir">$(option_prefix)/var/lib</setVar>
    <setVar name="localedir">$(option_prefix)/share/locale</setVar>

    <setVar name="pkglibdir">$(libdir)/$(package)</setVar>
    <setVar name="pkgincludedir">$(includedir)/aqhome/$(package)</setVar>
    <setVar name="pkgdatadir">$(datadir)/$(package)</setVar>

    <setVar name="httpdatadir">/var/www</setVar>

    <option id="enable_testcode" type="string">
      <default>TRUE</default>
      <choices>TRUE FALSE</choices>
    </option>
    <ifVarMatches name="option_enable_testcode" value="TRUE" >
      <define name="AQHOME_ENABLE_TESTCODE" value="1" />
    </ifVarMatches>


    <option id="local_install" type="string">
      <default>FALSE</default>
      <choices>TRUE FALSE</choices>
    </option>
    <ifVarMatches name="option_local_install" value="TRUE" >
      <define name="ENABLE_LOCAL_INSTALL" value="1" />
    </ifVarMatches>


    <option id="debug" type="string">
      <default>TRUE</default>
      <choices>TRUE FALSE</choices>
    </option>
    <ifVarMatches name="option_debug" value="TRUE" >
      <setVar name="CFLAGS">
        -ggdb -Wall -Og -W
         -Wbad-function-cast  -Wmissing-parameter-type
         -Wnested-externs -Wstringop-overflow=2
         -Wdeclaration-after-statement -Wpointer-sign
         -Wunused-parameter
      </setVar>
      <setVar name="CXXFLAGS">-ggdb -Wall -Og</setVar>
    </ifVarMatches>



    <!-- paths -->
    <ifVarMatches name="GWBUILD_SYSTEM" value="windows" > <!-- long version of IF statement with THEN and ELSE -->
      <then>
        <define name="OS_WIN32" value="1" />
        <setVar name="aqhome_sys_is_windows">1</setVar>
        <setVar name="aqhome_cfg_searchdir">etc</setVar>
        <setVar name="aqhome_locale_searchdir">share/locale</setVar>
        <setVar name="aqhome_data_searchdir">share"</setVar>
        <setVar name="aqhome_rtdata_searchdir">var/lib</setVar>
      </then>
      <else>
        <define       name="OS_POSIX" value="1" />
        <setVar       name="aqhome_sys_is_windows">0</setVar>
        <ifVarMatches name="option_local_install"     value="TRUE" >
          <then>
            <setVar   name="aqhome_cfg_searchdir">etc</setVar>
            <setVar   name="aqhome_locale_searchdir">share/locale</setVar>
            <setVar   name="aqhome_data_searchdir">share</setVar>
            <setVar   name="aqhome_rtdata_searchdir">var/lib</setVar>
          </then>
          <else>
            <setVar name="aqhome_cfg_searchdir">$(sysconfdir)</setVar>
            <setVar name="aqhome_locale_searchdir">$(datadir)/locale</setVar>
            <setVar name="aqhome_data_searchdir">$(datadir)</setVar>
            <setVar name="aqhome_rtdata_searchdir">$(rtdatadir)</setVar>
          </else>
        </ifVarMatches>
      </else>
    </ifVarMatches>
    <define name="AQHOME_SYS_IS_WINDOWS" value="$(aqhome_sys_is_windows)" />



    <!-- use "-Owith_avr=TRUE" or "FALSE" to enable or disable assembling AVR code -->
    <option id="with_avr" type="string">
      <default>TRUE</default>
      <choices>TRUE FALSE</choices>
    </option>



    <checkheaders>
      signal.h
      sys/stat.h
      sys/types.h
    </checkheaders>


    <checkfunctions type="c" >
      getpid
    </checkfunctions>



    <checkProgs>
      <prog cmd="avrdude" id="avrdude" />
    </checkProgs>



    <dependencies>
      <dep id="gwenhywfar" name="gwenhywfar" minversion="5.11.2" required="TRUE" >
        <variables>plugindir gwengui-fox16</variables>
      </dep>
      <dep id="aqcgi" name="aqcgi" minversion="0.0.1" required="TRUE" />
      <dep id="aqdiagram" name="aqdiagram" minversion="0.0.1" required="TRUE" />
<!--      <dep id="aqdatabase" name="aqdatabase" minversion="1.99.1" required="TRUE" >
        <variables>aqdatabase_typemakerdir</variables>
      </dep>
-->
    </dependencies>



    <!-- symbol visibility -->
    <checkCompiler>
      <arg name="has_symbol_visibility">-fvisibility=hidden</arg>
    </checkCompiler>
    
    <ifVarMatches name="has_symbol_visibility" value="TRUE" >
      <setVar name="visibility_cflags">-fvisibility=hidden</setVar>
      <define name="GCC_WITH_VISIBILITY_ATTRIBUTE" />
    </ifVarMatches>



    <subdirs>
      aqhome
      apps
      devices
      etc
      scripts
    </subdirs>

    <ifVarMatches name="option_with_avr" value="TRUE" >
      <subdirs>
        avr
      </subdirs>
    </ifVarMatches>




    <!-- build with "gwbuild -B flash" -->
    <ifVarMatches name="avrdude_EXISTS" value="TRUE" >
      <buildFiles name="flash" auto="FALSE" >
        <!-- TODO: input does not see built files! -->
        <input>
          <files match="*.hex" />
        </input>
        
        <output>
        </output>
        <!-- see http://eleccelerator.com/fusecalc/fusecalc.php?chip=attiny84 -->
        <!-- disable divide by 8: -U lfuse:w:0xEA:m     default (divide by 8): -U lfuse:w:0x6A:m -->
        <!-- changes to hfuse: enable EESAVE -->
        <!-- changes to efuse: enable SELFPRGEN -->
        <cmd tool="$(avrdude)" checkDates="FALSE"  >
          -p t84 -c stk500 -P /dev/ttyACM0 -B16 -U hfuse:w:0xD7:m -U efuse:w:0xFE:m  -U flash:w:avr/att84_temp1.hex
        </cmd>

        <buildMessage>
          Flashing hex file to AVR.
        </buildMessage>
      </buildFiles>

      <buildFiles name="flash2" auto="FALSE" >
        <!-- TODO: input does not see built files! -->
        <input>
          <files match="*.hex" />
        </input>
        
        <output>
        </output>

        <cmd tool="$(avrdude)" checkDates="FALSE"  >
          -p t84 -c stk500 -P /dev/ttyACM0 -B16 -U hfuse:w:0xD7:m -U efuse:w:0xFE:m  -U flash:w:avr/att84_bootloader.hex
        </cmd>

        <buildMessage>
          Flashing BASE hex file to AVR.
        </buildMessage>
      </buildFiles>

      <buildFiles name="flash3" auto="FALSE" >
        <!-- TODO: input does not see built files! -->
        <input>
          <files match="*.hex" />
        </input>
        
        <output>
        </output>

        <cmd tool="$(avrdude)" checkDates="FALSE"  >
          -p t84 -c stk500 -P /dev/ttyACM0 -B16 -U hfuse:w:0xD7:m -U efuse:w:0xFE:m  -U flash:w:avr/att84_testflashimg.hex
        </cmd>

        <buildMessage>
          Flashing test image hex file to AVR.
        </buildMessage>
      </buildFiles>

    </ifVarMatches>
        


  </project>

</gwbuild>
