Ref. https://linuxspot.tistory.com/45
make 는 실제로 소스를 컴파일하는 명령어입니다. make install은 make 명령어를 통해 빌드된 바이너리와 라이브러리를 prefix(configure 스크립트의 옵션 중 하나)로 지정된 폴더에 설치하는 명령어입니다.
현재 개발중인 소스에 Autotools를 적용하려면 다음의 두 파일을 작성해야 됩니다.
'Makefile.am' An input to automake
'configure.ac' An input to autoconf
Makefile.am은 automake 명령어의 입력으로 사용되는데, automake는 Makefile.am을 기반으로 Makefile.in 파일을 생성합니다. Makefile.in은 Makefile을 생성하기위한 템플릿이라고 보면 될 것 같습니다.
configure.ac는 autoconf 명령어의 입력으로 사용되는 파일입니다. 내부적으로 복잡한 과정을 거치지만 결과적으로 configure 스크립트를 생성하게 됩니다. configure.ac의 경우 autoscan 이라는 명령어를 통해 configure.scan 이라는 기본 파일을 생성할 수 있습니다. 일반적으로 configure.scan 파일을 configure.ac로 복사한 후 필요한 옵션들을 추가하는 방법을 사용합니다.
1.code 작성
2.autotool
- $autoscan
- configure.scan에서 아래내용을 수정후 파일명을 configure.ac로 변경
- Makefile.am 생성
- $autoreconf --install
- $./configure
- make
Example) Hello1
Tutorial
Learning the GNU developement tools에 나와있는 예제를 바탕으로 간단한 tutorial을 소개하겠습니다. (http://autotoolset.sourceforge.net/tutorial.html#SEC50)
작업 디레토리를 hello로 생성 한 뒤, 아래의 파일들을 생성합니다.
hello/Makefile.am
SUBDIRS = src
hello/src/hello.c
#include <stdio.h>
int main(void)
{
printf("Hello autotools\n");
return 0;
}
hello/src/Makefile.am
bin_PROGRAMS = hello
hello_SOURCES = hello.c
hello 폴더에 있는 Makefile.am은 SUBDIRS 변수를 이용해 source가 있는 하위 디렉토리(src)를 설정합니다. 여러 폴더에 소스가 있는 경우 상위 폴더에서 위와 같이 작성하면 빌드시 재귀적으로 Makefile이 수행 됩니다.
src 폴더의 Makefile.am는 실제 컴파일 될 소스와 target을 작성합니다. 위의 경우 실행파일 hello를 생성할 것이며 hello 바이너리를 생성하기 위한 source로 hello.c 파일을 컴파일 한다는 의미입니다.
이제 configure.ac 파일을 만들기 위해서 autoscan 명령어를 입력합니다.
hello $] autoscan
autoscan 입력 후 configure.scan 파일이 생성된 것을 확인할 수 있습니다.
hello $] ls
autoscan.log configure.scan Makefile.am src
configure.scan 파일을 configure.ac로 복사한 후, 편집기로 configure.ac 파일에 다음을 추가합니다.
[configure.scan]
[configure.ac]
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61) AC_INIT(hello, 1.0, bug@repot-address.com) AM_INIT_AUTOMAKE(hello, 1.0) 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
|
'잘좀하자 개발 > Yocto' 카테고리의 다른 글
[AutoTool] Troubleshooting (0) | 2019.10.17 |
---|---|
[AutoTool] #1 Install (0) | 2019.10.17 |
[Bitbake] CMD (0) | 2019.10.17 |
[BitBake] Tutorial (0) | 2019.03.12 |