xref: /openbmc/u-boot/scripts/dtc/pylibfdt/Makefile (revision baefb63a)
1# 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   $@
17      cmd_pymod = unset CC; unset CROSS_COMPILE; unset CFLAGS;\
18		LDFLAGS="$(HOSTLDFLAGS)" \
19		VERSION="u-boot-$(UBOOTVERSION)" \
20		CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
21		SOURCES="$(PYLIBFDT_srcs)" \
22		SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
23		$(PYTHON) $< --quiet build_ext --inplace
24
25$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
26	$(call if_changed,pymod)
27
28always += _libfdt.so
29
30clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
31