@@ -3,15 +3,15 @@ TARGET?=test
33
44# Compiler
55CC =g++
6- CFLAGS =-Wall -I. -O3 -g -Wextra -Wunused-function
6+ CFLAGS =-Wall -Wextra -fsanitize=address -fsanitize=undefined -I. -O3 -g
77
88ifdef USE_CPP17
99CFLAGS+=-std =c++17
10- endif
10+ endif # USE_CPP17
1111
1212# Target
1313LD =g++
14- LFLAGS =-Wall -I. -lm -g
14+ LFLAGS =-Wall -fsanitize=address -fsanitize=undefined - I. -lm -g
1515LIBS =-lsystemc -lm
1616
1717# Source directories
@@ -21,6 +21,17 @@ BINDIR=./
2121INCDIR =-I. -I./include -I$(SYSTEMC ) /include -Ibasic_protocol -I$(SYSTEMC ) /include/tlm_core/tlm_2
2222LIBDIR =-L. -L$(SYSTEMC ) /lib-linux64
2323
24+ ifdef USING_TLM_TB_EN
25+ EDGE_DIR =../edge-detector
26+ GRAY_DIR =../rgb2gray
27+ FILTER_DIR =../filter
28+ UNIFICATION_DIR =../unification
29+ COMPRESSION_DIR =../compression
30+
31+ SRCDIRS =$(SRCDIR ) $(EDGE_DIR ) /src $(GRAY_DIR ) /src $(FILTER_DIR ) /src $(UNIFICATION_DIR ) /src $(COMPRESSION_DIR ) /src
32+ INCDIR+ =-I$(EDGE_DIR ) /include -I$(GRAY_DIR ) /include -I$(FILTER_DIR ) /include -I$(UNIFICATION_DIR ) /include -I$(COMPRESSION_DIR ) /include
33+ endif # USING_TLM_TB_EN
34+
2435ifdef INCLUDE_OPENCV
2536# Target
2637LIBS+ =-lopencv_imgcodecs -lopencv_core -lopencv_highgui -lopencv_imgproc
@@ -35,15 +46,38 @@ LFLAGS += $(shell pkg-config --libs opencv4)
3546endif # INCLUDE_OPENCV_PKG
3647endif # INCLUDE_OPENCV
3748
49+ ifndef USING_TLM_TB_EN
3850SOURCES := $(wildcard $(SRCDIR ) /* .cpp)
3951INCLUDES := $(wildcard $(INCDIR ) /* .hpp)
4052OBJECTS := $(SOURCES:$(SRCDIR ) /%.cpp=$(OBJDIR ) /%.o )
53+ else
54+ SOURCES = $(wildcard * .cpp) $(foreach DIR, $(SRCDIRS ) , $(wildcard $(DIR ) /* .cpp) )
55+ SOURCES_WITHOUT_PATH = $(notdir $(SOURCES ) )
56+ INCLUDES := $(wildcard $(INCDIR ) /* .hpp)
57+ OBJECTS = $(SOURCES_WITHOUT_PATH:%.cpp=$(OBJDIR ) /%.o )
58+
59+ VPATH = $(sort $(dir $(SOURCES ) ) )
60+ endif # USING_TLM_TB_EN
4161
4262$(BINDIR ) /$(TARGET ) : clean $(OBJECTS )
4363 @$(LD ) $(OBJECTS ) $(LFLAGS ) $(LIBS ) $(LIBDIR ) -o $@
4464
65+ ifndef USING_TLM_TB_EN
4566$(OBJECTS ) : $(OBJDIR ) /% .o : $(SRCDIR ) /% .cpp
4667 @$(CC ) $(CFLAGS ) $(INCDIR ) -c $< -o $@
68+ else
69+ $(OBJECTS ) : $(OBJDIR ) /% .o : % .cpp
70+ @$(CC ) $(CFLAGS ) $(INCDIR ) -c $< -o $@
71+ endif # USING_TLM_TB_EN
72+
73+ valgrind :
74+ valgrind --leak-check=full -s ./$(TARGET )
75+
76+ drmemory :
77+ drmemory -- ./$(TARGET )
78+
79+ heaptrack :
80+ heaptrack ./$(TARGET )
4781
4882.PHONY : clean
4983clean :
0 commit comments