"크로스컴파일"의 두 판 사이의 차이
(새 문서: 타겟: arm =크로스 컴파일러 설치= $ sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf =pkg-config스크립트=) |
(→configure.ac 생성) |
||
(같은 사용자의 중간 판 12개는 보이지 않습니다) | |||
5번째 줄: | 5번째 줄: | ||
$ sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf | $ sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf | ||
− | =pkg- | + | =pkg-config 스크립트= |
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | #!/bin/sh | ||
+ | if [ "$CROSS_COMPILING" = TRUE ]; then | ||
+ | SYSROOT=[타켓루트경로] | ||
+ | export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig:${SYSROOT}/usr/share/pkgconfig | ||
+ | export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig | ||
+ | export PKG_CONFIG_SYSROOT_DIR=${SYSROOT} | ||
+ | fi | ||
+ | |||
+ | exec pkg-config "$@" | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | =빌드과정= | ||
+ | |||
+ | 흔히 configure 전까지의 과정을 묶어서 bootstrap 또는 autogen.sh 라는 script 로 만들어서 한꺼번에 실행시킨다. | ||
+ | |||
+ | ==Makefile.am 작성== | ||
+ | |||
+ | #바이너리명 | ||
+ | bin_PROGRAMS = hello | ||
+ | #소스명 | ||
+ | hello_SOURCES = hello.c | ||
+ | |||
+ | ==configure.ac 생성== | ||
+ | |||
+ | $ autoscan | ||
+ | |||
+ | 생성된 configure.scan를 수정하여 configure.ac로 저장 | ||
+ | |||
+ | AC_INIT, AM_INIT_AUTOMAKE는 필수이다. | ||
+ | |||
+ | AC_INIT는 적절히 수정한다. | ||
+ | |||
+ | AM_INIT_AUTOMAKE는 추가한다. | ||
+ | |||
+ | AM_INIT_AUTOMAKE | ||
+ | |||
+ | ==configure 생성== | ||
+ | |||
+ | $ aclocal | ||
+ | $ autoheader | ||
+ | $ autoconf | ||
+ | |||
+ | ==Makefile.in 생성== | ||
+ | |||
+ | $ automake --foreign --add-missing --copy | ||
+ | |||
+ | ==Makefile 생성== | ||
+ | |||
+ | $ ./configure | ||
+ | |||
+ | ===Makefile 구조=== | ||
+ | <syntaxhighlight lang="makefile"> | ||
+ | 목적규칙: 의존성 | ||
+ | 레시피 | ||
+ | 의존성: 파일이 바뀌었는지 확인할 파일들(증분빌드) | ||
+ | 설치 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==빌드== | ||
+ | |||
+ | $ make | ||
+ | $ make check | ||
+ | $ make install | ||
+ | |||
+ | 기본설치 경로: /usr/local | ||
+ | [[분류:프로그래밍]] |
2022년 4월 10일 (일) 02:08 기준 최신판
타겟: arm
목차
크로스 컴파일러 설치[편집 | 원본 편집]
$ sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
pkg-config 스크립트[편집 | 원본 편집]
#!/bin/sh
if [ "$CROSS_COMPILING" = TRUE ]; then
SYSROOT=[타켓루트경로]
export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig:${SYSROOT}/usr/share/pkgconfig
export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
fi
exec pkg-config "$@"
빌드과정[편집 | 원본 편집]
흔히 configure 전까지의 과정을 묶어서 bootstrap 또는 autogen.sh 라는 script 로 만들어서 한꺼번에 실행시킨다.
Makefile.am 작성[편집 | 원본 편집]
#바이너리명 bin_PROGRAMS = hello #소스명 hello_SOURCES = hello.c
configure.ac 생성[편집 | 원본 편집]
$ autoscan
생성된 configure.scan를 수정하여 configure.ac로 저장
AC_INIT, AM_INIT_AUTOMAKE는 필수이다.
AC_INIT는 적절히 수정한다.
AM_INIT_AUTOMAKE는 추가한다.
AM_INIT_AUTOMAKE
configure 생성[편집 | 원본 편집]
$ aclocal $ autoheader $ autoconf
Makefile.in 생성[편집 | 원본 편집]
$ automake --foreign --add-missing --copy
Makefile 생성[편집 | 원본 편집]
$ ./configure
Makefile 구조[편집 | 원본 편집]
목적규칙: 의존성
레시피
의존성: 파일이 바뀌었는지 확인할 파일들(증분빌드)
설치
빌드[편집 | 원본 편집]
$ make $ make check $ make install
기본설치 경로: /usr/local