Patrick Georgi | 7051707 | 2020-05-10 18:47:05 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: BSD-3-Clause |
| 2 | |
Karthikeyan Ramasubramanian | 236245e | 2022-09-06 14:02:41 -0600 | [diff] [blame] | 3 | top ?= $(abspath ../..) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 4 | ifneq ($(CC),) |
| 5 | HOSTCC ?= $(CC) |
| 6 | else |
Zheng Bao | 9c7ff7b | 2015-11-17 22:57:39 +0800 | [diff] [blame] | 7 | HOSTCC ?= cc |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 8 | endif |
Zheng Bao | 9c7ff7b | 2015-11-17 22:57:39 +0800 | [diff] [blame] | 9 | |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 10 | READ_SRC = amdfwread.c |
| 11 | READ_OBJ = $(READ_SRC:%.c=%.o) |
Zheng Bao | f080cd5 | 2023-03-22 12:50:36 +0800 | [diff] [blame] | 12 | TOOL_SRC = amdfwtool.c data_parse.c signed_psp.c handle_file.c |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 13 | TOOL_OBJ = $(TOOL_SRC:%.c=%.o) |
| 14 | HEADER=amdfwtool.h |
| 15 | TARGETS = amdfwread amdfwtool |
Zheng Bao | fdd47ef | 2021-09-17 13:30:08 +0800 | [diff] [blame] | 16 | WERROR=-Werror |
Karthikeyan Ramasubramanian | ff63106 | 2023-09-29 17:35:22 +0000 | [diff] [blame] | 17 | CFLAGS :=-O2 -Wall -Wextra -Wshadow ${WERROR} |
Karthikeyan Ramasubramanian | 236245e | 2022-09-06 14:02:41 -0600 | [diff] [blame] | 18 | CFLAGS += -I $(top)/src/commonlib/bsd/include |
Karthikeyan Ramasubramanian | abaca2a | 2023-07-13 17:24:13 -0600 | [diff] [blame] | 19 | CFLAGS += -D_GNU_SOURCE # memmem() from string.h |
Zheng Bao | 9c7ff7b | 2015-11-17 22:57:39 +0800 | [diff] [blame] | 20 | |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 21 | ifneq ($(PKG_CONFIG),) |
| 22 | HOSTPKGCONFIG ?= $(PKG_CONFIG) |
| 23 | else |
| 24 | HOSTPKGCONFIG ?= pkg-config |
| 25 | endif |
| 26 | CFLAGS += $(shell $(HOSTPKGCONFIG) --cflags libcrypto) |
Karthikeyan Ramasubramanian | ff63106 | 2023-09-29 17:35:22 +0000 | [diff] [blame] | 27 | ifneq ($(.SHELLSTATUS),0) |
| 28 | $(error "Ensure that pkg-config is installed.") |
| 29 | endif |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 30 | LDFLAGS += $(shell $(HOSTPKGCONFIG) --libs libcrypto) |
| 31 | |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 32 | all: $(TARGETS) |
Zheng Bao | 7698a55 | 2020-09-29 17:32:36 +0800 | [diff] [blame] | 33 | |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 34 | amdfwread: $(READ_OBJ) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 35 | $(HOSTCC) $(READ_OBJ) $(LDFLAGS) -o $@ |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 36 | |
| 37 | amdfwtool: $(TOOL_OBJ) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 38 | $(HOSTCC) $(TOOL_OBJ) $(LDFLAGS) -o $@ |
Zheng Bao | 7698a55 | 2020-09-29 17:32:36 +0800 | [diff] [blame] | 39 | |
| 40 | %.o: %.c $(HEADER) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 41 | $(HOSTCC) $(CFLAGS) -c -o $@ $< |
Zheng Bao | 9c7ff7b | 2015-11-17 22:57:39 +0800 | [diff] [blame] | 42 | |
| 43 | clean: |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 44 | @rm -f $(TARGETS) $(READ_OBJ) $(TOOL_OBJ) |
Felix Held | e862a00 | 2021-01-07 18:52:55 +0100 | [diff] [blame] | 45 | |
| 46 | distclean: clean |
Martin Roth | d509076 | 2021-02-13 22:50:13 -0700 | [diff] [blame] | 47 | |
| 48 | help: |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 49 | @echo "${TARGETS}: Tools to create and read from AMD firmware combinations" |
Martin Roth | d509076 | 2021-02-13 22:50:13 -0700 | [diff] [blame] | 50 | @echo "Targets: all, clean, distclean, help" |
| 51 | @echo "To disable warnings as errors, run make as:" |
| 52 | @echo " make all WERROR=\"\"" |
| 53 | |
| 54 | .PHONY: all clean distclean help |