autotools 를 이용하여 프로젝트 빌드 구성
디렉토리 구성
.
├── Makefile.am
├── configure.ac
└── src
├── Makefile.am
└── hello.c
1 directory, 3 files
autotools 빌드 구성하기
configure.ac
AC_INIT([datast], [1.0], [jy.park@piolink.com])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AM_SILENT_RULES([yes])
AM_MAINTAINER_MODE
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
debug_default=minimum
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug=[no/minimum/yes]],
[turn on debugging (default=$debug_default)]),,
enable_debug=$debug_default)
if test "x$enable_debug" = "xyes"; then
test $cflags_set || CFLAGS="$CFLAGS -g"
DATAST_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
else
if test "x$enable_debug" = "xno"; then
DATAST_DEBUG_FLAGS="-D_DISABLE_ASSERT -DG_DISABLE_CHECKS"
fi
fi
AC_SUBST(DATAST_DEBUG_FLAGS)
LT_INIT
AC_PROG_CC
AM_PROG_CC_C_O
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Makefile am
SUBDIRS = src
ACLOCAL_AMFLAGS = -I m4
src/Makefile.am
bin_PROGRAMS = hello
hello_SOURCES = hello.c
src/hello.c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello world!\n");
return 0;
}
Autotools 구성하기
$ autoreconf -i
aclocal: warning: couldn't open directory 'm4': No such file or directory
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:10: installing 'build-aux/ar-lib'
configure.ac:10: installing 'build-aux/compile'
configure.ac:30: installing 'build-aux/config.guess'
configure.ac:30: installing 'build-aux/config.sub'
configure.ac:5: installing 'build-aux/install-sh'
configure.ac:5: installing 'build-aux/missing'
src/Makefile.am: installing 'build-aux/depcomp'
빌드에 필요한 스크립트들이 설치된다.
.
├── Makefile.am
├── Makefile.in
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── output.2
│ ├── requests
│ ├── traces.0
│ ├── traces.1
│ └── traces.2
├── build-aux
│ ├── ar-lib
│ ├── compile
│ ├── config.guess
│ ├── config.sub
│ ├── depcomp
│ ├── install-sh
│ ├── ltmain.sh
│ └── missing
├── config.h.in
├── configure
├── configure.ac
├── m4
│ ├── libtool.m4
│ ├── ltoptions.m4
│ ├── ltsugar.m4
│ ├── ltversion.m4
│ └── lt~obsolete.m4
└── src
├── Makefile.am
├── Makefile.in
└── hello.c
빌드, 컴파일 및 실행
$ ./configure
$ make
$ ./src/hello
'C' 카테고리의 다른 글
[GLIB2] GObject 개념 익히기 (0) | 2022.02.10 |
---|---|
[GLIB2] 개발 환경 구축 (0) | 2022.02.08 |
C언어 개발 환경 구축 (3) - YouCompleteMe (0) | 2020.07.17 |
C언어 개발 환경 구축 (2) - autotools (0) | 2020.07.17 |
C언어 개발 환경 구축 (1) - vim 에디터 (2) | 2020.07.17 |