diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index 9962e9bcbb246..bd9e0fb1f54d4 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -25,6 +25,12 @@ CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables # CIRCUITPY-CHANGE CFLAGS += -DCIRCUITPY +# Build a static executable. +# Useful for builds that must run on multiple operating system versions. Used for published mpy-cross versions. +ifdef STATIC_BUILD +CFLAGS += -static -static-libgcc -static-libstdc++ +endif + # Debugging/Optimization ifdef DEBUG CFLAGS += -g @@ -47,6 +53,10 @@ LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections endif LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) +ifdef STATIC_BUILD +LDFLAGS += -static -static-libgcc -static-libstdc++ +endif + # source files # CIRCUITPY-CHANGE: extra files SRC_C = \