-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile.global
783 lines (653 loc) · 35.2 KB
/
Makefile.global
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# PROJECT_NAME
# VERSION_MAJOR, VERSION_MINOR, VERSION_TWEAK (optional)
# PROJECT_VERSION
# LIBRARY_TARGETS
# EXECUTABLE_TARGETS
# APPLICATION_TARGETS
# TARGET_NAME_${target} for all targets
# HUMAN_READABLE_TARGET_NAME_${target} for all application targets
# PLATFORMS (optionally PLATFORMS_${target})
# CCFLAGS (optionally CCFLAGS_${target}, CCFLAGS_${configuration}, CCFLAGS_${platform}, CCFLAGS_${target}_${configuration}, CCFLAGS_${target}_${platform}, CCFLAGS_${configuration}_${platform}, CCFLAGS_${target}_${configuration}_${platform})
# LINKFLAGS (optionally LINKFLAGS_${target}, LINKFLAGS_${configuration}, LINKFLAGS_${platform}, LINKFLAGS_${target}_${configuration}, LINKFLAGS_${target}_${platform}, LINKFLAGS_${configuration}_${platform}, LINKFLAGS_${target}_${configuration}_${platform})
# PROJECT_LIBRARY_DEPENDENCIES_${target}
# STEM_LIBRARY_DEPENDENCIES (optionally STEM_LIBRARY_DEPENDENCIES_${target}, STEM_LIBRARY_DEPENDENCIES_${platform}, STEM_LIBRARY_DEPENDENCIES_${target}_${platform})
# THIRDPARTY_LIBRARY_DEPENDENCIES (optionally THIRDPARTY_LIBRARY_DEPENDENCIES_${target}, THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}, THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform})
# SOURCES_${target} (optional for unittest target)
# SOURCES_unittest_suites
# INCLUDES
# RESOURCES (optionally RESOURCES_${target}, RESOURCES_${platform}, RESOURCES_${target}_${platform})
# LINKFILES (optionally LINKFILES_${target}, LINKFILES_${platform}, LINKFILES_${target}_${platform})
# ANALYZER_EXCLUDE_SOURCES_${analyzer}
# CLANGFLAGS (optionally CLANGFLAGS_${target}, CLANGFLAGS_${platform}, CLANGFLAGS_${target}_${platform})
# SPLINTFLAGS (optionally SPLINTFLAGS_${target}, SPLINTFLAGS_${platform}, SPLINTFLAGS_${target}_${platform})
# DEPENDENCY_SED_COMMANDS
# PLIST_FILE_${target}_${platform} for macosx, iphonesimulator, and iphoneos platforms
# INSTALLED_TARGETS
UNAME = ${shell uname}
ifeq (${UNAME},Linux)
-include ~/.stem.defines
STEM_SHARED_DIR ?= /usr/local/stem
HOST_PLATFORM = linux
else ifeq (${UNAME},Darwin)
-include ~/.stem.defines
STEM_SHARED_DIR ?= /usr/local/stem
HOST_PLATFORM = macosx
else
STEM_SHARED_DIR ?= C:/stem
-include ${STEM_SHARED_DIR}/stem.defines
HOST_PLATFORM = windows
endif
define newline_and_tab
endef
TARGET_PLATFORMS_macosx ?= macosx iphonesimulator iphoneos
TARGET_PLATFORMS_linux ?= linux32 linux64
TARGET_PLATFORMS_windows ?= win32 win64
CODESIGN_IDENTITY ?= "iPhone Developer"
TARGETS = ${LIBRARY_TARGETS} ${EXECUTABLE_TARGETS} ${APPLICATION_TARGETS}
PLATFORMS ?= macosx iphonesimulator iphoneos linux32 linux64 win32 win64
PLATFORMS_library ?= ${filter ${PLATFORMS},macosx iphonesimulator iphoneos linux32 linux64 win32 win64}
PLATFORMS_unittest ?= ${filter ${PLATFORMS},macosx iphonesimulator linux32 linux64 win32 win64}
PLATFORMS_testharness ?= ${filter ${PLATFORMS},macosx iphonesimulator iphoneos linux32 linux64 win32 win64}
PLATFORMS_mainapp ?= ${filter ${PLATFORMS},macosx iphonesimulator iphoneos linux32 linux64 win32 win64}
TARGET_PLATFORMS = ${filter ${TARGET_PLATFORMS_${HOST_PLATFORM}},${PLATFORMS}}
TARGET_PLATFORMS_library ?= ${filter ${TARGET_PLATFORMS},${PLATFORMS_library}}
TARGET_PLATFORMS_unittest ?= ${filter ${TARGET_PLATFORMS},${PLATFORMS_unittest}}
TARGET_PLATFORMS_testharness ?= ${filter ${TARGET_PLATFORMS},${PLATFORMS_testharness}}
TARGET_PLATFORMS_mainapp ?= ${filter ${TARGET_PLATFORMS},${PLATFORMS_mainapp}}
ANALYZERS = splint clang
TARGET_NAME_library ?= libstem_${PROJECT_NAME}
TARGET_NAME_unittest ?= ${PROJECT_NAME}_unittest
TARGET_NAME_testharness ?= ${PROJECT_NAME}_testharness
TARGET_NAME_mainapp ?= ${PROJECT_NAME}
CONFIGURATIONS_library ?= debug profile release
CONFIGURATIONS_unittest ?= debug
CONFIGURATIONS_testharness ?= debug profile release
CONFIGURATIONS_mainapp ?= debug profile release
#Per-target analyzer settings
CLANGFLAGS_unittest ?= ${CCFLAGS_unittest}
SPLINTFLAGS_unittest ?= ${CCFLAGS_unittest}
#Per-configuration compile/link settings
CCFLAGS_debug ?= -g -DDEBUG
CCFLAGS_profile ?= -g -O3
CCFLAGS_release ?= -O3
#Per-platform compile/link settings
SDKROOT_macosx ?= ${shell xcrun --show-sdk-path}
MACOSX_VERSION_MIN ?= 10.6
CC_macosx_i386 ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find cc} -arch i386
CC_macosx_x86_64 ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find cc} -arch x86_64
AR_macosx ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find ar}
RANLIB_macosx ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find ranlib}
SPLINT_macosx ?= /usr/local/bin/splint
CLANG_macosx ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find clang}
STRIP_macosx_release ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find strip} -S $1
ARCHS_macosx ?= i386 x86_64
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_macosx += -isysroot ${SDKROOT_macosx} -mmacosx-version-min=${MACOSX_VERSION_MIN}
LINKFLAGS_macosx += -isysroot ${SDKROOT_macosx} -mmacosx-version-min=${MACOSX_VERSION_MIN}
endif
SDKROOT_iphonesimulator ?= ${shell xcrun --show-sdk-path --sdk iphonesimulator}
SDKROOT_iphonesimulator_unittest ?= ${SDKROOT_iphonesimulator}
IPHONEOS_TARGET_MIN ?= 7.1
CC_iphonesimulator_i386 ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find cc} -arch i386
AR_iphonesimulator ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find ar}
RANLIB_iphonesimulator ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find ranlib}
SPLINT_iphonesimulator ?= /usr/local/bin/splint
CLANG_iphonesimulator ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find clang}
STRIP_iphonesimulator_release ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find strip} -S $1
ARCHS_iphonesimulator ?= i386
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_iphonesimulator += -isysroot ${SDKROOT_iphonesimulator} -mios-simulator-version-min=${IPHONEOS_TARGET_MIN} -fobjc-abi-version=2 -fobjc-legacy-dispatch
LINKFLAGS_iphonesimulator += -isysroot ${SDKROOT_iphonesimulator} -mios-simulator-version-min=${IPHONEOS_TARGET_MIN} -Xlinker -objc_abi_version -Xlinker 2
endif
SDKROOT_iphoneos ?= ${shell xcrun --show-sdk-path --sdk iphoneos}
CC_iphoneos_armv7 ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find cc} -arch armv7
CC_iphoneos_arm64 ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find cc} -arch arm64
AR_iphoneos ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find ar}
RANLIB_iphoneos ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find ranlib}
SPLINT_iphoneos ?= /usr/local/bin/splint
CLANG_iphoneos ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find clang}
STRIP_iphoneos_release ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find strip} -S $1
ARCHS_iphoneos ?= armv7 arm64
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_iphoneos += -isysroot ${SDKROOT_iphoneos} -miphoneos-version-min=${IPHONEOS_TARGET_MIN} -fobjc-abi-version=2 -fobjc-legacy-dispatch
LINKFLAGS_iphoneos += -isysroot ${SDKROOT_iphoneos} -miphoneos-version-min=${IPHONEOS_TARGET_MIN} -Xlinker -objc_abi_version -Xlinker 2
endif
CC_linux32_i386 ?= /usr/bin/gcc
AR_linux32 ?= /usr/bin/ar
RANLIB_linux32 ?= /usr/bin/ranlib
SPLINT_linux32 ?= /usr/local/bin/splint
CLANG_linux32 ?= /usr/local/bin/clang
STRIP_linux32_release ?= /usr/bin/strip -S $1
ARCHS_linux32 ?= i386
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_linux32 += -m32
LINKFLAGS_linux32 += -m32 -Wl,-E
endif
CC_linux64_x86_64 ?= /usr/bin/gcc
AR_linux64 ?= /usr/bin/ar
RANLIB_linux64 ?= /usr/bin/ranlib
SPLINT_linux64 ?= /usr/local/bin/splint
CLANG_linux64 ?= /usr/local/bin/clang
STRIP_linux64_release ?= /usr/bin/strip -S $1
ARCHS_linux64 ?= x86_64
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_linux64 += -m64
LINKFLAGS_linux64 += -m64 -Wl,-E
endif
MINGW_W32_PATH ?= C:/MinGW
MINGW_W32_VERSION ?= 4.6.2
SPLINT_WIN_PATH ?= C:/splint-3.1.1/bin/splint.exe
CLANG_WIN_PATH ?= C:/llvm/bin/clang.exe
CC_win32_i386 ?= ${MINGW_W32_PATH}/bin/gcc.exe
AR_win32 ?= ${MINGW_W32_PATH}/bin/ar.exe
RANLIB_win32 ?= ${MINGW_W32_PATH}/bin/ranlib.exe
SPLINT_win32 ?= ${SPLINT_WIN_PATH}
CLANG_win32 ?= ${CLANG_WIN_PATH}
STRIP_win32_release ?= ${MINGW_W32_PATH}/bin/strip.exe -S $1
WINDRES_win32 ?= ${MINGW_W32_PATH}/bin/windres.exe
ARCHS_win32 ?= i386
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_win32 +=
LINKFLAGS_win32 +=
LINKFLAGS_unittest_win32 += -mconsole
endif
EXECUTABLE_SUFFIX_win32 = .exe
MINGW_W64_PATH ?= C:/MinGW-w64
MINGW_W64_VERSION ?= 4.7.0
CC_win64_x86_64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-gcc.exe
AR_win64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-ar.exe
RANLIB_win64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-ranlib.exe
SPLINT_win64 ?= ${SPLINT_WIN_PATH}
CLANG_win64 ?= ${CLANG_WIN_PATH}
STRIP_win64_release ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-strip.exe -S $1
WINDRES_win64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-windres.exe
ARCHS_win64 ?= x86_64
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS_win64 +=
LINKFLAGS_win64 +=
LINKFLAGS_unittest_win64 += -mconsole
endif
EXECUTABLE_SUFFIX_win64 = .exe
#General compile/link settings
DEFINE_CCFLAGS += -DVERSION_MAJOR=${VERSION_MAJOR}u -DVERSION_MINOR=${VERSION_MINOR}u -DVERSION_TWEAK=${VERSION_TWEAK}u
WARNING_CCFLAGS += -Wall -Wextra -Wno-unused-parameter -Werror
OTHER_CCFLAGS += -std=gnu99
ifeq ($(filter echo_info,${MAKECMDGOALS}),)
CCFLAGS += ${DEFINE_CCFLAGS} ${WARNING_CCFLAGS} ${OTHER_CCFLAGS}
endif
SOURCES_unittest += \
build/intermediate/TestList.c \
${SOURCES_unittest_suites}
#General analyzer settings
CLANGFLAGS_win32 += -I ${MINGW_W32_PATH}/include -I ${MINGW_W32_PATH}/lib/gcc/mingw32/${MINGW_W32_VERSION}/include
CLANGFLAGS_win64 += -I ${MINGW_W64_PATH}/include -I ${MINGW_W64_PATH}/lib/gcc/mingw32/${MINGW_W64_VERSION}/include
SPLINTFLAGS += -exportlocal
.PHONY: all
all: ${TARGETS} ${if ${filter unittest,${EXECUTABLE_TARGETS}},test} ${if ${INCLUDES},include}
#TestList.c is automatically generated from ${SOURCES_unittest_suites}. It is used by the unit test framework to determine which tests to run.
build/intermediate/TestList.c: build/intermediate/TestSuites.txt | build/intermediate
echo 'const char * UnitTest_suiteNameList[] = {${foreach file,${SOURCES_unittest_suites},"${basename ${notdir ${file}}}",} (void *) 0};' > $@
#TestSuites.txt tracks the state of ${SOURCES_unittest_suites} so that TestList.c can be updated if and only if ${SOURCES_unittest_suites} has changed. .PHONY is abused slightly to cause the target to be conditionally remade.
ifneq (${shell echo "${SOURCES_unittest_suites}" | cmp - build/intermediate/TestSuites.txt 2>&1},)
.PHONY: build/intermediate/TestSuites.txt
endif
build/intermediate/TestSuites.txt: | build/intermediate
echo "${SOURCES_unittest_suites}" > $@
build/intermediate/icon_win32.coff: resources/icon.ico resources/icon.rc
${WINDRES_win32} resources/icon.rc -o $@ -O coff
build/intermediate/icon_win64.coff: resources/icon.ico resources/icon.rc
${WINDRES_win64} resources/icon.rc -o $@ -O coff
define configuration_object_list_template #(target, configuration)
${foreach platform,${TARGET_PLATFORMS_$1}, \
${call platform_object_list_template,$1,$2,${platform}} \
}
endef
define platform_object_list_template #(target, configuration, platform)
${foreach arch,${ARCHS_$3}, \
${call arch_object_list_template,$1,$2,$3,${arch}} \
}
endef
define arch_object_list_template #(target, configuration, platform, arch)
${foreach source,${SOURCES_$1} ${SOURCES_$1_$3}, \
build/intermediate/$1-$2-$3-$4/${notdir ${basename ${source}}}.o \
}
endef
#Produces OBJECTS_${target}_${configuration} variables for each permutation of target and configuration in that target
${foreach target,${TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${eval OBJECTS_${target}_${configuration} = ${call configuration_object_list_template,${target},${configuration}}} \
} \
}
define create_directory_target_template #(dir)
ifneq (${UNAME},Linux)
.LOW_RESOLUTION_TIME: $1
endif
$1:
mkdir -p $1
endef
${foreach target,${TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval ${call create_directory_target_template,build/${target}/${configuration}-${platform}}} \
${foreach arch,${ARCHS_${platform}}, \
${eval ${call create_directory_target_template,build/intermediate/${target}-${configuration}-${platform}-${arch}}} \
} \
} \
} \
}
${eval ${call create_directory_target_template,build/intermediate}}
#ifeq ($(filter clean echo_info,${MAKECMDGOALS}),)
#${foreach target,${TARGETS}, \
# ${foreach platform,${TARGET_PLATFORMS_${target}}, \
# ${eval COMPUTED_STEM_LIBRARY_DEPENDENCIES_${target}_${platform} = ${shell ruby ${STEM_SHARED_DIR}/stemconfig.rb --add-dependencies --stem-only ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \
# ${eval COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform} = ${shell ruby ${STEM_SHARED_DIR}/stemconfig.rb --add-dependencies --thirdparty-only ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \
# ${eval COMPUTED_LINKFLAGS_${target}_${platform} = ${shell ruby ${STEM_SHARED_DIR}/stemconfig.rb --link-flags ${platform} ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \
# } \
#}
#endif
define include_ccflags_template #(target, platform)
-I source \
${foreach stem_dependency,${COMPUTED_STEM_LIBRARY_DEPENDENCIES_$1_$2},-I ${STEM_SHARED_DIR}/${stem_dependency}/include} \
${foreach thirdparty_dependency,${COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_$1_$2},-I ${STEM_SHARED_DIR}/${dir ${thirdparty_dependency}}include}
endef
define define_ccflags_template #(target, configuration, platform, arch)
-DSTEM_TARGET_$1 -DSTEM_CONFIGURATION_$2 -DSTEM_PLATFORM_$3 -DSTEM_ARCH_$4
endef
define dependency_template #(target, configuration, platform, arch, source_file)
ifneq (${PRINT_D_COMMANDS},1)
.SILENT: build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.d
endif
build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.d: $5 ${PREREQS} ${PREREQS_$1} | build/intermediate/$1-$2-$3-$4
${CC_$3_$4} ${CCFLAGS} ${CCFLAGS_$1} ${CCFLAGS_$2} ${CCFLAGS_$3} ${CCFLAGS_$1_$2} ${CCFLAGS_$1_$3} ${CCFLAGS_$2_$3} ${CCFLAGS_$1_$2_$3} ${call include_ccflags_template,$1,$3} ${call define_ccflags_template,$1,$2,$3,$4} -MM -o [email protected] $5
sed 's,\(${notdir ${basename $5}}\)\.o[ :]*,$${basename $$@}.o $${basename $$@}.d: ,g;${DEPENDENCY_SED_COMMANDS}' < [email protected] > $$@
endef
#Produces dependency build targets for all source files in each configuration/platform/arch
ifeq ($(filter clean echo_info analyze analyze_clang analyze_splint,${MAKECMDGOALS}),)
${foreach target,${TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${foreach arch,${ARCHS_${platform}}, \
${foreach source,${SOURCES_${target}} ${SOURCES_${target}_${platform}}, \
${eval ${call dependency_template,${target},${configuration},${platform},${arch},${source}}} \
${eval -include build/intermediate/${target}-${configuration}-${platform}-${arch}/${notdir ${basename ${source}}}.d} \
} \
} \
} \
} \
}
endif
define compile_template #(target, configuration, platform, arch, source_file)
build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.o: $5 ${PREREQS} ${PREREQS_$1} | build/intermediate/$1-$2-$3-$4
${CC_$3_$4} ${CCFLAGS} ${CCFLAGS_$1} ${CCFLAGS_$2} ${CCFLAGS_$3} ${CCFLAGS_$1_$2} ${CCFLAGS_$1_$3} ${CCFLAGS_$2_$3} ${CCFLAGS_$1_$2_$3} ${call include_ccflags_template,$1,$3} ${call define_ccflags_template,$1,$2,$3,$4} -c -o $$@ $5
endef
#Produces object build targets for all source files in each configuration/platform/arch
${foreach target,${TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${foreach arch,${ARCHS_${platform}}, \
${foreach source,${SOURCES_${target}} ${SOURCES_${target}_${platform}}, \
${eval ${call compile_template,${target},${configuration},${platform},${arch},${source}}} \
} \
} \
} \
} \
}
define library_template #(target, configuration, platform, arch, output_file)
build/intermediate/$1-$2-$3-$4/$5: ${call arch_object_list_template,$1,$2,$3,$4}
${AR_$3} rc $$@ $$^
${RANLIB_$3} $$@
endef
#Produces static library build targets for each arch/platform/target for library targets
${foreach target,${LIBRARY_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${foreach arch,${ARCHS_${platform}}, \
${eval ${call library_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}.a}} \
} \
} \
} \
}
define executable_template #(target, configuration, platform, arch, output_file, dependent_libraries)
build/intermediate/$1-$2-$3-$4/$5: ${call arch_object_list_template,$1,$2,$3,$4} $6 ${LINKFILES} ${LINKFILES_$1} ${LINKFILES_$3} ${LINKFILES_$1_$3}
${CC_$3_$4} -o $$@ $$^ ${LINKFLAGS} ${LINKFLAGS_$1} ${LINKFLAGS_$2} ${LINKFLAGS_$3} ${LINKFLAGS_$1_$2} ${LINKFLAGS_$1_$3} ${LINKFLAGS_$2_$3} ${LINKFLAGS_$1_$2_$3} ${foreach project_library,${PROJECT_LIBRARY_DEPENDENCIES_$1} ${PROJECT_LIBRARY_DEPENDENCIES_$1_$3},${LINKFLAGS_${project_library}} ${LINKFLAGS_${project_library}_$3}} ${COMPUTED_LINKFLAGS_$1_$3} ${LINKFILES} ${LINKFILES_$1} ${LINKFILES_$3} ${LINKFILES_$1_$3}
endef
#HACK: shell/% filtered out, since shell doesn't have anything to link and there's no mechanism for distinguishing between include-only and linked libraries
define library_dependency_template #(target, configuration, platform)
${foreach library,${filter ${link_library}%,${PROJECT_LIBRARY_DEPENDENCIES_$1} ${PROJECT_LIBRARY_DEPENDENCIES_$1_$3}}, \
build/${library}/$2-$3/${TARGET_NAME_${library}}.a \
} \
${foreach library,${filter-out shell/%,${COMPUTED_STEM_LIBRARY_DEPENDENCIES_$1_$3}}, \
${STEM_SHARED_DIR}/${library}/library/$2-$3/libstem_${word 1,${subst /, ,${library}}}.a \
} \
${foreach library,${COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_$1_$3}, \
${STEM_SHARED_DIR}/${dir ${library}}library/$3/${notdir ${library}} \
}
endef
#Produces executable build targets for each arch/platform/target for executable and application targets
${foreach target,${EXECUTABLE_TARGETS} ${APPLICATION_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${foreach arch,${ARCHS_${platform}}, \
${eval ${call executable_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}},${call library_dependency_template,${target},${configuration},${platform}}}} \
} \
} \
} \
}
define thin_binary_list_template #(target, configuration, platform, target_name)
${foreach arch,${ARCHS_$3}, \
build/intermediate/$1-$2-$3-${arch}/$4 \
}
endef
#Produces THIN_BINARIES_${target}_${configuration}_${platform} variables for each target/configuration/platform for library targets
${foreach target,${LIBRARY_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval THIN_BINARIES_${target}_${configuration}_${platform} = ${call thin_binary_list_template,${target},${configuration},${platform},${TARGET_NAME_${target}}.a}} \
} \
} \
}
#Produces THIN_BINARIES_${target}_${configuration}_${platform} variables for each target/configuration/platform for executable targets
${foreach target,${EXECUTABLE_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval THIN_BINARIES_${target}_${configuration}_${platform} = ${call thin_binary_list_template,${target},${configuration},${platform},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}}}} \
} \
} \
}
#Produces THIN_BINARIES_${target}_${configuration}_${platform} variables for each target/configuration/platform for application targets
${foreach target,${APPLICATION_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval THIN_BINARIES_${target}_${configuration}_${platform} = ${call thin_binary_list_template,${target},${configuration},${platform},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}}}} \
} \
} \
}
define assemble_library_macosx #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}.a: ${THIN_BINARIES_$1_$2_$3} | build/$1/$2-$3
lipo -create -output $$@ ${THIN_BINARIES_$1_$2_$3}
endef
define assemble_library_linux #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}.a: ${THIN_BINARIES_$1_$2_$3} | build/$1/$2-$3
cp ${THIN_BINARIES_$1_$2_$3} $$@
endef
define assemble_library_windows #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}.a: ${THIN_BINARIES_$1_$2_$3} | build/$1/$2-$3
cp ${THIN_BINARIES_$1_$2_$3} $$@
endef
#Produces final library build targets
${foreach target,${LIBRARY_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval ${call assemble_library_${HOST_PLATFORM},${target},${configuration},${platform}}} \
} \
} \
}
define copy_target_resources #(target, platform, resources_dir)
${if ${strip ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$2} ${RESOURCES_$1_$2}},mkdir -p $3,}
${foreach resource,${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$2} ${RESOURCES_$1_$2}, \
cp -r ${resource} $3${newline_and_tab} \
}
${if ${strip ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$2} ${RESOURCES_$1_$2}},find $3 -name .svn -print0 -or -name .DS_Store -print0 | xargs -0 rm -rf}
endef
define copy_target_dynamiclibs #(target, platform, dll_dir)
${foreach dynamiclib,${DYNAMICLIBS_$1} ${DYNAMICLIBS_$1_$2}, \
cp ${dynamiclib} $3${newline_and_tab} \
}
endef
define assemble_executable_macosx #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$3} ${RESOURCES_$1_$3} | build/$1/$2-$3
lipo -create -output $$@ ${THIN_BINARIES_$1_$2_$3}
${call STRIP_$3_$2,$$@}
${call copy_target_resources,$1,$3,$${dir $$@}}
${call copy_target_dynamiclibs,$1,$3,$${dir $$@}}
endef
define assemble_executable_linux #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$3} ${RESOURCES_$1_$3} | build/$1/$2-$3
cp ${THIN_BINARIES_$1_$2_$3} $$@
${call STRIP_$3_$2,$$@}
${call copy_target_resources,$1,$3,$${dir $$@}}
${call copy_target_dynamiclibs,$1,$3,$${dir $$@}}
endef
define assemble_executable_windows #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}.exe: ${THIN_BINARIES_$1_$2_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$3} ${RESOURCES_$1_$3} | build/$1/$2-$3
cp ${THIN_BINARIES_$1_$2_$3} $$@
${call STRIP_$3_$2,$$@}
${call copy_target_resources,$1,$3,$${dir $$@}}
${call copy_target_dynamiclibs,$1,$3,$${dir $$@}}
endef
#Produces final executable build targets
${foreach target,${EXECUTABLE_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval ${call assemble_executable_${HOST_PLATFORM},${target},${configuration},${platform}}} \
} \
} \
}
PLIST_PLATFORM_CASED_iphonesimulator = iPhoneSimulator
PLIST_PLATFORM_LOWER_iphonesimulator = iphonesimulator
PLIST_SDK_NAME_iphonesimulator = iphonesimulator${IPHONESIMULATOR_VERSION_MIN}
PLIST_PLATFORM_CASED_iphoneos = iPhoneOS
PLIST_PLATFORM_LOWER_iphoneos = iphoneos
PLIST_SDK_NAME_iphoneos = iphoneos${IPHONEOS_VERSION_MIN}
define create_app_bundle #(target, platform, executable_dir, plist_dir, resources_dir)
mkdir -p $3 $4 $5
sed -e "s/\$$$${PRODUCT_NAME}/${TARGET_NAME_$1}/g" \
-e "s/\$$$${HUMAN_READABLE_PRODUCT_NAME}/${HUMAN_READABLE_TARGET_NAME_$1}/g" \
-e "s/\$$$${VERSION}/${PROJECT_VERSION}/g" \
-e "s/\$$$${COPYRIGHT_YEAR}/"`date +%Y`"/g" \
-e "s/\$$$${BUILD_NUMBER}/0/g" \
-e "s/\$$$${PLATFORM_CASED}/${PLIST_PLATFORM_CASED_$2}/g" \
-e "s/\$$$${PLATFORM_LOWER}/${PLIST_PLATFORM_LOWER_$2}/g" \
-e "s/\$$$${SDK}/${PLIST_SDK_NAME_$2}/g" \
${PLIST_FILE_$1_$2} > $4/Info.plist
echo "APPL????" > $4/PkgInfo
${call copy_target_resources,$1,$2,$5}
endef
define assemble_application_macosx #(target, configuration)
build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/MacOS/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_macosx} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_macosx} ${RESOURCES_$1_macosx} | build/$1/$2-macosx
${call create_app_bundle,$1,macosx,build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/MacOS,build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents,build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/Resources}
lipo -create -output "$$@" ${THIN_BINARIES_$1_$2_macosx}
${call STRIP_macosx_$2,"$$@"}
endef
define assemble_application_iphonesimulator #(target, configuration)
build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_iphonesimulator} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_iphonesimulator} ${RESOURCES_$1_iphonesimulator} | build/$1/$2-iphonesimulator
${call create_app_bundle,$1,iphonesimulator,build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app,build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app,build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app}
lipo -create -output "$$@" ${THIN_BINARIES_$1_$2_iphonesimulator}
${call STRIP_iphonesimulator_$2,"$$@"}
endef
define assemble_application_iphoneos #(target, configuration)
build/$1/$2-iphoneos/${TARGET_NAME_$1}.app/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_iphoneos} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_iphoneos} ${RESOURCES_$1_iphoneos} | build/$1/$2-iphoneos
${call create_app_bundle,$1,iphoneos,build/$1/$2-iphoneos/${TARGET_NAME_$1}.app,build/$1/$2-iphoneos/${TARGET_NAME_$1}.app,build/$1/$2-iphoneos/${TARGET_NAME_$1}.app}
lipo -create -output "$$@" ${THIN_BINARIES_$1_$2_iphoneos}
${call STRIP_iphoneos_$2,"$$@"}
endef
define assemble_application_linux32 #(target, configuration)
build/$1/$2-linux32/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_linux32} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_linux32} ${RESOURCES_$1_linux32} | build/$1/$2-linux32
${call copy_target_resources,$1,linux32,build/$1/$2-linux32/Resources}
${call copy_target_dynamiclibs,$1,linux32,build/$1/$2-linux32}
cp ${THIN_BINARIES_$1_$2_linux32} "$$@"
${call STRIP_linux32_$2,"$$@"}
endef
define assemble_application_linux64 #(target, configuration)
build/$1/$2-linux64/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_linux64} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_linux64} ${RESOURCES_$1_linux64} | build/$1/$2-linux64
${call copy_target_resources,$1,linux64,build/$1/$2-linux64/Resources}
${call copy_target_dynamiclibs,$1,linux64,build/$1/$2-linux64}
cp ${THIN_BINARIES_$1_$2_linux64} "$$@"
${call STRIP_linux64_$2,"$$@"}
endef
define assemble_application_win32 #(target, configuration)
build/$1/$2-win32/${TARGET_NAME_$1}.exe: ${THIN_BINARIES_$1_$2_win32} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_win32} ${RESOURCES_$1_win32} | build/$1/$2-win32
${call copy_target_resources,$1,win32,build/$1/$2-win32/Resources}
${call copy_target_dynamiclibs,$1,win32,build/$1/$2-win32}
cp ${THIN_BINARIES_$1_$2_win32} "$$@"
${call STRIP_win32_$2,"$$@"}
endef
define assemble_application_win64 #(target, configuration)
build/$1/$2-win64/${TARGET_NAME_$1}.exe: ${THIN_BINARIES_$1_$2_win64} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_win64} ${RESOURCES_$1_win64} | build/$1/$2-win64
${call copy_target_resources,$1,win64,build/$1/$2-win64/Resources}
${call copy_target_dynamiclibs,$1,win64,build/$1/$2-win64}
cp ${THIN_BINARIES_$1_$2_win64} "$$@"
${call STRIP_win64_$2,"$$@"}
endef
#Produces final application build targets
${foreach target,${APPLICATION_TARGETS}, \
${foreach configuration,${CONFIGURATIONS_${target}}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval ${call assemble_application_${platform},${target},${configuration}}} \
} \
} \
}
define library_dependency_template #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}.a
endef
define executable_dependency_template #(target, configuration, platform)
build/$1/$2-$3/${TARGET_NAME_$1}${EXECUTABLE_SUFFIX_$3}
endef
define application_dependency_template #(target, configuration, platform)
build/$1/$2-$3/${call application_file_template_$3,$1}
endef
define application_file_template_macosx #(target)
$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/MacOS/${TARGET_NAME_$1}
endef
define application_file_template_iphonesimulator #(target)
${TARGET_NAME_$1}.app/${TARGET_NAME_$1}
endef
define application_file_template_iphoneos #(target)
${TARGET_NAME_$1}.app/${TARGET_NAME_$1}
endef
define application_file_template_linux32 #(target)
${TARGET_NAME_$1}
endef
define application_file_template_linux64 #(target)
${TARGET_NAME_$1}
endef
define application_file_template_win32 #(target)
${TARGET_NAME_$1}.exe
endef
define application_file_template_win64 #(target)
${TARGET_NAME_$1}.exe
endef
define target_template #(target, target_type)
.PHONY: $1
$1: ${foreach configuration,${CONFIGURATIONS_$1},${foreach platform,${TARGET_PLATFORMS_$1},${call $2_dependency_template,$1,${configuration},${platform}}}}
endef
${foreach target,${LIBRARY_TARGETS}, \
${eval ${call target_template,${target},library}} \
}
${foreach target,${EXECUTABLE_TARGETS}, \
${eval ${call target_template,${target},executable}} \
}
${foreach target,${APPLICATION_TARGETS}, \
${eval ${call target_template,${target},application}} \
}
.PHONY: test
test: ${foreach platform,${TARGET_PLATFORMS_unittest},run_unittests_${platform}}
.PHONY: run_unittests_macosx
run_unittests_macosx: unittest
./build/unittest/debug-macosx/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-macosx"
.PHONY: run_unittests_iphonesimulator
run_unittests_iphonesimulator: unittest
DYLD_ROOT_PATH=${SDKROOT_iphonesimulator_unittest} \
./build/unittest/debug-iphonesimulator/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-iphonesimulator"
.PHONY: run_unittests_linux32
run_unittests_linux32: unittest
./build/unittest/debug-linux32/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-linux32"
.PHONY: run_unittests_linux64
run_unittests_linux64: unittest
./build/unittest/debug-linux64/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-linux64"
.PHONY: run_unittests_win32
run_unittests_win32: unittest
./build/unittest/debug-win32/${TARGET_NAME_unittest}.exe "${CURDIR}/build/unittest/debug-win32"
.PHONY: run_unittests_win64
run_unittests_win64: unittest
./build/unittest/debug-win64/${TARGET_NAME_unittest}.exe "${CURDIR}/build/unittest/debug-win64"
define analyze_file_template_clang #(target, platform, file)
build/analyzer-results/clang-$1-$2/${basename ${notdir $3}}.txt: $3 ${PREREQS} ${PREREQS_$1} | build/analyzer-results/clang-$1-$2
${CLANG_$2} --analyze ${call include_ccflags_template,$1,$2} ${call define_ccflags_template,$1,analyze,$2,none} ${CLANGFLAGS} ${CLANGFLAGS_$1} ${CLANGFLAGS_$2} ${CLANGFLAGS_$1_$2} -o $${basename $$@}.plist $3 > $$@ 2>&1; true
@cat $$@
endef
define analyze_file_template_splint #(target, platform, file)
build/analyzer-results/splint-$1-$2/${basename ${notdir $3}}.txt: $3 ${PREREQS} ${PREREQS_$1} | build/analyzer-results/splint-$1-$2
${SPLINT_$2} ${call include_ccflags_template,$1,$2} ${call define_ccflags_template,$1,analyze,$2,none} ${SPLINTFLAGS} ${SPLINTFLAGS_$1} ${SPLINTFLAGS_$2} ${SPLINTFLAGS_$1_$2} $3 > $$@ 2>&1; true
@cat $$@
endef
define analyzed_sources_template #(analyzer, target, platform)
${sort ${filter-out ${ANALYZER_EXCLUDE_SOURCES_$1},${SOURCES_$2} ${SOURCES_$2_$3}}}
endef
define analyzer_output_template #(analyzer, target, platform)
${foreach file,${call analyzed_sources_template,$1,$2,$3}, \
build/analyzer-results/$1-$2-$3/${basename ${notdir ${file}}}.txt \
}
endef
define analyze_target_template #(analyzer, target, platform)
.PHONY: analyze_$1_$2_$3
analyze_$1_$2_$3: ${call analyzer_output_template,$1,$2,$3}
endef
define analyze_template #(analyzer)
.PHONY: analyze_$1
analyze_$1: ${foreach target,${TARGETS},${foreach platform,${TARGET_PLATFORMS_${target}},analyze_$1_${target}_${platform}}}
endef
${foreach analyzer,${ANALYZERS}, \
${eval ${call analyze_template,${analyzer}}} \
${foreach target,${TARGETS}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval ${call analyze_target_template,${analyzer},${target},${platform}}} \
${foreach file,${call analyzed_sources_template,${analyzer},${target},${platform}}, \
${eval ${call analyze_file_template_${analyzer},${target},${platform},${file}}} \
} \
} \
} \
}
${foreach analyzer,${ANALYZERS}, \
${foreach target,${TARGETS}, \
${foreach platform,${TARGET_PLATFORMS_${target}}, \
${eval ${call create_directory_target_template,build/analyzer-results/${analyzer}-${target}-${platform}}} \
} \
} \
}
.PHONY: analyze
analyze: ${foreach analyzer,${ANALYZERS},analyze_${analyzer}}
${foreach dir,${sort ${foreach include_file,${INCLUDES},build/include/${notdir ${patsubst %/,%,${dir ${include_file}}}}}}, \
${eval ${call create_directory_target_template,${dir}}} \
}
.PHONY: include
include: ${INCLUDES} | ${foreach include_file,${INCLUDES},build/include/${notdir ${patsubst %/,%,${dir ${include_file}}}}}
${foreach include_file,${INCLUDES}, \
cp ${include_file} build/include/${notdir ${patsubst %/,%,${dir ${include_file}}}}${newline_and_tab} \
}
.PHONY: clean
clean:
rm -rf build
IOS_SIM ?= ios-sim
define launch_target_iphonesimulator_template #(target)
.PHONY: launch_$1_iphonesimulator
launch_$1_iphonesimulator: $1
${IOS_SIM} launch "build/$1/debug-iphonesimulator/${TARGET_NAME_$1}.app" ${IOS_SIM_ARGS}
endef
define add_blob_header #(source_file, target_file)
ruby -e "contents = \"\"; File.open(\"$1\", \"r\") {|file| contents = file.read}; File.open(\"$2\", \"w\") {|file| file.write(\"\xFA\xDE\x71\x71\"); file.write([contents.length + 8].pack(\"N\")); file.write(contents)}"
endef
RESOURCE_RULES_PLIST ?= /Developer/Platforms/MacOSX.platform/ResourceRules.plist
define codesign_target_iphoneos_template #(target)
.PHONY: codesign_$1_iphoneos
codesign_$1_iphoneos: $1
sed -e "s/\$$$${PRODUCT_NAME}/${TARGET_NAME_$1}/g" resources/Entitlements.plist > build/intermediate/Entitlements.plist
${call add_blob_header,build/intermediate/Entitlements.plist,build/intermediate/Entitlements.xcent}
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
${foreach configuration,${CONFIGURATIONS_$1},\
cp "${RESOURCE_RULES_PLIST}" "build/$1/${configuration}-iphoneos/${TARGET_NAME_$1}.app"${newline_and_tab} \
/usr/bin/codesign -f -s ${CODESIGN_IDENTITY} --resource-rules=${RESOURCE_RULES_PLIST} --entitlements=build/intermediate/Entitlements.xcent "build/$1/${configuration}-iphoneos/${TARGET_NAME_$1}.app"${newline_and_tab} \
}
endef
${foreach target,${APPLICATION_TARGETS}, \
${eval ${call launch_target_iphonesimulator_template,${target}}} \
${eval ${call codesign_target_iphoneos_template,${target}}} \
}
INSTALL_DIR = ${STEM_SHARED_DIR}/${PROJECT_NAME}/${PROJECT_VERSION}
.PHONY: install
install:
mkdir -p "${INSTALL_DIR}/include" ${foreach installed_target,${INSTALLED_TARGETS},"${INSTALL_DIR}/${installed_target}"}
cp Changes.txt License.txt ReadMe.txt ${INSTALL_DIR}
cp -r build/include/* ${INSTALL_DIR}/include
${foreach installed_target,${INSTALLED_TARGETS},cp -r build/${installed_target}/* "${INSTALL_DIR}/${installed_target}"${newline_and_tab}}