友達、
flex+bison+C コード (おもちゃのコード、あなたが言う) 用に gnu-autotools を介して Makefile を作成しようとしています。手書きの Makefile は正常に動作します
CC=gcc #-g -Wall
FLEX=flex
BISON=bison
LIBS=lfl
PROG=parse
${PROG}:bib.y scan.l main.c
${BISON} -d bib.y
${FLEX} -i scan.l
${CC} -Wall main.c lex.yy.c bib.tab.c `pkg-config --cflags --libs gtk+-3.0 glib-2.0` -${LIBS} -o $@
clean:
rm -f lex.yy.c bib.tab.h ${PROG} bib.tab.c
touch scan.l bib.y main.c
未使用の変数に関する警告のみを与える:
$ make -f MAKEFILE
bison -d bib.y
flex -i scan.l
gcc -Wall main.c lex.yy.c bib.tab.c `pkg-config --cflags --libs gtk+-3.0 glib-2.0` -lfl -o parse
main.c: In function ‘main’:
main.c:35:8: warning: type defaults to ‘int’ in declaration of ‘yy_create_buffer’ [-Wimplicit-int]
main.c:35:8: warning: unused variable ‘yy_create_buffer’ [-Wunused-variable]
lex.yy.c:1120:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
lex.yy.c:1161:16: warning: ‘input’ defined but not used [-Wunused-function]
bib.y: In function ‘parse_entry’:
bib.y:79:9: warning: unused variable ‘author’ [-Wunused-variable]
しかし、autotools を使用してそれを作成しようとすると、次のような問題が発生します。
##Configure.ac (made mostly with autoscan)
AC_PREREQ([2.69])
AC_INIT([Bi-Try],[1.0],[rudra.banerjee@aol.co.uk])
AM_INIT_AUTOMAKE([1.9.6])
# Checks for programs.
AC_PROG_CC
AC_PROG_YACC
AC_PROG_LEX
# Checks for libraries.
#AC_PROG_LIBTOOL
# Checks for header files.
# Checks for library functions.
AM_PATH_GTK_3_0([3.4.0],,AC_MSG_ERROR([Gtk+ 3.0.0 or higher required.]))
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
そしてmakefile.am
bin_PROGRAMS = bitry
bitry_SOURCES = bib.y scan.l main.c
AM_YFLAGS = -d
AM_LFLAGS = -i
bitry_LDADD = @GTK_LIBS@ @LEXLIB@
AM_CFLAGS = @GTK_CFLAGS@
プロセスの出力は次のとおりです。
$ autoreconf --install Makefile.am: './INSTALL' のインストール Makefile.am: GNU General Public License v3 ファイルを使用した './COPYING' のインストール Makefile.am: COPYING ファイルをバージョン管理システム Makefile.am に追加することを検討してください:プロジェクトが使用するライセンスに関する質問を避けるため
$ ./configure -q
$ make -s
scan.o: In function `yy_get_previous_state':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1070: multiple definition of `yyin'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1070: first defined here
scan.o: In function `yy_switch_to_buffer':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1254: multiple definition of `yy_switch_to_buffer'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1254: first defined here
scan.o: In function `yy_delete_buffer':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1329: multiple definition of `yy_delete_buffer'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1329: first defined here
scan.o: In function `yy_flush_buffer':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1375: multiple definition of `yy_flush_buffer'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1375: first defined here
scan.o: In function `yy_create_buffer':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1299: multiple definition of `yy_create_buffer'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1299: first defined here
scan.o: In function `yyrestart':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1237: multiple definition of `yyrestart'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1237: first defined here
scan.o: In function `yylex':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:663: multiple definition of `yylex'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:663: first defined here
scan.o: In function `yy_get_previous_state':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1072: multiple definition of `yyout'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1072: first defined here
scan.o: In function `yypush_buffer_state':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1404: multiple definition of `yypush_buffer_state'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1404: first defined here
scan.o: In function `yypop_buffer_state':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1433: multiple definition of `yypop_buffer_state'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1433: first defined here
scan.o: In function `yy_scan_buffer':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1501: multiple definition of `yy_scan_buffer'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1501: first defined here
scan.o: In function `yy_scan_bytes':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1551: multiple definition of `yy_scan_bytes'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1551: first defined here
scan.o: In function `yy_scan_string':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1538: multiple definition of `yy_scan_string'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1538: first defined here
scan.o: In function `yyget_lineno':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1616: multiple definition of `yyget_lineno'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1616: first defined here
scan.o:(.data+0x0): multiple definition of `yylineno'
bib.o:(.data+0x0): first defined here
scan.o: In function `yyget_in':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1624: multiple definition of `yyget_in'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1624: first defined here
scan.o: In function `yyget_out':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1632: multiple definition of `yyget_out'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1632: first defined here
scan.o: In function `yyget_leng':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1640: multiple definition of `yyget_leng'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1640: first defined here
scan.o: In function `yyget_text':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1649: multiple definition of `yyget_text'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1649: first defined here
scan.o: In function `yyset_lineno':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1658: multiple definition of `yyset_lineno'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1658: first defined here
scan.o: In function `yyset_in':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1669: multiple definition of `yyset_in'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1669: first defined here
scan.o: In function `yyset_out':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1674: multiple definition of `yyset_out'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1674: first defined here
scan.o: In function `yyget_debug':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1680: multiple definition of `yyget_debug'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1680: first defined here
scan.o: In function `yy_get_previous_state':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1066: multiple definition of `yy_flex_debug'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1066: first defined here
scan.o: In function `yyset_debug':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1684: multiple definition of `yyset_debug'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1684: first defined here
scan.o: In function `yylex_destroy':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1717: multiple definition of `yylex_destroy'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1717: first defined here
scan.o: In function `yyalloc':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1763: multiple definition of `yyalloc'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1763: first defined here
scan.o: In function `yyrealloc':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1775: multiple definition of `yyrealloc'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1775: first defined here
scan.o: In function `yyfree':
/home/rudra/Programs/lex/Parsing/ruda/scan.c:1780: multiple definition of `yyfree'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.c:1780: first defined here
scan.o: In function `yywrap':
/home/rudra/Programs/lex/Parsing/ruda/scan.l:16: multiple definition of `yywrap'
bib.o:/home/rudra/Programs/lex/Parsing/ruda/bib.l:16: first defined here
main.o: In function `main':
/home/rudra/Programs/lex/Parsing/ruda/main.c:36: undefined reference to `setup_tree'
/home/rudra/Programs/lex/Parsing/ruda/main.c:44: undefined reference to `yyparse'
bib.o: In function `yylex':
bib.c:(.text+0x7c1): undefined reference to `yylval'
bib.c:(.text+0x84b): undefined reference to `yylval'
bib.c:(.text+0x872): undefined reference to `yylval'
scan.o: In function `yylex':
scan.c:(.text+0x7c1): undefined reference to `yylval'
scan.c:(.text+0x84b): undefined reference to `yylval'
scan.o:scan.c:(.text+0x872): more undefined references to `yylval' follow
collect2: error: ld returned 1 exit status
make: *** [bitry] Error 1
経験豊富な人の参考になるように、makefile の長い出力を投稿しました。あなたの助けを楽しみにしています。