0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

buildrootに新規アプリを追加

Last updated at Posted at 2024-10-22

必要なファイル

├─ package
│   ├─ helloworld
│   │   ├─ Config.in
│   │   ├─ Makefile
│   │   ├─ helloworld.mk
│   │   └─ helloworld.c
│   ├─ Config.in
...

package/helloworld/Config.in

config BR2_PACKAGE_HELLOWORLD
    bool "helloworld"
    help
      A simple hello world application.

package/helloworld/Makefile

好きに変更してください。

helloworld:
	$(CC) $(CFLAGS) -o helloworld helloworld.c $(LDFLAGS)

package/helloworld/helloworld.mk

HELLOWORLD_LICENSE = Public Domain

define HELLOWORLD_EXTRACT_CMDS
	cp package/helloworld/* $(@D)
endef

define HELLOWORLD_BUILD_CMDS
	(cd $(@D);CC=$(TARGET_CC) CFLAGS="$(TARGET_CFLAGS)" make)
endef

define HELLOWORLD_INSTALL_TARGET_CMDS
	$(INSTALL) -m 755 -D $(@D)/helloworld $(TARGET_DIR)/usr/bin/helloworld
endef

$(eval $(generic-package))

package/helloworld/helloworld.c

好きに作ってください。

package/Config.in

これだけは新規作成ではなく、
既存ファイルにsource "package/helloworld/Config.in"を追加

diff --git a/package/Config.in b/package/Config.in
index e1ceb81dc0..0c9939c3de 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -8,6 +8,7 @@ menu "Target packages"
        source "package/skeleton-init-openrc/Config.in"
        source "package/skeleton-init-systemd/Config.in"
        source "package/skeleton-init-sysv/Config.in"
+       source "package/helloworld/Config.in"
 
 menu "Audio and video applications"
        source "package/alsa-utils/Config.in"

menuconfig

Target packages から選択し、有効にする。

image.png

Save -> Exit

ビルド

make

実行

qemuでのコマンド例

$ qemu-system-x86_64 -M q35 -enable-kvm -kernel output/images/bzImage -append "root=/dev/vda console=ttyS0" -drive file=./output/images/rootfs.ext2,if=virtio,format=raw -net nic,model=virtio -display gtk -vga std -serial stdio

image.png

アプリのみ再ビルド

アプリのコードを修正した場合makeだけではアプリが再ビルドされない。

以下で行う。
make [package name]-dirclean;make [package name];make

helloworldの場合は以下

make helloworld-dirclean
make helloworld
make
0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?