Makefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.
  6. LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
  7. include $(LIBFDT_srcdir)/Makefile.libfdt
  8. # Unfortunately setup.py (or actually the Python distutil implementation) puts
  9. # files into the same directory as the .i file. We cannot touch the source
  10. # directory, so we "ship" .i file into the objtree.
  11. PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \
  12. $(obj)/libfdt.i
  13. # create a version string compliant with PEP 440
  14. PEP_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(subst -,,$(EXTRAVERSION))
  15. quiet_cmd_pymod = PYMOD $@
  16. cmd_pymod = unset CROSS_COMPILE; unset CFLAGS; \
  17. CC="$(HOSTCC)" LDSHARED="$(HOSTCC) -shared " \
  18. LDFLAGS="$(HOSTLDFLAGS)" \
  19. VERSION="$(PEP_VERSION)" \
  20. CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
  21. SOURCES="$(PYLIBFDT_srcs)" \
  22. SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
  23. $(PYTHON3) $< --quiet build_ext --inplace
  24. rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
  25. @# Remove the library since otherwise Python doesn't seem to regenerate
  26. @# the libfdt.py file if it is missing.
  27. @rm -f $(obj)/_libfdt*.so
  28. $(call if_changed,pymod)
  29. @# Rename the file to _libfdt.so so this Makefile doesn't run every time
  30. @if [ ! -e $(obj)/_libfdt.so ]; then \
  31. mv $(obj)/_libfdt*.so $(obj)/_libfdt.so; \
  32. fi
  33. $(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild
  34. @:
  35. always += _libfdt.so libfdt.py
  36. clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c