xref: /openbmc/linux/tools/include/nolibc/Makefile (revision ee65728e)
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
10nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
11arch_file := arch-$(nolibc_arch).h
12all_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
16all:
17
18# Note: when ARCH is "x86" we concatenate both x86_64 and i386
19headers:
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
37headers_standalone: headers
38	$(Q)$(MAKE) -C $(srctree) headers
39	$(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)/sysroot
40
41clean:
42	$(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"
43