blob: 80b6ad2ae71c118d4356006b3b706d8f6d7d8afd [file] [log] [blame]
Masahiro Yamada47ae5392017-10-17 13:42:43 +09001# Unfortunately setup.py below cannot handle srctree being ".." which it often
2# is. It fails with an error like:
3# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
4# No such file or directory
5# To fix this, use an absolute path.
6LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
7
8include $(LIBFDT_srcdir)/Makefile.libfdt
9
10# Unfortunately setup.py (or actually the Python distutil implementation) puts
11# files into the same directory as the .i file. We cannot touch the source
12# directory, so we "ship" .i file into the objtree.
13PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \
14 $(obj)/libfdt.i
15
16quiet_cmd_pymod = PYMOD $@
Marek Vasut7f93db72018-05-18 09:56:53 +020017 cmd_pymod = unset CROSS_COMPILE; unset CFLAGS; \
18 CC="$(HOSTCC)" LDSHARED="$(HOSTCC) -shared " \
Masahiro Yamada47ae5392017-10-17 13:42:43 +090019 LDFLAGS="$(HOSTLDFLAGS)" \
20 VERSION="u-boot-$(UBOOTVERSION)" \
21 CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
22 SOURCES="$(PYLIBFDT_srcs)" \
23 SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
Simon Glass7ccca832019-10-31 07:42:59 -060024 $(PYTHON3) $< --quiet build_ext --inplace
Masahiro Yamada47ae5392017-10-17 13:42:43 +090025
26$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
Simon Glass63592732020-07-09 18:39:33 -060027 @# Remove the library since otherwise Python doesn't seem to regenerate
28 @# the libfdt.py file if it is missing.
29 rm -f $(obj)/_libfdt*.so
Masahiro Yamada47ae5392017-10-17 13:42:43 +090030 $(call if_changed,pymod)
31
32always += _libfdt.so
33
34clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c