The BSP Makefile

Every BSP has a Makefile in its base directory and can have other Makefiles in subdirectories.

Most of the targets in the Makefile are board-specific. For the list of targets for each board, see the “Build the BSP (commandline)” section in the user's guide of the BSP you are working with. The Makefiles in a BSP typically define these targets in the Makefile:

all

Runs all the targets in the Makefile.

If you don't specify a target, make defaults to this target.

clean

Removes all IFS images.

For more information about Makefiles in general, see the GNU website at www.gnu.org/.

Sample Makefile

Below is a sample BSP Makefile for an ARM board. Note that the image-building process uses additional Makefiles, such as the /images/Makefile (see Product-specific targets), to build the final target image:

# This is the top-level Makefile for all source packages.
# It makes all the code in the "src" directory, then installs it in the
# "install" directory, then makes the images in the images directory 
# (if present).

ROOT_DIR := $(notdir $(CURDIR))
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)
unexport ROOT_DIR

.PHONY: all install clean links make_links dummy images prebuilt binaries

# Expands to a single newline character
define NEWLINE


endif

SUFFIXES := .mk

all: install links $(if $(wildcard images/*),images)
	@echo done

subdirs:=$(subst /Makefile,,$(wildcard */[Mm]akefile))

clean:
	$(foreach dir,$(subdirs), $(MAKE) -C$(dir) clean $(NEWLINE))
	-$(RM_HOST) -r install/*

install: $(if $(wildcard prebuilt/*),prebuilt)
	$(MAKE) -Csrc hinstall
	$(MAKE) -Csrc

# Have to invoke "make_links" target because the first make expands
# the $(wildcard ...) too soon - we might not have copied things into
# the "install" tree yet.
links:
	$(MAKE) make_links

make_links:
	$(foreach file,$(wildcard install/*/boot/build/*),cd images;$(LN_HOST) ../$(file) $(notdir $(file));cd ..;)

images:
	$(MAKE) -Cimages

prebuilt:
	cp -rf prebuilt/* install

For information about the make utility, see make in the Utilities Reference.

Product-specific targets

Some BSPs may be delivered with more than one possible target image already configured. For example, the x86_64 BSP includes a Makefile that defines a target image with Screen Graphics Subsystem support, and a target image without Screen support. The Makefile in the BSP's /images directory defines multiple targets, so you can generate either image or both:

all
Invokes both targets.
ifs-target
Invokes the build without Screen support, where target is the name of your platform (e.g., x86_64-generic).
ifs-target-graphics
Invokes the build with Screen support, where target is the name of your platform (e.g., x86_64-generic).