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 err.h \ 34 errno.h \ 35 fcntl.h \ 36 getopt.h \ 37 inttypes.h \ 38 limits.h \ 39 math.h \ 40 nolibc.h \ 41 poll.h \ 42 sched.h \ 43 signal.h \ 44 stackprotector.h \ 45 std.h \ 46 stdarg.h \ 47 stdbool.h \ 48 stddef.h \ 49 stdint.h \ 50 stdlib.h \ 51 string.h \ 52 sys.h \ 53 sys/auxv.h \ 54 sys/ioctl.h \ 55 sys/mman.h \ 56 sys/mount.h \ 57 sys/prctl.h \ 58 sys/ptrace.h \ 59 sys/random.h \ 60 sys/reboot.h \ 61 sys/resource.h \ 62 sys/select.h \ 63 sys/stat.h \ 64 sys/syscall.h \ 65 sys/sysmacros.h \ 66 sys/time.h \ 67 sys/timerfd.h \ 68 sys/types.h \ 69 sys/uio.h \ 70 sys/utsname.h \ 71 sys/wait.h \ 72 time.h \ 73 types.h \ 74 unistd.h \ 75 stdio.h \ 76 77 78# install all headers needed to support a bare-metal compiler 79all: headers 80 81install: help 82 83help: 84 @echo "Supported targets under nolibc:" 85 @echo " all call \"headers\"" 86 @echo " clean clean the sysroot" 87 @echo " headers prepare a multi-arch sysroot in \$${OUTPUT}sysroot" 88 @echo " headers_standalone like \"headers\", and also install kernel headers" 89 @echo " help this help" 90 @echo "" 91 @echo "These targets may also be called from tools as \"make nolibc_<target>\"." 92 @echo "" 93 @echo "Currently using the following variables:" 94 @echo " ARCH = $(ARCH)" 95 @echo " OUTPUT = $(OUTPUT)" 96 @echo "" 97 98# installs headers for all archs at once. 99headers: 100 $(Q)mkdir -p "$(OUTPUT)sysroot/include" 101 $(Q)cp --parents $(arch_files) $(all_files) "$(OUTPUT)sysroot/include/" 102 103headers_standalone: headers 104 $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot 105 106CFLAGS_s390 := -m64 107CFLAGS := $(CFLAGS_$(ARCH)) 108 109headers_check: headers_standalone 110 $(Q)for header in $(filter-out crt.h std.h,$(all_files)); do \ 111 $(CC) $(CFLAGS) $(CLANG_CROSS_FLAGS) -Wall -Werror -nostdinc -fsyntax-only -x c /dev/null \ 112 -I$(or $(objtree),$(srctree))/usr/include -include $$header -include $$header || exit 1; \ 113 done 114 115clean: 116 $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot" 117