unix/Makefile: Only checkout libffi submodule when used.

This moves the libffi submodule variable modifier inside of the if
statement where it is actually used so that the submodule will only be
checked out if it is actually being used.

A new DEPLIBS variable is also introduced to prevent building the libffi
submodule when not needed.

Signed-off-by: David Lechner <david@pybricks.com>
This commit is contained in:
David Lechner 2022-07-18 11:40:27 -05:00 committed by Damien George
parent e82aa2abc4
commit c947c25294

View File

@ -30,7 +30,7 @@ UNAME_S := $(shell uname -s)
include $(TOP)/py/py.mk
include $(TOP)/extmod/extmod.mk
GIT_SUBMODULES += lib/berkeley-db-1.xx lib/libffi
GIT_SUBMODULES += lib/berkeley-db-1.xx
INC += -I.
INC += -I$(TOP)
@ -202,6 +202,9 @@ endif
ifeq ($(MICROPY_PY_FFI),1)
ifeq ($(MICROPY_STANDALONE),1)
# Build libffi from source.
GIT_SUBMODULES += lib/libffi
DEPLIBS += libffi
LIBFFI_CFLAGS_MOD := -I$(shell ls -1d $(BUILD)/lib/libffi/out/lib/libffi-*/include)
ifeq ($(MICROPY_FORCE_32BIT),1)
LIBFFI_LDFLAGS_MOD = $(BUILD)/lib/libffi/out/lib32/libffi.a
@ -209,6 +212,7 @@ LIBFFI_CFLAGS_MOD := -I$(shell ls -1d $(BUILD)/lib/libffi/out/lib/libffi-*/inclu
LIBFFI_LDFLAGS_MOD = $(BUILD)/lib/libffi/out/lib/libffi.a
endif
else
# Use system version of libffi.
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
endif
@ -325,7 +329,7 @@ else
CROSS_COMPILE_HOST =
endif
deplibs: libffi
deplibs: $(DEPLIBS)
libffi: $(BUILD)/lib/libffi/include/ffi.h