diff --git a/Documentation/getting_started_development.md b/Documentation/getting_started_development.md index 053aa807d..f7407bab6 100644 --- a/Documentation/getting_started_development.md +++ b/Documentation/getting_started_development.md @@ -47,18 +47,18 @@ Note that the current iteration of `enter.sh` will try to load the **overlayfs** ``` root@somehashinhex:/build# -root@somehashinhex:/build# cat scripts/build-all.sh +root@somehashinhex:/build# make help [...] ``` -The _hassos_ developers provides another convenience script that will build hassos images for a (rather long!) list of targets - if you're not interested in building artifacts for all supported platforms, make sure to take a peek inside and monkeypatch away... After you're done making changes, start it, and go make a cup of tea. Or fifteen. +The _hassos_ developers provide a Makefile that will build hassos images for a (rather long!) list of targets. For example run the command below to start building the _ova_ variant, and go make a cup of tea. Or fifteen. ``` -root@0db6f7079872:/build# scripts/build-all.sh +root@0db6f7079872:/build# make ova [...] ``` -Personally, I removed all advertised build targets from the `all_platforms` array variable, expect for the _ova_ variant. That will result in a single VMDK image file at the very end of the build process. This image file is a compressed block device dump with a proper GPT partition table, prepared to ship into any OVA-compatible hypervisor's innards. For me, the end of the **ova** build steps looks like this: +That will result in a single VMDK image file at the very end of the build process. This image file is a compressed block device dump with a proper GPT partition table, prepared to ship into any OVA-compatible hypervisor's innards. For me, the end of the **ova** build steps looks like this: ``` [...] diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..32a691a47 --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +RELEASE_DIR = /build/release + +BUILDROOT=/build/buildroot +BUILDROOT_EXTERNAL=/build/buildroot-external +DEFCONFIG_DIR = $(BUILDROOT_EXTERNAL)/configs + +TARGETS := $(notdir $(patsubst %_defconfig,%,$(wildcard $(DEFCONFIG_DIR)/*_defconfig))) +TARGETS_CONFIG := $(notdir $(patsubst %_defconfig,%-config,$(wildcard $(DEFCONFIG_DIR)/*_defconfig))) + +.NOTPARALLEL: $(TARGETS) $(TARGETS_CONFIG) all + +.PHONY: $(TARGETS) $(TARGETS_CONFIG) all clean help + +all: $(TARGETS) + +$(RELEASE_DIR): + mkdir -p $(RELEASE_DIR) + +$(TARGETS_CONFIG): %-config: + @echo "config $*" + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$*_defconfig" + +$(TARGETS): %: $(RELEASE_DIR) %-config + @echo "build $@" + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) + cp -f $(BUILDROOT)/output/images/hassos_* $(RELEASE_DIR)/ + + # Do not clean when building for one target +ifneq ($(words $(filter $(TARGETS),$(MAKECMDGOALS))), 1) + @echo "clean $@" + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) clean +endif + @echo "finished $@" + +clean: + $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) clean + +help: + @echo "Supported targets: $(TARGETS)" + @echo "Run 'make ' to build a target image." + @echo "Run 'make all' to build all target images." + @echo "Run 'make clean' to clean the build output." + @echo "Run 'make -config' to configure buildroot for a target." diff --git a/scripts/build-all.sh b/scripts/build-all.sh deleted file mode 100755 index 7d74f628c..000000000 --- a/scripts/build-all.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -mkdir -p /build/release - -all_platforms=(ova rpi rpi0_w rpi2 rpi3 rpi3_64 tinker odroid_c2 intel_nuc opi_prime) -for platform in "${all_platforms[@]}"; do - make -C /build/buildroot BR2_EXTERNAL=/build/buildroot-external \ - "${platform}_defconfig" - make -C /build/buildroot BR2_EXTERNAL=/build/buildroot-external - cp -f /build/buildroot/output/images/hassos_* /build/release/ - - make -C /build/buildroot BR2_EXTERNAL=/build/buildroot-external \ - clean -done