<?xml?>

<!-- ***************************************************************************
 begin       : Sun Apr 11 2021
 copyright   : (C) 2024 by Martin Preuss
 email       : martin@libchipcard.de

 ***************************************************************************
 * This file is part of the project "AqBanking".                           *
 * Please see toplevel file COPYING of that project for license details.   *
 ***************************************************************************/

  This is a build file for gwbuild, a build system that comes with libgwenhywfar,
  see https://www.aquamaniac.de/rdm/projects/aqbanking/wiki/Gwbuild
  
  It is not meant as a replacement for other build systems (like the currently used autotools, cmake etc.) but rather
  as an addition created, maintained and used almost exclusively by myself.
-->

<gwbuild>

  <project name="aqbanking" version="6.6.3"
           so_current="50" so_age="5" so_revision="3"
           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="AQBANKING_VERSION_MAJOR">$(project_vmajor)</setVar>
    <setVar name="AQBANKING_VERSION_MINOR">$(project_vminor)</setVar>
    <setVar name="AQBANKING_VERSION_PATCHLEVEL">$(project_vpatchlevel)</setVar>
    <setVar name="AQBANKING_VERSION_BUILD">$(project_vbuild)</setVar>
    <setVar name="AQBANKING_VERSION_TAG">$(project_vtag)</setVar>
    <setVar name="AQBANKING_SO_CURRENT">$(project_so_current)</setVar>
    <setVar name="AQBANKING_SO_REVISION">$(project_so_revision)</setVar>
    <setVar name="AQBANKING_SO_AGE">$(project_so_age)</setVar>
    <setVar name="AQBANKING_SO_EFFECTIVE">$(project_so_effective)</setVar>
    <setVar name="AQBANKING_VERSION_STRING">
      $(project_vmajor).$(project_vminor).$(project_vpatchlevel)
    </setVar>
    <setVar name="AQBANKING_VERSION_FULL_STRING">
      $(project_vmajor).$(project_vminor).$(project_vpatchlevel).$(project_vbuild)$(project_vtag)
    </setVar>


    <!-- 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="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="localedir">$(option_prefix)/share/locale</setVar>

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


    <option id="backends" type="stringlist" definePrefix="AQBANKING_WITH_PLUGIN_BACKEND_" >
      <choices>aqhbci aqofxconnect aqebics aqpaypal aqfints aqgivve aqnone</choices>
      <alias name="all">aqhbci aqofxconnect aqebics aqpaypal aqgivve aqnone</alias>
      <default>all</default>
    </option>
