-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
47 lines (34 loc) · 1.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#VARIANT?=G
DEVICE?=DDR3_1333
CXXFLAGS=-O3 -g
LIB_NAME=libbobsim.so
EXE_NAME=BOBSim
LINKFLAGS=
SRC = $(wildcard *.cpp)
OBJ = $(subst LibraryStubs.o,,$(addsuffix .o, $(basename $(SRC))))
LOBJ = $(patsubst RandomStreamSim%.lo,,$(addsuffix .lo, $(basename $(SRC))))
REBUILDABLES=$(OBJ) $(EXE_NAME) ${LOBJ} ${LIB_NAME}
all: ${EXE_NAME}
# $@ target name, $^ target deps, $< matched pattern
$(EXE_NAME): $(OBJ)
$(CXX) $(LINK_FLAGS) -o $@ $^
@echo "Built $@ successfully"
#for now, I'm assuming that -ltcmalloc will be linked with the binary, not the library
$(LIB_NAME): $(LOBJ)
$(CXX) -shared -Wl,-soname,$@ -o $@ $^
@echo "Built $@ successfully"
#include the autogenerated dependency files for each .o file
-include $(OBJ:.o=.dep)
-include $(LOBJ:.lo=.dep)
# build dependency list via gcc -M and save to a .dep file
%.dep : %.cpp
@$(CXX) -M $(CXXFLAGS) $< > $@
%.po : %.cpp
g++ -O3 -ffast-math -fPIC -DNO_STORAGE -o $@ -c $<
# build all .cpp files to .o files
%.o : %.cpp
g++ $(CXXFLAGS) -D${DEVICE} -o $@ -c $<
%.lo : %.cpp
g++ $(CXXFLAGS) -D${DEVICE} -DLOG_OUTPUT -fPIC -o $@ -c $<
clean:
-rm -f ${REBUILDABLES} *.dep