projects/linux·blob master · refs

132 lines · 2.8 KiB

1# SPDX-License-Identifier: GPL-2.0
2# Makefile for nolibc installation and tests
3include ../../scripts/Makefile.include
4
5# we're in ".../tools/include/nolibc"
6ifeq ($(srctree),)
7srctree := $(patsubst %/tools/include/,%,$(dir $(CURDIR)))
8endif
9
10# when run as make -C tools/ nolibc_<foo> the arch is not set
11ifeq ($(ARCH),)
12include $(srctree)/scripts/subarch.include
13ARCH = $(SUBARCH)
14endif
15
16# OUTPUT is only set when run from the main makefile, otherwise
17# it defaults to this nolibc directory.
18OUTPUT ?= $(CURDIR)/
19
20architectures := \
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
37arch_files := arch.h $(addsuffix .h, $(addprefix arch-, $(architectures)))
38all_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# install all headers needed to support a bare-metal compiler
95all: headers
96
97install: help
98
99help:
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# installs headers for all archs at once.
115headers:
116 $(Q)mkdir -p "$(OUTPUT)sysroot/include"
117 $(Q)cp --parents $(arch_files) $(all_files) "$(OUTPUT)sysroot/include/"
118
119headers_standalone: headers
120 $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
121
122CFLAGS_s390 := -m64
123CFLAGS := $(CFLAGS_$(ARCH))
124
125headers_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
131clean:
132 $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"