unix: Allow to build libffi from source and link against it.

Linking against local libffi (and other libs in future) is triggered by
"make MICROPY_STANDALONE=1". Before that, dependent libs should be built
with "make deplibs".
This commit is contained in:
Paul Sokolovsky 2015-08-30 10:57:38 +03:00
parent 39c91d3624
commit a9058bf294

View File

@ -77,13 +77,26 @@ ifeq ($(MICROPY_PY_SOCKET),1)
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1 CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
SRC_MOD += modsocket.c SRC_MOD += modsocket.c
endif endif
ifeq ($(MICROPY_PY_FFI),1) ifeq ($(MICROPY_PY_FFI),1)
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
ifeq ($(MICROPY_STANDALONE),1)
LIBFFI_CFLAGS_MOD := -I$(shell ls -1d ../lib/libffi/out/lib/libffi-*/include)
ifeq ($(MICROPY_FORCE_32BIT),1)
LIBFFI_LDFLAGS_MOD = ../lib/libffi/out/lib32/libffi.a
else
LIBFFI_LDFLAGS_MOD = ../lib/libffi/out/lib/libffi.a
endif
else
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi) LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1 LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
ifeq ($(UNAME_S),Linux)
LDFLAGS_MOD += -ldl
endif endif
ifeq ($(UNAME_S),Linux)
LIBFFI_LDFLAGS_MOD += -ldl
endif
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD) LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
SRC_MOD += modffi.c SRC_MOD += modffi.c
endif endif
@ -172,3 +185,19 @@ $(BUILD)/frozen_upip/upip.py: $(UPIP_TARBALL)
$(Q)rm -rf $(dir $@) $(Q)rm -rf $(dir $@)
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
$(Q)cp $(BUILD)/micropython-upip-*/upip*.py $(dir $@) $(Q)cp $(BUILD)/micropython-upip-*/upip*.py $(dir $@)
# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overriden.
ifneq ($(CROSS_COMPILE),)
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
else
CROSS_COMPILE_HOST =
endif
deplibs: libffi
libffi:
cd ../lib/libffi; git clean -d -x -f
cd ../lib/libffi; ./autogen.sh
cd ../lib/libffi; ./configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out CC="$(CC)" CXX="$(CXX)" LD="$(LD)"; make install