-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (123 loc) · 4.93 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#
# Copyright (c) 2009-2020 Intel Corporation
# written by Roman Dementiev and Jim Harris
#
EXE = pcm.x pcm-numa.x pcm-latency.x pcm-power.x pcm-sensor.x pcm-msr.x pcm-memory.x pcm-tsx.x pcm-pcie.x pcm-core.x pcm-iio.x pcm-lspci.x pcm-pcicfg.x
EXE += pcm-mmio.x
EXE += c_example.x
EXE += c_example_shlib.x
EXE += pcm-raw.x
UNAME:=$(shell uname)
ifeq ($(UNAME), Linux)
EXE += daemon-binaries
endif
CXXFLAGS += -Wall -g -O3 -Wno-unknown-pragmas -std=c++11 -fPIC
# uncomment if your Linux kernel supports access to /dev/mem from user space
# CXXFLAGS += -DPCM_USE_PCI_MM_LINUX
# rely on Linux perf support (user needs CAP_SYS_ADMIN privileges), comment out to disable
ifneq ($(wildcard /usr/include/linux/perf_event.h),)
CXXFLAGS += -DPCM_USE_PERF
endif
ifeq ($(UNAME), Linux)
LIB= -pthread -lrt
EXE += pcm-sensor-server.x
CXXFLAGS += -Wextra
OPENSSL_LIB=
# Disabling until we can properly check for dependencies, enable
# yourself if you have the required headers and library installed
#CXXFLAGS += -DUSE_SSL
#OPENSSL_LIB=-lssl -lcrypto -lz -ldl
endif
ifeq ($(UNAME), DragonFly)
LIB= -pthread -lrt
endif
ifeq ($(UNAME), Darwin)
LIB= -lpthread MacMSRDriver/build/Release/libPcmMsr.dylib
CXXFLAGS += -I/usr/include -IMacMSRDriver
endif
ifeq ($(UNAME), FreeBSD)
CXX=c++
LIB= -lpthread -lc++
endif
COMMON_OBJS = msr.o cpucounters.o pci.o mmio.o client_bw.o utils.o topology.o dashboard.o debug.o threadpool.o
EXE_OBJS = $(EXE:.x=.o)
OBJS = $(COMMON_OBJS) $(EXE_OBJS)
# ensure 'make' does not delete the intermediate .o files
.PRECIOUS: $(OBJS)
all: $(EXE) lib
lib: libPCM.a
daemon-binaries:
make -C daemon/daemon/Debug
make -C daemon/client/Debug
klocwork: $(EXE)
-include $(OBJS:.o=.d)
libPCM.a: $(COMMON_OBJS)
ar -rcs $@ $^
%.x: %.o $(COMMON_OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LIB)
pcm-sensor-server.o: pcm-sensor-server.cpp favicon.ico.h
pcm-sensor-server.x: pcm-sensor-server.o $(COMMON_OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LIB) $(OPENSSL_LIB)
libpcm.so: $(COMMON_OBJS) pcm-core.o
$(CXX) $(LDFLAGS) $(CXXFLAGS) -DPCM_SILENT -shared $^ $(LIB) -o $@
c_example.x: c_example.c libpcm.so
$(CC) -DPCM_DYNAMIC_LIB $< -ldl -Wl,-rpath,$(shell pwd) -o $@
c_example_shlib.x: c_example.c libpcm.so
$(CC) $< -L./ -Wl,-rpath,$(shell pwd) -lpcm -o $@
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $*.cpp -o $*.o
@# the following lines generate dependency files for the
@# target object
@# from http://scottmcpeak.com/autodepend/autodepend.html
$(CXX) -MM $(CXXFLAGS) $*.cpp > $*.d
@# these sed/fmt commands modify the .d file to add a target
@# rule for each .h and .cpp file with no dependencies;
@# this will force 'make' to rebuild any objects that
@# depend on a file that has been renamed rather than
@# exiting with an error
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
memoptest.x: memoptest.cpp
g++ -Wall -g -O0 -std=c++11 memoptest.cpp -o memoptest.x
dashboardtest.x: dashboardtest.cpp $(COMMON_OBJS)
$(CXX) -o $@ $^ $(LIB)
nice:
uncrustify --replace -c ~/uncrustify.cfg *.cpp *.h WinMSRDriver/Win7/*.h WinMSRDriver/Win7/*.c WinMSRDriver/WinXP/*.h WinMSRDriver/WinXP/*.c PCM_Win/*.h PCM_Win/*.cpp
prefix=/usr
ifneq ($(DESTDIR),)
prefix=${DESTDIR}/usr
endif
install: all
mkdir -p ${prefix}/sbin/
install -s -m 755 pcm-core.x ${prefix}/sbin/pcm-core
install -s -m 755 pcm-iio.x ${prefix}/sbin/pcm-iio
install -s -m 755 pcm-latency.x ${prefix}/sbin/pcm-latency
install -s -m 755 pcm-lspci.x ${prefix}/sbin/pcm-lspci
install -s -m 755 pcm-memory.x ${prefix}/sbin/pcm-memory
install -s -m 755 pcm-msr.x ${prefix}/sbin/pcm-msr
install -s -m 755 pcm-numa.x ${prefix}/sbin/pcm-numa
install -s -m 755 pcm-pcicfg.x ${prefix}/sbin/pcm-pcicfg
install -s -m 755 pcm-pcie.x ${prefix}/sbin/pcm-pcie
install -s -m 755 pcm-power.x ${prefix}/sbin/pcm-power
install -s -m 755 pcm-sensor.x ${prefix}/sbin/pcm-sensor
install -s -m 755 pcm-tsx.x ${prefix}/sbin/pcm-tsx
install -s -m 755 pcm-raw.x ${prefix}/sbin/pcm-raw
install -s -m 755 pcm.x ${prefix}/sbin/pcm
ifeq ($(UNAME), Linux)
mkdir -p ${prefix}/bin/
install -s -m 755 daemon/client/Debug/client ${prefix}/bin/pcm-client
install -s -m 755 daemon/daemon/Debug/daemon ${prefix}/sbin/pcm-daemon
install -s -m 755 pcm-sensor-server.x ${prefix}/sbin/pcm-sensor-server
endif
install -m 755 pcm-bw-histogram.sh ${prefix}/sbin/pcm-bw-histogram
mkdir -p ${prefix}/share/pcm/
install -m 644 opCode.txt ${prefix}/share/pcm/
clean:
rm -rf *.x *.o *~ *.d *.a *.so
ifeq ($(UNAME), Linux)
make -C daemon/daemon/Debug clean
make -C daemon/client/Debug clean
endif