<commit_before># Makefile
# Building the scalar MIPS CPU simulator.
# MIPT-MIPS Assignment 4.
# <NAME>.
#

.SUFFIXES:
.PHONY: clean test
.PRECIOUS: %/t/test.o %/t/test.out

# Including options and compiler flags
include ./options.mk

#
# Enter for build "perf_sim" program
OBJ_DIR=obj
CPPS= \
    infra/elf_parser/elf_parser.cpp \
    infra/memory/memory.cpp \
    infra/config/config.cpp \
    infra/ports/ports.cpp \
    infra/cache/cache_tag_array.cpp \
    mips/mips_instr.cpp \
    func_sim/func_sim.cpp \
    perf_sim.cpp

OBJS= $(addprefix $(OBJ_DIR)/, $(notdir $(CPPS:%.cpp=%.o)))
DEPS= $(OBJS:.o=.d)
LIBS= elf boost_program_options boost_timer

vpath %.cpp $(dir $(CPPS))

mipt-mips: $(OBJS) $(OBJ_DIR)/main.o
	@$(CXX) $(LDFLAGS) $(LPATH) -o $@ $^ $(addprefix -l,$(LIBS))
	@echo "---------------------------------"
	@echo "$@ is built SUCCESSFULLY"

# Rules to get GTest
GTEST_LIB= $(GTEST_LPATH)/libgtest.a
$(GTEST_LIB):
	@$(MAKE) -C $(GTEST_DIR)

####### TESTS #######

TESTS= \
    infra/elf_parser \
    infra/memory \
    mips

test: $(addsuffix /t/test.run, $(TESTS))

clean-tests: $(addsuffix /t/test.clean, $(TESTS))

%/t/test.o: %/t/unit_test.cpp
	@echo "[$(CXX)] $@"
	@$(CXX) $(CXXFLAGS) -Wno-effc++ -o $@ -c $< $(INCL) -I $(GTEST_INCL)
	@$(CXX) $(CXXFLAGS) -Wno-effc++ -o $(patsubst %.o, %.d, $@) -MM -MT $@ $< $(INCL) -I $(GTEST_INCL)

# TODO: remove dependencies from ALL objs
%/t/test.out: $(OBJS) %/t/test.o $(GTEST_LIB)
	@echo "[ld] $@"
	@$(CXX) $(LDFLAGS) $(LPATH) -pthread -o $@ $^ $(addprefix -l,$(LIBS)) -l pthread

%/t/test.run: %/t/test.out
	@echo "[$<]"
	@(cd $(dir $^) && exec ./test.out)

%/t/test.clean:
	rm -f $(dir $@)test.*

####### DISASM #######

DISASM_CPPS= \
    infra/memory/memory.cpp \
    infra/elf_parser/elf_parser.cpp \
    func_sim/func_sim.cpp \
    mips/mips_instr.cpp \
    disasm.cpp
DISASM_OBJS= $(addprefix $(OBJ_DIR)/, $(notdir $(DISASM_CPPS:%.cpp=%.o)))

disasm: $(DISASM_OBJS)
	@$(CXX) $(LDFLAGS) -o $@ $^ -l elf
	@echo "---------------------------------"
	@echo "$@ is built SUCCESSFULLY"

####### COMMON #######

-include $(DEPS)

$(OBJ_DIR)/%.o: %.cpp
	@mkdir -p $(OBJ_DIR)
	@echo "[$(CXX)] $@"
	@$(CXX) $(CXXFLAGS) -o $@ -c $< $(INCL)
	@$(CXX) $(CXXFLAGS) -o $(patsubst %.o, %.d, $@) -MM -MT $@ $< $(INCL)

clean: clean-tests
	rm -rf obj
	rm -f mipt-mips disasm

<commit_msg>Take unit tests header dependencies into account<commit_after># Makefile
# Building the scalar MIPS CPU simulator.
# MIPT-MIPS Assignment 4.
# <NAME>.
#

