Skip to content

Commit 85d5d32

Browse files
committed
Add STATIC_BUILD make flag for mpy-cross to build a static executable
1 parent e875f4e commit 85d5d32

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mpy-cross/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ CWARN += -Wpointer-arith -Wuninitialized
3535
CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
3636
CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables
3737

38+
# Build a static executable.
39+
# Useful for Windows builds, etc., that must run on multiple operating system versions.
40+
ifdef STATIC_BUILD
41+
CFLAGS += -static -static-libgcc -static-libstdc++
42+
endif
43+
44+
3845
# Debugging/Optimization
3946
ifdef DEBUG
4047
CFLAGS += -g
@@ -57,6 +64,10 @@ LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
5764
endif
5865
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
5966

67+
ifdef STATIC_BUILD
68+
LDFLAGS += -static -static-libgcc -static-libstdc++
69+
endif
70+
6071
# source files
6172
SRC_C = \
6273
main.c \

0 commit comments

Comments
 (0)