Skip to content

Commit 7100a18

Browse files
jgavillalobosErickOF
authored andcommitted
Update Makefile to use other folders for the reused blocks
1 parent 8a8db0e commit 7100a18

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

modules/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ BINDIR=./
2121
INCDIR=-I. -I./include -I$(SYSTEMC)/include -Ibasic_protocol -I$(SYSTEMC)/include/tlm_core/tlm_2
2222
LIBDIR=-L. -L$(SYSTEMC)/lib-linux64
2323

24+
ifdef USING_TLM_TB_EN
25+
SRCDIRS=$(SRCDIR) ../edge-detector/src
26+
INCDIR+=-I../edge-detector/include
27+
endif # USING_TLM_TB_EN
28+
2429
ifdef INCLUDE_OPENCV
2530
# Target
2631
LIBS+=-lopencv_imgcodecs -lopencv_core -lopencv_highgui -lopencv_imgproc
@@ -35,15 +40,29 @@ LFLAGS += $(shell pkg-config --libs opencv4)
3540
endif # INCLUDE_OPENCV_PKG
3641
endif # INCLUDE_OPENCV
3742

43+
ifndef USING_TLM_TB_EN
3844
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
3945
INCLUDES := $(wildcard $(INCDIR)/*.hpp)
4046
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
47+
else
48+
SOURCES = $(wildcard *.cpp) $(foreach DIR, $(SRCDIRS), $(wildcard $(DIR)/*.cpp))
49+
SOURCES_WITHOUT_PATH = $(notdir $(SOURCES))
50+
INCLUDES := $(wildcard $(INCDIR)/*.hpp)
51+
OBJECTS = $(SOURCES_WITHOUT_PATH:%.cpp=$(OBJDIR)/%.o)
52+
53+
VPATH = $(sort $(dir $(SOURCES)))
54+
endif # USING_TLM_TB_EN
4155

4256
$(BINDIR)/$(TARGET): clean $(OBJECTS)
4357
@$(LD) $(OBJECTS) $(LFLAGS) $(LIBS) $(LIBDIR) -o $@
4458

59+
ifndef USING_TLM_TB_EN
4560
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
4661
@$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
62+
else
63+
$(OBJECTS): $(OBJDIR)/%.o : %.cpp
64+
@$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
65+
endif # USING_TLM_TB_EN
4766

4867
.PHONY: clean
4968
clean:

modules/edge-detector/src/tb_edge_detector.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef USING_TLM_TB_EN
2+
13
#define int64 systemc_int64
24
#define uint64 systemc_uint64
35
#include <systemc.h>
@@ -350,3 +352,5 @@ int sc_main(int, char*[])
350352

351353
return 0;
352354
}
355+
356+
#endif // USING_TLM_TB_EN

modules/router/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ ifdef EDGE_DETECTOR_AT_EN
3737
LFLAGS += -DEDGE_DETECTOR_AT_EN
3838
endif # EDGE_DETECTOR_AT_EN
3939

40+
ifdef USING_TLM_TB_EN
41+
CFLAGS += -DUSING_TLM_TB_EN
42+
LFLAGS += -DUSING_TLM_TB_EN
43+
endif # USING_TLM_TB_EN
44+
45+
.PHONY: print-all
46+
print-all:
47+
@echo "Incdir is $(INCDIR)"
48+
@echo "Srcdir is $(SRCDIR)"
49+
@echo "Srcdirs are $(SRCDIRS)"
50+
@echo "Includes are $(INCLUDES)"
51+
@echo "Sources are $(SOURCES)"
52+
@echo "Objects are $(OBJECTS)"
53+
54+
.PHONY: print-flags
55+
print-flags:
56+
@echo "Flags are $(CFLAGS)"
57+
4058
# Run the compiled file
4159
run:
4260
@./test

0 commit comments

Comments
 (0)