mirさんの記事の「GNU Autotools で Hello World !」をやってみました。
Autotoolsというのを使って、Makeファイルを作っちゃおうというものです。
そもそも、Linux上でCを書いた経験もないので、ほとんど記事のまんまですが。。

環境は、Windows上のVMwareにCentOS4.4の環境です。

ページを参考に、ファイルを作ってみます。


# ll
-rw-rw-r--  1 maruta maruta 45 11  3 16:58 Makefile.em
-rw-rw-r--  1 maruta maruta 70 11  3 16:59 configure.in
-rw-rw-r--  1 maruta maruta 75 11  3 16:58 hello.c

ここでよく見ると Makefile.emになってます。。 Makefile.amじゃないとダメなのですがタイポしてます。
行った作業のままに書いてみます。

記事を参考に autoconfを実行


$ autoconf
-bash: autoconf: command not found

どうやら入っていないようです。。


$ yum list | grep autoconf
autoconf.noarch                          2.59-5                 base
autoconf213.noarch                       2.13-9                 base

どちらを入れればいいのかわからないのですが。。
とりあえず実行。


# yum install autoconf
Setting up Install Process
Setting up repositories

update                    100% |=========================|  951 B    00:00     

base                      100% |=========================| 1.1 kB    00:00     

addons                    100% |=========================|  951 B    00:00 ETA
addons                    100% |=========================|  951 B    00:00     

extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files

primary.xml.gz            100% |=========================| 150 kB    00:12     

update    : ################################################## 483/483
Added 13 new packages, deleted 0 old in 2.04 seconds

primary.xml.gz            100% |=========================|  61 kB    00:00     

extras    : ################################################## 252/252
Added 9 new packages, deleted 0 old in 0.82 seconds
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for autoconf to pack into transaction set.

autoconf-2.59-5.noarch.rp 100% |=========================|  17 kB    00:00
---> Package autoconf.noarch 0:2.59-5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 autoconf                noarch     2.59-5           base              628 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 628 k
Is this ok [y/N]: y
Downloading Packages:

(1/1): autoconf-2.59-5.no  87% |=====================    | 552 kB    00:00 ETA
(1/1): autoconf-2.59-5.no 100% |=========================| 628 kB    00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction

  Installing: autoconf                     ######################### [1/1] 

Installed: autoconf.noarch 0:2.59-5
Complete!

ちゃんと入ったようなので続き。


$ autofonfconf
configure.in:2: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.

なんか、大丈夫そうです。
次に、aclocal


$ aclocal
-bash: aclocal: command not found
$ yum list  | grelp aclocal

同じく入っていないようです。。
しかも、yumにもそれらしいパッケージはありません。

困ったときのGoogleさん。
「aclocal インストール」でぐぐったらビンゴです。
http://www.linux.or.jp/JF/JFdocs/LFS-BOOK/chapter06/automake.html
どうやら、Automakeと一緒に入るようです。


# yum install automake
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for automake to pack into transaction set.

automake-1.9.2-3.noarch.r 100% |=========================|  23 kB    00:00
---> Package automake.noarch 0:1.9.2-3 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 automake                noarch     1.9.2-3          base              442 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 442 k
Is this ok [y/N]: y
Downloading Packages:

(1/1): automake-1.9.2-3.n 100% |=========================| 442 kB    00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction

  Installing: automake                     ######################### [1/1] 

Installed: automake.noarch 0:1.9.2-3
Complete!

確認してみると、ちゃんと入ってます。


$ which aclocal
/usr/bin/aclocal

aclocal、autoconfを実行。

次にautomakeを実行します。


$ automake
configure.in: required file `./install-sh' not found
configure.in: required file `./missing' not found
automake: no `Makefile.am' found for any configure output

なんか変です。。記事の内容とエラーのコメント数が違います。

まぁ環境の違いだろうーぐらいの軽い気持ちで先に進んでみます。


$ automake -c -a -c
configure.in: installing `./install-sh'
configure.in: installing `./missing'
automake: no `Makefile.am' found for any configure output
$ ls -CF
Makefile.em  aclocal.m4  autom4te.cache/  configure*  configure.in  hello.c  install-sh*  missing*

確実に変です。。
COPYING、INSTALL、depcomp、install-sh、missingとかが出来るはずですが、出来ていません。

よくよく見比べてみると・・・・・・・・なんか、ファイル名が違う・・
というわけで、リネームして再実行


