<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?ifdef var.Platform ?>
<?define ModuleName = "psqlODBC_$(var.Platform)" ?>
<?if $(var.Platform) = x64 ?>
<?define BIT64 = "yes" ?>
<?define ANSIFOLDER = "AMD64ANSI" ?>
<?define UNICODEFOLDER = "AMD64" ?>
<?define Module_PackageId = "970B6E07-7105-4d66-80FA-9E208952FB96" ?>
<?define CIDPFILES = "5C9A19B5-D7C6-4bb4-BBBC-88C2A67A59B0" ?>
<?else?>
<?define BIT64 = "no" ?>
<?define ANSIFOLDER = "MultibyteRelease" ?>
<?define UNICODEFOLDER = "Release" ?>
<?define Module_PackageId = "ACF10866-5C01-46f0-90F0-D5618638CA4A" ?>
<?define CIDPFILES = "00A1ACE3-B7C2-41b8-A1F1-DB565990DA50" ?>
<?endif?>
<?else?>
<?define BIT64 = "no" ?>
<?define Platform = "x86" ?>
<?define ModuleName = "psqlODBC" ?>
<?define ANSIFOLDER = "MultibyteRelease" ?>
<?define UNICODEFOLDER = "Release" ?>
<?define Module_PackageId = "ACF10866-5C01-46f0-90F0-D5618638CA48" ?>
<?define CIDPFILES = "00A1ACE3-B7C2-41b8-A1F1-DB565990DA4E" ?>
<?endif?>

  <Module
    Id="$(var.ModuleName)"
    Version="$(var.VERSION)"
    Language="1033">
    
    <Package 
      Id="$(var.Module_PackageId)"
      Description="PostgreSQL ODBC Driver"
      Keywords="PostgreSQL, ODBC"
      Manufacturer="PostgreSQL Global Development Group" 
      InstallerVersion="300"
      Platform="$(var.Platform)" 
      Languages="1033"
      SummaryCodepage="1252" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="BINDIR" Name=".">
        <Component Id="psqlodbc.files" Guid="$(var.CIDPFILES)" Win64="$(var.BIT64)">

          <!-- PostgreSQL -->
          <File Id="psqlodbc30a.dll" Name="psqlodbc30a.dll" Source="../$(var.ANSIFOLDER)/psqlodbc30a.dll">
	    <ODBCDriver Id="Psqlodbc_9.0_Driver_ANSI" Name="PostgreSQL ANSI($(var.Platform))" />
	  </File>
          <File Id="psqlodbc35w.dll" Name="psqlodbc35w.dll" Source="../$(var.UNICODEFOLDER)/psqlodbc35w.dll">
	    <ODBCDriver Id="Psqlodbc_9.0_Driver" Name="PostgreSQL Unicode($(var.Platform))" />
	  </File>
          <File Id="pgxalib.dll" Name="pgxalib.dll" Source="../$(var.UNICODEFOLDER)/pgxalib.dll" />
          <File Id="pgenlist.dll" Name="pgenlist.dll" Source="../$(var.UNICODEFOLDER)/pgenlist.dll" />
          <File Id="pgenlista.dll" Name="pgenlista.dll" Source="../$(var.ANSIFOLDER)/pgenlista.dll" />
<?if "$(var.LIBPQBINDIR)" != "" ?>
          <File Id="libpq.dll" Name="libpq.dll" Source="$(var.LIBPQBINDIR)\libpq.dll" KeyPath="yes" />
          
          <!-- Gettext -->
          <File Id="libintl.dll" Name="libintl.dll" Source="$(var.LIBPQBINDIR)\libintl.dll" />
          <File Id="libiconv.dll" Name="libiconv.dll" Source="$(var.LIBPQBINDIR)\libiconv.dll" />
          
          <!-- SSL -->
          <File Id="libeay32.dll" Name="libeay32.dll" Source="$(var.LIBPQBINDIR)\libeay32.dll" />
          <File Id="ssleay32.dll" Name="ssleay32.dll" Source="$(var.LIBPQBINDIR)\ssleay32.dll" />
<?endif ?>

<?if "$(var.GSSBINDIR)" != "" ?>
<?if $(var.BIT64) = no ?>
	  <!-- GSSAPI -->
          <File Id="gssapi32.dll" Name="gssapi32.dll" Source="$(var.GSSBINDIR)\gssapi32.dll" />

          <!-- MIT Kerberos -->
           <File Id="comerr32.dll" Name="comerr32.dll" Source="$(var.GSSBINDIR)\comerr32.dll" />
          <File Id="krb5_32.dll" Name="krb5_32.dll" Source="$(var.GSSBINDIR)\krb5_32.dll" />
          <File Id="k5sprt32.dll" Name="k5sprt32.dll" Source="$(var.GSSBINDIR)\k5sprt32.dll" />
          <!-- VC++ 7.1 runtime - required by Kerberos -->
          <File Id="msvcr71.dll" Name="msvcr71.dll" Source="$(var.GSSBINDIR)\msvcr71.dll" />
<?else ?>
	  <!-- GSSAPI -->
          <File Id="gssapi64.dll" Name="gssapi64.dll" Source="$(var.GSSBINDIR)\gssapi64.dll" />

          <!-- MIT Kerberos -->
           <File Id="comerr64.dll" Name="comerr64.dll" Source="$(var.GSSBINDIR)\comerr64.dll" />
          <File Id="krb5_64.dll" Name="krb5_64.dll" Source="$(var.GSSBINDIR)\krb5_64.dll" />
          <File Id="k5sprt64.dll" Name="k5sprt64.dll" Source="$(var.GSSBINDIR)\k5sprt64.dll" />
<?endif ?>
<?endif ?>
          <!-- Note, installing the driver properly (IE, using ODBCDriver) has proven unreliable -->
          <!--       so we install the registry keys manually ourselves.                         -->
        </Component>
      </Directory>
    </Directory>

  </Module>
</Wix>
