From f7b6b89a6fddc25be929d18f714e2b61345d20cb Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Thu, 12 Oct 2023 18:48:09 -0300 Subject: [PATCH 1/2] Improve Makefile so it is overridable and provides standardized targets This commit rework the Makefile targets so it provides a standardized set of targets and allow overriding of variables so cross compiling is properly supported. Fixes: #1. Signed-off-by: Otavio Salvador --- Makefile | 14 +++++++------- src/Makefile | 34 ++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index c799b13..a722744 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,13 @@ # SPDX-License-Identifier: GPL-2.0-or-later #============================================================================== -SRC_DIR := src - -.PHONY: all clean - all: - @$(MAKE) -C $(SRC_DIR)/ - @mv $(SRC_DIR)/cst_signer . + @$(MAKE) -C src + +install: + @$(MAKE) -C src install clean: - @rm -rf cst_signer src/fdt.o + @$(MAKE) -C src clean + +.PHONY: all install clean diff --git a/src/Makefile b/src/Makefile index 5e6dade..101be12 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,23 +4,33 @@ # SPDX-License-Identifier: GPL-2.0-or-later #============================================================================== -CC = gcc +CC ?= gcc +CFLAGS ?= -g -Wall -Werror +CPPFLAGS ?= +LDFLAGS ?= +INCLUDES = -I../inc/ -COPTS = -g -Wall -Werror -CFLAGS = -I../inc/. +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin +DATADIR ?= $(PREFIX)/share -DEPS = cst_signer.h cfg_parser.h mkimage_helper.h -SRCS = cst_signer.c cfg_parser.c mkimage_helper.c fdt.o +SRCS = cst_signer.c cfg_parser.c mkimage_helper.c fdt.c -.PHONY: all clean +all: cst-signer -all: cst_signer fdt.o +%.o : %.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) $< -o $@ -fdt.o: fdt.c - $(CC) -c -w -o $@ $< $(CFLAGS) +cst-signer: $(SRCS:.c=.o) + $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) -o $@ $(SRCS:.c=.o) -cst_signer: cst_signer.c fdt.o - $(CC) $(COPTS) $(CFLAGS) -o $@ $(SRCS) +install: cst-signer + install -D -m 0755 cst-signer $(DESTDIR)/$(BINDIR)/cst-signer + install -D -m 0755 -t $(DESTDIR)$(DATADIR)/doc/cst-signer \ + ../csf_ahab.cfg.sample \ + ../csf_hab4.cfg.sample clean: - rm -rf cst_signer fdt.o + rm -rf cst-signer *.o + +.PHONY: all install clean From bc8252ae969b6df0c97e8e1156f27638f5e5ec14 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Thu, 12 Oct 2023 18:52:02 -0300 Subject: [PATCH 2/2] Fix include of headers so it indicates it uses the includedir Signed-off-by: Otavio Salvador --- src/cfg_parser.c | 2 +- src/cst_signer.c | 10 ++++++---- src/fdt.c | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cfg_parser.c b/src/cfg_parser.c index 0f4ea0a..e289d13 100644 --- a/src/cfg_parser.c +++ b/src/cfg_parser.c @@ -4,7 +4,7 @@ * */ -#include "cfg_parser.h" +#include #define DELIMITER "=" diff --git a/src/cst_signer.c b/src/cst_signer.c index 4d8825b..34d1711 100644 --- a/src/cst_signer.c +++ b/src/cst_signer.c @@ -4,11 +4,13 @@ * */ -#include "cst_signer.h" -#include "cfg_parser.h" -#include "mkimage_helper.h" -#include "fdt.h" #include + +#include +#include +#include +#include + #define RSIZE 256 uint32_t g_image_offset = 0; diff --git a/src/fdt.c b/src/fdt.c index 34cf585..9aecca9 100644 --- a/src/fdt.c +++ b/src/fdt.c @@ -13,7 +13,8 @@ #include #include #include -#include "fdt.h" + +#include static struct fdt_errtabent fdt_errtable[] = {