$ mv Makefile.em Makefile.am
$ automake
Makefile.am: required file `./INSTALL' not found
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
Makefile.am: required file `./COPYING' not found
Makefile.am: required file `./depcomp' not found
$ automake -a -c
Makefile.am: installing `./INSTALL'
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
Makefile.am: installing `./COPYING'
Makefile.am: installing `./depcomp'
$ ls -CF
COPYING  Makefile.am  autom4te.cache/  configure.in  hello.c      missing*
INSTALL  aclocal.m4   configure*       depcomp*      install-sh*

おぉ、こんどはばっちりですね。

続き


$ touch NEWS README AUHAUTHORS ChangeLog
[maruta@vmmaruta works]$ automake
Makefile.am: required file `./README' not found
Makefile.am: required file `./AUTHORS' not found

ん?? なんか変だ。。というわけで確認するとタイポが


$ ll
 252
-rw-r--r--  1 maruta maruta  17992 11  3 17:09 COPYING
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 ChangeLog
-rw-r--r--  1 maruta maruta   9273 11  3 17:09 INSTALL
-rw-rw-r--  1 maruta maruta     45 11  3 16:58 Makefile.am
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 NEWS
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 READMEAUTHORS
-rw-rw-r--  1 maruta maruta  38499 11  3 17:08 aclocal.m4
drwxr-xr-x  2 maruta maruta   4096 11  3 17:08 autom4te.cache
-rwxrwxr-x  1 maruta maruta 121589 11  3 17:08 configure
-rw-rw-r--  1 maruta maruta     70 11  3 16:59 configure.in
-rwxr-xr-x  1 maruta maruta  15205 11  3 17:09 depcomp
-rw-rw-r--  1 maruta maruta     75 11  3 16:58 hello.c
-rwxr-xr-x  1 maruta maruta   9206 11  3 17:09 install-sh
-rwxr-xr-x  1 maruta maruta  10587 11  3 17:09 missing
$ rm READMEAUTHORS
$ touch README ATUTHORS
$ automake
Makefile.am: required file `./AUTHORS' not found
$ mv ATUTHORS AUTHORS
$ automake
$ ll
 272
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 AUTHORS
-rw-r--r--  1 maruta maruta  17992 11  3 17:09 COPYING
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 ChangeLog
-rw-r--r--  1 maruta maruta   9273 11  3 17:09 INSTALL
-rw-rw-r--  1 maruta maruta     45 11  3 16:58 Makefile.am
-rw-rw-r--  1 maruta maruta  16586 11  3 17:10 Makefile.in
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 NEWS
-rw-rw-r--  1 maruta maruta      0 11  3 17:10 README
-rw-rw-r--  1 maruta maruta  38499 11  3 17:08 aclocal.m4
drwxr-xr-x  2 maruta maruta   4096 11  3 17:08 autom4te.cache
-rwxrwxr-x  1 maruta maruta 121589 11  3 17:08 configure
-rw-rw-r--  1 maruta maruta     70 11  3 16:59 configure.in
-rwxr-xr-x  1 maruta maruta  15205 11  3 17:09 depcomp
-rw-rw-r--  1 maruta maruta     75 11  3 16:58 hello.c
-rwxr-xr-x  1 maruta maruta   9206 11  3 17:09 install-sh
-rwxr-xr-x  1 maruta maruta  10587 11  3 17:09 missing

なんかミスしまくってますが、なんとか出来ました。

続いて configure!


$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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 ANSI C... 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

無事通りました!

rootにsuしてから make install


# make install
if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"hello\" -DVERSION=\"0.1\"  -I. -I.     -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi
gcc  -g -O2   -o hello  hello.o
make[1]: Entering directory `/home/maruta/works'
test -z "/usr/local/bin" || mkdir -p -- "/usr/local/bin"
  /usr/bin/install -c 'hello' '/usr/local/bin/hello'
make[1]: `install-data-am'
make[1]: Leaving directory `/home/maruta/works'

ばっちりですね。


$ which hello
/usr/local/bin/hello
$ hello
Hello World!

ちゃんと入りました~

まぁ、記事見ながらそのまんまやったので、入って当たり前ですが。
やっぱり自分の手を動かしながらやるとタイポも含めて、少しでも身にしみてくるような気がします。
これを踏まえて、MySQLディレクトリの中とか見てみると、違った発見がありそうです。

今回、Linuxのインストール時に開発ツールを選択しなかったためと思われますが、automake、autoconfの2つが必要でした。
また、MySQLのソースコンパイル時に入れた、gcc、なども必要かもしれません。