GNU Autotools를 이용한 프로젝트 만들기
Linux/Linux 일반 :
2009/04/21 17:09
다음 트리는 실제 autotools를 이용해서 작업하기 위해 사전에 입력해 둔 파일들 입니다. 즉 hello프로젝트에 필요한 파일들 입니다.
Makefile.am
automake의 입력으로 들어 갑니다.
autogen.sh
autotools를 편하게 쓰고자 만든 스크립트 입니다. 수동 입력하셔도 무방합니다.
src/Makefile.am
src/hello.c
필요한 모든 파일을 입력하셨으면, Autotools를 이용해서 프로젝트를 만들어 봅시다.
Step 1) autoscan을 이용해서 configure.scan을 만듭니다.
빨간색으로 표시된 두개의 파일이 생성됩니다.
configure.scan
Step 2) configure.scan을 이용하여 configure.ac를 만듭니다.
다음과 같이 편집합니다.
configure.ac
Step 3) autogen.sh 수행에 앞서 몇개의 빈(empty) 파일을 만듭니다.
Step 4) autogen.sh을 수행합니다.
Step 5) configure를 실행합니다.
Step 6-1) make를 수행합니다.
Step 6-2) make dist통해 배포본을 만듭니다.
이제 모든 작업이 끝났습니다.
자세한 사항은 autotools 문서를 참고하시기 바랍니다.
tifler@blackbox-home:~/Work/autotools-template$ tree
.
|-- Makefile.am
|-- autogen.sh
`-- src
|-- Makefile.am
`-- hello.c
1 directory, 4 files
.
|-- Makefile.am
|-- autogen.sh
`-- src
|-- Makefile.am
`-- hello.c
1 directory, 4 files
Makefile.am
automake의 입력으로 들어 갑니다.
SUBDIRS=@DIRS@
autogen.sh
autotools를 편하게 쓰고자 만든 스크립트 입니다. 수동 입력하셔도 무방합니다.
#!/bin/sh
aclocal
autoheader
autoconf
automake --add-missing --copy
aclocal
autoheader
autoconf
automake --add-missing --copy
src/Makefile.am
bin_PROGRAMS = hello
linux_SOURCES = hello.c
linux_SOURCES = hello.c
src/hello.c
#include <stdio.h>
int main(int argc, char **argv)
{
return printf("hello autotools\n");
}
int main(int argc, char **argv)
{
return printf("hello autotools\n");
}
필요한 모든 파일을 입력하셨으면, Autotools를 이용해서 프로젝트를 만들어 봅시다.
Step 1) autoscan을 이용해서 configure.scan을 만듭니다.
tifler@blackbox-home:~/Work/autotools-template$ ls
Makefile.am autogen.sh src
tifler@blackbox-home:~/Work/autotools-template$ autoscan
tifler@blackbox-home:~/Work/autotools-template$ ls
Makefile.am autogen.sh autoscan.log configure.scan src
tifler@blackbox-home:~/Work/autotools-template$
Makefile.am autogen.sh src
tifler@blackbox-home:~/Work/autotools-template$ autoscan
tifler@blackbox-home:~/Work/autotools-template$ ls
Makefile.am autogen.sh autoscan.log configure.scan src
tifler@blackbox-home:~/Work/autotools-template$
빨간색으로 표시된 두개의 파일이 생성됩니다.
configure.scan
# -*- 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([src/hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
autoscan.log 는 무시합니다.# 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([src/hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Step 2) configure.scan을 이용하여 configure.ac를 만듭니다.
tifler@blackbox-home:~/Work/autotools-template$ cp configure.scan configure.ac
tifler@blackbox-home:~/Work/autotools-template$ vi configure.ac
tifler@blackbox-home:~/Work/autotools-template$ vi configure.ac
다음과 같이 편집합니다.
configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(hello, 1.0, nungdo@gmail.com)
AM_INIT_AUTOMAKE(hello, 1.0)
AC_CONFIG_SRCDIR([src/hello.c])
AM_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(hello, 1.0, nungdo@gmail.com)
AM_INIT_AUTOMAKE(hello, 1.0)
AC_CONFIG_SRCDIR([src/hello.c])
AM_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Step 3) autogen.sh 수행에 앞서 몇개의 빈(empty) 파일을 만듭니다.
tifler@blackbox-home:~/Work/autotools-template$ touch NEWS
tifler@blackbox-home:~/Work/autotools-template$ touch README
tifler@blackbox-home:~/Work/autotools-template$ touch AUTHORS
tifler@blackbox-home:~/Work/autotools-template$ touch COPYING
tifler@blackbox-home:~/Work/autotools-template$ touch ChangeLog
tifler@blackbox-home:~/Work/autotools-template$ touch README
tifler@blackbox-home:~/Work/autotools-template$ touch AUTHORS
tifler@blackbox-home:~/Work/autotools-template$ touch COPYING
tifler@blackbox-home:~/Work/autotools-template$ touch ChangeLog
Step 4) autogen.sh을 수행합니다.
tifler@blackbox-home:~/Work/autotools-template$ ./autogen.sh
configure.ac:6: installing `./install-sh'
configure.ac:6: installing `./missing'
src/Makefile.am: installing `./depcomp'
Makefile.am: installing `./INSTALL'
tifler@blackbox-home:~/Work/autotools-template$ ls
AUTHORS Makefile.am aclocal.m4 config.h.in depcomp
COPYING Makefile.in autogen.sh configure install-sh
ChangeLog NEWS autom4te.cache configure.ac missing
INSTALL README autoscan.log configure.scan src
configure.ac:6: installing `./install-sh'
configure.ac:6: installing `./missing'
src/Makefile.am: installing `./depcomp'
Makefile.am: installing `./INSTALL'
tifler@blackbox-home:~/Work/autotools-template$ ls
AUTHORS Makefile.am aclocal.m4 config.h.in depcomp
COPYING Makefile.in autogen.sh configure install-sh
ChangeLog NEWS autom4te.cache configure.ac missing
INSTALL README autoscan.log configure.scan src
Step 5) configure를 실행합니다.
tifler@blackbox-home:~/Work/autotools-template$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
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 ISO C89... 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: creating src/Makefile
config.status: creating config.h
config.status: executing depfiles commands
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
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 ISO C89... 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: creating src/Makefile
config.status: creating config.h
config.status: executing depfiles commands
Step 6-1) make를 수행합니다.
tifler@blackbox-home:~/Work/autotools-template$ make
make all-recursive
make[1]: Entering directory `/home/tifler/Work/autotools-template'
Making all in src
make[2]: Entering directory `/home/tifler/Work/autotools-template/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -o hello hello.o
make[2]: Leaving directory `/home/tifler/Work/autotools-template/src'
make[2]: Entering directory `/home/tifler/Work/autotools-template'
make[2]: `all-am'를 위해 할 일이 없습니다
make[2]: Leaving directory `/home/tifler/Work/autotools-template'
make[1]: Leaving directory `/home/tifler/Work/autotools-template'
tifler@blackbox-home:~/Work/autotools-template$ ls src
Makefile Makefile.am Makefile.in hello hello.c hello.o
make all-recursive
make[1]: Entering directory `/home/tifler/Work/autotools-template'
Making all in src
make[2]: Entering directory `/home/tifler/Work/autotools-template/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc -g -O2 -o hello hello.o
make[2]: Leaving directory `/home/tifler/Work/autotools-template/src'
make[2]: Entering directory `/home/tifler/Work/autotools-template'
make[2]: `all-am'를 위해 할 일이 없습니다
make[2]: Leaving directory `/home/tifler/Work/autotools-template'
make[1]: Leaving directory `/home/tifler/Work/autotools-template'
tifler@blackbox-home:~/Work/autotools-template$ ls src
Makefile Makefile.am Makefile.in hello hello.c hello.o
Step 6-2) make dist통해 배포본을 만듭니다.
tifler@blackbox-home:~/Work/autotools-template$ make dist
{ test ! -d hello-1.0 || { find hello-1.0 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr hello-1.0; }; }
test -d hello-1.0 || mkdir hello-1.0
list='src'; for subdir in $list; do \
if test "$subdir" = .; then :; else \
test -d "hello-1.0/$subdir" \
|| /bin/mkdir -p "hello-1.0/$subdir" \
|| exit 1; \
distdir=`CDPATH="${ZSH_VERSION+.}:" && cd hello-1.0 && pwd`; \
top_distdir=`CDPATH="${ZSH_VERSION+.}:" && cd hello-1.0 && pwd`; \
(cd $subdir && \
make \
top_distdir="$top_distdir" \
distdir="$distdir/$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
make[1]: Entering directory `/home/tifler/Work/autotools-template/src'
make[1]: Leaving directory `/home/tifler/Work/autotools-template/src'
find hello-1.0 -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec /bin/bash /home/tifler/Work/autotools-template/install-sh -c -m a+r {} {} \; \
|| chmod -R a+r hello-1.0
tardir=hello-1.0 && /bin/bash /home/tifler/Work/autotools-template/missing --run tar chof - "$tardir" | GZIP=--best gzip -c >hello-1.0.tar.gz
{ test ! -d hello-1.0 || { find hello-1.0 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr hello-1.0; }; }
tifler@blackbox-home:~/Work/autotools-template$ ls
AUTHORS Makefile.in autoscan.log configure.ac src
COPYING NEWS config.h configure.scan stamp-h1
ChangeLog README config.h.in depcomp
INSTALL aclocal.m4 config.log hello-1.0.tar.gz
Makefile autogen.sh config.status install-sh
Makefile.am autom4te.cache configure missing
{ test ! -d hello-1.0 || { find hello-1.0 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr hello-1.0; }; }
test -d hello-1.0 || mkdir hello-1.0
list='src'; for subdir in $list; do \
if test "$subdir" = .; then :; else \
test -d "hello-1.0/$subdir" \
|| /bin/mkdir -p "hello-1.0/$subdir" \
|| exit 1; \
distdir=`CDPATH="${ZSH_VERSION+.}:" && cd hello-1.0 && pwd`; \
top_distdir=`CDPATH="${ZSH_VERSION+.}:" && cd hello-1.0 && pwd`; \
(cd $subdir && \
make \
top_distdir="$top_distdir" \
distdir="$distdir/$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
make[1]: Entering directory `/home/tifler/Work/autotools-template/src'
make[1]: Leaving directory `/home/tifler/Work/autotools-template/src'
find hello-1.0 -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec /bin/bash /home/tifler/Work/autotools-template/install-sh -c -m a+r {} {} \; \
|| chmod -R a+r hello-1.0
tardir=hello-1.0 && /bin/bash /home/tifler/Work/autotools-template/missing --run tar chof - "$tardir" | GZIP=--best gzip -c >hello-1.0.tar.gz
{ test ! -d hello-1.0 || { find hello-1.0 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr hello-1.0; }; }
tifler@blackbox-home:~/Work/autotools-template$ ls
AUTHORS Makefile.in autoscan.log configure.ac src
COPYING NEWS config.h configure.scan stamp-h1
ChangeLog README config.h.in depcomp
INSTALL aclocal.m4 config.log hello-1.0.tar.gz
Makefile autogen.sh config.status install-sh
Makefile.am autom4te.cache configure missing
이제 모든 작업이 끝났습니다.
자세한 사항은 autotools 문서를 참고하시기 바랍니다.
'Linux > Linux 일반' 카테고리의 다른 글
| ubuntu edgy server locale 변경 (0) | 2009/04/21 |
|---|---|
| GNU Autotools를 이용한 프로젝트 만들기 (0) | 2009/04/21 |
| stty -a (0) | 2009/03/04 |
| 우분투 네트워크 bonding (2) | 2009/02/16 |


