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