1c727fd784
Right now cbmem uses a fix path to reach coreboot src path (../../). This makes it impossible to compile cbmem out of the coreboot tree (e.g. copy just the cbmem directory elsewhere and compile). This patch adapts the technique from cbfstool and adds a variable called 'TOP' which points to coreboot root directory and which can be overridden at build time by providing it to make as an argument. This will enable a stand-alone build of cbmem. Change-Id: I2732f75310e10716e5aa74e094e0bf628ad22f0b Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69686 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
42 lines
1 KiB
Makefile
42 lines
1 KiB
Makefile
##
|
|
## SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
PROGRAM = cbmem
|
|
TOP ?= $(abspath ../..)
|
|
ROOT = $(TOP)/src
|
|
CC ?= $(CROSS_COMPILE)gcc
|
|
INSTALL ?= /usr/bin/env install
|
|
PREFIX ?= /usr/local
|
|
CFLAGS ?= -O2
|
|
WERROR=-Werror
|
|
CFLAGS += -Wall -Wextra -Wmissing-prototypes -Wshadow $(WERROR)
|
|
CPPFLAGS += -I . -I $(ROOT)/commonlib/include -I $(ROOT)/commonlib/bsd/include
|
|
CPPFLAGS += -include $(ROOT)/commonlib/bsd/include/commonlib/bsd/compiler.h
|
|
|
|
OBJS = $(PROGRAM).o
|
|
|
|
all: $(PROGRAM)
|
|
|
|
$(PROGRAM): $(OBJS)
|
|
|
|
clean:
|
|
rm -f $(PROGRAM) *.o .dependencies *~ junit.xml
|
|
|
|
install: $(PROGRAM)
|
|
$(INSTALL) -d $(DESTDIR)$(PREFIX)/sbin/
|
|
$(INSTALL) cbmem $(DESTDIR)$(PREFIX)/sbin/
|
|
|
|
distclean: clean
|
|
|
|
.dependencies:
|
|
@$(CC) $(CFLAGS) $(CPPFLAGS) -MM *.c > .dependencies
|
|
|
|
help:
|
|
@echo "${PROGRAM}: View machine's cbmem contents"
|
|
@echo "Targets: all, clean, distclean, help, install"
|
|
@echo "To disable warnings as errors, run make as:"
|
|
@echo " make all WERROR=\"\""
|
|
|
|
.PHONY: all clean distclean install help
|
|
|
|
-include .dependencies
|