Skip to content

Commit ed1239f

Browse files
committed
Add mpconfigport.mk file to configure which modules to include into build.
Proof of concept, controls "ffi" module as one which requires external dependencies.
1 parent 382b3d0 commit ed1239f

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

unix/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include ../py/mkenv.mk
2+
-include mpconfigport.mk
23

34
# define main target
45
PROG = micropython
@@ -10,9 +11,16 @@ QSTR_DEFS = qstrdefsport.h
1011
include ../py/py.mk
1112

1213
# compiler settings
13-
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX
14-
CFLAGS += -I/usr/lib/libffi-3.0.13/include
15-
LDFLAGS = -lm -ldl -lffi
14+
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD)
15+
LDFLAGS = $(LDFLAGS_MOD) -lm
16+
17+
ifeq ($(MICROPY_MOD_FFI),1)
18+
# Note - include path below is specific to @dpgeorge
19+
CFLAGS_MOD += -I/usr/lib/libffi-3.0.13/include -DMICROPY_MOD_FFI=1
20+
LDFLAGS_MOD += -ldl -lffi
21+
SRC_MOD += ffi.c
22+
endif
23+
1624

1725
# Debugging/Optimization
1826
ifdef DEBUG
@@ -26,7 +34,7 @@ SRC_C = \
2634
main.c \
2735
file.c \
2836
socket.c \
29-
ffi.c \
37+
$(SRC_MOD)
3038

3139
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
3240
LIB = -lreadline

unix/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ int main(int argc, char **argv) {
242242

243243
file_init();
244244
rawsocket_init();
245+
#if MICROPY_MOD_FFI
245246
ffi_init();
247+
#endif
246248

247249
// Here is some example code to create a class and instance of that class.
248250
// First is the Python, then the C code.

unix/mpconfigport.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enable/disable modules to be included in interpreter
2+
3+
# ffi module requires libffi (libffi-dev Debian package)
4+
MICROPY_MOD_FFI = 0

0 commit comments

Comments
 (0)