<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (c) 2011 Niels Martin Hansen
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.
    * Neither the name of the Aegisub Group nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.

  Aegisub Project http://www.aegisub.org/
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- Build credit text -->
  <ItemDefinitionGroup Condition="'$(AegisubBuildCredit)'==''">
    <ClCompile>
      <PreprocessorDefinitions>BUILD_CREDIT="$(AegisubBuildCredit)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- Update checker -->
  <ItemDefinitionGroup Condition="'$(AegisubUseUpdateChecker)'=='true'">
    <ClCompile>
      <PreprocessorDefinitions>
        WITH_UPDATE_CHECKER;
        UPDATE_CHECKER_SERVER="$(UpdateCheckerServer)";
        UPDATE_CHECKER_BASE_URL="$(UpdateCheckerURL)";
        %(PreprocessorDefinitions)
      </PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- Hunspell support -->
  <ItemDefinitionGroup>
    <ClCompile>
      <PreprocessorDefinitions>WITH_HUNSPELL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories>$(AegisubContribBase)hunspell\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- CSRI helper library support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseCsri)'=='HelperLibrary'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_CSRI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- CSRI external library support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseCsri)'=='External'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_CSRI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>$(CsriLibraryPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
      <AdditionalDependencies>$(CsriLibraryName);%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>

  <!-- FFmpegSource support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseFfms)'=='true'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_FFMS2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- Avisynth support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseAvisynth)'=='true'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_AVISYNTH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- FFTW support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseFftw)'=='true'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_FFTW3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- OpenAL support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseOpenAl)'=='true'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_OPENAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- DirectSound support -->
  <ItemDefinitionGroup Condition="'$(AegisubUseDSound)'=='true'">
    <ClCompile>
      <PreprocessorDefinitions>WITH_DIRECTSOUND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <AdditionalDependencies>dsound.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>

  <!-- Special builds -->
  <ItemDefinitionGroup>
    <ClCompile>
      <PreprocessorDefinitions Condition="'$(StartupLog)'=='true'">WITH_STARTUPLOG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- General configuration, always required libraries -->
  <ItemDefinitionGroup>
    <ClCompile>
      <PreprocessorDefinitions>
        NOMINMAX;
        %(PreprocessorDefinitions)
      </PreprocessorDefinitions>
      <AdditionalIncludeDirectories>
        $(SrcDir)include\;
        $(AegisubSourceBase)libaegisub\include;
        $(AegisubSourceBase)build;
        $(AegisubSourceBase)include;
        $(AegisubSourceBase)src;
        %(AdditionalIncludeDirectories)
      </AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>$(AegisubLibraryDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
    </Link>
  </ItemDefinitionGroup>

  <!-- Add property pages -->
  <ItemGroup>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)Aegisub.xml" />
    <ProjectTools Include="AegisubConfig" />
  </ItemGroup>

  <!-- Compile translations if msgfmt is available -->
  <Target Name="Translations"
    AfterTargets="ClCompile"
    Condition="'$(MsgFmtPath)'!=''"
    Inputs="@(MsgFmt)"
    Outputs="$(AegisubBinaryDir)locale\%(Filename)\aegisub.mo"
    >
    <Error Condition="!Exists($(MsgFmtPath))" Text="$(MsgFmtPath) not found" />
    <MakeDir Directories="$(AegisubBinaryDir)locale\%(MsgFmt.Filename)" />
    <Exec Command="$(MsgFmtPath) -o $(AegisubBinaryDir)locale\%(MsgFmt.Filename)\aegisub.mo %(MsgFmt.Identity)" />
  </Target>
</Project>
