title: Calling SED for a source in Makefile.am
body: <p>I've got c++ code that needs a sed done to it prior to compilation.  How do I place this into <code>Makefile.am</code>?</p>
  
  <p>I tried the typical makefile setup and the target appears to not exist:</p>
  
  <blockquote>
    <p><code>gentest.cc:</code></p>
    
    <blockquote>
      <p><code>$(SED) -i "s|FIND|REPLACE|" gentest.cc</code></p>
    </blockquote>
  </blockquote>
  
  <p>If you are interested as to why I want to do this, it's because I wrote my program (<code>slider3.py</code>) in python and my partner wrote his in c++ (<code>gentest.cc</code>) and his needs to call mine.  I'm accomplishing this by editing the <code>argv</code> and then using <code>execv()</code>.</p>
  
  <blockquote>
    <p><code>... {</code></p>
    
    <p><code>char **argv2 = new char*[argc];</code></p>
    
    <p><code>memset(argv2,0,sizeof(argv2));</code></p>
    
    <p><code>argv2[0] = "__PREFIX__/bin/slider3.py";</code></p>
    
    <p><code>memcpy(argv2 + 1, argv + 2, sizeof(char *) * (argc - 2));</code></p>
    
    <p><code>int oranges = execv(argv2[0], argv2);</code></p>
    
    <p><code>printf("%s\n", strerror(oranges));</code></p>
    
    <p><code>return oranges;</code></p>
    
    <p><code>} ...</code></p>
  </blockquote>
  
  <p>I've already handled getting the <code>#!</code> added to <code>slider3.py</code> and <code>chmod +x</code> by using the method that was not working for <code>gentest.cc</code>.  I've also handled adding <code>slider3.py</code> to the list of files that get installed.</p>
  
  <blockquote>
    <p><code>EXTRA_DIST=testite.sh slider3_base.py</code></p>
    
    <p><code>bin_SCRIPTS = slider3.py</code></p>
    
    <p><code>CLEANFILES = $(bin_SCRIPTS)</code></p>
    
    <p><code>slider3.py: slider3_base.py</code></p>
    
    <blockquote>
      <p><code>rm -f slider3.py</code></p>
      
      <p><code>echo "#! " $(PYTHON) &gt; slider3.py</code></p>
      
      <p><code>cat slider3_base.py &gt;&gt; slider3.py</code></p>
      
      <p><code>chmod +x slider3.py</code></p>
    </blockquote>
  </blockquote>
  
  <p><code>gentest</code> is defined this way in <code>Makefile.am</code>:</p>
  
  <blockquote>
    <p><code>bin_PROGRAMS = gentest</code></p>
    
    <p><code>gentest_SOURCES = gentest.cc</code></p>
    
    <p><code>gentest_LDADD = libgen.a #../libsbsat.la $(LIBM)</code></p>
  </blockquote>
  
  <p>And this fails to be run during make (note the <code>@</code> pattern is successfully expanded in <code>Makefile</code>):</p>
  
  <blockquote>
    <p><code>gentest.cc:</code></p>
    
    <blockquote>
      <p><code>$(SED) -i "s|__PREFIX__|@prefix@|" gentest.cc</code></p>
    </blockquote>
  </blockquote>
  
  <p>Any ideas on how to get <code>sed</code> to run before compiling <code>gentest.cc</code>?</p>