-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
437 lines (392 loc) · 14.2 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
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
rsync ?= yes
ifeq ($(rsync),yes)
cp = rsync -u
else
cp = cp -u
endif
ifeq ($(debug),1)
debug_specific_cflags = -g -O0
debug_csharp = /define:DEBUG /debug+
build_dir = Debug
openhome_configuration = Debug
android_ndk_debug = 1
else
debug_specific_cflags = -g -O2
debug_csharp = /optimize+ /debug:pdbonly
build_dir = Release
openhome_configuration = Release
android_ndk_debug=0
endif
# Figure out platform, openhome_system and openhome_architecture
gcc_machine = $(shell ${CROSS_COMPILE}gcc -dumpmachine)
MACHINE = $(shell uname -s)
$(info CROSS_COMPILE: ${CROSS_COMPILE})
$(info Machine reported by compiler is: ${gcc_machine})
$(info Machine reported by uname is: ${MACHINE})
ifeq ($(MACHINE),Darwin)
ifeq ($(iOs-armv7),1)
platform = iOS
detected_openhome_system = iOs
detected_openhome_architecture = armv7
else ifeq ($(iOs-arm64),1)
platform = iOS
detected_openhome_system = iOs
detected_openhome_architecture = arm64
else ifeq ($(iOs-x86),1)
platform = iOS
detected_openhome_system = iOs
detected_openhome_architecture = x86
else
platform = IntelMac
detected_openhome_system = Mac
ifeq ($(mac-64),1)
detected_openhome_architecture = x64
else
detected_openhome_architecture = x86
endif
endif
else ifneq (, $(findstring powerpc, $(gcc_machine)))
platform = Linux-ppc32
detected_openhome_system = Linux
detected_openhome_architecture = ppc32
else ifeq ($(Android-anycpu), 1)
platform = Android
detected_openhome_system = Android
detected_openhome_architecture = anycpu
else
# At present, platform == Vanilla is used for Kirkwood, x86 and x64 Posix builds.
platform ?= Vanilla
ifeq ($(Qnap-anycpu), 1)
detected_openhome_system = Qnap
else ifneq (,$(findstring linux,$(gcc_machine)))
detected_openhome_system = Linux
endif
ifeq ($(gcc_machine),arm-none-linux-gnueabi)
detected_openhome_architecture = armel
endif
ifeq ($(gcc_machine),arm-linux-gnueabi)
detected_openhome_architecture = armel
endif
ifeq ($(gcc_machine),arm-linux-gnueabihf)
detected_openhome_architecture = armhf
endif
ifneq (,$(findstring i686,$(gcc_machine)))
detected_openhome_architecture = x86
endif
ifneq (,$(findstring i586,$(gcc_machine)))
detected_openhome_architecture = x86
endif
ifneq (,$(findstring i486,$(gcc_machine)))
detected_openhome_architecture = x86
endif
ifneq (,$(findstring i386,$(gcc_machine)))
detected_openhome_architecture = x86
endif
ifneq (,$(findstring amd64,$(gcc_machine)))
detected_openhome_architecture = x64
endif
ifneq (,$(findstring x86_64,$(gcc_machine)))
detected_openhome_architecture = x64
endif
endif
detected_openhome_system ?= Unknown
detected_openhome_architecture ?= Unknown
ifneq (${openhome_system},)
ifneq (${openhome_system},${detected_openhome_system})
$(warning Detected compiler is for system ${detected_openhome_system} but expected ${openhome_system}. Build will probably fail.)
endif
endif
ifneq (${openhome_architecture},)
ifneq (${openhome_architecture},${detected_openhome_architecture})
$(warning Detected compiler is for architecture ${detected_openhome_architecture} but expected ${openhome_architecture}. Build will probably fail.)
endif
endif
openhome_system = ${detected_openhome_system}
openhome_architecture = ${detected_openhome_architecture}
ifeq ($(platform),Android)
osbuilddir = $(platform)-$(detected_openhome_architecture)
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/
android_build_dir = OpenHome/Net/Bindings/Android/libs/
managed_only = yes
endif
ifeq ($(platform),iOS)
nocpp11=yes
linkopts_ohNet =
platform_prefix=iPhoneOS
platform_compiler=arm-apple-darwin10
platform_arch=$(detected_openhome_architecture)
ifeq ($(detected_openhome_architecture),x86)
platform_prefix=iPhoneSimulator
platform_compiler=i686-apple-darwin10
platform_arch=i386
endif
devroot=/Applications/Xcode.app/Contents/Developer
toolroot=$(devroot)/Toolchains/XcodeDefault.xctoolchain/usr/bin
sdkroot=$(devroot)/Platforms/$(platform_prefix).platform/Developer/SDKs/$(platform_prefix).sdk
platform_cflags = -I$(sdkroot)/usr/include/ -miphoneos-version-min=2.2 -pipe -no-cpp-precomp -isysroot $(sdkroot) -DPLATFORM_MACOSX_GNU -DPLATFORM_IOS
# TODO: Support armv6 for old devices
osbuilddir = $(platform)-$(detected_openhome_architecture)
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/
platform_linkflags = -L$(sdkroot)/usr/lib/ -arch $(platform_arch) -L$(sdkroot)/usr/lib/system
compiler = $(toolroot)/clang -arch $(platform_arch) -isysroot $(sdkroot) -o $(objdir)
# No support for linking Shared Objects for ARM MAC
# link = $(devroot)/usr/bin/llvm-gcc-4.2 -pthread -Wl $(platform_linkflags)
ar = $(toolroot)/ar rc $(objdir)
mono_lib_dir=/Developer/MonoTouch/usr/lib/mono/Xamarin.iOS
csharpdefines = /define:IOS /r:$(mono_lib_dir)/Xamarin.iOS.dll /r:$(mono_lib_dir)/System.dll /r:$(mono_lib_dir)/System.Core.dll
no_shared_objects = yes
endif
ifeq ($(platform),IntelMac)
# Darwin, not ARM -> Intel Mac
platform ?= IntelMac
linkopts_ohNet = -Wl,-install_name,@loader_path/libohNet.dylib
ifeq ($(mac-64),1)
platform_cflags = -DPLATFORM_MACOSX_GNU -arch x86_64 -mmacosx-version-min=10.7
platform_linkflags = -arch x86_64 -framework CoreFoundation -framework SystemConfiguration
osbuilddir = Mac-x64
openhome_architecture = x64
else
platform_cflags = -DPLATFORM_MACOSX_GNU -m32 -mmacosx-version-min=10.7
platform_linkflags = -m32 -framework CoreFoundation -framework SystemConfiguration
osbuilddir = Mac-x86
openhome_architecture = x86
endif
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/
compiler = clang -fPIC -stdlib=libc++ -o $(objdir)
link = clang++ -pthread -stdlib=libc++ $(platform_linkflags)
ar = ar rc $(objdir)
openhome_system = Mac
endif
ifneq (,$(findstring $(platform),Vanilla Linux-ppc32))
ifeq ($(gcc4_1), yes)
version_specific_cflags = ${CROSS_COMPILE_CFLAGS}
version_specific_cflags_third_party = -Wno-non-virtual-dtor
version_specific_java_cflags = -Wstrict-aliasing=0
else
gcc_min_ver = $(shell ${CROSS_COMPILE}gcc -dumpversion | cut -f2 -d'.')
version_specific_cflags = $(shell if [ $(gcc_min_ver) -ge 6 ]; then echo '-Wno-psabi'; fi)
version_specific_cflags += ${CROSS_COMPILE_CFLAGS}
version_specific_cflags_third_party =
version_specific_java_cflags =
endif
version_specific_linkflags = ${CROSS_COMPILE_LINKFLAGS}
version_specific_library_path = ${CROSS_COMPILE_LIBRARY_PATH}
version_specific_includes = ${CROSS_COMPILE_INCLUDES}
# Continuing with the non-Darwin settings...
objdir = Build/Obj/$(osdir)/$(build_dir)/
compiler = ${CROSS_COMPILE}gcc -o $(objdir)
link = $(version_specific_library_path) ${CROSS_COMPILE}g++ $(platform_linkflags)
ar = $(version_specific_library_path) ${CROSS_COMPILE}ar rc $(objdir)
endif
ifeq ($(platform), Core-ppc32)
# platform == Core1
openhome_system = Core
openhome_architecture = ppc32
endian = BIG
platform_cflags = -mcpu=403
platform_linkflags = -mcpu=403 ${CROSS_LINKFLAGS}
linkopts_ohNet =
osdir = Core
osbuilddir = Core-ppc32
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/
native_only = yes
compiler = ${CROSS_COMPILE}gcc -o $(objdir)
link = ${CROSS_COMPILE}g++ $(platform_linkflags)
ar = ${CROSS_COMPILE}ar rc $(objdir)
endif
ifeq ($(platform), Core-armv5)
# platform == Core2
openhome_system = Core
openhome_architecture = armv5
endian = LITTLE
platform_cflags = -mcpu=arm926ej-s -Wno-psabi -fexceptions -marm -mapcs -fno-omit-frame-pointer
platform_linkflags = -mcpu=arm926ej-s ${CROSS_LINKFLAGS}
linkopts_ohNet =
osdir = Core
osbuilddir = Core-armv5
objdir = Build/Obj/$(osbuilddir)/$(build_dir)/
native_only = yes
compiler = ${CROSS_COMPILE}gcc -o $(objdir)
link = ${CROSS_COMPILE}g++ $(platform_linkflags)
ar = ${CROSS_COMPILE}ar rc $(objdir)
endif
ifeq ($(platform), Linux-ppc32)
# platform == Linux-ppc32
endian = BIG
platform_cflags = $(version_specific_cflags) -fPIC
platform_linkflags = $(version_specific_linkflags) -pthread
linkopts_ohNet = -Wl,-soname,libohNet.so
osbuilddir = Posix
osdir = Posix
endif
ifeq ($(platform), Vanilla)
# platform == Vanilla (i.e. Kirkwood, x86 or x64)
platform_cflags = $(version_specific_cflags) -fPIC
platform_linkflags = $(version_specific_linkflags) -pthread
linkopts_ohNet = -Wl,-soname,libohNet.so
osbuilddir = Posix
osdir = Posix
endian ?= LITTLE
ifeq ($(Qnap-anycpu), 1)
openhome_system = Qnap
else
openhome_system = Linux
endif
endif
$(info Building for system ${openhome_system} and architecture ${openhome_architecture})
# Macros used by Common.mak
native_only ?= no
managed_only ?= no
no_shared_objects ?= no
endian ?= LITTLE
cflags_base = -fexceptions -Wall $(version_specific_cflags_third_party) -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_$(endian)_ENDIAN -DDEFINE_TRACE $(debug_specific_cflags) -fvisibility=hidden $(platform_cflags)
cflags_third_party = $(cflags_base) -Wno-int-to-pointer-cast
ifeq ($(nocpp11), yes)
cppflags = $(cflags_base) -Werror
else ifeq ($(platform),IntelMac)
cppflags = $(cflags_base) -std=c++11 -Werror
else
cppflags = $(cflags_base) -std=c++0x -D__STDC_VERSION__=199901L -Werror
endif
cflags = $(cflags_base) -Werror
depsPlatform = ${openhome_system}-${openhome_architecture}
header_install = Build/Include
inc_build = dependencies/$(depsPlatform)/ohNet-$(depsPlatform)-Release/include/ohnet
includes = -I$(inc_build)/ $(version_specific_includes)
bundle_build = Build/Bundles
osdir ?= Posix
objext = o
libprefix = lib
libext = a
sharedlibprefix = lib
ifeq ($(MACHINE), Darwin)
sharedlibext = dylib
dllext = dylib
else
sharedlibext = so
dllext = so
endif
exeext = elf
linkoutput = -o
dllprefix = lib
ifeq ($(MACHINE), Darwin)
link_dll = $(version_specific_library_path) clang++ -pthread $(platform_linkflags) -shared -stdlib=libc++
else
link_dll = $(version_specific_library_path) ${CROSS_COMPILE}g++ -pthread $(platform_linkflags) -shared -shared-libgcc
endif
ifeq ($(platform), iOS)
csharp = /Developer/MonoTouch/usr/bin/smcs /nologo $(debug_csharp)
else
csharp = mcs /nologo $(debug_csharp)
endif
csharpdefines ?=
publicjavadir = OpenHome/Net/Bindings/Java/
ifeq ($(platform), IntelMac)
includes_jni = -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/include/malloc
link_jvm = /System/Library/Frameworks/JavaVM.framework/JavaVM
javac = /usr/bin/javac
jar = /usr/bin/jar
else
includes_jni = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
ifeq ($(platform), Linux-ppc32)
libjvm_dir ?= $(JAVA_HOME)/jre/lib/ppc/server
else
ifneq (,$(findstring arm,$(gcc_machine)))
libjvm_dir ?= $(JAVA_HOME)/jre/lib/arm/server
else
libjvm_dir ?= $(JAVA_HOME)/jre/lib/i386/server
endif
endif
link_jvm = $(libjvm_dir)/libjvm.so
javac = $(JAVA_HOME)/bin/javac
jar = $(JAVA_HOME)/bin/jar
endif
java_cflags = -fexceptions -Wall $(version_specific_java_cflags) -Werror -pipe -D_GNU_SOURCE -D_REENTRANT -DDEFINE_$(endian)_ENDIAN -DDEFINE_TRACE $(debug_specific_cflags) $(platform_cflags)
jarflags = cf
dirsep = /
prefix = /usr/local
installlibdir = $(prefix)/lib/ohNet
installincludedir = $(prefix)/include/ohNet
installpkgconfdir = $(prefix)/lib/pkgconfig
mkdir = mkdir -p
rmdir = rm -rf
uset4 = no
ifeq ($(Android-anycpu), 1)
build_targets_base = make_obj_dir CpProxyJavaClasses DvDeviceJavaClasses CpProxyDotNetAssemblies DvDeviceDotNetAssemblies
else
ifeq ($(managed_only), yes)
build_targets_base = make_obj_dir CpProxyDotNetAssemblies DvDeviceDotNetAssemblies
else
ifeq ($(native_only), yes)
build_targets_base = $(native_targets)
else
build_targets_base = $(all_targets)
endif
endif
endif
ifeq ($(uset4), yes)
build_targets = $(build_targets_base) tt
else
build_targets = $(build_targets_base)
endif
default : all
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
# Include the rules to prepare the template engine and the macros to use it.
ifeq ($(uset4), yes)
include T4Linux.mak
endif
# Actual building of code is shared between platforms
include Common.mak
# Include the generated makefiles. Because nmake on Windows requires contortions to
# include such files and handle their non-existance, these includes have to be at
# the platform-specific level.
ifeq ($(uset4),yes)
include Generated/GenerateSourceFiles.mak
endif
include Generated/Proxies.mak
include Generated/Devices.mak
endif
include UserTargets.mak
# Following macros must be provided by each file which wraps Common.mak
make_obj_dir:
$(mkdir) $(objdir)
copy_build_includes:
$(mkdir) $(header_install)
$(mkdir) $(header_install)/OpenHome
$(mkdir) $(header_install)/OpenHome/Net
$(mkdir) $(header_install)/OpenHome/Net/Core
$(mkdir) $(header_install)/OpenHome/Net/C
$(mkdir) $(header_install)/OpenHome/Net/Cpp
$(cp) OpenHome/Net/ControlPoint/Proxies/*.h $(header_install)/OpenHome/Net/Core
$(cp) OpenHome/Net/Device/Providers/*.h $(header_install)/OpenHome/Net/Core
$(cp) OpenHome/Net/Bindings/C/ControlPoint/Proxies/*.h $(header_install)/OpenHome/Net/C
$(cp) OpenHome/Net/Bindings/C/Device/Providers/*.h $(header_install)/OpenHome/Net/C
$(cp) OpenHome/Net/Bindings/Cpp/ControlPoint/Proxies/*.h $(header_install)/OpenHome/Net/Cpp
$(cp) OpenHome/Net/Bindings/Cpp/Device/Providers/*.h $(header_install)/OpenHome/Net/Cpp
java_packages = ohnet \
openhome.net.controlpoint \
openhome.net.controlpoint.proxies \
openhome.net.core \
org.openhome.net.device \
org.openhome.net.test \
docs:
rm -rf Build/Docs
$(mkdir) Build/Docs
$(mkdir) Build/Docs/C
doxygen DoxyfileC
$(mkdir) Build/Docs/CppCore
doxygen DoxyfileCppCore
$(mkdir) Build/Docs/CppStd
doxygen DoxyfileCppStd
$(mkdir) Build/Docs/Cs
doxygen DoxyfileCs
$(mkdir) Build/Docs/Java
doxygen DoxyfileJava
$(mkdir) Build/Docs/Js
perl ./JsDoc/jsdoc.pl -d Build/Docs/Js OpenHome/Net/Bindings/Js/ControlPoint OpenHome/Net/Bindings/Js/ControlPoint/Proxies
bundle-after-build: $(build_targets)
$(mkdir) $(bundle_build)
python bundle_binaries.py --system $(openhome_system) --architecture $(openhome_architecture) --configuration $(openhome_configuration)
bundle:
$(mkdir) $(bundle_build)
python bundle_binaries.py --system $(openhome_system) --architecture $(openhome_architecture) --configuration $(openhome_configuration)