| 1 |
|
| 2 |
|
| 3 | include ../../scripts/Makefile.include
|
| 4 |
|
| 5 |
|
| 6 | ifeq ($(srctree),)
|
| 7 | srctree := $(patsubst %/tools/include/,%,$(dir $(CURDIR)))
|
| 8 | endif
|
| 9 |
|
| 10 |
|
| 11 | ifeq ($(ARCH),)
|
| 12 | include $(srctree)/scripts/subarch.include
|
| 13 | ARCH = $(SUBARCH)
|
| 14 | endif
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 | OUTPUT ?= $(CURDIR)/
|
| 19 |
|
| 20 | architectures := \
|
| 21 | alpha \
|
| 22 | arm \
|
| 23 | arm64 \
|
| 24 | hexagon \
|
| 25 | loongarch \
|
| 26 | m68k \
|
| 27 | mips \
|
| 28 | openrisc \
|
| 29 | parisc \
|
| 30 | powerpc \
|
| 31 | riscv \
|
| 32 | s390 \
|
| 33 | sh \
|
| 34 | sparc \
|
| 35 | x86 \
|
| 36 |
|
| 37 | arch_files := arch.h $(addsuffix .h, $(addprefix arch-, $(architectures)))
|
| 38 | all_files := \
|
| 39 | alloca.h \
|
| 40 | assert.h \
|
| 41 | byteswap.h \
|
| 42 | compiler.h \
|
| 43 | crt.h \
|
| 44 | ctype.h \
|
| 45 | dirent.h \
|
| 46 | elf.h \
|
| 47 | endian.h \
|
| 48 | err.h \
|
| 49 | errno.h \
|
| 50 | fcntl.h \
|
| 51 | getopt.h \
|
| 52 | inttypes.h \
|
| 53 | limits.h \
|
| 54 | math.h \
|
| 55 | nolibc.h \
|
| 56 | poll.h \
|
| 57 | sched.h \
|
| 58 | signal.h \
|
| 59 | stackprotector.h \
|
| 60 | std.h \
|
| 61 | stdarg.h \
|
| 62 | stdbool.h \
|
| 63 | stddef.h \
|
| 64 | stdint.h \
|
| 65 | stdlib.h \
|
| 66 | string.h \
|
| 67 | sys.h \
|
| 68 | sys/auxv.h \
|
| 69 | sys/ioctl.h \
|
| 70 | sys/mman.h \
|
| 71 | sys/mount.h \
|
| 72 | sys/prctl.h \
|
| 73 | sys/ptrace.h \
|
| 74 | sys/random.h \
|
| 75 | sys/reboot.h \
|
| 76 | sys/resource.h \
|
| 77 | sys/select.h \
|
| 78 | sys/sendfile.h \
|
| 79 | sys/stat.h \
|
| 80 | sys/syscall.h \
|
| 81 | sys/sysmacros.h \
|
| 82 | sys/time.h \
|
| 83 | sys/timerfd.h \
|
| 84 | sys/types.h \
|
| 85 | sys/uio.h \
|
| 86 | sys/utsname.h \
|
| 87 | sys/wait.h \
|
| 88 | time.h \
|
| 89 | types.h \
|
| 90 | unistd.h \
|
| 91 | stdio.h \
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 | all: headers
|
| 96 |
|
| 97 | install: help
|
| 98 |
|
| 99 | help:
|
| 100 | @echo "Supported targets under nolibc:"
|
| 101 | @echo " all call \"headers\""
|
| 102 | @echo " clean clean the sysroot"
|
| 103 | @echo " headers prepare a multi-arch sysroot in \$${OUTPUT}sysroot"
|
| 104 | @echo " headers_standalone like \"headers\", and also install kernel headers"
|
| 105 | @echo " help this help"
|
| 106 | @echo ""
|
| 107 | @echo "These targets may also be called from tools as \"make nolibc_<target>\"."
|
| 108 | @echo ""
|
| 109 | @echo "Currently using the following variables:"
|
| 110 | @echo " ARCH = $(ARCH)"
|
| 111 | @echo " OUTPUT = $(OUTPUT)"
|
| 112 | @echo ""
|
| 113 |
|
| 114 |
|
| 115 | headers:
|
| 116 | $(Q)mkdir -p "$(OUTPUT)sysroot/include"
|
| 117 | $(Q)cp --parents $(arch_files) $(all_files) "$(OUTPUT)sysroot/include/"
|
| 118 |
|
| 119 | headers_standalone: headers
|
| 120 | $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
|
| 121 |
|
| 122 | CFLAGS_s390 := -m64
|
| 123 | CFLAGS := $(CFLAGS_$(ARCH))
|
| 124 |
|
| 125 | headers_check: headers_standalone
|
| 126 | $(Q)for header in $(filter-out crt.h std.h,$(all_files)); do \
|
| 127 | $(CC) $(CFLAGS) $(CLANG_CROSS_FLAGS) -Wall -Werror -nostdinc -fsyntax-only -x c /dev/null \
|
| 128 | -I$(or $(objtree),$(srctree))/usr/include -include $$header -include $$header || exit 1; \
|
| 129 | done
|
| 130 |
|
| 131 | clean:
|
| 132 | $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"
|