| # 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)/ |
| |
| ifeq ($(V),1) |
| Q= |
| else |
| Q=@ |
| endif |
| |
| arch_file := arch-$(ARCH).h |
| all_files := \ |
| compiler.h \ |
| crt.h \ |
| ctype.h \ |
| dirent.h \ |
| elf.h \ |
| errno.h \ |
| fcntl.h \ |
| getopt.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/random.h \ |
| sys/reboot.h \ |
| sys/resource.h \ |
| sys/stat.h \ |
| sys/syscall.h \ |
| sys/sysmacros.h \ |
| sys/time.h \ |
| sys/timerfd.h \ |
| sys/types.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 sysroot in tools/include/nolibc/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 "" |
| |
| headers: |
| $(Q)mkdir -p $(OUTPUT)sysroot |
| $(Q)mkdir -p $(OUTPUT)sysroot/include |
| $(Q)cp --parents $(all_files) $(OUTPUT)sysroot/include/ |
| $(Q)if [ "$(ARCH)" = "i386" -o "$(ARCH)" = "x86_64" ]; then \ |
| cat arch-x86.h; \ |
| elif [ -e "$(arch_file)" ]; then \ |
| cat $(arch_file); \ |
| else \ |
| echo "Fatal: architecture $(ARCH) not yet supported by nolibc." >&2; \ |
| exit 1; \ |
| fi > $(OUTPUT)sysroot/include/arch.h |
| |
| headers_standalone: headers |
| $(Q)$(MAKE) -C $(srctree) headers |
| $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot |
| |
| headers_check: headers_standalone |
| $(Q)for header in $(filter-out crt.h std.h,$(all_files)); do \ |
| $(CC) $(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" |