Skip to content

Commit

Permalink
build: Allow setting flags from the environment
Browse files Browse the repository at this point in the history
This adds `UK_ASFLAGS`, `UK_CFLAGS`, `UK_CXXFLAGS`, `UK_GOCFLAGS`, and
`UK_LDFLAGS` for explicitly setting these build flags for Unikraft.

For reference, see
- https://github.com/torvalds/linux/blob/v6.4/Documentation/kbuild/kbuild.rst#environment-variables
- https://github.com/torvalds/linux/blob/v6.4/Makefile#L1097-L1101

Signed-off-by: Martin Kröning <[email protected]>
Reviewed-by: Stefan Jumarea <[email protected]>
Reviewed-by: Marco Schlumpp <[email protected]>
Approved-by: Simon Kuenzer <[email protected]>
Tested-by: Unikraft CI <[email protected]>
GitHub-Closes: #957
  • Loading branch information
mkroening authored and unikraft-bot committed Aug 4, 2023
1 parent 2f2ecc9 commit 73a18e2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 646,13 @@ CFLAGS = -DCC_VERSION=$(CC_VERSION)
CXXFLAGS = -DCC_VERSION=$(CC_VERSION)
GOCFLAGS = -DCC_VERSION=$(CC_VERSION)

# Add user supplied flags as the last assignments
ASFLAGS = $(UK_ASFLAGS)
CFLAGS = $(UK_CFLAGS)
CXXFLAGS = $(UK_CXXFLAGS)
GOCFLAGS = $(UK_GOCFLAGS)
LDFLAGS = $(UK_LDFLAGS)

# ensure $(BUILD_DIR)/kconfig, $(BUILD_DIR)/include and $(BUILD_DIR)/include/uk exists
$(call mk_sub_build_dir,kconfig)
$(call mk_sub_build_dir,include)
Expand Down Expand Up @@ -1100,6 1107,13 @@ help:
@echo ' L=[PATH]:[PATH]:.. - colon-separated list of paths to external libraries'
@echo ' P=[PATH]:[PATH]:.. - colon-separated list of paths to external platforms'
@echo ''
@echo 'Environment variables:'
@echo ' UK_ASFLAGS - explicit Unikraft-specific additions to the assembler flags (the ASFLAGS variable is ignored)'
@echo ' UK_CFLAGS - explicit Unikraft-specific additions to the C compiler flags (the CFLAGS variable is ignored)'
@echo ' UK_CXXFLAGS - explicit Unikraft-specific additions to the C compiler flags (the CXXFLAGS variable is ignored)'
@echo ' UK_GOCFLAGS - explicit Unikraft-specific additions to the GO compiler flags (the GOCFLAGS variable is ignored)'
@echo ' UK_LDFLAGS - explicit Unikraft-specific additions to the linker flags (the LDFLAGS variable is ignored)'
@echo ''
@echo 'Miscellaneous:'
@echo ' print-version - print Unikraft version'
@echo ' print-libs - print library names enabled for build'
Expand Down

0 comments on commit 73a18e2

Please sign in to comment.