buildroot中配置自定义APP

675 阅读1分钟

C

# package/Config.in
source "package/helloworld/Config.in"

# package/helloworld/Config.in
config BR2_PACKAGE_HELLOWORLD
    bool "helloworld"
    help
      This is a demo to add local app.

# package/helloworld/helloworld.mk
HELLOWORLD_VERSION:= 1.0.0
HELLOWORLD_SITE:= $(CURDIR)/work/helloworld
HELLOWORLD_SITE_METHOD:=local
HELLOWORLD_INSTALL_TARGET:=YES

define HELLOWORLD_BUILD_CMDS
    $(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D) all
endef

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

define HELLOWORLD_PERMISSIONS
    /bin/helloworld f 4755 0 0 - - - - -
endef

$(eval $(generic-package))

# work/helloworld/helloworld.c
#include <stdio.h>

void main(void)
{
    printf("Hello world.\n");
}

# work/helloworld/Makefile
CPPFLAGS += 
LDLIBS += 

all: helloworld

analyzestack: helloworld.o
    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)

clean:
    rm -f *.o helloworld

.PHONY: all clean

CXX

# package/Config.in
source "package/cxk_demo/Config.in"

# package/cxk_demo/Config.in
config BR2_PACKAGE_CXK_DEMO
	bool "cxk_demo"
	help
	  This is some text to describe what cxk-demo is.
	  
# package/cxk_demo/cxk_demo.mk
CXK_DEMO_SITE = $(CURDIR)/work/cxk_demo
CXK_DEMO_SITE_METHOD = local
CXK_DEMO_INSTALL_STAGING = YES
CXK_DEMO_CONF_OPTS = -DBUILD_DEMOS=ON
$(eval $(cmake-package))

# work/cxk_demo/main.cpp
#include <iostream>
int main() {
    std::cout << "Hello" << std::endl;
    return 0;
}

# work/cxk_demo/CMakeList.txt
cmake_minimum_required(VERSION 3.10)
project(cxk_demo)
set(CMAKE_CXX_STANDARD 14)

add_executable(cxk_demo main.cpp)

INSTALL(TARGETS cxk_demo RUNTIME DESTINATION bin)