title: Standalone, minimal configure script for portable code
body: <p>I've run into an issue with portability of code that I've written that I wish to distribute, it isn't. The Makefiles that I send along require a lot of editing before users can compile and optimize the code for their systems, which is something I'd like to avoid (obviously). I've been looking into automake and autoconf lately and I've been able to successfully generate a configure script to generate Makefiles for my system. The problem is that I can't seem to get it to work on machines that don't have autoconf or automake installed or just a different version. So I don't have to put it all here, I've been able to replicate these results with a simpler "hello world" program</p>
  
  <p>hello.c</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int main(){
    cout &lt;&lt; "Hello World" &lt;&lt; endl;
    return 0;
  }
  </code></pre>
  
  <p>Makefile.am</p>
  
  <pre><code>bin_PROGRAMS=hello
  hello_SOURCES=hello.c
  </code></pre>
  
  <p>Then I run autoscan. I don't particularly care about the versions here, so I just move <code>configure.scan</code> to <code>configure.ac</code>. Then I run automake. Just for the sake of completeness, I get these errors:</p>
  
  <pre><code>configure.ac: error: no proper invocation of AM_INIT_AUTOMAKE was found.
  configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
  configure.ac: that aclocal.m4 is present in the top-level directory,
  configure.ac: and that aclocal.m4 was recently regenerated (using aclocal)
  Makefile.am: error: required file './INSTALL' not found
  Makefile.am:   'automake --add-missing' can install 'INSTALL'
  Makefile.am: error: required file './NEWS' not found
  Makefile.am: error: required file './README' not found
  Makefile.am: error: required file './AUTHORS' not found
  Makefile.am: error: required file './ChangeLog' not found
  Makefile.am: error: required file './COPYING' not found
  Makefile.am:   'automake --add-missing' can install 'COPYING'
  configure.ac:7: error: required file 'config.h.in' not found
  Makefile.am: error: required file './depcomp' not found
  Makefile.am:   'automake --add-missing' can install 'depcomp'
  /usr/share/automake-1.13/am/depend2.am: error: am__fastdepCC does not appear in AM_CONDITIONAL
  /usr/share/automake-1.13/am/depend2.am:   The usual way to define 'am__fastdepCC' is to add 'AC_PROG_CC'
  /usr/share/automake-1.13/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again
  /usr/share/automake-1.13/am/depend2.am: error: AMDEP does not appear in AM_CONDITIONAL
  /usr/share/automake-1.13/am/depend2.am:   The usual way to define 'AMDEP' is to add one of the compiler tests
  /usr/share/automake-1.13/am/depend2.am:     AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,
  /usr/share/automake-1.13/am/depend2.am:     AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC
  /usr/share/automake-1.13/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again 
  </code></pre>
  
  <p>So I fix the errors:</p>
  
  <pre><code>touch NEWS README AUTHORS ChangeLog
  automake --add-missing
  add `AM_INIT_AUTOMAKE(hello, 1.0)` to configure.ac
  aclocal
  autoheader
  automake
  </code></pre>
  
  <p>And then the only error I get is the fact that automake doesn't like the number of argument that I pass into <code>AM_INIT_AUTOMAKE</code>. Then I run <code>autoconf</code> and <code>configure</code>. The configure script does it's thing and generates a usable makefile. Now the problem is when I try to move it to a different system.</p>
  
  <p>I can get the configure script to run, but then I get the following error when I try to <code>make</code></p>
  
  <pre><code>cd . &amp;&amp; /bin/sh /home/dbwy/autohell/missing automake-1.13 --gnu
  /home/dbwy/autohell/missing: line 81: automake-1.13: command not found
  WARNING: 'automake-1.13' is missing on your system.
           You should only need it if you modified 'Makefile.am' or
           'configure.ac' or m4 files included by 'configure.ac'.
           The 'automake' program is part of the GNU Automake package:
           &lt;http://www.gnu.org/software/automake&gt;
           It also requires GNU Autoconf, GNU m4 and Perl in order to run:
           &lt;http://www.gnu.org/software/autoconf&gt;
           &lt;http://www.gnu.org/software/m4/&gt;
           &lt;http://www.perl.org/&gt;
  make: *** [Makefile.in] Error 1
  </code></pre>
  
  <p>So it seems as though my problem is in the fact that the Makefiles that get generated by <code>configure</code> are implicitly dependent on <code>automake</code>. I know in my experiences using configure files in the past that this isn't always required (because I just installed the autotools suite to generate this project), so I'm wondering how I can do this? I.e. how can I create a configure file that I can give to any UNIX-type machine and have them be able to install it without having automake or autoconf (I run into a problem with autoconf on a Mac). My end goal is to be able to give someone the source tree and configure script and have them be able to customize which compiler they use, etc...</p>