Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Makefile for nolibc installation and tests
  3. include ../../scripts/Makefile.include
  4. # we're in ".../tools/include/nolibc"
  5. ifeq ($(srctree),)
  6. srctree := $(patsubst %/tools/include/,%,$(dir $(CURDIR)))
  7. endif
  8. # when run as make -C tools/ nolibc_<foo> the arch is not set
  9. ifeq ($(ARCH),)
  10. include $(srctree)/scripts/subarch.include
  11. ARCH = $(SUBARCH)
  12. endif
  13. # OUTPUT is only set when run from the main makefile, otherwise
  14. # it defaults to this nolibc directory.
  15. OUTPUT ?= $(CURDIR)/
  16. ifeq ($(V),1)
  17. Q=
  18. else
  19. Q=@
  20. endif
  21. arch_files := arch.h $(wildcard arch-*.h)
  22. all_files := \
  23. compiler.h \
  24. crt.h \
  25. ctype.h \
  26. dirent.h \
  27. elf.h \
  28. errno.h \
  29. fcntl.h \
  30. getopt.h \
  31. inttypes.h \
  32. limits.h \
  33. math.h \
  34. nolibc.h \
  35. poll.h \
  36. sched.h \
  37. signal.h \
  38. stackprotector.h \
  39. std.h \
  40. stdarg.h \
  41. stdbool.h \
  42. stddef.h \
  43. stdint.h \
  44. stdlib.h \
  45. string.h \
  46. sys.h \
  47. sys/auxv.h \
  48. sys/ioctl.h \
  49. sys/mman.h \
  50. sys/mount.h \
  51. sys/prctl.h \
  52. sys/ptrace.h \
  53. sys/random.h \
  54. sys/reboot.h \
  55. sys/resource.h \
  56. sys/select.h \
  57. sys/stat.h \
  58. sys/syscall.h \
  59. sys/sysmacros.h \
  60. sys/time.h \
  61. sys/timerfd.h \
  62. sys/types.h \
  63. sys/uio.h \
  64. sys/utsname.h \
  65. sys/wait.h \
  66. time.h \
  67. types.h \
  68. unistd.h \
  69. stdio.h \
  70. # install all headers needed to support a bare-metal compiler
  71. all: headers
  72. install: help
  73. help:
  74. @echo "Supported targets under nolibc:"
  75. @echo " all call \"headers\""
  76. @echo " clean clean the sysroot"
  77. @echo " headers prepare a multi-arch sysroot in \$${OUTPUT}sysroot"
  78. @echo " headers_standalone like \"headers\", and also install kernel headers"
  79. @echo " help this help"
  80. @echo ""
  81. @echo "These targets may also be called from tools as \"make nolibc_<target>\"."
  82. @echo ""
  83. @echo "Currently using the following variables:"
  84. @echo " ARCH = $(ARCH)"
  85. @echo " OUTPUT = $(OUTPUT)"
  86. @echo ""
  87. # installs headers for all archs at once.
  88. headers:
  89. $(Q)mkdir -p "$(OUTPUT)sysroot"
  90. $(Q)mkdir -p "$(OUTPUT)sysroot/include"
  91. $(Q)cp --parents $(arch_files) $(all_files) "$(OUTPUT)sysroot/include/"
  92. headers_standalone: headers
  93. $(Q)$(MAKE) -C $(srctree) headers
  94. $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
  95. CFLAGS_s390 := -m64
  96. CFLAGS := $(CFLAGS_$(ARCH))
  97. headers_check: headers_standalone
  98. $(Q)for header in $(filter-out crt.h std.h,$(all_files)); do \
  99. $(CC) $(CFLAGS) $(CLANG_CROSS_FLAGS) -Wall -Werror -nostdinc -fsyntax-only -x c /dev/null \
  100. -I$(or $(objtree),$(srctree))/usr/include -include $$header -include $$header || exit 1; \
  101. done
  102. clean:
  103. $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"