<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <?if $(var.Platform)=x64 ?>

  <?define Win64=yes ?>
  <?define PIProgramFilesFolder=ProgramFiles64Folder ?>

  <?define ToolsBinDir=dirBin64 ?>
  <?define GuidKinit=BAA5BD92-163E-4AA5-8C99-EA2100F3D9DE ?>
  <?define GuidKdestroy=289C2C0D-F41D-4E46-9819-6B9B63F83418 ?>
  <?define GuidKtutil=28B09087-4731-41F4-B734-C71E84EC31FC ?>
  <?define GuidKdigest=D13DA4C0-B1BB-4C02-8ED2-5DFC7D16B19D ?>
  <?define GuidKpasswd=20A984EC-5BCB-4B93-A3A9-7AACBDC625E9 ?>
  <?define GuidKvno=2B932C2B-9167-4051-BDF7-A104E9983CE6 ?>
  <?define GuidKcpytkt=17734691-7CB3-4E9A-AADC-6D4205795F43 ?>
  <?define GuidKdeltkt=3E853905-8CDA-4E14-8EBA-C0C4EEDB811A ?>
  <?define GuidHeimtools=F411A9F1-A186-40CB-B55B-CADBE0166268 ?>
  <?define GuidKadmin=E628E9AA-43AB-47EE-8A01-815C027555F2 ?>

  <?define ConfigDir=INSTALLDIR64 ?>

  <?else?>

  <?define Win64=no ?>
  <?define PIProgramFilesFolder=ProgramFilesFolder ?>

  <?define ToolsBinDir=dirBin32 ?>
  <?define GuidKinit=038F19D7-F7C9-4B6A-8359-321CD1FAD347 ?>
  <?define GuidKdestroy=07D96FBC-2251-4EBC-AA68-12C6C52F44E6 ?>
  <?define GuidKtutil=CE082458-E2C5-4744-A423-88C23AD3C81C ?>
  <?define GuidKdigest=3FFBFAB0-FB37-411C-AF4E-53BCC468D7D1 ?>
  <?define GuidKpasswd=B66C04B5-EE1D-48C3-A25B-4DCAAA8F459B ?>
  <?define GuidKvno=4C6015BE-1347-4D12-8841-FF90E0B9D6A8 ?>
  <?define GuidKcpytkt=CBCDFC80-601B-4F26-A020-7D1278735B95 ?>
  <?define GuidKdeltkt=6450EE72-E472-4709-B457-B579BFB2472B ?>
  <?define GuidHeimtools=11800964-4A5F-466E-B2FE-DD2EFC54DDB9 ?>
  <?define GuidKadmin=B31F9FFC-D588-4A3E-9AEA-C9E9137B08F0 ?>

  <?define ConfigDir=INSTALLDIR32 ?>

  <?endif?>

  <Product Name='!(loc.ProductName) $(var.Version)'
           Id='*' UpgradeCode='81E64C32-1D09-4E3D-9EA2-EECD9C4D16CE'
           Language='!(loc.LanguageCode)' Codepage='1252' Version='$(var.Version)'
           Manufacturer='!(loc.Manufacturer)'>

    <Package Id='*' Description='!(loc.Description)'
      Manufacturer='!(loc.Manufacturer)'
      InstallerVersion='300' Languages='!(loc.LanguageCode)'
      Compressed='yes' SummaryCodepage='1252'
      Platform='$(var.Platform)'
      InstallScope='perMachine'
      InstallPrivileges='elevated'
      Keywords='Heimdal,Kerberos,GSS' />

    <Directory Id='TARGETDIR' Name='SourceDir' DiskId='1'>

      <?ifdef Target32 ?>
      <Directory Id='ProgramFilesFolder'>
        <Directory Id='INSTALLDIR32' Name='Heimdal'>
          <Directory Id='dirBin32' Name='bin'>
          </Directory>
        </Directory>
      </Directory>
      <?endif?>

      <?ifdef Target64?>
      <Directory Id='ProgramFiles64Folder'>
        <Directory Id='INSTALLDIR64' Name='Heimdal'>
          <Directory Id='dirBin64' Name='bin'>
          </Directory>
        </Directory>
      </Directory>
      <?endif?>

    </Directory>

    <?ifdef Target32?>
    <DirectoryRef Id='dirBin32' DiskId='1'>
      <Component Id='comp.SearchPath.32' Feature='feature.Main'
                 Guid='BA6C1A53-E479-4E87-9B61-7BA793DBAE56' Win64='no'>
	<RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
		     Key='Software\Heimdal\CurrentVersion'>
          <RegistryValue Name='InstallPath' Type='string'
                         Value='[dirBin32]' KeyPath='yes' />
        </RegistryKey>
        <Environment Id='env.Path.32' Name='PATH' Action='set' Part='last'
                     Separator=';' Value='[dirBin32]' System='yes' />
      </Component>

      <Merge Id='Heimdal.Assemblies.32' Language='0'
             SourceFile='$(var.InstDir32)\Heimdal.msm' />

      <Merge Id='Heimdal.GSS.32' Language='0'
	     SourceFile='$(var.InstDir32)\Heimdal.GSS.msm' />

      <Merge Id='Heimdal.Policy.32' Language='0'
             SourceFile='$(var.InstDir32)\Heimdal.Policy.msm' />

      <Merge Id='Runtime.32' Language='0'
             SourceFile='$(var.RuntimeModule32)' />

    </DirectoryRef>
    <?endif?>

    <?ifdef Target64?>
    <DirectoryRef Id='dirBin64' DiskId='1'>
      <Component Id='comp.SearchPath.64' Feature='feature.Main'
                 Guid='2F189729-2253-47A1-AA68-06FE3A9697A7' Win64='yes'>
	<RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
		     Key='Software\Heimdal\CurrentVersion'>
          <RegistryValue Name='InstallPath' Type='string'
                         Value='[dirBin64]' KeyPath='yes' />
        </RegistryKey>
        <Environment Id='env.Path' Name='PATH' Action='set' Part='last'
                     Separator=';' Value='[dirBin64]' System='yes' />
      </Component>

      <Merge Id='Heimdal.Assemblies.64' Language='0'
             SourceFile='$(var.InstDir64)\Heimdal.msm' />

      <Merge Id='Heimdal.GSS.64' Language='0'
	     SourceFile='$(var.InstDir64)\Heimdal.GSS.msm' />

      <Merge Id='Heimdal.Policy.64' Language='0'
             SourceFile='$(var.InstDir64)\Heimdal.Policy.msm' />

      <Merge Id='Runtime.64' Language='0'
             SourceFile='$(var.RuntimeModule64)' />

    </DirectoryRef>
    <?endif?>

    <DirectoryRef Id='$(var.ToolsBinDir)' FileSource='$(var.BinDir)'>

      <Component Id='comp.kinit'
                 Guid='$(var.GuidKinit)'
                 Win64='$(var.Win64)'>
        <File Name='kinit.exe' KeyPath='yes' />
        <File Name='kinit.pdb' />
      </Component>

      <Component Id='comp.ktutil'
                 Guid='$(var.GuidKtutil)'
                 Win64='$(var.Win64)'>
        <File Name='ktutil.exe' KeyPath='yes' />
        <File Name='ktutil.pdb' />
      </Component>

      <Component Id='comp.kdestroy'
                 Guid='$(var.GuidKdestroy)'
                 Win64='$(var.Win64)'>
        <File Name='kdestroy.exe' KeyPath='yes' />
        <File Name='kdestroy.pdb' />
      </Component>

      <Component Id='comp.kdigest'
                 Guid='$(var.GuidKdigest)'
                 Win64='$(var.Win64)'>
        <File Name='kdigest.exe' KeyPath='yes' />
        <File Name='kdigest.pdb' />
      </Component>

      <Component Id='comp.kpasswd'
                 Guid='$(var.GuidKpasswd)'
                 Win64='$(var.Win64)'>
        <File Name='kpasswd.exe' KeyPath='yes' />
        <File Name='kpasswd.pdb' />
      </Component>

      <Component Id='comp.kvno'
                 Guid='$(var.GuidKvno)'
                 Win64='$(var.Win64)'>
        <File Name='kvno.exe' KeyPath='yes' />
        <File Name='kvno.pdb' />
      </Component>

      <Component Id='comp.kcpytkt'
                 Guid='$(var.GuidKcpytkt)'
                 Win64='$(var.Win64)'>
        <File Name='kcpytkt.exe' KeyPath='yes' />
        <File Name='kcpytkt.pdb' />
      </Component>

      <Component Id='comp.kdeltkt'
                 Guid='$(var.GuidKdeltkt)'
                 Win64='$(var.Win64)'>
        <File Name='kdeltkt.exe' KeyPath='yes' />
        <File Name='kdeltkt.pdb' />
      </Component>

      <Component Id='comp.heimtools'
                 Guid='$(var.GuidHeimtools)'
                 Win64='$(var.Win64)'>
        <File Name='heimtools.exe' KeyPath='yes'>
          <CopyFile Id='klist.exe' DestinationName='klist.exe' DestinationProperty='$(var.ToolsBinDir)' />
          <CopyFile Id='kswitch.exe' DestinationName='kswitch.exe' DestinationProperty='$(var.ToolsBinDir)' />
        </File>
        <File Name='heimtools.pdb'>
          <CopyFile Id='klist.pdb' DestinationName='klist.pdb' />
          <CopyFile Id='kswitch.pdb' DestinationName='kswitch.pdb' />
        </File>
      </Component>

      <Component Id='comp.kadmin'
		 Guid='$(var.GuidKadmin)'
		 Win64='$(var.Win64)'>
	<File Name='kadmin.exe' KeyPath='yes' />
	<File Name='kadmin.pdb' />
      </Component>

      <Component Id='comp.Heimdal.chm'
                 Guid='785F6668-EBDB-4F18-8BEF-F72ECECB43D6'>
        <File Source='$(var.DocDir)\heimdal.chm' />
      </Component>

      <Component Id='comp.HX509.chm'
                 Guid='CBB379D6-629D-4EB9-AC0D-0167651F14EF'>
        <File Source='$(var.DocDir)\hx509.chm' />
      </Component>

    </DirectoryRef>

    <DirectoryRef Id='TARGETDIR'>
      <Directory Id='CommonAppDataFolder' Name='ProgramData'>
	<Directory Id='dirCommonKerberos' Name='Kerberos' FileSource='$(var.SrcDir)'>

          <Component Id='comp.krb5.conf'
                     Guid='ED28951F-7B17-4DF5-91D7-4DC11C810E66'
                     Permanent='yes' NeverOverwrite='yes'>
            <File Name='krb5.conf' KeyPath='yes' Id='krb5_conf' />
            <Environment Id='KRB5_CONFIG_by_krb5.conf' Name='KRB5_CONFIG' Action='set' System='yes' Value='[#krb5_conf]' />
            <!-- Backwards compatibility -->
	    <RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
			 Key='Software\MIT\Kerberos'>
              <RegistryValue Name='config' Type='string' Value='[#krb_conf]' />
            </RegistryKey>
            <Condition>Not LEGACYKRB5INI And Not LEGACYKRB5CONF And Not LEGACYKRB5REG32 And Not LEGACYKRB5REG64</Condition>
          </Component>

          <Component Id='comp.krb5.ini.move'
                     Guid='316CB754-4332-4C02-95C1-4AC82590712D'>
            <CopyFile Id='copy_krb5.ini' Delete='yes'
                      DestinationDirectory='dirCommonKerberos'
                      DestinationName='krb5.conf' DestinationShortName='krb5.cnf'
                      SourceProperty='LEGACYKRB5INI' />
            <Environment Id='KRB5_CONFIG_by_legacy_krb5.ini' Name='KRB5_CONFIG'
                         Action='set' System='yes' Value='[dirCommonKerberos]krb5.conf' />
	    <RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
			 Key='Software\Heimdal\CurrentVersion'>
              <RegistryValue Name='LegacyKrb5IniLocation' Type='string'
                             Value='[LEGACYKRB5INI]' KeyPath='yes' />
            </RegistryKey>
            <!-- Backwards compatibility -->
	    <RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
			 Key='Software\MIT\Kerberos'>
              <RegistryValue Name='config' Type='string'
                             Value='[dirCommonKerberos]krb5.conf' />
            </RegistryKey>
            <Condition>LEGACYKRB5INI</Condition>
          </Component>

          <Component Id='comp.krb5.conf.move'
                     Guid='ADCE6801-0FD3-46E7-955A-FC9214CFE0AB'>
            <CopyFile Id='copy_krb5.conf' Delete='yes'
                      DestinationDirectory='dirCommonKerberos'
                      DestinationName='krb5.conf' DestinationShortName='krb5.cnf'
                      SourceProperty='LEGACYKRB5CONF' />
            <Environment Id='KRB5_CONFIG_by_legacy_krb5.conf' Name='KRB5_CONFIG'
                         Action='set' System='yes' Value='[dirCommonKerberos]krb5.conf' />
	    <RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
			 Key='Software\Heimdal\CurrentVersion'>
	    <RegistryValue Name='LegacyKrb5ConfLocation' Type='string'
                             Value='[LEGACYKRB5CONF]' KeyPath='yes' />
            </RegistryKey>
            <!-- Backwards compatibility -->
	    <RegistryKey ForceDeleteOnUninstall='yes' Root='HKLM'
			 Key='Software\MIT\Kerberos'>
              <RegistryValue Name='config' Type='string'
                             Value='[dirCommonKerberos]krb5.conf' />
            </RegistryKey>
            <Condition>LEGACYKRB5CONF</Condition>
          </Component>

        </Directory>
      </Directory>
      <Directory Id='WindowsFolder'>
      </Directory>
    </DirectoryRef>

    <Media Id='1' Cabinet='Disk1' CompressionLevel='high' EmbedCab='yes' />

    <Upgrade Id='81E64C32-1D09-4E3D-9EA2-EECD9C4D16CE'>
      <UpgradeVersion IncludeMaximum='no' MigrateFeatures='yes' Maximum='$(var.Version)'
                      Property='PREVIOUSINSTALLATION' />
      <UpgradeVersion Minimum='$(var.Version)' IncludeMinimum='yes'
                      Maximum='127.127.32767.32767'
                      OnlyDetect='yes' Property='EXISTINGINSTALLATION' />
    </Upgrade>

    <!-- Search for existing configuration files -->

    <Property Id='LEGACYKRB5INI' Secure='yes'>
      <DirectorySearch Id='dirSearchKrb5Ini' Depth='1' Path='[WindowsFolder]'>
        <FileSearch Name='krb5.ini' />
      </DirectorySearch>
    </Property>

    <Property Id='LEGACYKRB5CONF' Secure='yes'>
      <DirectorySearch Id='dirSearchKrb5Conf' Depth='1' Path='[WindowsFolder]'>
        <FileSearch Name='krb5.conf' />
      </DirectorySearch>
    </Property>

    <Property Id='LEGACYKRB5REG32' Secure='yes'>
      <RegistrySearch Id='regSearchKrb5ConfUser' Key='Software\MIT\Kerberos' Name='config'
                      Root='HKLM' Type='file' Win64='no'>
        <FileSearch Name='krb5.ini' />
      </RegistrySearch>
    </Property>

    <?if $(var.Platform)=x64 ?>
    <Property Id='LEGACYKRB5REG64' Secure='yes'>
      <RegistrySearch Id='regSearchKrb5ConfMach' Key='Software\MIT\Kerberos' Name='config'
                      Root='HKLM' Type='file' Win64='yes'>
        <FileSearch Name='krb5.ini' />
      </RegistrySearch>
    </Property>
    <?endif?>

    <InstallExecuteSequence>
      <RemoveExistingProducts After='InstallFinalize' />
    </InstallExecuteSequence>

    <Condition Message='!(loc.AdminRequired)'>Installed OR Privileged</Condition>
    <Condition Message='!(loc.AlreadyInstalled)'>Installed OR NOT EXISTINGINSTALLATION</Condition>

    <Feature Id='feature.Main' ConfigurableDirectory='$(var.ConfigDir)'
             Title='!(loc.FeaMainTitle)'
             Description='!(loc.FeaMainDesc)' Display='expand'
             Level='1' TypicalDefault='install' InstallDefault='local'>

      <ComponentRef Id='comp.HX509.chm' />
      <ComponentRef Id='comp.Heimdal.chm' />
      <ComponentRef Id='comp.kcpytkt' />
      <ComponentRef Id='comp.kdeltkt' />
      <ComponentRef Id='comp.kdestroy' />
      <ComponentRef Id='comp.kdigest' />
      <ComponentRef Id='comp.kinit' />
      <ComponentRef Id='comp.kpasswd' />
      <ComponentRef Id='comp.krb5.conf' />
      <ComponentRef Id='comp.krb5.conf.move' />
      <ComponentRef Id='comp.krb5.ini.move' />
      <ComponentRef Id='comp.ktutil' />
      <ComponentRef Id='comp.kvno' />
      <ComponentRef Id='comp.heimtools' />
      <ComponentRef Id='comp.kadmin' />

      <?ifdef MKShim ?>
      <?ifdef Target64?>
      <ComponentGroupRef Id='comp.Heimdal.MKShim.64' />
      <?else?>
      <ComponentGroupRef Id='comp.Heimdal.MKShim.32' />
      <?endif?>
      <?endif?>

      <?ifdef Target64?>
      <MergeRef Id='Heimdal.Assemblies.64' />
      <MergeRef Id='Heimdal.GSS.64' />
      <MergeRef Id='Heimdal.Policy.64' />
      <MergeRef Id='Runtime.64' />
      <?else?>
      <MergeRef Id='Heimdal.Assemblies.32' />
      <MergeRef Id='Heimdal.GSS.32' />
      <MergeRef Id='Heimdal.Policy.32' />
      <MergeRef Id='Runtime.32' />
      <?endif?>

      <?ifdef Target32?>
      <?ifdef Target64?>
      <!-- If we are building the combined installer, the 32-bit
           libraries go into a separate feature. -->
      <Feature Id='feature.32BitLibraries'
               ConfigurableDirectory='INSTALLDIR32'
               Title='!(loc.Fea32BitTitle)'
               Description='!(loc.Fea32BitDesc)'
               Level='1' TypicalDefault='install' InstallDefault='local'>
        <?ifdef MKShim ?>
        <ComponentGroupRef Id='comp.Heimdal.MKShim.32' />
        <?endif?>
        <MergeRef Id='Heimdal.Assemblies.32' />
	<MergeRef Id='Heimdal.GSS.32' />
        <MergeRef Id='Heimdal.Policy.32' />
        <MergeRef Id='Runtime.32' />
      </Feature>
      <?endif?>
      <?endif?>

    </Feature>

    <!-- Properties for Add/Remove Programs -->

    <Property Id='ARPHELPLINK' Value='http://www.h5l.org' />

    <Property Id='ARPCONTACT' Value='heimdal@h5l.org' />

    <Property Id='ARPURLINFOABOUT' Value='http://www.h5l.org' />

    <!-- Other properties -->

    <UIRef Id='WixUI_FeatureTree' />

    <WixVariable Id="WixUIBannerBmp" Value="images\Heimdal_banner.bmp" />
    <WixVariable Id="WixUIDialogBmp" Value="images\Heimdal_dialog.bmp" />

  </Product>
</Wix>
