<?xml?>

<GwenBuilder name="SharedLib">

  <inputFiles>
    <acceptedInputTypes>object</acceptedInputTypes>
    <acceptedInputFiles>*.o</acceptedInputFiles>
  </inputFiles>

  <outputFiles>
    <file type="sharedlib" install="target" >
      lib$(target_name).so.$(target_so_effective).$(target_so_age).$(target_so_revision)
    </file>
    <file type="symlink" install="target" >
      lib$(target_name).so.$(target_so_effective)
    </file>
    <file type="symlink" >
      lib$(target_name).so
    </file>
  </outputFiles>
  
  <targetLinkSpecs>
    -L$(folder) -l$(target_name)
  </targetLinkSpecs>
  
  <buildCommands deleteOutFileFirst="TRUE" checkDates="TRUE" checkDepends="TRUE" >

    <cmd tool="$(GWBUILD_TOOL_CC)" >
      <args>
        <fixed>-shared -fPIC -Wl,-no-undefined -Wl,-soname,lib$(target_name).so.$(target_so_effective)</fixed>
        <blank/>
        <fixed>$(ldflags) $(local/ldflags)</fixed>
        <blank/>
        <inputFiles match="*.o" />
        <blank/>
        <fixed>-o</fixed>
        <blank/>
        <outputFiles index="0" />
        <blank/>
        <ifHasSubTargetLibs>
          <fixed>-Wl,--whole-archive</fixed>
          <blank/>
          <subTargetLibs/>
          <blank/>
        </ifHasSubTargetLibs>
        <ifHasLibraries>
          <fixed>-Wl,--no-whole-archive</fixed>
          <blank/>
          <libraries/>
        </ifHasLibraries>
      </args>
      <mainOutputFile index="0" />
      <buildMessage>
        Linking 'lib$(target_name).so.$(target_so_effective).$(target_so_age).$(target_so_revision)'
      </buildMessage>
    </cmd>

    <cmd tool="ln" >
      <args>
        <fixed>
          -s lib$(target_name).so.$(target_so_effective).$(target_so_age).$(target_so_revision)
             lib$(target_name).so.$(target_so_effective)
        </fixed>
      </args>
      <mainOutputFile index="1" />
      <buildMessage>
        Creating symbolic link 'lib$(target_name).so.$(target_so_effective)'
      </buildMessage>
    </cmd>

    <cmd tool="ln">
      <args>
        <fixed>
          -s lib$(target_name).so.$(target_so_effective).$(target_so_age).$(target_so_revision)
             lib$(target_name).so
        </fixed>
      </args>
      <mainOutputFile index="2" />
      <buildMessage>
        Creating symbolic link 'lib$(target_name).so'
      </buildMessage>
    </cmd>

    
  </buildCommands>


  <!-- not yet... -->
  <postInstallCommands>

    <cmd tool="cp" ignoreResult="FALSE">
      <args>
        <fixed>
          -d
        </fixed>
        <blank/>
        <fixed>
          lib$(target_name).so.$(target_so_effective).$(target_so_age).$(target_so_revision)
        </fixed>
        <blank/>
        <fixed>
          lib$(target_name).so.$(target_so_effective)
        </fixed>
<!--
        <blank/>
        <fixed>
          lib$(target_name).so
        </fixed>
        <blank/>
-->
        <outputFiles index="0" useField="installPath"/>
        <fixed>/</fixed>
      </args>
    </cmd>

  </postInstallCommands>
  


</GwenBuilder>
