Merge tag 'selinux-pr-20220523' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-block.git] / tools / include / nolibc / Makefile
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 nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
11 arch_file := arch-$(nolibc_arch).h
12 all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
13              sys.h time.h types.h unistd.h
14
15 # install all headers needed to support a bare-metal compiler
16 all:
17
18 # Note: when ARCH is "x86" we concatenate both x86_64 and i386
19 headers:
20         $(Q)mkdir -p $(OUTPUT)sysroot
21         $(Q)mkdir -p $(OUTPUT)sysroot/include
22         $(Q)cp $(all_files) $(OUTPUT)sysroot/include/
23         $(Q)if [ "$(ARCH)" = "x86" ]; then      \
24                 sed -e                          \
25                   's,^#ifndef _NOLIBC_ARCH_X86_64_H,#if !defined(_NOLIBC_ARCH_X86_64_H) \&\& defined(__x86_64__),' \
26                   arch-x86_64.h;                \
27                 sed -e                          \
28                   's,^#ifndef _NOLIBC_ARCH_I386_H,#if !defined(_NOLIBC_ARCH_I386_H) \&\& !defined(__x86_64__),' \
29                   arch-i386.h;                  \
30         elif [ -e "$(arch_file)" ]; then        \
31                 cat $(arch_file);               \
32         else                                    \
33                 echo "Fatal: architecture $(ARCH) not yet supported by nolibc." >&2; \
34                 exit 1;                         \
35         fi > $(OUTPUT)sysroot/include/arch.h
36
37 headers_standalone: headers
38         $(Q)$(MAKE) -C $(srctree) headers
39         $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)/sysroot
40
41 clean:
42         $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"