Reintroduced multiple emulator backend directories
Fixes a "make -j" concurrency bug due to deleting files that another parallel rule depends on.
This commit is contained in:
parent
83df4bcc35
commit
8f71c4da2d
@ -2,6 +2,7 @@ default: all
|
||||
|
||||
base_dir = $(abspath ..)
|
||||
generated_dir = $(abspath ./generated-src)
|
||||
generated_src_debug = $(abspath ./generated-src-debug)
|
||||
sim_dir = .
|
||||
output_dir = $(sim_dir)/output
|
||||
|
||||
@ -15,35 +16,42 @@ CXXSRCS := emulator mm mm_dramsim2
|
||||
CXXFLAGS := $(CXXFLAGS) -std=c++11 -I$(RISCV)/include -I$(base_dir)/csrc -I$(base_dir)/dramsim2
|
||||
LDFLAGS := $(LDFLAGS) -L$(RISCV)/lib -Wl,-rpath,$(RISCV)/lib -L. -ldramsim -lfesvr -lpthread
|
||||
OBJS := $(addsuffix .o,$(CXXSRCS) $(MODEL).$(CONFIG))
|
||||
DEBUG_OBJS := $(addsuffix .debug.o,$(CXXSRCS) $(MODEL).$(CONFIG))
|
||||
|
||||
$(MODEL).$(CONFIG).o: %.o: $(generated_dir)/%.h
|
||||
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls $(generated_dir)/$(MODEL).$(CONFIG)-*.cpp))
|
||||
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls $(generated_dir)/$(MODEL).$(CONFIG)-*.cpp)) -o $@
|
||||
|
||||
$(MODEL).$(CONFIG).debug.o: %.debug.o: $(generated_src_debug)/%.h
|
||||
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls $(generated_src_debug)/$(MODEL).$(CONFIG)-*.cpp))
|
||||
$(LD) -r $(patsubst %.cpp,%.o,$(shell ls $(generated_src_debug)/$(MODEL).$(CONFIG)-*.cpp)) -o $@
|
||||
|
||||
$(generated_dir)/%.o: $(generated_dir)/%.cpp $(generated_dir)/%.h
|
||||
$(CXX) $(CXXFLAGS) -I$(generated_dir) -c -o $@ $<
|
||||
|
||||
$(generated_src_debug)/%.o: $(generated_src_debug)/%.cpp $(generated_src_debug)/%.h
|
||||
$(CXX) $(CXXFLAGS) -I$(generated_src_debug) -c -o $@ $<
|
||||
|
||||
$(addsuffix .o,$(CXXSRCS)): %.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h $(generated_dir)/$(MODEL).$(CONFIG).h
|
||||
$(CXX) $(CXXFLAGS) -include $(generated_dir)/$(MODEL).$(CONFIG).h -I$(generated_dir) -c -o $@ $<
|
||||
|
||||
$(generated_dir)/nodebug.d $(generated_dir)/$(MODEL).$(CONFIG).d : $(chisel_srcs)
|
||||
rm -f $(generated_dir)/debug.d $(shell ls $(generated_dir)/$(MODEL).$(CONFIG)*)
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS) --noIoDebug"
|
||||
touch $(generated_dir)/nodebug.d
|
||||
$(addsuffix .debug.o,$(CXXSRCS)): %.debug.o: $(base_dir)/csrc/%.cc $(base_dir)/csrc/*.h $(generated_src_debug)/$(MODEL).$(CONFIG).h
|
||||
$(CXX) $(CXXFLAGS) -include $(generated_src_debug)/$(MODEL).$(CONFIG).h -I$(generated_src_debug) -c -o $@ $<
|
||||
|
||||
$(generated_dir)/debug.d : $(chisel_srcs)
|
||||
rm -f $(generated_dir)/nodebug.d $(shell ls $(generated_dir)/$(MODEL).$(CONFIG)*)
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS) --debug --vcd --ioDebug"
|
||||
touch $(generated_dir)/debug.d
|
||||
$(generated_dir)/$(MODEL).$(CONFIG).d $(generated_dir)/$(MODEL).$(CONFIG).h : $(chisel_srcs)
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS) --noIoDebug"
|
||||
|
||||
$(generated_src_debug)/$(MODEL).$(CONFIG).h : $(chisel_srcs)
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS)-debug --debug --vcd --ioDebug"
|
||||
|
||||
emu = emulator-$(MODEL)-$(CONFIG)
|
||||
$(emu): $(generated_dir)/nodebug.d $(OBJS) libdramsim.a
|
||||
$(emu): $(generated_dir)/$(MODEL).$(CONFIG).h $(OBJS) libdramsim.a
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
|
||||
|
||||
emu_debug = emulator-$(MODEL)-$(CONFIG)-debug
|
||||
$(emu_debug): $(generated_dir)/debug.d $(OBJS) libdramsim.a
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)
|
||||
|
||||
$(emu_debug): $(generated_dir)/$(MODEL).$(CONFIG).d $(generated_src_debug)/$(MODEL).$(CONFIG).h $(DEBUG_OBJS) libdramsim.a
|
||||
$(CXX) $(CXXFLAGS) -o $@ $(DEBUG_OBJS) $(LDFLAGS)
|
||||
|
||||
all: $(emu)
|
||||
debug: $(emu_debug)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user