Debian Codegraph @

tools/include/nolibc/Makefile

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