From 105c506ac639e89318621f7df89609f0c9525f26 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 8 Apr 2018 12:49:12 +0100 Subject: [PATCH] sample-package: create --- README.adoc | 36 ++++++++++++++++++++++++--------- br2 | 1 + build | 2 +- sample_package/Config.in | 4 ++++ sample_package/Makefile | 16 +++++++++++++++ sample_package/external.desc | 1 + sample_package/external.mk | 21 +++++++++++++++++++ sample_package/sample_package.c | 7 +++++++ 8 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 sample_package/Config.in create mode 100644 sample_package/Makefile create mode 100644 sample_package/external.desc create mode 100644 sample_package/external.mk create mode 100644 sample_package/sample_package.c diff --git a/README.adoc b/README.adoc index 4a5041c..3912ed6 100644 --- a/README.adoc +++ b/README.adoc @@ -221,6 +221,7 @@ Not all packages have an alias, when they don't, just use the form: ./build -- -reconfigure .... +[[retype]] === Don't retype arguments all the time It gets annoying to retype `-a aarch64` for every single command, or to remember `./build -B` setups. @@ -2792,15 +2793,7 @@ Buildroot built-in libraries, mostly under Libraries > Other: * libtommath * qhull -There are not yet enabled, but it should be easy to so: - -* enable them in link:br2[] and rebuild -* create a test program that uses each library under link:kernel_module/user[] - -External open source benchmarks. We will try to create Buildroot packages for them, add them to this repo, and potentially upstream: - -* http://parsec.cs.princeton.edu/ Mentioned on docs: http://gem5.org/PARSEC_benchmarks -* http://www.m5sim.org/Splash_benchmarks +There are not yet enabled, but it should be easy to so, see: <> ===== BLAS @@ -3637,13 +3630,15 @@ dmesg == Buildroot -=== Change Buildroot options +=== Custom Buildroot options We provide the following mechanisms: * `./build -b mybr2.gitignore`: append the file `mybr2.gitignore` to a single build. Must be passed every time you run `./build`. A good template is provided by: * `./build -B 'BR2_SOM_OPTION="myval"'`: append a single option to a single build. +You will then likely want to make those more permanent with: <> + === Find Buildroot options with make menuconfig `make menuconfig` is a convenient way to find Buildroot configurations: @@ -3733,6 +3728,27 @@ watch -n1 'ccache -s' while a build is going on in another terminal and my cooler is humming. Especially when the hit count goes up ;-) The joys of system programming. +=== Add new Buildroot packages + +First, see if you can't get away without actually adding a new package, for example: + +* if you have a standalone C file with no dependencies besides the C standard library to be compiled with GCC, just add a new file under link:kernel_module/user[] and you are done +* if you have a dependency on a library, first check if Buildroot doesn't have a package for it already with `ls buildroot/package`. If yes, just enable that package as explained at: <> + +If none of those methods are flexible enough for you, create a new package as follows: + +* use link:sample_package[] as a starting point +* fork this repository, and modify that package to do what you want +* read the comments on that package to get an idea of how to start +* check the main manual for more complicated things: https://buildroot.org/downloads/manual/manual.html +* don't forget to rebuild with: ++ +.... +./build -- sample_package-reconfigure +.... ++ +if you make any changes to that package after the initial build: <> + === BR2_TARGET_ROOTFS_EXT2_SIZE When adding new large package to the Buildroot root filesystem, it may fail with the message: diff --git a/br2 b/br2 index d8528c1..f31eeec 100644 --- a/br2 +++ b/br2 @@ -1,5 +1,6 @@ # Custom packages BR2_PACKAGE_KERNEL_MODULE=y +BR2_SAMPLE_PACKAGE=y # Rootfs BR2_TARGET_ROOTFS_CPIO=n diff --git a/build b/build index 5a931ac..b44b05b 100755 --- a/build +++ b/build @@ -112,7 +112,7 @@ if "$configure"; then for p in $(find "${root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do patch -N -r - -p 1 <"$p" || : done - make O="$buildroot_out_dir" BR2_EXTERNAL="../kernel_module:../gem5:../parsec-benchmark" "$defconfig" + make O="$buildroot_out_dir" BR2_EXTERNAL="../kernel_module:../gem5:../parsec-benchmark:../sample_package" "$defconfig" # TODO Can't get rid of these for now. # http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config for config_fragment in $config_fragments; do diff --git a/sample_package/Config.in b/sample_package/Config.in new file mode 100644 index 0000000..197d53d --- /dev/null +++ b/sample_package/Config.in @@ -0,0 +1,4 @@ +config BR2_PACKAGE_SAMPLE_PACKAGE + bool "sample_package" + help + Sample Buildroot package. diff --git a/sample_package/Makefile b/sample_package/Makefile new file mode 100644 index 0000000..b1bed7d --- /dev/null +++ b/sample_package/Makefile @@ -0,0 +1,16 @@ +.PHONY: all clean + +CFLAGS_EXTRA ?= -ggdb3 -fopenmp -O0 -std=c99 -Wall -Werror -Wextra +IN_EXT ?= .c +LIBS := +OUT_EXT ?= .out + +OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT)))) + +all: $(OUTS) + +%$(OUT_EXT): %$(IN_EXT) + $(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS) + +clean: + rm -f *'$(OUT_EXT)' diff --git a/sample_package/external.desc b/sample_package/external.desc new file mode 100644 index 0000000..d148f8e --- /dev/null +++ b/sample_package/external.desc @@ -0,0 +1 @@ +name: SAMPLE_PACKAGE diff --git a/sample_package/external.mk b/sample_package/external.mk new file mode 100644 index 0000000..34725a8 --- /dev/null +++ b/sample_package/external.mk @@ -0,0 +1,21 @@ +################################################################################ +# +# sample_package +# +################################################################################ + +SAMPLE_PACKAGE_VERSION = 1.0 +SAMPLE_PACKAGE_SITE = $(BR2_EXTERNAL_SAMPLE_PACKAGE_PATH) +SAMPLE_PACKAGE_SITE_METHOD = local + +define SAMPLE_PACKAGE_BUILD_CMDS + # D contains the source code of this package. + $(MAKE) -C '$(@D)' CC="$(TARGET_CC)" LD="$(TARGET_LD)" +endef + +define SAMPLE_PACKAGE_INSTALL_TARGET_CMDS + # Anything put inside TARGET_DIR will end up on the guest relative to the root directory. + $(INSTALL) -D -m 0755 $(@D)/*.out '$(TARGET_DIR)' +endef + +$(eval $(generic-package)) diff --git a/sample_package/sample_package.c b/sample_package/sample_package.c new file mode 100644 index 0000000..fa60b2a --- /dev/null +++ b/sample_package/sample_package.c @@ -0,0 +1,7 @@ +#include +#include + +int main(void) { + puts("hello sample_package"); + return EXIT_SUCCESS; +}