You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hexview/Makefile

76 lines
1.8 KiB

4 years ago
SRC=$(wildcard src/*.cpp)
INCLUDE =include
4 years ago
_HX_FEAT?= -DFIXED_ROW_SIZE=24
CXXFLAGS?= -pipe -O3 -march=native
4 years ago
CXXFLAGS+= -flto -felide-constructors -fgraphite -fno-strict-aliasing -fno-exceptions -fomit-frame-pointer -fmerge-all-constants -fmodulo-sched -funswitch-loops -fsplit-loops
4 years ago
CXXFLAGS+= -Wall -pedantic --std=gnu++20 $(addprefix -I,$(INCLUDE))
LDFLAGS?= -O3 -flto
LDFLAGS+= -lfmt
4 years ago
4 years ago
PROJ = hexview
4 years ago
4 years ago
OBJ = $(addprefix obj/,$(SRC:.cpp=.o))
4 years ago
### PGO target specific ###
# Number of times to run profiling
PGO_ITERATIONS = 512
# Size in kb of training files
PGO_DATASET_SIZE = $$(( 1024 * 4 ))
PGO_OBJ = $(addprefix profile/,$(SRC:.cpp=.o))
PROF_FLAGS = -fprofile-generate
###
4 years ago
.PHONY: all
4 years ago
all: | dirs $(PROJ)
4 years ago
dirs:
@mkdir -p obj/src
@mkdir -p profile/src
4 years ago
4 years ago
obj/%.o: %.cpp
4 years ago
$(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) -o $@ $(LDFLAGS)
4 years ago
profile/%.o: %.cpp
4 years ago
$(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
4 years ago
$(PROJ): $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
strip $@
4 years ago
pgo-generate: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
4 years ago
pgo-profile: pgo-generate
4 years ago
for i in {1..$(PGO_ITERATIONS)}; do \
4 years ago
dd if=/dev/urandom of=/tmp/$(PROJ)-pgo-test bs=1024 count=$(PGO_DATASET_SIZE) >> /dev/null 2>&1; \
4 years ago
printf "\rIteration $$i / $(PGO_ITERATIONS)"; \
4 years ago
./pgo-generate /tmp/$(PROJ)-pgo-test > /tmp/$(PROJ)-pgo-output; \
done
4 years ago
@echo ""
4 years ago
rm /tmp/$(PROJ)-pgo-test
rm /tmp/$(PROJ)-pgo-output
4 years ago
rm pgo-generate
4 years ago
pgo-use: PROF_FLAGS = -fprofile-use
pgo-use: LDFLAGS+= -lgcov
4 years ago
pgo-use: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
4 years ago
$(PROJ)-pgo: | dirs pgo-profile
find ./profile -name \*.o -exec rm {} +
$(MAKE) pgo-use
4 years ago
mv pgo-use $@
strip $@
4 years ago
clean:
rm -f $(PROJ)
4 years ago
rm -f $(PROJ)-pgo
4 years ago
rm -rf obj
rm -rf profile
4 years ago
rm -f pgo-{test,output,generate}