.SUFFIXES:
.PHONY: clean test
.PRECIOUS: %/t/test.o %/t/test.out

# Including options and compiler flags
include ./options.mk

#
# Enter for build "perf_sim" program
OBJ_DIR=obj
CPPS= \
    infra/elf_parser/elf_parser.cpp \
    infra/memory/memory.cpp \
    infra/config/config.cpp \
    infra/ports/ports.cpp \
    infra/cache/cache_tag_array.cpp \
    mips/mips_instr.cpp \
    func_sim/func_sim.cpp \
    perf_sim.cpp

OBJS= $(addprefix $(OBJ_DIR)/, $(notdir $(CPPS:%.cpp=%.o)))
DEPS= $(OBJS:.o=.d)
LIBS= elf boost_program_options boost_timer

vpath %.cpp $(dir $(CPPS))

mipt-mips: $(OBJS) $(OBJ_DIR)/main.o
	@$(CXX) $(LDFLAGS) $(LPATH) -o $@ $^ $(addprefix -l,$(LIBS))
	@echo "---------------------------------"
	@echo "$@ is built SUCCESSFULLY"

###### Rules to get GTest #######

GTEST_LIB= $(GTEST_LPATH)/libgtest.a
$(GTEST_LIB):
	@$(MAKE) -C $(GTEST_DIR)

####### TESTS #######

TESTS= \
    infra/elf_parser \
    infra/memory \
    mips

test: $(addsuffix /t/test.run, $(TESTS))

clean-tests: $(addsuffix /t/test.clean, $(TESTS))

-include $(addsuffix /t/test.d, $(TESTS))

%/t/test.o: %/t/unit_test.cpp
	@echo "[$(CXX)] $@"
	@$(CXX) $(CXXFLAGS) -Wno-effc++ -o $@ -c $< $(INCL) -I $(GTEST_INCL)
	@$(CXX) $(CXXFLAGS) -Wno-effc++ -o $(patsubst %.o, %.d, $@) -MM -MT $@ $< $(INCL) -I $(GTEST_INCL)

# TODO: remove dependencies from ALL objs
%/t/test.out: $(OBJS) %/t/test.o $(GTEST_LIB)
	@echo "[ld] $@"
	@$(CXX) $(LDFLAGS) $(LPATH) -pthread -o $@ $^ $(addprefix -l,$(LIBS)) -l pthread

%/t/test.run: %/t/test.out
	@echo "[$<]"
	@(cd $(dir $^) && exec ./test.out)

%/t/test.clean:
	rm -f $(dir $@)test.*

####### DISASM #######

DISASM_CPPS= \
    infra/memory/memory.cpp \
    infra/elf_parser/elf_parser.cpp \
    func_sim/func_sim.cpp \
    mips/mips_instr.cpp \
    disasm.cpp

disasm: $(addprefix $(OBJ_DIR)/, $(notdir $(DISASM_CPPS:%.cpp=%.o)))
	@$(CXX) $(LDFLAGS) -o $@ $^ -l elf
	@echo "---------------------------------"
	@echo "$@ is built SUCCESSFULLY"

####### COMMON #######

-include $(DEPS)

$(OBJ_DIR)/%.o: %.cpp
	@mkdir -p $(OBJ_DIR)
	@echo "[$(CXX)] $@"
	@$(CXX) $(CXXFLAGS) -o $@ -c $< $(INCL)
	@$(CXX) $(CXXFLAGS) -o $(patsubst %.o, %.d, $@) -MM -MT $@ $< $(INCL)

clean: clean-tests
	rm -rf obj
	rm -f mipt-mips disasm


{'fraction_non_alphanumeric': 0.2617039223956137, 'fraction_numerical': 0.00042176296921130323, 'mean_word_length': 2.9790268456375837, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '188415', 'n_tokens_mistral': 2134, 'n_tokens_neox': 2010, 'n_words': 422}