Shammer's Philosophy

My private adversaria

Autotoolset を使ってみる

Tarball からビルドする際、呪文のように

  1. ./configure
  2. make
  3. make install

を実行しているが、この形式でインストールが可能にしてくれるのがAutotoolsetというもの。ちょっとだけ試しに使ってみる。

実行ファイルの用意

#include <stdio.h>

int main(){
    printf("HelloWorld\n");
    return 0;
}

その他のファイル

Makefile.am
bin_PROGRAMS = main
main_SOURCES = main.c
configure.in
AC_INIT(main, 0.1)
AC_PREREQ(2.65)
AC_CONFIG_SRCDIR(main.c)
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_INSTALL
AC_OUTPUT(Makefile)
実行結果
Workspace$ aclocal
Workspace$ autoconf
Workspace$ automake -a
Makefile.am: required file `./NEWS' not found
Makefile.am: required file `./README' not found
Makefile.am: required file `./AUTHORS' not found
Makefile.am: required file `./ChangeLog' not found
Workspace$  touch NEWS README AUTHORS ChangeLog
Workspace$ automake -a
Workspace$ ls
aclocal.m4  autom4te.cache  configure     COPYING  INSTALL     main.c       Makefile.in  NEWS
AUTHORS     ChangeLog       configure.in  depcomp  install-sh  Makefile.am  missing      README
Workspace$ ./configure 
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... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... 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 gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
Workspace$ make
gcc -DPACKAGE_NAME=\"main\" -DPACKAGE_TARNAME=\"main\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"main\ 0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"main\" -DVERSION=\"0.1\" -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc  -g -O2   -o main main.o  
Workspace$ ls
aclocal.m4      ChangeLog      configure     depcomp     main    Makefile     missing
AUTHORS         config.log     configure.in  INSTALL     main.c  Makefile.am  NEWS
autom4te.cache  config.status  COPYING       install-sh  main.o  Makefile.in  README
Workspace$ ./main
HelloWorld
Workspace$

なるほど。いつもやっていたアクションはこういう仕組みで作成されていたのか。。。よくわからないファイルもたくさんあったけれども、それぞれこの作業の過程で作成されるもののようだ。