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 | ||
15 | # OUTPUT is only set when run from the main makefile, otherwise | |
16 | # it defaults to this nolibc directory. | |
17 | OUTPUT ?= $(CURDIR)/ | |
18 | ||
19 | ifeq ($(V),1) | |
20 | Q= | |
21 | else | |
22 | Q=@ | |
23 | endif | |
24 | ||
25 | CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables | |
26 | LDFLAGS := -s | |
27 | ||
28 | all: nolibc-test | |
29 | ||
30 | nolibc-test: nolibc-test.c | |
31 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ | |
32 | -nostdlib -static -include ../../../include/nolibc/nolibc.h $^ -lgcc | |
33 | ||
34 | initramfs: nolibc-test | |
35 | $(QUIET_MKDIR)mkdir -p initramfs | |
36 | $(call QUIET_INSTALL, initramfs/init) | |
37 | $(Q)cp nolibc-test initramfs/init | |
38 | ||
39 | clean: | |
40 | $(call QUIET_CLEAN, nolibc-test) | |
41 | $(Q)rm -f nolibc-test | |
42 | $(call QUIET_CLEAN, initramfs) | |
43 | $(Q)rm -rf initramfs |