forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.mingw
280 lines (240 loc) · 7.58 KB
/
Makefile.mingw
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# Makefile for building BOINC with MinGW (gcc and gnumake)
# if you want to use install/uninstall targets, set this to the prefix
BOINC_PREFIX ?= /usr/local
# set this for the BOINC sourc directory. This default should work for calling from within lib/ or api/
BOINC_SRC ?= ..
# if MINGW is set, define all used tools based on that
ifdef MINGW
CC = $(MINGW)-gcc
CXX = $(MINGW)-g++
AR = $(MINGW)-ar
RANLIB = $(MINGW)-ranlib
endif
# headers to install
HEADERS = $(BOINC_SRC)/version.h \
$(BOINC_SRC)/api/boinc_api.h \
$(BOINC_SRC)/api/boinc_opencl.h \
$(BOINC_SRC)/api/graphics2.h \
$(BOINC_SRC)/lib/app_ipc.h \
$(BOINC_SRC)/lib/boinc_win.h \
$(BOINC_SRC)/lib/url.h \
$(BOINC_SRC)/lib/common_defs.h \
$(BOINC_SRC)/lib/diagnostics.h \
$(BOINC_SRC)/lib/diagnostics_win.h \
$(BOINC_SRC)/lib/error_numbers.h \
$(BOINC_SRC)/lib/filesys.h \
$(BOINC_SRC)/lib/hostinfo.h \
$(BOINC_SRC)/lib/proxy_info.h \
$(BOINC_SRC)/lib/prefs.h \
$(BOINC_SRC)/lib/miofile.h \
$(BOINC_SRC)/lib/mfile.h \
$(BOINC_SRC)/lib/parse.h \
$(BOINC_SRC)/lib/util.h \
$(BOINC_SRC)/lib/coproc.h \
$(BOINC_SRC)/lib/cal_boinc.h \
$(BOINC_SRC)/lib/cl_boinc.h \
$(BOINC_SRC)/lib/opencl_boinc.h \
$(BOINC_SRC)/svn_version.h \
$(BOINC_SRC)/win_build/config.h \
$(BOINC_SRC)/lib/str_util.h \
$(BOINC_SRC)/lib/wslinfo.h
ZIP_HEADERS = zip/boinc_zip.h
# objects to compile
API_OBJ = boinc_api.o graphics2_util.o
API_LOBJ = boinc_api.lo graphics2_util.lo
OCL_OBJ = boinc_opencl.o
GPH_OBJ = graphics2.o graphics2_util.o
LIB_OBJ = app_ipc.o \
base64.o \
coproc.o \
diagnostics.o \
diagnostics_win.o \
filesys.o \
hostinfo.o \
md5.o \
md5_file.o \
mem_usage.o \
mfile.o \
miofile.o \
opencl_boinc.o \
procinfo_win.o \
procinfo.o \
proc_control.o \
parse.o \
prefs.o \
proxy_info.o \
str_util.o \
shmem.o \
stackwalker_win.o \
url.o \
util.o \
win_util.o \
wslinfo.o
ZIP_OBJ = zip/boinc_zip.o \
zip/api.o \
zip/apihelp.o \
zip/crc32.o \
zip/crypt.o \
zip/explode.o \
zip/extract.o \
zip/fileio.o \
zip/globals.o \
zip/inflate.o \
zip/list.o \
zip/match.o \
zip/nt.o \
zip/process.o \
zip/ttyio.o \
zip/unreduce.o \
zip/unshrink.o \
zip/unzip.o \
zip/zipinfo.o \
zip/deflate.o \
zip/trees.o \
zip/util.o \
zip/win32.o \
zip/win32_boinc.o \
zip/win32i64.o \
zip/win32zip.o \
zip/z_fileio.o \
zip/z_globals.o \
zip/z_nt.o \
zip/zip.o \
zip/zipfile.o \
zip/zipup.o
REGEXP_OBJS = \
regexp.o \
regsub.o \
regerror.o \
regexp_memory.o \
regexp_report.o
# libraries to build
API_BIN = libboinc_api.a
API_LIB = libboinc_api.la
OCL_BIN = libboinc_opencl.a
LIB_BIN = libboinc.a
GPH_BIN = libboinc_graphics2.a
ZIP_BIN = libboinc_zip.a
# all objects (for clean target)
OBJ = $(API_OBJ) $(API_LOBJ) $(OCL_OBJ) $(LIB_OBJ) $(GPH_OBJ) $(ZIP_OBJ)
# all libraries (zip not listed anymore)
BIN = $(OCL_BIN) $(LIB_BIN) $(GPH_BIN)
# -gstabs is necessary for MinGWs backtrace to work
#DEBUG = -D__DEBUG__ -gstabs -g3
DEBUG ?= -DNDEBUG
# where to find headers
INCS = -I"$(BOINC_SRC)" -I"$(BOINC_SRC)/db" -I"$(BOINC_SRC)/lib" -I"$(BOINC_SRC)/api" -I"$(BOINC_SRC)/zip" -I"$(BOINC_SRC)/win_build"
OPTFLAGS = -O3
# various cpp & gcc flags (for both C and C++ mode)
# set NOCYGWIN=-mno-cygwin to build non-Cygwin Windows libs under Cygwin
# -D_WIN32_WINDOWS=0x0410 sets to use Win98 API
WINVERFLAGS = -D_WINDOWS -D_WIN32 -DWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_MT
HAVEFLAGS = -DHAVE_STRCASECMP
CCXXFLAGS = $(INCS) $(DEBUG) --include $(BOINC_SRC)/version.h -DEINSTEINATHOME_CROSS_BUILD -DMINGW_WIN32 \
$(HAVEFLAGS) $(WINVERFLAGS) -DBOINC \
-DNODB -D_CONSOLE -fexceptions $(OPTFLAGS) $(NOCYGWIN)
# flags for compiling boinc_zip
ZIP_VCPROJ_FLAGS = -DWIN32 -D_LIB -DDLL -D_CRT_SECURE_NO_WARNINGS -DNO_MKTEMP -DUSE_ZIPMAIN -DNO_CRYPT \
-DIZ_PWLEN=80 -DNO_ASM -DNO_UNICODE_SUPPORT -DNO_MBCS
ZIP_BOINC_RENAMES = \
-Dinflate=inflate_boinc \
-Ddeflate=deflate_boinc \
-Dget_crc_table=get_crc_table_boinc \
-Dlongest_match=longest_match_boinc \
-Dinflate_codes=inflate_codes_boinc
ZIP_FLAGS = $(ZIP_VCPROJ_FLAGS) $(ZIP_BOINC_RENAMES) -DUSE_MINGW_GLOBBING -DUSE_STRM_INPUT $(INCS) -O2 $(NOCYGWIN)
# LDFLAGS = -lwinmm
CFLAGS ?=
CFLAGS += $(CCXXFLAGS)
CXXFLAGS ?=
CXXFLAGS += $(CCXXFLAGS)
# default target
all: $(BIN) $(API_BIN)
all-la: $(BIN) $(API_LIB)
# zip target
.PHONY: boinc_zip
boinc_zip: $(ZIP_BIN)
# The MinGW 64Bit msvcrt library doesn't export __p___mb_cur_max(), so
# we need to hack our own in this case. However this is only needed for
# boinc_zip, which is compiled without Unicode/MBCS support, so a function
# that alway returns 2 (as max character length) should be more than safe.
# The source file is in zip/zip.
ZIP_MINGW64_FIX ?= $(if $(findstring x86_64-w64-mingw32,$(CXX)),zip/__p___mb_cur_max.o,)
.PHONY: wrapper
wrapper: wrapper.exe
wrapper.exe: wrapper.o $(REGEXP_OBJS) $(API_BIN) $(LIB_BIN) $(ZIP_BIN) $(ZIP_MINGW64_FIX)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ -lpsapi
# set to the target tools when cross-compiling
RANLIB ?= ranlib
LIBTOOL ?= $(BOINC_SRC)/libtool
# rules for the indivisual libraries
$(API_LIB): $(API_LOBJ)
$(LIBTOOL) --mode=link --tag=CXX $(CXX) -all-static $(DEBUG) $(LDFLAGS) -O -o $@ $(API_LOBJ) -lboinc -lpsapi -rpath $(BOINC_PREFIX)/lib
$(API_BIN): $(API_OBJ)
$(AR) rc $@ $^
$(OCL_BIN): $(OCL_OBJ)
$(AR) rc $@ $^
$(LIB_BIN): $(LIB_OBJ)
$(AR) rc $@ $^
$(GPH_BIN): $(GPH_OBJ)
$(AR) rc $@ $^
$(ZIP_BIN): zip $(ZIP_OBJ)
$(AR) rc $@ $(ZIP_OBJ)
# standard BOINC code - .C and .cpp versions
%.o: $(BOINC_SRC)/api/%.C
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.o: $(BOINC_SRC)/lib/%.C
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.o: $(BOINC_SRC)/api/%.cpp
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.o: $(BOINC_SRC)/lib/%.cpp
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
# libtool libboinc_api
%.lo: $(BOINC_SRC)/api/%.cpp
$(LIBTOOL) --mode=compile --tag=CXX $(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.lo: $(BOINC_SRC)/lib/%.cpp
$(LIBTOOL) --mode=compile --tag=CXX $(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
# for the wrapper
wrapper.o: $(BOINC_SRC)/samples/wrapper/wrapper.cpp
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
%.o: $(BOINC_SRC)/samples/wrapper/%.c
$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
# for boinc_zip. Don't change the order!
zip:
mkdir -p $@
zip/%.o: $(BOINC_SRC)/zip/%.cpp
$(CXX) -c $< -o $@ $(ZIP_FLAGS)
zip/%.o: $(BOINC_SRC)/zip/unzip/win32/%.c
$(CC) -c $< -o $@ $(ZIP_FLAGS)
zip/%.o: $(BOINC_SRC)/zip/unzip/%.c
$(CC) -c $< -o $@ $(ZIP_FLAGS)
zip/%.o: $(BOINC_SRC)/zip/zip/win32/%.c
$(CC) -c $< -o $@ $(ZIP_FLAGS)
zip/%.o: $(BOINC_SRC)/zip/zip/%.c
$(CC) -c $< -o $@ $(ZIP_FLAGS)
zip/z_util.o: $(BOINC_SRC)/zip/zip/util.c
$(CC) -c $< -o $@ $(ZIP_FLAGS)
$(BOINC_SRC)/svn_version.h:
cd $(BOINC_SRC) && sh ./generate_svn_version.sh
# additional targets
install: $(BIN) $(API_BIN) $(HEADERS)
mkdir -p $(BOINC_PREFIX)/include/boinc $(BOINC_PREFIX)/lib
cp $(HEADERS) $(BOINC_PREFIX)/include/boinc
$(RANLIB) $(BIN) $(API_BIN)
cp $(BIN) $(API_BIN) $(BOINC_PREFIX)/lib
install-la: $(BIN) $(API_LIB) $(HEADERS)
mkdir -p $(BOINC_PREFIX)/include/boinc $(BOINC_PREFIX)/lib
cp $(HEADERS) $(BOINC_PREFIX)/include/boinc
$(RANLIB) $(BIN)
cp $(BIN) $(BOINC_PREFIX)/lib
$(LIBTOOL) --mode=install cp $(API_LIB) $(BOINC_PREFIX)/lib
install-zip: $(ZIP_BIN) $(ZIP_HEADERS)
mkdir -p $(BOINC_PREFIX)/include/ $(BOINC_PREFIX)/lib
cp $(ZIP_HEADERS) $(BOINC_PREFIX)/include/
$(RANLIB) $(ZIP_BIN)
cp $(ZIP_BIN) $(BOINC_PREFIX)/lib
uninstall:
${RM} -rf $(BOINC_PREFIX)/include/boinc
( cd $(BOINC_PREFIX)/lib && $(RM) -f $(BIN) $(API_BIN) $(API_LIB) || exit 0 )
clean:
${RM} -rf *.o $(BIN) $(API_BIN) $(API_LIB) $(OCL_BIN) $(LIB_BIN) $(GPH_BIN) .libs $(ZIP_BIN) zip $(REGEXP_OBJS) wrapper.o wrapper.exe