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