<!--    <define name="AQBANKING_WITH_PLUGIN_BACKEND_AQNONE" value="1" quoted="FALSE" /> -->


    <option id="imexporters" type="stringlist" definePrefix="AQBANKING_WITH_PLUGIN_IMEXPORTER_" >
      <choices>csv eri2 ofx openhbci1 swift xmldb yellownet sepa ctxfile q43 camt xml</choices>
      <alias name="all">csv eri2 ofx openhbci1 swift xmldb yellownet sepa ctxfile q43 camt xml</alias>
      <default>all</default>
    </option>


    <option id="parsers" type="stringlist" definePrefix="AQBANKING_WITH_PLUGIN_PARSER_">
      <choices>swift</choices>
      <alias name="all">swift</alias>
      <default>all</default>
    </option>

    <option id="bankinfos" type="stringlist" definePrefix="AQBANKING_WITH_PLUGIN_BANKINFO_">
      <choices>de</choices>
      <alias name="all">de</alias>
      <default>all</default>
    </option>


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

    <option id="enable_gui_tests" type="string">
      <default>TRUE</default>
      <choices>TRUE FALSE</choices>
    </option>

    <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 -O0</setVar>
      <setVar name="CXXFLAGS">-ggdb -Wall -O0</setVar>
    </ifVarMatches>


    <!-- paths -->
    <setVar name="aqbanking_plugin_installdir">$(pkglibdir)/plugins/$(project_so_effective)</setVar>
    <ifVarMatches name="GWBUILD_SYSTEM" value="windows" > <!-- long version of IF statement with THEN and ELSE -->
      <then>
        <define name="OS_WIN32" value="1" />
        <setVar name="aqbanking_sys_is_windows">1</setVar>
        <setVar name="aqbanking_plugin_searchdir">lib/aqbanking/plugins/$(project_so_effective)</setVar>
        <setVar name="aqbanking_cfg_searchdir">etc</setVar>
        <setVar name="aqbanking_locale_searchdir">share/locale</setVar>
        <setVar name="aqbanking_data_searchdir">share"</setVar>
        <setVar name="aqfints_datadir">share/aqbanking/backends/aqfints</setVar>
      </then>
      <else>
        <define       name="OS_POSIX" value="1" />
        <setVar       name="aqbanking_sys_is_windows">0</setVar>
        <ifVarMatches name="option_local_install"     value="TRUE" >
          <then>
            <setVar   name="aqbanking_plugin_searchdir">lib/aqbanking/plugins/$(project_so_effective)</setVar>
            <setVar   name="aqbanking_cfg_searchdir">etc</setVar>
            <setVar   name="aqbanking_locale_searchdir">share/locale</setVar>
            <setVar   name="aqbanking_data_searchdir">share</setVar>
            <setVar   name="aqfints_datadir">share/aqbanking/backends/aqfints</setVar>
          </then>
          <else>
            <setVar name="aqbanking_plugin_searchdir">$(pkglibdir)/plugins/$(project_so_effective)</setVar>
            <setVar name="aqbanking_cfg_searchdir">$(sysconfdir)</setVar>
            <setVar name="aqbanking_locale_searchdir">$(datadir)/locale</setVar>
            <setVar name="aqbanking_data_searchdir">$(datadir)</setVar>
            <setVar name="aqfints_datadir">$(pkgdatadir)/backends/aqfints</setVar>
          </else>
        </ifVarMatches>
      </else>
    </ifVarMatches>
    <define name="AQBANKING_SYS_IS_WINDOWS" value="$(aqbanking_sys_is_windows)" />


    <!-- dependencies ( pkg-config and libs) -->
    <dependencies>
      <dep id="gwenhywfar" name="gwenhywfar" minversion="5.11.2" required="TRUE" >
        <variables>plugindir gwengui-gtk3</variables>
      </dep>

      <ifVarMatches name="option_enable_gui_tests" value="TRUE" >
        <dep id="gtk3" name="gtk+-3.0" required="TRUE" />
      </ifVarMatches>

      <ifVarHasValue name="option_backends" value="aqebics" >
        <dep id="xmlsec" name="xmlsec1" minversion="1.0.0" required="TRUE" />
        <dep id="xml" name="libxml-2.0" required="TRUE" />
        <dep id="xslt" name="libxslt" required="TRUE" />
        <dep id="zlib" name="zlib" required="TRUE" />
      </ifVarHasValue>
      
    </dependencies>
  

    <checklibs>
      <lib id="gmp" name="gmp" function="__gmpz_init" />
    </checklibs>


    <!-- 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>


    <checkheaders>
      locale.h libintl.h iconv.h
      fcntl.h stdlib.h string.h unistd.h
      assert.h ctype.h errno.h fcntl.h stdio.h stdlib.h string.h strings.h locale.h
      netinet/in.h signal.h
    </checkheaders>
  
  
    <checkfunctions type="c" >
      setlocale
      memmove 
      memset 
      strcasecmp 
      strdup 
      strerror 
      snprintf
    </checkfunctions>


    <checkProgs>
      <prog cmd="xmlmerge" id="xmlmerge" />
      <prog cmd="xgettext" id="xgettext" />
      <prog cmd="astyle"   id="astyle" />
      <prog cmd="msgmerge" id="msgmerge" />
    </checkProgs>


    <!-- compatibility defines/vars with Makefile.am -->
    <setVar name="aqbanking_ldflags">-L$${libdir}</setVar>
    <setVar name="aqbanking_libs">-laqbanking</setVar>
    <setVar name="aqbanking_includes">-I$${includedir}/aqbanking6</setVar>
    <setVar name="aqbanking_plugindir">$${libdir}/aqbanking/plugins/$(AQBANKING_SO_EFFECTIVE)</setVar>
    <setVar name="aqbanking_pkgdatadir">$${datadir}/aqbanking</setVar>
    <setVar name="gwenhywfar_includes">$(gwenhywfar_cflags)</setVar>
    <setVar name="OSYSTEM">$(GWBUILD_SYSTEM)</setVar>

    <define name="LOCALEDIR"              value="$(aqbanking_locale_searchdir)"   quoted="TRUE" />
    <define name="AQBANKING_DATA_DIR"     value="$(aqbanking_data_searchdir)"     quoted="TRUE" />
    <define name="AQBANKING_PLUGINS"      value="$(aqbanking_plugin_searchdir)"   quoted="TRUE" />

    <define name="OS_TYPE"      value="$(GWBUILD_SYSTEM)"    quoted="TRUE" />
    <define name="OS_SHORTNAME" value="$(GWBUILD_SYSTEM)"    quoted="TRUE" />

    <subdirs>
      po
      src
      admin
    </subdirs>


    <extradist>
      AUTHORS
      COPYING
      INSTALL
      NEWS
      README
    </extradist>


    <!-- Build with "gwbuild -B i18n-src" -->
    <ifVarMatches name="xgettext_EXISTS" value="TRUE" >
      <buildFiles name="i18n-src" auto="FALSE" >
        <input>
          <files match="*.c" />
          <files match="*.cpp" />
        </input>
  
        <output>
          aqbanking.pot
        </output>
        
        <cmd tool="$(xgettext)" checkDates="TRUE" deleteOutFileFirst="TRUE" >
          -C -c -ki18n -ktr2i18n -kI18N -kI18S -kI18N_NOOP -ktranslate -kaliasLocale -ktr -ktrUtf8
          --msgid-bugs-address=aqbanking-user@lists.aqbanking.de
          -o $(OUTPUT[0]) $(INPUT[])
        </cmd>
  
        <buildMessage>
          Extracting I18N strings into $(OUTPUT[0])
        </buildMessage>
      </buildFiles>
    </ifVarMatches>


    <!-- Build with "gwbuild -B format-src" -->
    <ifVarMatches name="astyle_EXISTS" value="TRUE" >
      <buildFiles name="format-src" auto="FALSE" >
        <input>
          <files match="*.c" />
          <files match="*.cpp" />
          <files match="*.h" />
        </input>
  
        <output>
        </output>
        
        <cmd tool="$(astyle)" checkDates="FALSE"  >
          --style=stroustrup
          -s2
          --min-conditional-indent=0
          --indent-labels
          --max-continuation-indent=80
          --pad-comma
          --pad-header
          --unpad-paren
          --align-pointer=name
          --break-closing-braces
          --break-one-line-headers
          --attach-return-type
          --convert-tabs
          --max-code-length=120
          --break-after-logical
          --preserve-date
          --suffix=none
             $(INPUT[])
        </cmd>
  
        <buildMessage>
          Formatting source files in-place.
        </buildMessage>
      </buildFiles>
    </ifVarMatches>


    <writeFile name="aqbanking.pc" install="$(libdir)/pkgconfig" />

  </project>
  
</gwbuild>

