Radix cross Linux Build System

Cross-platform build system is designed to build distributions of different operating systems for a set of target devices

39 Commits   2 Branches   2 Tags
     5         kx 
     5         kx 
     5         kx The fundamental principle of the build system
     5         kx =============================================
     5         kx 
     5         kx Assume that we need to build the program or alienated package for working
     5         kx on the three devices with names **ci20**, **bt01** and **dm64**. The first two devices
     5         kx (**ci20**, **bt01**) are based on the **MIPS** architecture, and the third device (**dm64**)
     5         kx is built on **ARM**-based processor. Toolchains for building our program, for
     5         kx simplicity, let's call **mips** and **arm**, respectively.
     5         kx 
     5         kx The build script of the source program is the same for each of our devices
     5         kx and is written on **GNU Make**.
     5         kx 
     5         kx If we present all available combinations of command line calls, required for
     5         kx building the program for our devices, we get:
     5         kx 
     5         kx ```bash
     5         kx  $ TOOLCHAIN=mips HARDWARE=ci20 make
     5         kx  $ TOOLCHAIN=mips HARDWARE=bt01 make
     5         kx  $ TOOLCHAIN=arm  HARDWARE=dm64 make
     5         kx ```
     5         kx 
     5         kx or (in case when the **TOOLCHAIN-HARDWARE** pairs are transmitted as arguments):
     5         kx 
     5         kx ```bash
     5         kx  $ make TOOLCHAIN=mips HARDWARE=ci20
     5         kx  $ make TOOLCHAIN=mips HARDWARE=bt01
     5         kx  $ make TOOLCHAIN=arm  HARDWARE=dm64
     5         kx ```
     5         kx 
     5         kx Thus, the **build system** must receive a **TOOLCHAIN-HARDWARE** pair, and then the
     5         kx **build system** has to determine which toolchain must be used for a particular
     5         kx device.
     5         kx 
     5         kx Let us now consider how to organize the sequence of command calls (on the
     5         kx **build system** level) in such way that the user can do these actions by
     5         kx applying only one call:
     5         kx 
     5         kx ```bash
     5         kx  $ make
     5         kx ```
     5         kx 
     5         kx without specifying additional arguments which are responsible for selection
     5         kx of the target device and applicable toolchain.
     5         kx 
     5         kx If we describe the list of valid terget devices at the beginning of our script,
     5         kx for example, as follows:
     5         kx 
     5         kx ```make
     5         kx COMPONENT_TARGETS  = $(HARDWARE_CI20)
     5         kx COMPONENT_TARGETS += $(HARDWARE_BT01)
     5         kx COMPONENT_TARGETS += $(HARDWARE_DM64)
     5         kx ```
     5         kx 
     5         kx then the **build system** can automatically construct a list of possible
     5         kx **TOOLCHAIN-HARDWARE** combinations for a given build script, which will looks
     5         kx like following:
     5         kx 
     5         kx ```make
     5         kx   targets = target_mips_ci20 target_mips_bt01 target_arm_dm64
     5         kx ```
     5         kx 
     5         kx With such list, the **build system** can restore arguments which are needed for
     5         kx each of three our calls. It is very simple to do. On the **GNU Make** language we can
     5         kx do it as shown by following lines:
     5         kx 
     5         kx ```make
     5         kx target_%: TOOLCHAIN = $(shell echo $(word 2, $(subst _, , $@)))
     5         kx target_%: HARDWARE = $(shell echo $(word 3, $(subst _, , $@)))
     5         kx target_%:
     5         kx 	$(MAKE) TOOLCHAIN=$(TOOLCHAIN) HARDWARE=$(HARDWARE)
     5         kx ```
     5         kx 
     5         kx Thus, if we call the **Make** utility without arguments then **TOOLCHAIN** and **HARDWARE**
     5         kx variables will be undefined. In this case the **build system** starts to collect the
     5         kx targets list. When the **targets** list will be complete the **build system** can do the
     5         kx call
     5         kx 
     5         kx ```make
     5         kx 	$(MAKE) TOOLCHAIN=$(TOOLCHAIN) HARDWARE=$(HARDWARE)
     5         kx ```
     5         kx 
     5         kx with valid arguments.
     5         kx 
     5         kx When (at the next call) the system will make sure that the **TOOLCHAIN** and
     5         kx **HARDWARE** variables are defined, the control of the build process will be passed
     5         kx to our build script without additional calculations.
     5         kx 
     5         kx The described mechanism is directly derived from the **GNU Make** documentation.
     5         kx 
     5         kx 
     5         kx References
     5         kx ----------
     5         kx 1. <http://www.gnu.org/software/make/manual/>
     5         kx 2. <https://radix.pro/build-system/>
     5         kx