ツール autoreconf を試す。

はじめに

Makefileの直接編集によるビルドが、ちょっと手間かかると思った。
そこで、いろいろなツールを試してみようとしている。
以下 autoreconf で hello world を実行させるまでの手順を示す。

ソース等一式置いてある。
https://github.com/tomohikoseven/autoreconf

手順

  1. hello.cを作る
  2. Makefile.amを作る
  3. [autoscan]実行
  4. configure.scan -> configure.ac にファイル名変更
  5. configure.acの編集
  6. [autoreconf -ivf]の実行
  7. [./configure && make]の実行

1.hello.cを作る

andre@andre-VirtualBox:~/work/autoreconf/hello$ cat hello.c
#include

int
main( )
{
    printf( "hello world.\n" );
    return 0;
}

2.Makefile.amを作る

andre@andre-VirtualBox:~/work/autoreconf/hello$ cat Makefile.am
bin_PROGRAMS  = hello
hello_SOURCES = hello.c

3.[autoscan]実行

andre@andre-VirtualBox:~/work/autoreconf/hello$ autoscan

4.configure.scan -> configure.ac にファイル名変更

andre@andre-VirtualBox:~/work/autoreconf/hello$ cp -p configure.{scan,ac}

5.configure.acの編集

andre@andre-VirtualBox:~/work/autoreconf/hello$ diff configure{.scan,.ac}
5c5,6
< AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
    • -
> AC_INIT([hello], [1.0]) > AM_INIT_AUTOMAKE([-Wall -Werror foreign])

6.[autoreconf -ivf]の実行

andre@andre-VirtualBox:~/work/autoreconf/hello$ autoreconf -ivf
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:6: installing `./install-sh'
configure.ac:6: installing `./missing'
Makefile.am: installing `./depcomp'
autoreconf: Leaving directory `.'

7.[./configure && make]の実行

andre@andre-VirtualBox:~/work/autoreconf/hello$ ./configure && make
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... ccache gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether ccache gcc accepts -g... yes
checking for ccache gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of ccache gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
make  all-am
make[1]: ディレクトリ `/home/andre/work/autoreconf/hello' に入ります
ccache gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
ccache gcc  -g -O2   -o hello hello.o
make[1]: ディレクトリ `/home/andre/work/autoreconf/hello' から出ます

最後に、実行結果

andre@andre-VirtualBox:~/work/autoreconf/hello$ ./hello
hello world.