Masahiro Yamada | 15b97f5 | 2017-10-17 13:42:43 +0900 | [diff] [blame] | 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 | |
| 8 | include $(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. |
| 13 | PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \ |
| 14 | $(obj)/libfdt.i |
| 15 | |
| 16 | quiet_cmd_pymod = PYMOD $@ |
Marek Vasut | f919fbd | 2018-05-18 09:56:53 +0200 | [diff] [blame] | 17 | cmd_pymod = unset CROSS_COMPILE; unset CFLAGS; \ |
| 18 | CC="$(HOSTCC)" LDSHARED="$(HOSTCC) -shared " \ |
Masahiro Yamada | 15b97f5 | 2017-10-17 13:42:43 +0900 | [diff] [blame] | 19 | 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 Glass | b4cf5f1 | 2019-10-31 07:42:59 -0600 | [diff] [blame] | 24 | $(PYTHON3) $< --quiet build_ext --inplace |
Masahiro Yamada | 15b97f5 | 2017-10-17 13:42:43 +0900 | [diff] [blame] | 25 | |
Simon Glass | 91f414b | 2021-03-25 06:40:48 +1300 | [diff] [blame] | 26 | rebuild: $(src)/setup.py $(PYLIBFDT_srcs) |
Simon Glass | 73bc9e2 | 2020-07-09 18:39:33 -0600 | [diff] [blame] | 27 | @# Remove the library since otherwise Python doesn't seem to regenerate |
| 28 | @# the libfdt.py file if it is missing. |
Simon Glass | 91f414b | 2021-03-25 06:40:48 +1300 | [diff] [blame] | 29 | @rm -f $(obj)/_libfdt*.so |
Masahiro Yamada | 15b97f5 | 2017-10-17 13:42:43 +0900 | [diff] [blame] | 30 | $(call if_changed,pymod) |
Simon Glass | 91f414b | 2021-03-25 06:40:48 +1300 | [diff] [blame] | 31 | @# Rename the file to _libfdt.so so this Makefile doesn't run every time |
| 32 | @if [ ! -e $(obj)/_libfdt.so ]; then \ |
| 33 | mv $(obj)/_libfdt*.so $(obj)/_libfdt.so; \ |
| 34 | fi |
Masahiro Yamada | 15b97f5 | 2017-10-17 13:42:43 +0900 | [diff] [blame] | 35 | |
Simon Glass | 91f414b | 2021-03-25 06:40:48 +1300 | [diff] [blame] | 36 | $(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild |
Simon Glass | 4b5019e | 2021-03-28 11:27:18 +1300 | [diff] [blame] | 37 | @: |
Simon Glass | 91f414b | 2021-03-25 06:40:48 +1300 | [diff] [blame] | 38 | |
| 39 | always += _libfdt.so libfdt.py |
Masahiro Yamada | 15b97f5 | 2017-10-17 13:42:43 +0900 | [diff] [blame] | 40 | |
| 41 | clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c |