add debug target

master v1.2.0
Avril 3 years ago
parent 06314bcd48
commit 64af32ed33
Signed by: flanchan
GPG Key ID: 284488987C31F630

3
.gitignore vendored

@ -1,8 +1,7 @@
*~
test*
obj/
hexview
hexview-pgo
hexview-*
profile/
perf.*

@ -8,7 +8,7 @@ CXXFLAGS+= -Wall -pedantic --std=gnu++20 $(addprefix -I,$(INCLUDE))
LDFLAGS?= -O3 -flto
LDFLAGS+= -lfmt
PROJ = hexview
PROJECT = hexview
OBJ = $(addprefix obj/,$(SRC:.cpp=.o))
@ -24,8 +24,14 @@ PROF_FLAGS = -fprofile-generate
###
.PHONY: all
all: | dirs $(PROJ)
.PHONY: release
release: | dirs $(PROJECT)-release
.PHONY: debug
debug: | dirs $(PROJECT)-debug
.PHONY: pgo
pgo: | dirs $(PROJECT)-pgo
dirs:
@mkdir -p obj/src
@ -37,22 +43,28 @@ obj/%.o: %.cpp
profile/%.o: %.cpp
$(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
$(PROJ): $(OBJ)
$(PROJECT)-release: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
strip $@
$(PROJECT)-debug: CXXFLAGS = -O0 -g -Wall -pedantic --std=gnu++20 $(addprefix -I,$(INCLUDE)) -fno-exceptions -felide-constructors
$(PROJECT)-debug: LDFLAGS = -lfmt
$(PROJECT)-debug: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
pgo-generate: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
pgo-profile: pgo-generate
for i in {1..$(PGO_ITERATIONS)}; do \
dd if=/dev/urandom of=/tmp/$(PROJ)-pgo-test bs=1024 count=$(PGO_DATASET_SIZE) >> /dev/null 2>&1; \
dd if=/dev/urandom of=/tmp/$(PROJECT)-pgo-test bs=1024 count=$(PGO_DATASET_SIZE) >> /dev/null 2>&1; \
printf "\rIteration $$i / $(PGO_ITERATIONS)"; \
./pgo-generate /tmp/$(PROJ)-pgo-test > /tmp/$(PROJ)-pgo-output; \
./pgo-generate /tmp/$(PROJECT)-pgo-test > /tmp/$(PROJECT)-pgo-output; \
done
@echo ""
rm /tmp/$(PROJ)-pgo-test
rm /tmp/$(PROJ)-pgo-output
rm /tmp/$(PROJECT)-pgo-test
rm /tmp/$(PROJECT)-pgo-output
rm pgo-generate
@ -61,15 +73,14 @@ pgo-use: LDFLAGS+= -lgcov
pgo-use: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
$(PROJ)-pgo: | dirs pgo-profile
$(PROJECT)-pgo: | dirs pgo-profile
find ./profile -name \*.o -exec rm {} +
$(MAKE) pgo-use
mv pgo-use $@
strip $@
clean:
rm -f $(PROJ)
rm -f $(PROJ)-pgo
rm -f $(PROJECT)-{release,debug,pgo}
rm -rf obj
rm -rf profile
rm -f pgo-{test,output,generate}

Loading…
Cancel
Save