Makefile 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# 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

quiet_cmd_pymod = PYMOD   $@
17 18
      cmd_pymod = unset CROSS_COMPILE; unset CFLAGS; \
		CC="$(HOSTCC)" LDSHARED="$(HOSTCC) -shared " \
19 20 21 22 23
		LDFLAGS="$(HOSTLDFLAGS)" \
		VERSION="u-boot-$(UBOOTVERSION)" \
		CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
		SOURCES="$(PYLIBFDT_srcs)" \
		SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
S
Simon Glass 已提交
24
		$(PYTHON3) $< --quiet build_ext --inplace
25

26
rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
27 28
	@# Remove the library since otherwise Python doesn't seem to regenerate
	@# the libfdt.py file if it is missing.
29
	@rm -f $(obj)/_libfdt*.so
30
	$(call if_changed,pymod)
31 32 33 34
	@# 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
35

36
$(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild
37
	@:
38 39

always += _libfdt.so libfdt.py
40 41

clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c