のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

autoconf2.13

初心者への GNU autoconf のススメを見ながらやってみる。

配布用ソフトウェアパッケージの作成時に使われるファイル:
 	
your source files --> [autoscan*] --> [configure.scan] --> configure.in

configure.in --.   .------> autoconf* -----> configure
               +---+
[aclocal.m4] --+   `---.
[acsite.m4] ---'       |
                       +--> [autoheader*] -> [config.h.in]
[acconfig.h] ----.     |
                 +-----'
[config.h.top] --+
[config.h.bot] --'

Makefile.in -------------------------------> Makefile.in

ソフトウェアパッケージの設定時に使われるファイル:
 	
                       .-------------> config.cache
configure* ------------+-------------> config.log
                       |
[config.h.in] -.       v            .-> [config.h] -.
               +--> config.status* -+               +--> make*
Makefile.in ---'                    `-> Makefile ---'
$ vi prog.c
$ touch Makefile.in <= 空のファイル作成
$ autoscan
prog.c:9: warning: getwd is deprecated, use getcwd instead
$ ls
Makefile.in  autoscan.log  configure.scan  prog.c <= configure.scanのファイルができた。
$ cat configure.scan 
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.68])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([prog.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([stdlib.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
$ cp configure.scan configure.in
$ autoconf
$ ls
Makefile.in     autoscan.log  configure.in    prog.c
autom4te.cache  configure     configure.scan
$ ./configure
config.status: error: cannot find input file: `config.h.in' <=これが必要
$ autoheader
$ ls
Makefile     autom4te.cache  config.h.in  config.status  configure.in    prog.c
Makefile.in  autoscan.log    config.log   configure      configure.scan
$ ./configure
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 how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h

$ ls
Makefile     autom4te.cache  config.h     config.log     configure     configure.scan
Makefile.in  autoscan.log    config.h.in  config.status  configure.in  prog.c
$ view Makefile <=空のファイルができる。
$ vi Makefile.in
#
# Makefile for autoconf tutorial
#

CC = @CC@
DEFS = @DEFS@
LIBS = @LIBS@

SRCS = pwd.c
OBJS = $(SRCS:.c=.o)
PROG = pwd

all: $(PROG)

$(PROG): $(OBJS)
	$(CC) -o $@ $(OBJS) $(LIBS)

.c.o:
	$(CC) $(DEFS) -c -o $@ $<

clean:
	rm -f $(OBJS)
$ ./configure 
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 how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
$ ls
Makefile     autom4te.cache  config.h     config.log     configure     configure.scan
Makefile.in  autoscan.log    config.h.in  config.status  configure.in  prog.c
$ automake
automake: `configure.ac' or `configure.in' is required
$ autoconf
autoconf: configure.in: No such file or directory
$ autoheader
/usr/bin/m4: cannot open `configure.in': No such file or directory
$ auto
autoconf        autoheader2.13  automake-1.11   autoreconf2.50  autoupdate2.13
autoconf2.13    autoheader2.50  automake-1.4    autoscan        
autoconf2.50    autom4te        autoreconf      autoscan2.13    
autoheader      automake        autoreconf2.13  autoupdate