Files
mmc-utils/Makefile
T
Ahmad Fatoum 9582278906 mmc-utils: support overriding CFLAGS without setting -DVERSION
Build tools like OpenEmbedded set the CFLAGS environment variable to be
in line with distro-wide decisions. Updating OpenEmbedded-core to point
at the new mmc-utils breaks, because VERSION would then be undefined.

Instead of having users workaround this by feeding in -DVERSION from
the outside, let's just move it out of environment-overridable CFLAGS
and into AM_CFLAGS instead.

This will inconvenience users that set their own VERSION a bit: The
Makefile sets -Werror and specifying -DVERSION twice will trigger it
because of the duplicate definition. This can be resolved by specifying
-UVERSION first. Given that the VERSION macro has only been there for a
month, this is deemed acceptable.

Fixes: 145c74ab6f ("mmc-utils: Change version string to git hash")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.kernel.org/r/20230526081100.1741293-1-a.fatoum@pengutronix.de
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-05-26 15:05:46 +02:00

60 lines
1.1 KiB
Makefile

CC ?= gcc
GIT_VERSION := "$(shell git describe --abbrev=6 --always --tags)"
AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \
-DVERSION=\"$(GIT_VERSION)\"
CFLAGS ?= -g -O2
objects = \
mmc.o \
mmc_cmds.o \
lsmmc.o \
3rdparty/hmac_sha/hmac_sha2.o \
3rdparty/hmac_sha/sha2.o
CHECKFLAGS = -Wall -Werror -Wuninitialized -Wundef
DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS) $(CFLAGS)
INSTALL = install
prefix ?= /usr/local
bindir = $(prefix)/bin
LIBS=
RESTORE_LIBS=
progs = mmc
# make C=1 to enable sparse
ifdef C
check = sparse $(CHECKFLAGS)
endif
all: $(progs) manpages
.c.o:
ifdef C
$(check) $<
endif
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
mmc: $(objects)
$(CC) $(CFLAGS) -o $@ $(objects) $(LDFLAGS) $(LIBS)
manpages:
$(MAKE) -C man
install-man:
$(MAKE) -C man install
clean:
rm -f $(progs) $(objects)
$(MAKE) -C man clean
install: $(progs) install-man
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(progs) $(DESTDIR)$(bindir)
-include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
.PHONY: all clean install manpages install-man