forked from intel/pcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) · 2.01 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
#
# Copyright (c) 2009-2015 Intel Corporation
# written by Roman Dementiev and Jim Harris
#
EXE = pcm.x pcm-numa.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
all: $(EXE)
lib: libPCM.a
klocwork: $(EXE)
CXXFLAGS += -Wall -g -O3 -Wno-unknown-pragmas
# 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
UNAME:=$(shell uname)
ifeq ($(UNAME), Linux)
LIB= -pthread -lrt
CXXFLAGS += -std=c++11
endif
ifeq ($(UNAME), DragonFly)
LIB= -pthread -lrt
CXXFLAGS += -std=c++11
endif
ifeq ($(UNAME), Darwin)
LIB= -lpthread MacMSRDriver/build/Release/libPcmMsr.dylib
CXXFLAGS += -I/usr/include -IMacMSRDriver -std=c++11
endif
ifeq ($(UNAME), FreeBSD)
CXX=c++
LIB= -lpthread -lc++
CXXFLAGS += -std=c++11
endif
COMMON_OBJS = msr.o cpucounters.o pci.o client_bw.o utils.o
EXE_OBJS = $(EXE:.x=.o)
OBJS = $(COMMON_OBJS) $(EXE_OBJS)
# ensure 'make' does not delete the intermediate .o files
.PRECIOUS: $(OBJS)
-include $(OBJS:.o=.d)
libPCM.a: $(OBJS)
ar -rcs $@ $^
%.x: %.o $(COMMON_OBJS)
$(CXX) -o $@ $^ $(LIB)
%.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
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
clean:
rm -rf *.x *.o *~ *.d