Skip to content

Instantly share code, notes, and snippets.

@cladmi
Created September 10, 2018 15:17
Show Gist options
  • Save cladmi/1c5af63c753635b7cb173cf8311d0b5b to your computer and use it in GitHub Desktop.
Save cladmi/1c5af63c753635b7cb173cf8311d0b5b to your computer and use it in GitHub Desktop.
Order in which file are included in `Makefile.include` and what they define regarding dependencies

Order of definitions in Makefile.include

Include paths for a normal build regarding modules dependencies handling.

In the following description I use USEMODULE only even if some files are setting USEPKG it is just a specific case.

INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include

# This also trigger including cpu makefile.features with explicit name
-include $(RIOTBOARD)/$(BOARD)/Makefile.features

include $(RIOTMAKE)/pseudomodules.inc.mk  (needed for $(RIOTMAKE)/modules.inc.mk)
include $(RIOTMAKE)/defaultmodules.inc.mk (used after Makefile.dep)


# Include Board and CPU configuration
INCLUDES += $(addprefix -I,$(wildcard $(RIOTBOARD)/$(BOARD)/include))
include $(RIOTBOARD)/$(BOARD)/Makefile.include
  -including board/common/common_boards/Makefile.include
    # This is defining 'CPU'
    # Defining USEMODULE +=
    # Doing specific behavior depending on the modules used

INCLUDES += -I$(RIOTCPU)/$(CPU)/include
include $(RIOTCPU)/$(CPU)/Makefile.include
    # This is defining 'CPU_FAM' 'CPU_ARCH'
    # Defining USEMODULE +=
    # Defining USEPKG +=
    # Doing specific behavior depending on the modules used

include $(RIOTBASE)/Makefile.dep
    # Processed in a loop until USEMODULE is stable
USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE))


# At that point, all dependencies and USEMODULE have been resolved
# In theory...

# Process modules Makefile.include:
include $(RIOTBASE)/sys/Makefile.include
include $(RIOTBASE)/drivers/Makefile.include

-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)

    # Define 'INCLUDES' 'USEMDOULE_INCLUDES'
    # Arduino specific stuff
    # CFLAGS 'SOCK_HAS_IPV6'
    # UNDEF += (objects that MUST be included when building)
    # CFLAGS for configuration
    # LINKFLAGS for print_float/newlib-nano (trigger printf_float inclusion)
    # CFLAGS += -fstack-protector

    # In packages

    # DIRS (in packages)

    # CFLAGS to disable warnings
    # PSEUDOMODULES

    # CFLAGS_FPU in nordic_softdevice_ble

    # USEMODULE in gecko_sdk (can be moved directly to Makefile.dep)
    # qDSA: QDSA_IMPL: duplication of the 'module' mechanism

    # PKG_BUILDDIR (is overwritten by other packages)

    # USEMODULE in ndn-riot (can be moved directly to Makefile.dep)

# include bindist target
include $(RIOTMAKE)/bindist.inc.mk
    # USEMODULE += $(BIN_USEMODULE)  # Modifying USEMODULE again ?
    # Add build objects to DIST_FILES

# Add all USEMODULE modules to CFLAGS and populate BASELIBS
include $(RIOTMAKE)/modules.inc.mk
    # Define BASELIBS == list of build archives
    # Add MODULE_module_name definition to CFLAGS

# Rules to start building
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment