2013-05-31 05:12:44 +08:00
|
|
|
CC ?= gcc
|
2023-04-12 23:04:42 +08:00
|
|
|
GIT_VERSION := "$(shell git describe --abbrev=6 --always --tags)"
|
2023-05-26 16:11:01 +08:00
|
|
|
AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \
|
|
|
|
-DVERSION=\"$(GIT_VERSION)\"
|
|
|
|
CFLAGS ?= -g -O2
|
2014-07-21 20:53:44 +08:00
|
|
|
objects = \
|
|
|
|
mmc.o \
|
|
|
|
mmc_cmds.o \
|
2016-02-23 13:37:28 +08:00
|
|
|
lsmmc.o \
|
2014-07-21 20:53:44 +08:00
|
|
|
3rdparty/hmac_sha/hmac_sha2.o \
|
|
|
|
3rdparty/hmac_sha/sha2.o
|
2012-02-13 00:43:14 +08:00
|
|
|
|
2013-05-31 05:12:44 +08:00
|
|
|
CHECKFLAGS = -Wall -Werror -Wuninitialized -Wundef
|
2012-02-13 00:43:14 +08:00
|
|
|
|
|
|
|
DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
|
|
|
|
|
2013-05-31 05:12:44 +08:00
|
|
|
override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
|
|
|
|
2012-02-13 00:43:14 +08:00
|
|
|
INSTALL = install
|
|
|
|
prefix ?= /usr/local
|
|
|
|
bindir = $(prefix)/bin
|
|
|
|
LIBS=
|
|
|
|
RESTORE_LIBS=
|
2024-03-29 15:28:38 +08:00
|
|
|
mandir = /usr/share/man
|
2012-02-13 00:43:14 +08:00
|
|
|
|
|
|
|
progs = mmc
|
|
|
|
|
2024-07-07 01:14:12 +08:00
|
|
|
# make C=1 to enable sparse - default
|
|
|
|
C ?= 1
|
2012-02-13 00:43:14 +08:00
|
|
|
ifdef C
|
2024-07-07 01:14:12 +08:00
|
|
|
check = sparse $(CHECKFLAGS) $(AM_CFLAGS)
|
2012-02-13 00:43:14 +08:00
|
|
|
endif
|
|
|
|
|
2024-03-29 15:28:38 +08:00
|
|
|
all: $(progs)
|
2012-02-13 00:43:14 +08:00
|
|
|
|
|
|
|
.c.o:
|
|
|
|
ifdef C
|
|
|
|
$(check) $<
|
|
|
|
endif
|
2014-07-21 20:53:44 +08:00
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
2012-02-13 00:43:14 +08:00
|
|
|
|
|
|
|
mmc: $(objects)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(objects) $(LDFLAGS) $(LIBS)
|
|
|
|
|
|
|
|
manpages:
|
2013-12-12 03:33:28 +08:00
|
|
|
$(MAKE) -C man
|
2012-02-13 00:43:14 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(progs) $(objects)
|
2013-12-12 03:33:28 +08:00
|
|
|
$(MAKE) -C man clean
|
2024-06-24 19:25:41 +08:00
|
|
|
$(MAKE) -C docs clean
|
2012-02-13 00:43:14 +08:00
|
|
|
|
2024-03-29 15:28:38 +08:00
|
|
|
install: $(progs)
|
2012-02-13 00:43:14 +08:00
|
|
|
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
|
|
|
|
$(INSTALL) $(progs) $(DESTDIR)$(bindir)
|
2024-07-21 10:20:12 +08:00
|
|
|
$(INSTALL) -m755 -d $(DESTDIR)$(mandir)/man1
|
2024-03-29 15:28:38 +08:00
|
|
|
$(INSTALL) -m 644 mmc.1 $(DESTDIR)$(mandir)/man1
|
2013-12-12 03:33:28 +08:00
|
|
|
|
2017-12-21 18:22:04 +08:00
|
|
|
-include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
|
|
|
|
|
2013-12-12 03:33:28 +08:00
|
|
|
.PHONY: all clean install manpages install-man
|
2024-06-24 19:25:41 +08:00
|
|
|
|
|
|
|
# Add this new target for building HTML documentation using docs/Makefile
|
|
|
|
html-docs:
|
|
|
|
$(MAKE) -C docs html
|