cbuildout-of-sourcemakepp

makepp: how to manage several builds with common source dir?


I have a source tree:

/bootloader
/firmware
/system

and want to manage two separate builds for firmware and bootloader, each of them using common system sources but compiles them differently (i.e. with its own set of options).

Builds must be out-of-tree. Obvious "repository" feature of makepp is not a solution here, because it breaks this principle. Symbolic links are not solution too, because it must work on Windows.

The problem actually is in shared system sources, whose relative path structure differs from others, causing common pattern rules not work for them:

BUILD_PATH = $(relative_to $(PROJECT_PATH), .)/BUILD/$(relative_to ., $(PROJECT_PATH)) # trick to be able to extend rules for specific files at different subtree levels (if we use Makeppfile for each level)
...
$(BUILD_PATH)/%.o : %.c
    ...

Approach with single RootMakeppfile and include *.mk files (instead loading them) also doesn't allow me to do something like that:

$(BUILD_ROOT_PATH)/*/%.o : %.c

I've tried a lot of totally different approaches. It's not such trivial, as it seems to be at first glance. Please, help.


Solution

  • I finally managed how to solve problem.

    Solution is to divide Rootmakeppfile project to two Rootmakeppfile subprojects (both loading ../system makeppfile in its own way), and perform build separately for each subproject (in its own build directory). Project structure with makefiles:

    /bootloader/
      ...
      BUILD/
      Rootmakeppfile
    /firmware/
      ...
      BUILD/
      Rootmakeppfile
    /system/
      ...
      Makeppfile
    /project.mk
    

    Common definitions .mk file should contain following lines:

    BUILD_ROOT_DIR = $(relative_to $(SUBPROJECT_PATH), .)/BUILD
    BUILD_OBJ_REL_PATH = $(BUILD_ROOT_DIR)/$(relative_to ., $(BUILD_OBJ_REL_DIR))
    BUILD_OBJ_REL_DIR ?= $(SUBPROJECT_PATH)
    

    Each subproject should include system as follows:

    load_makefile BUILD_OBJ_REL_DIR="$(SUBPROJECT_PATH)/.." ../system
    

    and define:

    global SUBPROJECT_PATH := $(abspath .)
    

    This approach makes possible to define pattern rules as follows:

    $(BUILD_OBJ_REL_PATH)/%.o : %.c
    

    Hope, it helps someone!