fix_libfdt_headers.sh 1.4 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. # Fixup inclusion of libfdt headers, which can fail in older u-boot versions
  3. # when libfdt-devel is installed system-wide.
  4. # The core change is equivalent to upstream commit
  5. # e0d20dc1521e74b82dbd69be53a048847798a90a (first in v2018.03). However, the fixup
  6. # is complicated by the fact that the underlying u-boot code changed multiple
  7. # times in history:
  8. # - The directory scripts/dtc/libfdt only exists since upstream commit
  9. # c0e032e0090d6541549b19cc47e06ccd1f302893 (first in v2017.11). For earlier
  10. # versions, create a dummy scripts/dtc/libfdt directory with symlinks for the
  11. # fdt-related files. This allows to use the same -I<path> option for both
  12. # cases.
  13. # - The variable 'srctree' used to be called 'SRCTREE' before upstream commit
  14. # 01286329b27b27eaeda045b469d41b1d9fce545a (first in v2014.04).
  15. # - The original location for libfdt, 'lib/libfdt/', used to be simply
  16. # 'libfdt' before upstream commit 0de71d507157c4bd4fddcd3a419140d2b986eed2
  17. # (first in v2010.06). Make the 'lib' part optional in the substitution to
  18. # handle this.
  19. if [ ! -d scripts/dtc/libfdt ]; then
  20. mkdir -p scripts/dtc/libfdt
  21. cd scripts/dtc/libfdt
  22. ln -s ../../../include/fdt.h .
  23. ln -s ../../../include/libfdt*.h .
  24. ln -s ../../../lib/libfdt/libfdt_internal.h .
  25. fi
  26. sed -i -e 's%-I\ *\$(srctree)/lib/libfdt%-I$(srctree)/scripts/dtc/libfdt%; s%-I\ *\$(SRCTREE)\(/lib\)\?/libfdt%-I$(SRCTREE)/scripts/dtc/libfdt%' tools/Makefile