Some target's don't need a BOARD to be specified, since they are the same for all...
authorDaniel Abrecht <public@danielabrecht.ch>
Sun, 15 May 2022 21:25:46 +0000 (21:25 +0000)
committerDaniel Abrecht <public@danielabrecht.ch>
Sun, 15 May 2022 21:25:46 +0000 (21:25 +0000)
chroot-build-helper/makefile
chroot-build-helper/real-makefile
makefile
platform/makefile
src/make-helper-functions.mk

index feb85360b7996e0142c90a9c0794a3405f2ac44e..fb6f603317d09add543207b451f17e3842f3d8e5 100644 (file)
@@ -1,4 +1,4 @@
-include ../src/make-helper-functions.mk
+include helper.mk
 
 # Genereting the build dependencies for debian packages to be built requires
 # the repos of those packages to be checked out. Always cloning them
index 38de510ebe58ec9007f67521f639069dfdd3cf11..ff4814b722a8de44bef27801ad2d84c2c04f731d 100644 (file)
@@ -1,7 +1,7 @@
-include ../src/make-helper-functions.mk
+include helper.mk
 include $(GENERATED_DEPENDENCIES_FILE)
 
-UEXEC=../build/bin/uexec
+UEXEC = $(project_root)/build/bin/uexec
 
 all: $(patsubst %,bin/$(BUILDER_PLATFORM)/$(DISTRO)/$(RELEASE)/%/.build,$(PACKAGES_TO_BUILD))
 repo: $(addprefix repo//,$(PACKAGES_TO_BUILD))
@@ -19,7 +19,7 @@ $(DEBOOTSTRAP_SCRIPT):
 build-env/$(DISTRO)/$(RELEASE)/rootfs: build-env/.dir | $(DEBOOTSTRAP_SCRIPT) $(UEXEC)
        set -ex; \
        mkdir -p "$@.tmp"; \
-       exec 8>"$@.lock"; \
+       exec 8>".$@.lock"; \
        flock 8; \
        if [ -d "$@" ]; then exit 0; fi; \
        uexec rm -rf "$@.tmp"; \
@@ -43,6 +43,8 @@ repo-add//%:
 clean-repo: $(addprefix clean-repo//,$(PACKAGES_TO_BUILD))
 update-repo: $(addprefix update-repo//,$(PACKAGES_TO_BUILD))
 
+buildenv: build-env/$(DISTRO)/$(RELEASE)/rootfs
+
 clean-buildenv: | $(UEXEC)
        uexec rm -rf "build-env/$(DISTRO)/$(RELEASE)"
        rmdir "build-env/$(DISTRO)/" || true
index 6626830057ab0178c03f304f12276d232dc22bb6..1efecd9a9cf91866c153f89d409d753152fd1902 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,3 +1,5 @@
+PLATFORM_AGNOSTIC_TARGETS += clean-fs-all clean-image-all
+
 include src/make-helper-functions.mk
 
 all: bin/$(IMAGE_NAME)
@@ -34,22 +36,19 @@ enter-buildenv:
        export PROMPT_COMMAND='if [ -z "$$PS_SET" ]; then PS_SET=1; PS1="(buildenv) $$PS1"; fi'; \
        $(USER_SHELL)
 
-%/.dir:
-       mkdir -p "$(dir $@)"
-       touch "$@"
-
-build/$(IMAGE_NAME)/deb/%.deb: | build/$(IMAGE_NAME)/deb/.dir
+build/$(DISTRO)-$(RELEASE)/deb/%.deb: | build/$(DISTRO)-$(RELEASE)/deb/.dir
        getdeb.sh "$@"
 
-$(DEBOOTSTRAP_SCRIPT): build/$(IMAGE_NAME)/deb/debootstrap.deb
+$(DEBOOTSTRAP_SCRIPT): build/$(DISTRO)-$(RELEASE)/deb/debootstrap.deb
        set -ex; \
-       exec 8>"build/.$(IMAGE_NAME).lock"; \
+       exec 8>"build/.debootstrap-$(DISTRO)-$(RELEASE).lock"; \
        flock 8; \
        if [ -e "$@" ]; then exit 0; fi; \
-       rm -rf "build/$(IMAGE_NAME)/debootstrap_script/"; \
-       mkdir -p "build/$(IMAGE_NAME)/debootstrap_script/"; \
-       cd "build/$(IMAGE_NAME)/debootstrap_script/"; \
-       ar x ../deb/debootstrap.deb; \
+       rm -rf "$$X_DEBOOTSTRAP_DIR"; \
+       mkdir -p "$$X_DEBOOTSTRAP_DIR"; \
+       debootstrap_deb="$$(realpath "build/$$DISTRO-$$RELEASE/deb/debootstrap.deb")"; \
+       cd "$$X_DEBOOTSTRAP_DIR"; \
+       ar x "$$debootstrap_deb"; \
        tar xzf data.tar.*;
        [ -e "$@" ]
        touch "$@"
@@ -97,8 +96,8 @@ clean-build: clean-image clean-fs
        rmdir build/ 2>/dev/null || true
 
 clean-build-all: clean-image-all clean-fs-all
-       $(MAKE) -C platform clean-build
-       $(MAKE) -C kernel clean-build
+       $(MAKE) -C platform clean-build-all
+       $(MAKE) -C kernel clean-build-all
        $(MAKE) -C chroot-build-helper clean-build-all
        rm -rf build/
 
index 5a4f0c0db6406e67d30ca6f2fbf650e26cf13972..5c86dd62ad7ca917abcb91305f9971c7506d7a1a 100644 (file)
@@ -1,8 +1,11 @@
 include ../src/make-helper-functions.mk
 
-all repo update-repo clean-repo clean-build clean-build-all: force
+all repo update-repo clean-repo clean-build: force
        make -C $(BUILDER_PLATFORM) $@
 
+clean-build-all: force
+       for BUILDER_PLATFORM in */; do $(MAKE) BUILDER_PLATFORM="$$BUILDER_PLATFORM" -C "$$BUILDER_PLATFORM" clean-build-all; done
+
 %: always
        make -C $(BUILDER_PLATFORM) $@
 
index 4b05753dd38d1b19a403db5391e5c9e718e006b7..ca2d840afef78b1c926764af6f87ae2ee929f7c4 100644 (file)
@@ -55,12 +55,32 @@ export $(CONFIG_VARS)
 
 CONF = user_config_override
 
-ifndef TO
+X_DEBOOTSTRAP_DIR = $(project_root)/build/$(DISTRO)-$(RELEASE)/debootstrap_script/
+DEBOOTSTRAP_SCRIPT = $(X_DEBOOTSTRAP_DIR)/usr/share/debootstrap/scripts/$(RELEASE)
+
+PLATFORM_AGNOSTIC_TARGETS += config-set//% config-unset//% config-after-update//%
+PLATFORM_AGNOSTIC_TARGETS += mirror//% chroot//% %/.dir
+PLATFORM_AGNOSTIC_TARGETS += $(project_root)/build/$(DISTRO)-$(RELEASE)/%
+PLATFORM_AGNOSTIC_TARGETS += build/$(DISTRO)-$(RELEASE)/%
+PLATFORM_AGNOSTIC_TARGETS += $(project_root)/build/bin/%
+PLATFORM_AGNOSTIC_TARGETS += build/bin/%
+PLATFORM_AGNOSTIC_TARGETS += $(DEBOOTSTRAP_SCRIPT)
+PLATFORM_AGNOSTIC_TARGETS += config-list
+PLATFORM_AGNOSTIC_TARGETS += generate_make_build_dependencies_for_debs
+PLATFORM_AGNOSTIC_TARGETS += clean-build-all
+
+ifndef BUILDER_PLATFORM
+ifneq (,$(MAKECMDGOALS))
+ifeq (,$(filter-out $(PLATFORM_AGNOSTIC_TARGETS),$(MAKECMDGOALS)))
+BUILDER_PLATFORM=none
+endif
+endif
+endif
+
 ifndef BUILDER_PLATFORM
 KNOWN_BOARDS=$(shell basename -a "$(project_root)/config/default/"b-*/ | sed 's|^b-||')
 $(error "$(newline)Please specify a board. Pass BOARD= to make, or set it in the config using `make config-set//BOARD TO=my-board`.$(newline)Availabe boards are: $(KNOWN_BOARDS)$(newline)")
 endif
-endif
 
 include $(project_root)/src/repositories.mk
 
@@ -70,12 +90,12 @@ include $(project_root)/src/package_list.mk
 
 export DEBIAN_FRONTEND=noninteractive
 
-ifndef TO
+ifneq ($(BUILDER_PLATFORM),none)
 include $(project_root)/platform/$(BUILDER_PLATFORM)/platform.mk
 endif
 
-export X_DEBOOTSTRAP_DIR = $(project_root)/build/$(IMAGE_NAME)/debootstrap_script/
-export DEBOOTSTRAP_SCRIPT = $(X_DEBOOTSTRAP_DIR)/usr/share/debootstrap/scripts/$(RELEASE)
+export X_DEBOOTSTRAP_DIR
+export DEBOOTSTRAP_SCRIPT
 
 define repodir
 repo/$(shell printf '%s\n' "$(repo-source@$(1))" | sed 's / ∕ g').git
@@ -152,7 +172,7 @@ config-set//%:
 config-unset//%:
        V="$(patsubst config-unset//%,%,$@)"; \
        sed -i "/^$$V[ ]*=/d" "$(project_root)/config/$(CONF)"
-       @ $(MAKE) --no-print-directory OLD_VALUE="$($(patsubst config-unset//%,%,$@))" "config-after-update@$(patsubst config-unset//%,%,$@)"
+       @ $(MAKE) --no-print-directory OLD_VALUE="$($(patsubst config-unset//%,%,$@))" "config-after-update//$(patsubst config-unset//%,%,$@)"
 
 clean-all: clean-repo clean-build
 clean-all-all: clean-repo clean-build-all