|
|
@ -39,6 +39,16 @@ OBJ_C = $(addprefix obj/c/,$(SRC_C:.c=.o))
|
|
|
|
OBJ_CXX = $(addprefix obj/cxx/,$(SRC_CXX:.cpp=.o))
|
|
|
|
OBJ_CXX = $(addprefix obj/cxx/,$(SRC_CXX:.cpp=.o))
|
|
|
|
OBJ = $(OBJ_C) $(OBJ_CXX)
|
|
|
|
OBJ = $(OBJ_C) $(OBJ_CXX)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PGO_OBJ_C = $(addprefix obj/pgo/c/,$(SRC_C:.c=.o))
|
|
|
|
|
|
|
|
PGO_OBJ_CXX = $(addprefix obj/pgo/cxx/,$(SRC_CXX:.cpp=.o))
|
|
|
|
|
|
|
|
PGO_OBJ = $(PGO_OBJ_C) $(PGO_OBJ_CXX)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PGO_ITERATIONS=5
|
|
|
|
|
|
|
|
PGO_SET_LOC?=/tmp/$(PROJECT)-pgo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PGO_FLAGS = -fprofile-generate
|
|
|
|
|
|
|
|
PGO_LDFLAGS=
|
|
|
|
|
|
|
|
|
|
|
|
# Phonies
|
|
|
|
# Phonies
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: release
|
|
|
|
.PHONY: release
|
|
|
@ -47,14 +57,16 @@ release: | dirs $(PROJECT)-release
|
|
|
|
.PHONY: debug
|
|
|
|
.PHONY: debug
|
|
|
|
debug: | dirs $(PROJECT)-debug
|
|
|
|
debug: | dirs $(PROJECT)-debug
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: pgo
|
|
|
|
|
|
|
|
pgo: | dirs $(PROJECT)-pgo
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
.PHONY: test
|
|
|
|
test: test-all
|
|
|
|
test: test-all
|
|
|
|
|
|
|
|
|
|
|
|
# Targets
|
|
|
|
# Targets
|
|
|
|
|
|
|
|
|
|
|
|
dirs:
|
|
|
|
dirs:
|
|
|
|
@mkdir -p obj/c{,xx}/src
|
|
|
|
@mkdir -p obj/{pgo/,}c{,xx}/src{,/rng}
|
|
|
|
@mkdir -p obj/cxx/src/rng
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj/c/%.o: %.c
|
|
|
|
obj/c/%.o: %.c
|
|
|
|
$(CC) -c $< $(CFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
$(CC) -c $< $(CFLAGS) -o $@ $(LDFLAGS)
|
|
|
@ -62,6 +74,12 @@ obj/c/%.o: %.c
|
|
|
|
obj/cxx/%.o: %.cpp
|
|
|
|
obj/cxx/%.o: %.cpp
|
|
|
|
$(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
$(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj/pgo/c/%.o: %.c
|
|
|
|
|
|
|
|
$(CC) -c $< $(CFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj/pgo/cxx/%.o: %.cpp
|
|
|
|
|
|
|
|
$(CXX) -c $< $(CXXFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(PROJECT)-release: CFLAGS+= $(RELEASE_CFLAGS)
|
|
|
|
$(PROJECT)-release: CFLAGS+= $(RELEASE_CFLAGS)
|
|
|
|
$(PROJECT)-release: CXXFLAGS += $(RELEASE_CXXFLAGS)
|
|
|
|
$(PROJECT)-release: CXXFLAGS += $(RELEASE_CXXFLAGS)
|
|
|
@ -76,11 +94,49 @@ $(PROJECT)-debug: LDFLAGS += $(DEBUG_LDFLAGS)
|
|
|
|
$(PROJECT)-debug: $(OBJ)
|
|
|
|
$(PROJECT)-debug: $(OBJ)
|
|
|
|
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pgo-generate: CFLAGS+= $(RELEASE_CFLAGS)
|
|
|
|
|
|
|
|
pgo-generate: CXXFLAGS += $(RELEASE_CXXFLAGS)
|
|
|
|
|
|
|
|
pgo-generate: LDFLAGS += $(RELEASE_LDFLAGS)
|
|
|
|
|
|
|
|
pgo-generate: $(PGO_OBJ)
|
|
|
|
|
|
|
|
$(CXX) $^ $(CXXFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pgo-reset:
|
|
|
|
|
|
|
|
find ./obj/pgo -name \*.gcda -exec rm {} +
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pgo-profile: | pgo-reset pgo-generate
|
|
|
|
|
|
|
|
mkdir -p $(PGO_SET_LOC)
|
|
|
|
|
|
|
|
for i in {1..$(PGO_ITERATIONS)}; do \
|
|
|
|
|
|
|
|
dd if=/dev/urandom of=$(PGO_SET_LOC)/small bs=1024 count=1 >> /dev/null 2>&1; \
|
|
|
|
|
|
|
|
printf "Iteration $$i / $(PGO_ITERATIONS)\r"; \
|
|
|
|
|
|
|
|
./pgo-generate -s $(PGO_SET_LOC)/small >>/dev/null; \
|
|
|
|
|
|
|
|
./pgo-generate -u $(PGO_SET_LOC)/small >>/dev/null; \
|
|
|
|
|
|
|
|
./pgo-generate -h >> /dev/null; \
|
|
|
|
|
|
|
|
FCNT=1 ./test.sh ./pgo-generate >>/dev/null; \
|
|
|
|
|
|
|
|
FCNT=2 ./test.sh ./pgo-generate >>/dev/null; \
|
|
|
|
|
|
|
|
FCNT=3 ./test.sh ./pgo-generate >>/dev/null; \
|
|
|
|
|
|
|
|
FCNT=4 ./test.sh ./pgo-generate >>/dev/null; \
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -rf $(PGO_SET_LOC)
|
|
|
|
|
|
|
|
rm pgo-generate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pgo-use: PGO_FLAGS = -fprofile-use
|
|
|
|
|
|
|
|
pgo-use: PGO_LDFLAGS = -lgcov -fprofile-use
|
|
|
|
|
|
|
|
pgo-use: CFLAGS+= $(RELEASE_CFLAGS)
|
|
|
|
|
|
|
|
pgo-use: CXXFLAGS += $(RELEASE_CXXFLAGS)
|
|
|
|
|
|
|
|
pgo-use: LDFLAGS += $(RELEASE_LDFLAGS)
|
|
|
|
|
|
|
|
pgo-use: $(PGO_OBJ)
|
|
|
|
|
|
|
|
$(CXX) $^ $(CXXFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(PROJECT)-pgo: | pgo-profile
|
|
|
|
|
|
|
|
find ./obj/pgo -name \*.o -exec rm {} +
|
|
|
|
|
|
|
|
$(MAKE) pgo-use
|
|
|
|
|
|
|
|
mv pgo-use $@
|
|
|
|
|
|
|
|
|
|
|
|
clean-rebuild:
|
|
|
|
clean-rebuild:
|
|
|
|
rm -rf obj
|
|
|
|
rm -rf obj
|
|
|
|
|
|
|
|
|
|
|
|
clean: clean-rebuild
|
|
|
|
clean: clean-rebuild
|
|
|
|
rm -f $(PROJECT)-{release,debug}
|
|
|
|
rm -f $(PROJECT)-{release,debug,pgo}
|
|
|
|
|
|
|
|
|
|
|
|
test-all:
|
|
|
|
test-all:
|
|
|
|
@./test.sh ./$(PROJECT)-*
|
|
|
|
@./test.sh ./$(PROJECT)-*
|
|
|
|