Autotools 格闘中

新しめの Autotools (Autoconf&Automake) を使ってみよう - Slide list を参考に作業を進める。

自前の Makefile が便利なんだけど、やっぱり配布するとなると autotools ですよね。

作業

autoscan
#生成された configure.scan をリネーム
mv configure.scan configure.in

configure.in 編集前。いろいろ間違っている気がする。

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([VM.h])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_MAKE_SET

# Checks for libraries.

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h sys/time.h utmp.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_INT8_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_C_VOLATILE

# Checks for library functions.
AC_FUNC_ALLOCA
AC_CHECK_FUNCS([gettimeofday memmove memset strtol])

AC_CONFIG_FILES([Makefile
                 scripts/Makefile])
AC_CONFIG_SUBDIRS([gc-7.1alpha3
                   onig/onig-5.7.0])
AC_OUTPUT

configure.in を編集

AC_INIT(monar, 0.0.1, higepon@users.sourceforge.xx)
AM_INIT_AUTOMAKE # 追加

#とりあえず一階層にしておく
AC_CONFIG_FILES([Makefile])
AC_CONFIG_SUBDIRS([])

# Checks for programs. のあたりに gosh チェックを追加。
AC_CHECK_PROG(GOSH, gosh, gosh, false)
if test "$GOSH" != "gosh"
    then AC_MSG_ERROR([gosh not found. Gauche (http://practical-scheme.net/gauche/) is required to build.])
fi

Makefile.am

BOEHM_GC_DIR  = ./gc-7.1alpha3

bin_PROGRAMS = monar
monar_SOURCES = main.cpp scheme.cpp read.cpp Port.cpp Regexp.cpp Symbol.cpp VM.cpp freeproc.cpp Instruction.h
monar_CXXFLAGS = -D MONA_SCHEME -D USE_BOEHM_GC
INCLUDES = -I $(BOEHM_GC_DIR)/include

# Instruction.h
Instruction.h: ./instruction.scm
	@GOSH@ ./scripts/gen-insn.scm $(PWD)/$< > $(PWD)/$@

これだと Instruction.h ターゲットが動いてくれないなあ。
依存関係をさらに明示しないといけないんだろうか。