0001
0002
0003 include ../../scripts/Makefile.include
0004
0005
0006 ifeq ($(srctree),)
0007 srctree := $(patsubst %/tools/include/,%,$(dir $(CURDIR)))
0008 endif
0009
0010
0011 ifeq ($(ARCH),)
0012 include $(srctree)/scripts/subarch.include
0013 ARCH = $(SUBARCH)
0014 endif
0015
0016
0017
0018 OUTPUT ?= $(CURDIR)/
0019
0020 ifeq ($(V),1)
0021 Q=
0022 else
0023 Q=@
0024 endif
0025
0026 nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
0027 arch_file := arch-$(nolibc_arch).h
0028 all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \
0029 sys.h time.h types.h unistd.h
0030
0031
0032 all: headers
0033
0034 install: help
0035
0036 help:
0037 @echo "Supported targets under nolibc:"
0038 @echo " all call \"headers\""
0039 @echo " clean clean the sysroot"
0040 @echo " headers prepare a sysroot in tools/include/nolibc/sysroot"
0041 @echo " headers_standalone like \"headers\", and also install kernel headers"
0042 @echo " help this help"
0043 @echo ""
0044 @echo "These targets may also be called from tools as \"make nolibc_<target>\"."
0045 @echo ""
0046 @echo "Currently using the following variables:"
0047 @echo " ARCH = $(ARCH)"
0048 @echo " OUTPUT = $(OUTPUT)"
0049 @echo ""
0050
0051
0052 headers:
0053 $(Q)mkdir -p $(OUTPUT)sysroot
0054 $(Q)mkdir -p $(OUTPUT)sysroot/include
0055 $(Q)cp $(all_files) $(OUTPUT)sysroot/include/
0056 $(Q)if [ "$(ARCH)" = "x86" ]; then \
0057 sed -e \
0058 's,^#ifndef _NOLIBC_ARCH_X86_64_H,#if !defined(_NOLIBC_ARCH_X86_64_H) \&\& defined(__x86_64__),' \
0059 arch-x86_64.h; \
0060 sed -e \
0061 's,^#ifndef _NOLIBC_ARCH_I386_H,#if !defined(_NOLIBC_ARCH_I386_H) \&\& !defined(__x86_64__),' \
0062 arch-i386.h; \
0063 elif [ -e "$(arch_file)" ]; then \
0064 cat $(arch_file); \
0065 else \
0066 echo "Fatal: architecture $(ARCH) not yet supported by nolibc." >&2; \
0067 exit 1; \
0068 fi > $(OUTPUT)sysroot/include/arch.h
0069
0070 headers_standalone: headers
0071 $(Q)$(MAKE) -C $(srctree) headers
0072 $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
0073
0074 clean:
0075 $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"