Commit | Line | Data |
---|---|---|
362aecb2 WT |
1 | # SPDX-License-Identifier: GPL-2.0 |
2 | # Makefile for nolibc tests | |
3 | include ../../../scripts/Makefile.include | |
4 | ||
5 | # we're in ".../tools/testing/selftests/nolibc" | |
6 | ifeq ($(srctree),) | |
7 | srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) | |
8 | endif | |
9 | ||
10 | ifeq ($(ARCH),) | |
11 | include $(srctree)/scripts/subarch.include | |
12 | ARCH = $(SUBARCH) | |
13 | endif | |
14 | ||
d248cabf WT |
15 | # kernel image names by architecture |
16 | IMAGE_i386 = arch/x86/boot/bzImage | |
17 | IMAGE_x86 = arch/x86/boot/bzImage | |
18 | IMAGE_arm64 = arch/arm64/boot/Image | |
19 | IMAGE_arm = arch/arm/boot/zImage | |
20 | IMAGE_mips = vmlinuz | |
21 | IMAGE_riscv = arch/riscv/boot/Image | |
22 | IMAGE = $(IMAGE_$(ARCH)) | |
23 | IMAGE_NAME = $(notdir $(IMAGE)) | |
24 | ||
5c43fd79 WT |
25 | # default kernel configurations that appear to be usable |
26 | DEFCONFIG_i386 = defconfig | |
27 | DEFCONFIG_x86 = defconfig | |
28 | DEFCONFIG_arm64 = defconfig | |
29 | DEFCONFIG_arm = multi_v7_defconfig | |
30 | DEFCONFIG_mips = malta_defconfig | |
31 | DEFCONFIG_riscv = defconfig | |
32 | DEFCONFIG = $(DEFCONFIG_$(ARCH)) | |
33 | ||
362aecb2 WT |
34 | # OUTPUT is only set when run from the main makefile, otherwise |
35 | # it defaults to this nolibc directory. | |
36 | OUTPUT ?= $(CURDIR)/ | |
37 | ||
38 | ifeq ($(V),1) | |
39 | Q= | |
40 | else | |
41 | Q=@ | |
42 | endif | |
43 | ||
44 | CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables | |
45 | LDFLAGS := -s | |
46 | ||
47 | all: nolibc-test | |
48 | ||
49 | nolibc-test: nolibc-test.c | |
50 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ | |
51 | -nostdlib -static -include ../../../include/nolibc/nolibc.h $^ -lgcc | |
52 | ||
53 | initramfs: nolibc-test | |
54 | $(QUIET_MKDIR)mkdir -p initramfs | |
55 | $(call QUIET_INSTALL, initramfs/init) | |
56 | $(Q)cp nolibc-test initramfs/init | |
57 | ||
5c43fd79 WT |
58 | defconfig: |
59 | $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare | |
60 | ||
d248cabf WT |
61 | kernel: initramfs |
62 | $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs | |
63 | ||
362aecb2 WT |
64 | clean: |
65 | $(call QUIET_CLEAN, nolibc-test) | |
66 | $(Q)rm -f nolibc-test | |
67 | $(call QUIET_CLEAN, initramfs) | |
68 | $(Q)rm -rf initramfs |