mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-09-20 05:30:25 +02:00
nvmutil: split nvmutil.c into multiple files
this is a big program now. act like it. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+73
-15
@@ -11,10 +11,8 @@ DESTDIR?=
|
||||
PREFIX?=/usr/local
|
||||
INSTALL?=install
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
# maybe add -I. here when running make
|
||||
# e.g. make LDIR=-I.
|
||||
LDIR?=
|
||||
|
||||
PORTABLE?=$(LDIR) $(CFLAGS)
|
||||
@@ -22,24 +20,73 @@ WARN?=$(PORTABLE) -Wall -Wextra
|
||||
STRICT?=$(WARN) -std=c90 -pedantic -Werror
|
||||
HELLFLAGS?=$(STRICT) -Weverything
|
||||
|
||||
# program name
|
||||
PROG=nvmutil
|
||||
|
||||
# source files
|
||||
|
||||
SRCS = nvmutil.c state.c file.c string.c usage.c command.c num.c io.c \
|
||||
checksum.c word.c
|
||||
|
||||
# object files
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
# default mode
|
||||
|
||||
MODE?=portable
|
||||
|
||||
# default mode, options
|
||||
|
||||
CFLAGS_MODE=$(PORTABLE)
|
||||
CC_MODE=$(CC)
|
||||
|
||||
# override modes (options)
|
||||
|
||||
ifeq ($(MODE),warn)
|
||||
CFLAGS_MODE=$(WARN)
|
||||
endif
|
||||
|
||||
ifeq ($(MODE),strict)
|
||||
CFLAGS_MODE=$(STRICT)
|
||||
endif
|
||||
|
||||
ifeq ($(MODE),hell)
|
||||
CFLAGS_MODE=$(HELLFLAGS)
|
||||
CC_MODE=$(HELLCC)
|
||||
endif
|
||||
|
||||
# (rebuild on .h changes)
|
||||
# (commented for portability)
|
||||
#
|
||||
# CFLAGS_MODE += -MMD -MP
|
||||
# -include $(OBJS:.o=.d)
|
||||
#
|
||||
# likely more compatible,
|
||||
# on its own:
|
||||
# -include $(OBJS:.o=.d)
|
||||
#
|
||||
# i want this to build on
|
||||
# old make, so i'll leave
|
||||
# this blanked by default
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
$(PROG): $(PROG).c
|
||||
$(CC) $(PORTABLE) $(PROG).c -o $(PROG) $(LDFLAGS)
|
||||
$(PROG): $(OBJS)
|
||||
$(CC_MODE) $(OBJS) -o $(PROG) $(LDFLAGS)
|
||||
|
||||
warn: $(PROG).c
|
||||
$(CC) $(WARN) $(PROG).c -o $(PROG) $(LDFLAGS)
|
||||
# generic rules
|
||||
|
||||
strict: $(PROG).c
|
||||
$(CC) $(STRICT) $(PROG).c -o $(PROG) $(LDFLAGS)
|
||||
|
||||
# clang-only extreme warnings (not portable)
|
||||
hell: $(PROG).c
|
||||
$(HELLCC) $(HELLFLAGS) $(PROG).c -o $(PROG) $(LDFLAGS)
|
||||
# .c.o: is the old style (portable)
|
||||
# modern equivalent:
|
||||
# %.o: %.c
|
||||
#
|
||||
.c.o:
|
||||
$(CC_MODE) $(CFLAGS_MODE) -c $< -o $@
|
||||
|
||||
# -m in install is not portable
|
||||
# to old/other/weird versions.
|
||||
# use chmod directly.
|
||||
#
|
||||
install: $(PROG)
|
||||
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
|
||||
$(INSTALL) $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
||||
@@ -49,8 +96,19 @@ uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
||||
|
||||
clean:
|
||||
rm -f $(PROG)
|
||||
rm -f $(PROG) $(OBJS) *.d
|
||||
|
||||
distclean: clean
|
||||
|
||||
# easy commands
|
||||
|
||||
warn:
|
||||
$(MAKE) MODE=warn
|
||||
|
||||
strict:
|
||||
$(MAKE) MODE=strict
|
||||
|
||||
hell:
|
||||
$(MAKE) MODE=hell
|
||||
|
||||
.PHONY: all warn strict hell install uninstall clean distclean
|
||||
|
||||
Reference in New Issue
Block a user