2021-11-23 20:13:52 +00:00
|
|
|
OBJ = src/xf_error.o \
|
|
|
|
src/xf_flashmap.o \
|
|
|
|
src/xf_nandio.o \
|
|
|
|
src/xf_package.o \
|
|
|
|
src/xf_stream.o \
|
|
|
|
src/xf_update.o
|
|
|
|
LIB = libx1000-installer.a
|
|
|
|
|
|
|
|
TOBJ = test_lib/core_alloc.o \
|
|
|
|
test_lib/fakenand.o \
|
|
|
|
test_lib/file.o \
|
|
|
|
test_lib/pathfuncs.o \
|
|
|
|
test_lib/md5.o \
|
|
|
|
test_lib/strlcpy.o \
|
2021-11-28 13:44:46 +00:00
|
|
|
test/main.o \
|
2021-11-28 14:45:11 +00:00
|
|
|
test/test_flashmap.o \
|
2021-11-28 13:44:46 +00:00
|
|
|
test/test_stream.o
|
2021-11-23 20:13:52 +00:00
|
|
|
TBIN = xf_test
|
|
|
|
|
|
|
|
# dependency needs to be built manually
|
|
|
|
MTARINC = -I../microtar/src
|
|
|
|
MTARLIB = ../microtar/libmicrotar.a
|
|
|
|
|
|
|
|
CPPFLAGS = -Iinclude -Itest_lib $(MTARINC) -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L
|
2021-11-28 13:42:52 +00:00
|
|
|
CFLAGS = -std=c99 -Wall -Wextra
|
|
|
|
LDFLAGS =
|
2021-11-23 20:13:52 +00:00
|
|
|
|
2021-11-28 13:42:52 +00:00
|
|
|
PROFRAW_FILE=$(TBIN).profraw
|
|
|
|
PROFDATA_FILE=$(TBIN).profdata
|
|
|
|
|
|
|
|
export LLVM_PROFILE_FILE=$(PROFRAW_FILE)
|
|
|
|
|
|
|
|
ifeq ($(COVERAGE),1)
|
|
|
|
CC = clang
|
|
|
|
CFLAGS += -g -Og -fprofile-instr-generate -fcoverage-mapping
|
|
|
|
LDFLAGS += -fprofile-instr-generate -fcoverage-mapping
|
|
|
|
else
|
|
|
|
CFLAGS += -O2
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(SANITIZE),1)
|
|
|
|
CFLAGS += -fsanitize=address -fsanitize=undefined
|
|
|
|
LDFLAGS += -fsanitize=address -fsanitize=undefined
|
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: all
|
2021-11-23 20:13:52 +00:00
|
|
|
all: $(LIB) $(TBIN)
|
|
|
|
|
2021-11-28 13:42:52 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: $(TBIN)
|
|
|
|
@./$(TBIN)
|
2021-11-23 20:13:52 +00:00
|
|
|
|
2021-11-28 13:42:52 +00:00
|
|
|
.PHONY: cov
|
|
|
|
cov: $(PROFDATA_FILE)
|
|
|
|
@llvm-cov report $(TBIN) -instr-profile=$(PROFDATA_FILE)
|
2021-11-23 20:13:52 +00:00
|
|
|
|
2021-11-28 13:42:52 +00:00
|
|
|
.PHONY: cov-show
|
|
|
|
cov-show: $(PROFDATA_FILE)
|
|
|
|
@llvm-cov show $(TBIN) --use-color -instr-profile=$(PROFDATA_FILE) $(f) | less -R
|
2021-11-23 20:13:52 +00:00
|
|
|
|
2021-11-28 13:42:52 +00:00
|
|
|
.PHONY: clean
|
2021-11-23 20:13:52 +00:00
|
|
|
clean:
|
|
|
|
rm -f $(LIB) $(OBJ)
|
|
|
|
rm -f $(TBIN) $(TOBJ)
|
2021-11-28 13:42:52 +00:00
|
|
|
rm -f $(PROFRAW_FILE) $(PROFDATA_FILE)
|
|
|
|
rm -f fakeNAND.bin fakeNAND_meta.bin
|
|
|
|
|
|
|
|
$(LIB): $(OBJ)
|
|
|
|
$(AR) rcs $@ $^ >/dev/null
|
|
|
|
|
|
|
|
$(TBIN): $(TOBJ) $(LIB) $(MTARLIB)
|
|
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
# use separate rule instead of depending on 'test' to avoid re-running
|
|
|
|
$(PROFRAW_FILE): $(TBIN)
|
|
|
|
@./$(TBIN)
|
|
|
|
|
|
|
|
$(PROFDATA_FILE): $(PROFRAW_FILE)
|
|
|
|
@llvm-profdata merge -sparse $(PROFRAW_FILE) -o $(PROFDATA_FILE)
|