2017-10-17 04:42:43 +00:00
|
|
|
# Unfortunately setup.py below cannot handle srctree being ".." which it often
|
|
|
|
# is. It fails with an error like:
|
|
|
|
# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
|
|
|
|
# No such file or directory
|
|
|
|
# To fix this, use an absolute path.
|
|
|
|
LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
|
|
|
|
|
|
|
|
include $(LIBFDT_srcdir)/Makefile.libfdt
|
|
|
|
|
|
|
|
# Unfortunately setup.py (or actually the Python distutil implementation) puts
|
|
|
|
# files into the same directory as the .i file. We cannot touch the source
|
|
|
|
# directory, so we "ship" .i file into the objtree.
|
|
|
|
PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \
|
|
|
|
$(obj)/libfdt.i
|
|
|
|
|
2022-07-31 02:57:11 +00:00
|
|
|
# create a version string compliant with PEP 440
|
|
|
|
PEP_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(subst -,,$(EXTRAVERSION))
|
|
|
|
|
2017-10-17 04:42:43 +00:00
|
|
|
quiet_cmd_pymod = PYMOD $@
|
2018-05-18 07:56:53 +00:00
|
|
|
cmd_pymod = unset CROSS_COMPILE; unset CFLAGS; \
|
|
|
|
CC="$(HOSTCC)" LDSHARED="$(HOSTCC) -shared " \
|
2017-10-17 04:42:43 +00:00
|
|
|
LDFLAGS="$(HOSTLDFLAGS)" \
|
2022-07-31 02:57:11 +00:00
|
|
|
VERSION="$(PEP_VERSION)" \
|
2017-10-17 04:42:43 +00:00
|
|
|
CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
|
|
|
|
SOURCES="$(PYLIBFDT_srcs)" \
|
|
|
|
SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
|
2019-10-31 13:42:59 +00:00
|
|
|
$(PYTHON3) $< --quiet build_ext --inplace
|
2017-10-17 04:42:43 +00:00
|
|
|
|
2021-03-24 17:40:48 +00:00
|
|
|
rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
|
2020-07-10 00:39:33 +00:00
|
|
|
@# Remove the library since otherwise Python doesn't seem to regenerate
|
|
|
|
@# the libfdt.py file if it is missing.
|
2021-03-24 17:40:48 +00:00
|
|
|
@rm -f $(obj)/_libfdt*.so
|
2017-10-17 04:42:43 +00:00
|
|
|
$(call if_changed,pymod)
|
2021-03-24 17:40:48 +00:00
|
|
|
@# Rename the file to _libfdt.so so this Makefile doesn't run every time
|
|
|
|
@if [ ! -e $(obj)/_libfdt.so ]; then \
|
|
|
|
mv $(obj)/_libfdt*.so $(obj)/_libfdt.so; \
|
|
|
|
fi
|
2017-10-17 04:42:43 +00:00
|
|
|
|
2021-03-24 17:40:48 +00:00
|
|
|
$(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild
|
2021-03-27 22:27:18 +00:00
|
|
|
@:
|
2021-03-24 17:40:48 +00:00
|
|
|
|
|
|
|
always += _libfdt.so libfdt.py
|
2017-10-17 04:42:43 +00:00
|
|
|
|
|
|
|
clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
|