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 |
Martin Roth | d509076 | 2021-02-13 22:50:13 -0700 | [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) |
| 27 | LDFLAGS += $(shell $(HOSTPKGCONFIG) --libs libcrypto) |
| 28 | |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 29 | all: $(TARGETS) |
Zheng Bao | 7698a55 | 2020-09-29 17:32:36 +0800 | [diff] [blame] | 30 | |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 31 | amdfwread: $(READ_OBJ) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 32 | $(HOSTCC) $(READ_OBJ) $(LDFLAGS) -o $@ |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 33 | |
| 34 | amdfwtool: $(TOOL_OBJ) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 35 | $(HOSTCC) $(TOOL_OBJ) $(LDFLAGS) -o $@ |
Zheng Bao | 7698a55 | 2020-09-29 17:32:36 +0800 | [diff] [blame] | 36 | |
| 37 | %.o: %.c $(HEADER) |
Kangheui Won | 5b84dfd | 2021-12-21 15:45:06 +1100 | [diff] [blame] | 38 | $(HOSTCC) $(CFLAGS) -c -o $@ $< |
Zheng Bao | 9c7ff7b | 2015-11-17 22:57:39 +0800 | [diff] [blame] | 39 | |
| 40 | clean: |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 41 | @rm -f $(TARGETS) $(READ_OBJ) $(TOOL_OBJ) |
Felix Held | e862a00 | 2021-01-07 18:52:55 +0100 | [diff] [blame] | 42 | |
| 43 | distclean: clean |
Martin Roth | d509076 | 2021-02-13 22:50:13 -0700 | [diff] [blame] | 44 | |
| 45 | help: |
Robert Zieba | 29bc79f | 2022-03-14 15:59:12 -0600 | [diff] [blame] | 46 | @echo "${TARGETS}: Tools to create and read from AMD firmware combinations" |
Martin Roth | d509076 | 2021-02-13 22:50:13 -0700 | [diff] [blame] | 47 | @echo "Targets: all, clean, distclean, help" |
| 48 | @echo "To disable warnings as errors, run make as:" |
| 49 | @echo " make all WERROR=\"\"" |
| 50 | |
| 51 | .PHONY: all clean distclean help |