-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
196 lines (159 loc) · 6.05 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Packages needed to build:
# - libuuid
# - libuuid-devel
# - mingw32-gcc
# - mingw32-pthreads (if pthread is missing in mingw32 dist)
# - mingw32-pthreads-static (if you want static pthread)
# These are optional for WIN64 build:
# - mingw64-gcc
# - mingw64-pthreads
# - mingw64-pthreads-static
#
# Packages needed for XML output:
# - libxml2
# - libxml2-devel
# - mingw32-libxml2 (below for windows 32/64 builds)
# - mingw32-win-iconv
# - mingw64-libxml2
# - mingw64-win-iconv
#
# Packages needed for libnuma support:
# - numactl-devel
# 32/64 cross-platform compilation tip:
# gcc supports multilib which means -m32/-m64 option pretty much
# takes care of 32/64bit code generation. All you need is to place
# needed 32/64 bit libraries in place as follows:
# - libxml2-devel.i686
# - libuuid.i686
# - libuuid-devel.i686
# - libgcc.i686
# - glibc-devel.i686
CC := gcc
ifndef march
march=64
#march=32
endif
# Windows cross-platform compilation
# Choose your mingw32 compiler name!
ifeq ($(strip $(march)), 32)
#MINGW_PREFIX :=i686-pc-mingw32
MINGW_PREFIX :=i686-w64-mingw32
else
MINGW_PREFIX :=x86_64-w64-mingw32
endif
# Use pthreadGC2 for older mingw32
WINPTHREAD_NAME=libwinpthread-1.dll
#WINPTHREAD_NAME=pthreadGC2.dll
WCC := $(MINGW_PREFIX)-gcc
CFLAGS := -g -O2 -Wall
# define PMB_THREAD for threaded benchmark
# flags for Linux
CFLAGS_LINUX :=
LFLAGS_LINUX :=
ifeq ($(strip $(march)), 32)
CFLAGS_LINUX += -m32
LFLAGS_LINUX += -m32
else
CFLAGS_LINUX += -m64
LFLAGS_LINUX += -m64
endif
#LFLAGS_LINUX += -Wl,--section-start=.pmbench_code_page=408000
# uncomment below to compile-in multi-threaded benchmark
CFLAGS_LINUX += -DPMB_THREAD=1 -pthread
LFLAGS_LINUX += -pthread
# uncomment below to compile-in numa affinityset. Requires threading.
#CFLAGS_LINUX += -DPMB_NUMA=1
#LFLAGS_LINUX += -lnuma
# uncomment below to add XALLOC
#CFLAGS_LINUX += -DXALLOC -I../xalloc
#LFLAGS_LINUX += ../xalloc/libxalloc.a
SRCPATH_WINARGP := ../argpwin
INCPATH_WINARGP := ../argpwin
LIBPATH_WINARGP := ../argpwin
#this is to Windows XP and after
CFLAGS_WIN := -D_WIN32_WINNT=0x0501 -I$(INCPATH_WINARGP)
LFLAGS_WIN := -lrpcrt4 -L$(LIBPATH_WINARGP)
# uncomment below to compile-in multi-threaded benchmark
CFLAGS_WIN += -DPMB_THREAD=1 -lpthread
LFLAGS_WIN += -lpthread
# uncomment below to add XALLOC
#CFLAGS_WIN += -DXALLOC -I../xalloc
#LFLAGS_WIN += ../xalloc/xalloc.dll
#-save-temps
LFLAGS_WIN += $(LIBPATH_WINARGP)/argp.dll
# libxml2
CFLAGS_WIN += -DPMB_XML=1 -I/usr/include/libxml2
CFLAGS_LINUX += -DPMB_XML=1 -I/usr/include/libxml2
LXML := -lxml2
.PHONY: all clean dist dist_src dist_bin dist_bin32 dist_bin64 dist_doc check help
all: pmbench pmbench.exe
pmbench: pmbench.o pattern.o system.o access.o xmlgen.o
$(CC) $+ -lm -luuid $(LXML) -o $@ $(LFLAGS_LINUX)
objdump -d $@ > [email protected]
check:
@sym=`readelf -S -W pmbench |grep .pmbench_code_page`;\
set -- junk $$sym;shift;\
echo "pmbench_code_page section size:0x$$6"
objdump -j .pmbench_code_page -t pmbench
clean:
@rm -f pmbench pmbench.exe *.o *.obj *.dmp *.i *.s .depend
help:
@echo "make [all|clean|dist|dist_src|check|help]"
@echo " all - make pmbench and pmbench.exe only. requires argp.dll"
@echo " clean - clean intermediate files"
@echo " dist - distributable binaries under ./dist_staging"
@echo " dist_src - distributable sources under ./dist_staging"
@echo " check - report binary section information"
@echo " help - print this help"
DISTDIR := dist_staging
dist: dist_bin dist_doc
dist_bin:
$(MAKE) -C $(SRCPATH_WINARGP) clean;
export march=64;$(MAKE) -C $(SRCPATH_WINARGP)
$(MAKE) clean
export march=64;$(MAKE) dist_bin64
$(MAKE) -C $(SRCPATH_WINARGP) clean;
export march=32;$(MAKE) -C $(SRCPATH_WINARGP)
$(MAKE) clean
export march=32;$(MAKE) dist_bin32
ifeq ($(strip $(MAKELEVEL)), 1)
dist_bin32: pmbench pmbench.exe
install -D ./pmbench $(DISTDIR)/bin/linux/i686/pmbench
install -D ./pmbench.exe $(DISTDIR)/bin/windows/win32/pmbench.exe
install -m664 -D $(LIBPATH_WINARGP)/argp.dll $(DISTDIR)/bin/windows/win32/dll/argp.dll
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/$(WINPTHREAD_NAME) $(DISTDIR)/bin/windows/win32/dll/$(WINPTHREAD_NAME)
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/libgcc_s_sjlj-1.dll $(DISTDIR)/bin/windows/win32/dll/libgcc_s_sjlj-1.dll
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/libxml2-2.dll $(DISTDIR)/bin/windows/win32/dll/libxml2-2.dll
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/iconv.dll $(DISTDIR)/bin/windows/win32/dll/iconv.dll
dist_bin64: pmbench pmbench.exe
install -D ./pmbench $(DISTDIR)/bin/linux/x86_64/pmbench
install -D ./pmbench.exe $(DISTDIR)/bin/windows/win64/pmbench.exe
install -m664 -D $(LIBPATH_WINARGP)/argp.dll $(DISTDIR)/bin/windows/win64/dll/argp.dll
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/$(WINPTHREAD_NAME) $(DISTDIR)/bin/windows/win64/dll/$(WINPTHREAD_NAME)
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/libxml2-2.dll $(DISTDIR)/bin/windows/win64/dll/libxml2-2.dll
install -m664 -D /usr/$(MINGW_PREFIX)/sys-root/mingw/bin/iconv.dll $(DISTDIR)/bin/windows/win64/dll/iconv.dll
endif
dist_doc:
install -m664 -D ./doc/pmbench.1 $(DISTDIR)/man/pmbench.1
install -m664 -t $(DISTDIR) ./doc/README ./doc/license-*.txt
dist_src:
install -d $(DISTDIR)/src/pmbench
install -m664 -t $(DISTDIR)/src/pmbench *.[ch]
install -m664 -t $(DISTDIR)/src/pmbench Makefile
rm -f $(DISTDIR)/src/pmbench/pendingreview.c
install -d $(DISTDIR)/src/pmbench/doc
install -m664 -t $(DISTDIR)/src/pmbench/doc ./doc/README ./doc/license-*.txt ./doc/pmbench.1
install -d $(DISTDIR)/src/argpwin
install -m664 -t $(DISTDIR)/src/argpwin $(SRCPATH_WINARGP)/*.[ch]
install -m664 -t $(DISTDIR)/src/argpwin $(SRCPATH_WINARGP)/Makefile
.SUFFIXES: .c .o .obj .dmp
%.o: %.c
$(CC) -c $(CFLAGS) $(CFLAGS_LINUX) -o $@ $<
pmbench.exe: pmbench.obj pattern.obj system.obj access.obj xmlgen.obj
$(WCC) $+ -lm -lrpcrt4 $(LXML) -o $@ $(LFLAGS_WIN)
objdump -d $@ > [email protected]
%.obj: %.c
$(WCC) -c $(CFLAGS) $(CFLAGS_WIN) -o $@ $< $(LXML)
.depend: pmbench.c pattern.c system.c access.c xmlgen.c
@gcc -MM $(CFLAGS) $^ > $@
-include .depend