autotools
ちょっと現実トウヒ気味に始めてみます。
てか、通勤方法が変わって本が全然読めなくなりました。それ以外にも理由はあるんですが、このあたりはスルーで。
最小規模の GNU Autotools
ええと、ココから example がオトせる模様。とりあえず 4 章から、という事にて foonly というナニを download。
バラしたら以下なカンジ。
$ tar xvf foonly-2.0.tar.gz foonly-2.0/ foonly-2.0/bootstrap foonly-2.0/configure.ac foonly-2.0/foo.c foonly-2.0/main.c foonly-2.0/Makefile.am foonly-2.0/nly.c foonly-2.0/parser.y foonly-2.0/scanner.l $
ええと、configure.in ではなくて configure.ac になってますな。微妙にハマッた記録を以下に。
駄目
ええと、bootstrap というナニがあるのでこれを実行すれば良いのかな。
$ ./bootstrap autoconf-wrapper: unrecognized option -fvi autoreconf: `aclocal.m4' is created autoreconf2.50: Entering directory `.' autoreconf2.50: configure.ac: not using Gettext autoreconf2.50: running: aclocal --output=aclocal.m4t autoreconf2.50: `aclocal.m4' is unchanged autoreconf2.50: configure.ac: tracing configure.ac:10: warning: AC_PROG_LEX invoked multiple times ../../lib/autoconf/programs.m4:779: AC_DECL_YYTEXT is expanded from... aclocal.m4:1080: AM_PROG_LEX is expanded from... configure.ac:10: the top level autoreconf2.50: configure.ac: not using Libtool autoreconf2.50: running: /usr/bin/autoconf --force configure.ac:10: warning: AC_PROG_LEX invoked multiple times ../../lib/autoconf/programs.m4:779: AC_DECL_YYTEXT is expanded from... aclocal.m4:1080: AM_PROG_LEX is expanded from... configure.ac:10: the top level autoreconf2.50: configure.ac: not using Autoheader autoreconf2.50: running: automake --add-missing --copy automake: configure.ac: installing `./install-sh' automake: configure.ac: installing `./mkinstalldirs' automake: configure.ac: installing `./missing' automake: configure.ac: installing `./config.guess' automake: configure.ac: installing `./config.sub' automake: Makefile.am: installing `./INSTALL' automake: Makefile.am: required file `./NEWS' not found automake: Makefile.am: required file `./README' not found automake: Makefile.am: installing `./COPYING' automake: Makefile.am: required file `./AUTHORS' not found automake: Makefile.am: required file `./ChangeLog' not found autoreconf2.50: Leaving directory `.' $
これは大丈夫と見てええのかどうか分かりませんが続けてみます。
$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking whether make sets $(MAKE)... yes ./configure: line 1873: foreign: command not found checking for working aclocal-1.4... found checking for working autoconf... found checking for working automake-1.4... found checking for working autoheader... found checking for working makeinfo... found 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 ISO C89... none needed checking for flex... flex checking for flex... (cached) flex checking lex output file root... lex.yy checking lex library... -lfl checking whether yytext is a pointer... yes checking for bison... bison -y configure: creating ./config.status config.status: creating Makefile config.status: WARNING: Makefile.in seems to ignore the --datarootdir setting $ make all gcc -DPACKAGE_NAME=\"foonly\" -DPACKAGE_TARNAME=\"foonly\" -DPACKAGE_VERSION=\"2.0\" -DPACKAGE_STRING=\"foonly\ 2.0\" -DPACKAGE_BUGREPORT=\"gary@ gnu.org\" -DPACKAGE=\"\" -DVERSION=\"\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -c main.c gcc -DPACKAGE_NAME=\"foonly\" -DPACKAGE_TARNAME=\"foonly\" -DPACKAGE_VERSION=\"2.0\" -DPACKAGE_STRING=\"foonly\ 2.0\" -DPACKAGE_BUGREPORT=\"gary@ gnu.org\" -DPACKAGE=\"\" -DVERSION=\"\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -c foo.c gcc -DPACKAGE_NAME=\"foonly\" -DPACKAGE_TARNAME=\"foonly\" -DPACKAGE_VERSION=\"2.0\" -DPACKAGE_STRING=\"foonly\ 2.0\" -DPACKAGE_BUGREPORT=\"gary@ gnu.org\" -DPACKAGE=\"\" -DVERSION=\"\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -c nly.c flex scanner.l && mv lex.yy.c scanner.c gcc -DPACKAGE_NAME=\"foonly\" -DPACKAGE_TARNAME=\"foonly\" -DPACKAGE_VERSION=\"2.0\" -DPACKAGE_STRING=\"foonly\ 2.0\" -DPACKAGE_BUGREPORT=\"gary@ gnu.org\" -DPACKAGE=\"\" -DVERSION=\"\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -c scanner.c bison -y parser.y && mv y.tab.c parser.c if test -f y.tab.h; then \ if cmp -s y.tab.h parser.h; then rm -f y.tab.h; else mv y.tab.h parser.h; fi; \ else :; fi gcc -DPACKAGE_NAME=\"foonly\" -DPACKAGE_TARNAME=\"foonly\" -DPACKAGE_VERSION=\"2.0\" -DPACKAGE_STRING=\"foonly\ 2.0\" -DPACKAGE_BUGREPORT=\"gary@ gnu.org\" -DPACKAGE=\"\" -DVERSION=\"\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -c parser.c parser.y: In function 'yyerror': parser.y:7: warning: incompatible implicit declaration of built-in function 'fprintf' parser.y:7: error: 'stderr' undeclared (first use in this function) parser.y:7: error: (Each undeclared identifier is reported only once parser.y:7: error: for each function it appears in.) make: *** [parser.o] Error 1 $
あらら。しかもワケワカらん parser.y で。中身は以下。以前 yacc のナニを色々掘ったコトもあるんですがさっぱり忘れてます。
$ cat parser.y %% x : '\n' ; %% yyerror (s) char *s; { fprintf (stderr, "%s\n", s); } $
これはメセジ的に include クサい、と思いググッて以下に修正。
$ cat parser.y %{ #include <stdio.h> %} %% x : '\n' ; %% yyerror (s) char *s; { fprintf (stderr, "%s\n", s); } $
これで make all したら正常終了したっぽい。ちなみに書籍には NEWS とか README とかを touch せい、とありますが bootstrap というスクリプトは以下
#!/bin/sh exec autoreconf -fvi
全然書籍と整合してないぞ (わら