0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Autotoolsでアプリを作成しYoctoでビルドする

Last updated at Posted at 2017-09-12

前提

yoctoのフルビルドは1回終わっているものとする

Autotoolsでアプリを作成

ファイル作成

main.c, configure.ac, Makefile.amを用意する

main.c
# include <stdio.h>

int main(int argc, char *argv[])
{
    printf("hello, world\n");
    return 0;
}
configure.ac
AC_INIT([Tutorial Program], 1.0)
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
Makefile.am
bin_PROGRAMS = tut_prog
tut_prog_SOURCES = main.c

automakeがエラーしないようにファイルを作成しておく(忘れるとbitbakeが途中で止まる)

$ touch NEWS README AUTOURS ChangeLog

LICENSEファイルも用意してmd5sumを求めておく(レシピファイルで使用)

ビルド確認

$ aclocal
$ autoconf
$ automake --add-missing --foreign -c
$ ./configure
$ make
$ ./tut_prog
hello, world

Yoctoでビルド

本来であればyocto-layerでレイヤーを作ったり、既存のレイヤーに追加するのが正しいのだが、今回はソースディレクトリをレイヤーにしてしまう。

ソースディレクトリ以下にrecipes/tut-prog/tut-prog_0.1.bbとconf/layer.confを作成
(bitbakeは最後の_(アンダースコア)以下をバージョン名と見るのでtut_prog.bbのような名前はNG?)

conf/layer.conf
BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes/*/*.bb \
            ${LAYERDIR}/recipes/*/*.bbappend \
"
recipes/tut-prog/tut-prog_0.1.bb
DESCRIPTION = "Tutorial Program"
HOMEPAGE = "http://itage.co.jp"

LICENSE = "MIT"
LIC_FILES_CHKSUM = " \
  file://LICENSE;md5=44098158ddc38babf0e3ad46849b7ce3 \
"

inherit autotools

S="<プロジェクトの絶対パス>"

do_fetch() {
}

__BB_DONT_CACHE = "1"

LIC_FILES_CHKSUMのmd5の値は$ md5sum LICENSEした値を記入する。
__BB_DONT_CACHE = "1"がないとソースディレクトリがまるごとビルドディレクトリへ移動させられてしまう。

Yoctoのbuild/conf/bblayers.confのBBLAYERSにプロジェクトの絶対パスを追加しておくのも忘れずに。

後はbitbakeするだけ。

# 環境変数ファイルは読み込んでいる前提
$ bitbake tut-prog

問題点

  • LISECEファイルなしで済ます方法がわからない
  • make distcleanが必要ですという旨のエラーが発生し、build/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/tut-prog/0.1-r0以下にコピーされたプロジェクト内でmake distcleanする必要がある
0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?