Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
20ifeq ($(V),1)
21Q=
22else
23Q=@
24endif
25
26arch_files := arch.h $(wildcard arch-*.h)
27all_files := \
28 compiler.h \
29 crt.h \
30 ctype.h \
31 dirent.h \
32 elf.h \
33 errno.h \
34 fcntl.h \
35 getopt.h \
36 inttypes.h \
37 limits.h \
38 math.h \
39 nolibc.h \
40 poll.h \
41 sched.h \
42 signal.h \
43 stackprotector.h \
44 std.h \
45 stdarg.h \
46 stdbool.h \
47 stddef.h \
48 stdint.h \
49 stdlib.h \
50 string.h \
51 sys.h \
52 sys/auxv.h \
53 sys/ioctl.h \
54 sys/mman.h \
55 sys/mount.h \
56 sys/prctl.h \
57 sys/random.h \
58 sys/reboot.h \
59 sys/resource.h \
60 sys/select.h \
61 sys/stat.h \
62 sys/syscall.h \
63 sys/sysmacros.h \
64 sys/time.h \
65 sys/timerfd.h \
66 sys/types.h \
67 sys/uio.h \
68 sys/utsname.h \
69 sys/wait.h \
70 time.h \
71 types.h \
72 unistd.h \
73 stdio.h \
74
75
76# install all headers needed to support a bare-metal compiler
77all: headers
78
79install: help
80
81help:
82 @echo "Supported targets under nolibc:"
83 @echo " all call \"headers\""
84 @echo " clean clean the sysroot"
85 @echo " headers prepare a multi-arch sysroot in \$${OUTPUT}sysroot"
86 @echo " headers_standalone like \"headers\", and also install kernel headers"
87 @echo " help this help"
88 @echo ""
89 @echo "These targets may also be called from tools as \"make nolibc_<target>\"."
90 @echo ""
91 @echo "Currently using the following variables:"
92 @echo " ARCH = $(ARCH)"
93 @echo " OUTPUT = $(OUTPUT)"
94 @echo ""
95
96# installs headers for all archs at once.
97headers:
98 $(Q)mkdir -p "$(OUTPUT)sysroot"
99 $(Q)mkdir -p "$(OUTPUT)sysroot/include"
100 $(Q)cp --parents $(arch_files) $(all_files) "$(OUTPUT)sysroot/include/"
101
102headers_standalone: headers
103 $(Q)$(MAKE) -C $(srctree) headers
104 $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
105
106headers_check: headers_standalone
107 $(Q)for header in $(filter-out crt.h std.h,$(all_files)); do \
108 $(CC) $(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
112clean:
113 $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"