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
hello.c
#include <iostream>
using namespace std;
int main(){
cout << "Hello World" << endl;
return 0;
}
Makefile.am
bin_PROGRAMS=hello
hello_SOURCES=hello.c
Then I run autoscan. I don't particularly care about the versions here, so I just move configure.scan
to configure.ac
. Then I run automake. Just for the sake of completeness, I get these errors:
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
So I fix the errors:
touch NEWS README AUTHORS ChangeLog
automake --add-missing
add `AM_INIT_AUTOMAKE(hello, 1.0)` to configure.ac
aclocal
autoheader
automake
And then the only error I get is the fact that automake doesn't like the number of argument that I pass into AM_INIT_AUTOMAKE
. Then I run autoconf
and configure
. 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.
I can get the configure script to run, but then I get the following error when I try to make
cd . && /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:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [Makefile.in] Error 1
So it seems as though my problem is in the fact that the Makefiles that get generated by configure
are implicitly dependent on automake
. 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...