amdfwtool: Use Makefile.mk for Makefile settings

When updating the Makefiles, to keep from having to update two files at
the same time, import Makefile.mk into the external Makefile. This
allows the bulk of the settings to be in a single location.

While I'm here, I adjusted the print statements to match the rest of
coreboot.

Change-Id: Id5b869f49b34b22e6a02fc086e7b42975141a87e
Signed-off-by: Martin Roth <gaumless@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/80715
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
This commit is contained in:
Martin Roth 2024-02-22 19:04:26 -07:00 committed by Felix Singer
parent f6ea67cba1
commit 10291e800c
2 changed files with 23 additions and 33 deletions

View File

@ -7,41 +7,24 @@ else
HOSTCC ?= cc HOSTCC ?= cc
endif endif
READ_SRC = amdfwread.c
READ_OBJ = $(READ_SRC:%.c=%.o)
TOOL_SRC = amdfwtool.c data_parse.c signed_psp.c handle_file.c
TOOL_OBJ = $(TOOL_SRC:%.c=%.o)
HEADER=amdfwtool.h
TARGETS = amdfwread amdfwtool TARGETS = amdfwread amdfwtool
WERROR=-Werror
CFLAGS :=-O2 -Wall -Wextra -Wshadow ${WERROR}
CFLAGS += -I $(top)/src/commonlib/bsd/include
CFLAGS += -D_GNU_SOURCE # memmem() from string.h
ifneq ($(PKG_CONFIG),)
HOSTPKGCONFIG ?= $(PKG_CONFIG)
else
HOSTPKGCONFIG ?= pkg-config
endif
CFLAGS += $(shell $(HOSTPKGCONFIG) --cflags libcrypto)
ifneq ($(.SHELLSTATUS),0)
$(error "Ensure that pkg-config is installed.")
endif
LDFLAGS += $(shell $(HOSTPKGCONFIG) --libs libcrypto)
all: $(TARGETS) all: $(TARGETS)
amdfwread: $(READ_OBJ) BUILD_ALL_TOOLS = 1
$(HOSTCC) $(READ_OBJ) $(LDFLAGS) -o $@ include ./Makefile.mk
amdfwtool: $(TOOL_OBJ) amdfwread: $(amdfwreadobj)
$(HOSTCC) $(TOOL_OBJ) $(LDFLAGS) -o $@ $(HOSTCC) $(amdfwreadobj) $(LDFLAGS) -o $@
%.o: %.c $(HEADER) amdfwtool: $(amdfwtoolobj)
$(HOSTCC) $(CFLAGS) -c -o $@ $< $(HOSTCC) $(amdfwtoolobj) $(LDFLAGS) -o $@
%.o: %.c $(amdfwheader)
$(HOSTCC) $(AMDFWTOOLCFLAGS) -c -o $@ $<
clean: clean:
@rm -f $(TARGETS) $(READ_OBJ) $(TOOL_OBJ) @rm -f $(TARGETS) $(amdfwreadobj) $(amdfwtoolobj)
distclean: clean distclean: clean

View File

@ -4,12 +4,18 @@ ifneq ($(BUILD_ALL_TOOLS)$(CONFIG_USE_AMDFWTOOL),)
amdfwtoolobj = amdfwtool.o data_parse.o signed_psp.o handle_file.o amdfwtoolobj = amdfwtool.o data_parse.o signed_psp.o handle_file.o
amdfwreadobj = amdfwread.o amdfwreadobj = amdfwread.o
amdfwheader = amdfwtool.h
AMDFWTOOLCFLAGS :=-O2 -Wall -Wextra -Wshadow -Werror WERROR ?= -Werror
AMDFWTOOLCFLAGS :=-O2 -Wall -Wextra -Wshadow $(WERROR)
AMDFWTOOLCFLAGS += -I $(top)/src/commonlib/bsd/include AMDFWTOOLCFLAGS += -I $(top)/src/commonlib/bsd/include
AMDFWTOOLCFLAGS += -D_GNU_SOURCE # memmem() from string.h AMDFWTOOLCFLAGS += -D_GNU_SOURCE # memmem() from string.h
ifneq ($(PKG_CONFIG),)
HOSTPKGCONFIG ?= $(PKG_CONFIG)
else
HOSTPKGCONFIG ?= pkg-config HOSTPKGCONFIG ?= pkg-config
endif
AMDFWTOOLCFLAGS += $(shell $(HOSTPKGCONFIG) --cflags libcrypto) AMDFWTOOLCFLAGS += $(shell $(HOSTPKGCONFIG) --cflags libcrypto)
ifneq ($(.SHELLSTATUS),0) ifneq ($(.SHELLSTATUS),0)
@ -17,15 +23,16 @@ $(error "Ensure that pkg-config is installed.")
endif endif
LDFLAGS += $(shell $(HOSTPKGCONFIG) --libs libcrypto) LDFLAGS += $(shell $(HOSTPKGCONFIG) --libs libcrypto)
$(objutil)/amdfwtool/%.o: $(top)/util/amdfwtool/%.c # $(HEADER) $(objutil)/amdfwtool/%.o: $(top)/util/amdfwtool/%.c $(dir)/$(amdfwheader)
printf " AMDFW $@\n"
$(HOSTCC) $(AMDFWTOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $< $(HOSTCC) $(AMDFWTOOLCFLAGS) $(HOSTCFLAGS) -c -o $@ $<
$(objutil)/amdfwtool/amdfwtool: $(addprefix $(objutil)/amdfwtool/,$(amdfwtoolobj)) $(objutil)/amdfwtool/amdfwtool: $(addprefix $(objutil)/amdfwtool/,$(amdfwtoolobj)) $(dir)/$(amdfwheader)
printf " AMDFWTOOL\n" printf " AMDFWTOOL $@\n"
$(HOSTCC) $(addprefix $(objutil)/amdfwtool/,$(amdfwtoolobj)) $(LDFLAGS) -o $@ $(HOSTCC) $(addprefix $(objutil)/amdfwtool/,$(amdfwtoolobj)) $(LDFLAGS) -o $@
$(objutil)/amdfwtool/amdfwread: $(addprefix $(objutil)/amdfwtool/,$(amdfwreadobj)) $(objutil)/amdfwtool/amdfwread: $(addprefix $(objutil)/amdfwtool/,$(amdfwreadobj)) $(dir)/$(amdfwheader)
printf " AMDFWREAD\n" printf " AMDFWREAD $@\n"
$(HOSTCC) $(addprefix $(objutil)/amdfwtool/,$(amdfwreadobj)) $(LDFLAGS) -o $@ $(HOSTCC) $(addprefix $(objutil)/amdfwtool/,$(amdfwreadobj)) $(LDFLAGS) -o $@
endif # ifneq ($(BUILD_ALL_TOOLS)$(CONFIG_USE_AMDFWTOOL),) endif # ifneq ($(BUILD_ALL_TOOLS)$(CONFIG_USE_AMDFWTOOL),)