projects/linux·blob master · refs

60 lines · 1.7 KiB

1# SPDX-License-Identifier: GPL-2.0
2ifeq ($(srctree),)
3srctree := $(patsubst %/,%,$(dir $(CURDIR)))
4srctree := $(patsubst %/,%,$(dir $(srctree)))
5srctree := $(patsubst %/,%,$(dir $(srctree)))
6srctree := $(patsubst %/,%,$(dir $(srctree)))
7endif
8
9# Include common tools build infrastructure
10include $(srctree)/tools/scripts/Makefile.include
11
12CC = $(CROSS_COMPILE)gcc
13BUILD_OUTPUT := $(CURDIR)
14PREFIX ?= /usr
15DESTDIR ?=
16
17ifeq ("$(origin O)", "command line")
18 BUILD_OUTPUT := $(O)
19endif
20
21# Include paths: tools/include has linux/kernel.h with ARRAY_SIZE
22INCLUDES = -I$(srctree)/tools/include
23INCLUDES += -I$(srctree)/tools/include/uapi
24INCLUDES += -I$(srctree)/include/uapi
25INCLUDES += -I$(srctree)/include
26
27override CFLAGS += -O2 -Wall -Wextra -D_GNU_SOURCE $(INCLUDES)
28override CFLAGS += -D_FILE_OFFSET_BITS=64
29override CFLAGS += -D__EXPORTED_HEADERS__
30
31TARGETS = test_amd_pmf
32
33all: $(TARGETS)
34
35test_amd_pmf: test-pmf.c
36 $(QUIET_CC)$(CC) $(CFLAGS) $< -o $(BUILD_OUTPUT)/$@ $(LDFLAGS)
37
38.PHONY: clean
39clean:
40 $(call QUIET_CLEAN, test_amd_pmf)$(RM) $(BUILD_OUTPUT)/test_amd_pmf
41
42.PHONY: install
43install: $(TARGETS)
44 $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
45 $(INSTALL) $(BUILD_OUTPUT)/test_amd_pmf $(DESTDIR)$(PREFIX)/bin/test_amd_pmf
46
47.PHONY: help
48help:
49 @echo "AMD Platform Tools Makefile"
50 @echo ""
51 @echo "Targets:"
52 @echo " all - Build all tools (default)"
53 @echo " test_amd_pmf - Build the PMF test tool"
54 @echo " clean - Remove built files"
55 @echo " install - Install tools to $(PREFIX)/bin"
56 @echo ""
57 @echo "Variables:"
58 @echo " O=<dir> - Build output directory"
59 @echo " PREFIX - Installation prefix (default: /usr)"
60 @echo " DESTDIR - Destination directory for install"