-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJamrules
More file actions
5814 lines (4824 loc) · 155 KB
/
Jamrules
File metadata and controls
5814 lines (4824 loc) · 155 KB
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
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# p4/Jamrules
#
# This Jamrules describes how to build most of Perforce, exclusive of
# windows only products.
#
# This file is organized into sections:
#
# Section 0. Generic helper rules
# Section 1. Global variable settings.
# Section 2. Library names.
# Section 3. Per-build type variable settings.
# Section 4. Per-platform variable settings.
# Section 5. Perforce-special rules and actions.
# Section 6. Perforce-special Windows rules.
# Section 7. QT build rules and actions.
# Section 8. Lua build rules and actions.
# Section 9. Boost provides free peer-reviewed portable C++ source libraries.
# Section 10. Google protocol buffers build rules and actions.
# Section 11. Unit test rules
# Section 12. Per-platform actions.
# Section 13. Useful miscellanea
#################################################
#
# Section 0. Generic helper rules
#
#################################################
#
# Special Rules
#
# ObjectCCFlags - C version of ObjectC++Flags
# FRemoveAny x : y ; - return new array of x minus any values in y
# FRegexpQuote list ; - quote regexp metacharacters into literals
# FSplit s : delim ; - split string at delim (default /)
# FStringToList s ; - return a list of chars from string
# FLengthCmp s1 : s2 ; - compare length of strings
# FVersionCmp x : y ; - compare version numbers (e.g. 3.4 vs. 4.5)
# FDirEntries path : pat ; - return a list of files matching pat in path
# FileIsDir x ; - returns just those elements that are existing directories
# OnTargetVarPrepend TARGET : VARIABLE : VALUES ;
# OnTargetVarAppend TARGET : VARIABLE : VALUES ;
# OnTargetVarDelete TARGET : VARIABLE : VALUES ;
# LinkDir app : dir ; - adds directory dir to the list of directories to be
# - scanned for libraries
# LinkLib app : lib ; - adds library for an app
# ExLibrary cpp ; - same as Library, but with exception support
# Deploy source : target ; - copies the source into the target
# - unlike InstallXYZ rules it ensures that directory will be created
# - and the target will be forced to be created before the install
# - operation is called
# MakeLocateWithSubDirectory - same as MakeLocate but the targets may have sub directory
# say object/depot.cpp
#
rule ObjectCCFlags
{
CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
}
rule FRemoveAny
{
# Usage: y = [ FRemoveAny $(x) : v1 v2 ... ] ;
# returns new array with any occurence of v1, v2, etc from $(x) elided
local _new ;
local _elt ;
for _elt in $(1)
{
if ! ( $(_elt) in $(2) ) { _new += $(_elt) ; }
}
return $(_new) ;
}
rule FRegexpQuote
{
# FRegexpQuote list ;
# Quote any egrep(1) regexp metacharacters in elements of
# list such that they will only match a literal expression.
# Returns the quoted list.
local result ;
local p ;
for p in $(<)
{
local q ;
while (1)
{
local r = [ Match ^([^][()*+.?\\]*)([][()*+.?\\])(.*) : $(p) ] ;
q += $(r[1]) ;
if $(r[2]) = ""
{
q += $(p) ;
break ;
}
q += \\$(r[2]) ;
p = $(r[3]) ;
}
result += $(q:J=) ;
}
return $(result) ;
}
rule FSplit
{
# string : delim (default /)
local s = $(>:E=/) ;
local x = [ MATCH ([^$(s)]*)$(s)(.*) : $(<) ] ;
if ! $(x) { return $(<) ; }
return $(x[1]) [ FSplit $(x[2]) : $(>) ] ;
}
rule FStringToList
{
# Expand string into a list of characters.
if ! $(<) { return ; }
local x = [ MATCH ^(.)(.*) : $(<) ] ;
return $(x[1]) [ FStringToList $(x[2-]) ] ;
}
rule FLengthCmp
{
# x = [ FLengthCmp STRING1 : STRING2 ] ;
#
# Return [-1, 0, 1] if string1 is shorter than, same length as, or longer
# than, string2.
local i ;
local a ;
local b ;
# Jam doesn't understand numbers, so we can only count in unary.
for i in [ FStringToList $(<) ] { a += . ; }
for i in [ FStringToList $(>) ] { b += . ; }
if $(a) < $(b) { return -1 ; }
if $(a) > $(b) { return 1 ; }
return 0 ;
}
rule FVersionCmp
{
# x = [ FVersionCmp X1.Y1.Z1 : X2.Y2.Z2 ] ;
#
# Return [-1, 0, 1] if the version number X1.Y1.Z1 is less than, equivalent
# to, or greater than, X2.Y2.Z2. Version strings can be any alphanumeric
# dotted strings.
#
# This function is necessary because Jam doesn't understand numbers; the
# inequality operators use character collating order, so for example the
# naive comparison "10 > 8" is actually false.
#
# Leading zeroes in each field are ignored, so for example this function
# considers "3.4" and "3.4.0" to be equivalent.
local a = [ FSplit $(<:J=.) : \\. ] ; # normalize a.b c => a.b.c => a b c
local b = [ FSplit $(>:J=.) : \\. ] ;
local r ;
while $(a) || $(b)
{
local a1 = [ MATCH ^0*(.*) : $(a[1]) ] ; # strip leading zeroes
local b1 = [ MATCH ^0*(.*) : $(b[1]) ] ;
if $(a1) != $(b1)
{
r = [ FLengthCmp $(a1) : $(b1) ] ;
if $(r) = 0
{
if $(a1) < $(b1) { return -1 ; }
if $(a1) > $(b1) { return 1 ; }
}
return $(r) ;
}
a = $(a[2-]) ;
b = $(b[2-]) ;
}
return 0 ;
}
rule FDirEntries
{
# Usage: files = [ FDirEntries path to directory : pat ] ;
# Returns list of entries in directory which match pat (default '*')
local dir = [ FDirName $(<) ] ;
local pat = $(>) ;
if ! $(pat) { pat = "*" ; }
local ents = [ Glob $(dir) : $(pat) ] ; # => d/. d/.. d/a d/b
# We need to quote windows directories because they use
# backslashes, and those are regexp metacharacters.
# Safer on unix too.
local re = [ FRegexpQuote $(dir)$(SLASH) ] ;
ents = [ Match $(re)(.*) : $(ents) ] ; # => . .. a b
return [ FRemoveAny $(ents) : $(DOT) $(DOTDOT) ] ; # return minus . and ..
}
rule FileIsDir
{
# Returns a list of just those elements that are names of existing directories
local result ;
local f ;
for f in $(1)
{
if [ Glob $(f) : $(DOT) ]
{
result += $(f) ;
}
}
return $(result) ;
}
# Rules for modifying target-specific variables.
# If a variable does not already have a target-specific binding, one is
# created with a copy of the global value prior to altering the
# target-specific value.
#
# These use no local variables, to avoid shadowing anything in caller.
rule OnTargetVarPrepend
{
# OnTargetVarPrepend TARGET : VARIABLE : VALUES ;
$(2[1]) on $(1[1]) = $(3) [ on $(1[1]) return $($(2[1])) ] ;
}
rule OnTargetVarAppend
{
# OnTargetVarAppend TARGET : VARIABLE : VALUES ;
$(2[1]) on $(1[1]) = [ on $(1[1]) return $($(2[1])) ] $(3) ;
}
rule OnTargetVarDelete
{
# OnTargetVarDelete TARGET : VARIABLE : VALUES ;
$(2[1]) on $(1[1]) = [ on $(1[1]) FRemoveAny $($(2[1])) : $(3) ] ;
}
rule SetDefaultDirName
{
# Usage: SetDefaultDirName VARIABLE : DEFAULT ;
# Initialize VARIABLE with DEFAULT if it is not already set.
#
# If the variable's value after initialization is a multi-element
# list, it is assumed that the variable was inherited from the
# environment with spaces in the value and these are joined
# together to create a single string with spaces in it.
#
# HOWEVER, if the first string in the list matches a subdir token
# as defined by SubDir, resolve that and prepend it to the rest of
# the path separated by a / or \ (as appropriate per OS).
#
# This allows one e.g. to set SSLPREFIX to "AllP4 ../../3rd_party/whatever"
# and it will always point to the correct relative location regardless
# of where you invoke jam, and regardless of your workspace root.
$(1) ?= $(2) ;
if $($(1)[2]) && [ FSubDirPath $($(1)[1]) ]
{
$(1) = [ FSubDirPath $($(1)[1]) $($(1)[2-]:J=" ") ] ;
}
else
{
$(1) = $($(1):J=" ") ;
}
return $($(1)) ;
}
rule LinkDir
{
# Usage: LinkDir app : dir1 dir2 ... ] ;
local app = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
# On macs, search both normal libs and frameworks
if $(OS) = MACOSX { OnTargetVarAppend $(app) : LINKLIBS : -L$(>) -F$(>) ; }
else if $(UNIX) { OnTargetVarAppend $(app) : LINKLIBS : -L$(>) ; }
else if $(NT) { OnTargetVarAppend $(app) : LINKLIBS : /LIBPATH:"$(>)" ; }
else { Exit Don't know how to add additional library dir on $(OS). ; }
}
rule LinkLib
{
# Usage: LinkLib app : lib1 lib2 ... ] ;
local app = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
if $(UNIX) { OnTargetVarAppend $(app) : LINKLIBS : -l$(>) ; }
else if $(NT) { OnTargetVarAppend $(app) : LINKLIBS : $(>)$(SUFLIB) ; }
else { Exit Don't know how to link library on $(OS). ; }
}
rule ExLibrary
{
if $(OS) = NT
{
ObjectC++Flags $(>) : /EHsc ;
}
Library $(<) : $(>) ;
}
rule Deploy
{
# Deploy source : target ; - copies the source into the target
local _d = [ FDirName $(LOCATE_SOURCE[1]) $(<:D) ] ;
MkDir $(_d:G=dir) ;
Depends $(<) : $(_d:G=dir) ;
NotFile deploy ;
Depends deploy : $(<) ;
Depends all : deploy ;
Depends $(<) : $(>) ;
Clean clean : $(<) ;
SEARCH on $(>) = $(SEARCH_SOURCE) ;
MakeLocate $(<) : $(LOCATE_SOURCE) ;
}
actions Deploy
{
$(CP) $(>) $(<)
}
rule MakeLocateWithSubDirectory
{
# MakeLocateWithSubDirectory targets : directory ;
# Sets special variable LOCATE on targets, and arranges
# with MkDir to create target directory.
# Note we grist the directory name with 'dir',
# so that directory path components and other
# targets don't conflict.
for target in $(<)
{
local directory = [ FDirName $(>[1]) $(target:D) ] ;
if $(>)
{
LOCATE on $(target) = $(>) ;
Depends $(target) : $(directory:G=dir) ;
MkDir $(directory:G=dir) ;
}
}
}
rule SetCommonCompiler
{
# Basic setup for common cross-platform compilers (gcc, llvm/clang, etc).
# This doesn't include OS-specific compiler tweaking.
# If cross compiling on one platform for another, set
# CROSS_COMPILE to the prefix of the cross tools. For
# example, to build for ARM using an X86 host, set
# CROSS_COMPILE="arm-none-linux-gnueabi-" and OSPLAT="ARM".
# COMPILER_PREFIX can be e.g. "llvm-". This variable differs from
# CROSS_COMPILE in that it only affects the compiler tools,
# not other cross-compile-sensitive programs such as ranlib, ar,
# and so on.
# COMPILER_SUFFIX is used to specify special versions of the
# compiler, e.g. when needing to use "gcc34" or "g++34" to make a
# portable legacy build.
local linker = $(2:E=C++) ;
local prefix = $(3:E=$(COMPILER_PREFIX:E)$(CROSS_COMPILE:E)) ;
local suffix = $(4:E=$(COMPILER_SUFFIX:E)) ;
local wrap = $(COMPILER_WRAPPER:E="") ;
switch $(1:U)
{
case XC :
# make no return value from non-void func an error, and quiet
# some of the noisier clang warnings until we clean up the code
C++FLAGS += -Wno-parentheses -Wno-switch -Wreturn-type -Werror=return-type ;
LINK = $(OSLINK:E=$($(linker))) ;
case *CLANG* :
CC = $(wrap) $(prefix)clang$(suffix) ;
C++ = $(wrap) $(prefix)clang++$(suffix) ;
CC = [ FRemoveAny $(CC) : "" ] ;
C++ = [ FRemoveAny $(C++) : "" ] ;
# make no return value from non-void func an error, and quiet
# some of the noisier clang warnings until we clean up the code
C++FLAGS += -Wno-parentheses -Wno-switch -Wreturn-type -Werror=return-type ;
LINK = $(OSLINK:E=$($(linker))) ;
case *GCC* :
CC = $(wrap) $(prefix)gcc$(suffix) ;
C++ = $(wrap) $(prefix)g++$(suffix) ;
CC = [ FRemoveAny $(CC) : "" ] ;
C++ = [ FRemoveAny $(C++) : "" ] ;
# no return value from non-void func is an error in Visual Studio
# so make it a warning in gcc; unfortunately gcc 3.4.5 does not
# support making it an error, so we can't use -Werror=return-type
C++FLAGS += -Wreturn-type ;
LINK = $(OSLINK:E=$($(linker))) ;
}
STRIP = $(CROSS_COMPILE:E)strip ;
RANLIB = $(CROSS_COMPILE:E)ranlib ;
AR = $(CROSS_COMPILE:E)ar cru ;
}
rule SetOSXSdk
{
# Common setup for darwin/macosx platform.
# Determine correct version and location of SDK to use, and arch flags.
local _legacy = /Developer ; # sdk10.6 and earlier
# sdk10.7 and above live deep under Xcode.app
local _xcode = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform ;
local _prefix = $(_legacy) ;
local _sdkver = $(1:J=.) ; # Override computed sdk version
local _xflags = $(2) ; # additional flags to compiler+linker
# platforms for "universal" builds.
# Jam won't let you specify literal lists via E=, so assign it to a
# temporary variable first and dereference that. This grammar
# limitation is also the reason why we have to use $(GENFLAGS) as
# an lvalue instead of directly assigning CCFLAGS and C++FLAGS.
local _uplats_default = arm64 x86_64 ;
local _uplats = $(3:E=$(_uplats_default)) ;
switch $(OS:U)
{
case DARWIN :
if [ FVersionCmp $(OSVER) : 110 ] >= 0 { _prefix = $(_xcode)$(_legacy) ; }
local _v = [ MATCH ([0-9]+)[0-9]$ : $(OSVER) ] ;
# darwin: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
local _sdkmap = 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ;
_sdkver ?= 10.$(_sdkmap[$(_v)]) ;
case MACOSX :
local _v = [ MATCH ([0-9][0-9])([0-9]*)$ : $(OSVER) ] ;
_sdkver ?= $(_v:J=.) ;
if $(_v[1]) != 10 || [ FVersionCmp $(OSVER) : 107 ] >= 0
{
_prefix = $(_xcode)$(_legacy) ;
}
}
if $(_sdkver) = 10.4 { _sdkver = $(_sdkver)u ; } # "10.4u.sdk"
if ! [ FileIsDir $(_prefix)/SDKs/MacOSX$(_sdkver).sdk ]
{
local _cltools = /Library/Developer/CommandLineTools ;
if [ FileIsDir $(_cltools) ] { _prefix = $(_cltools) ; }
}
MACOSX_SDK ?= $(_prefix)/SDKs/MacOSX$(_sdkver).sdk ;
MACOSX_SDK_FLAGS ?= -isysroot $(MACOSX_SDK) ;
# OSPLAT=U : universal binary
local _arch _elt ;
switch $(OSPLAT:U)
{
case PPC : _arch = -arch ppc ;
case X86 : _arch = -arch i386 ;
case X86_64 : _arch = -arch x86_64 ;
case ARM64 : _arch = -arch arm64 ;
case U :
for _elt in $(_uplats) { _arch += -arch $(_elt) ; }
NOARSCAN = true ; # can't scan "fat" archives
}
# n.b. we used to have a "CS" OSVER suffix so you could produce a
# case-sensitive server on mac, but that's no longer necessary since
# you can now specify a different default at runtime on any platform.
$(GENFLAGS) += $(MACOSX_SDK_FLAGS) $(_arch) -DCASE_INSENSITIVE $(_xflags) ;
LINKFLAGS += $(MACOSX_SDK_FLAGS) $(_arch) $(_xflags) ;
}
# Tell Clang/GCC/VisualStudio which version of the language to use.
# Useful for enforcing an upper-bound on the language used in the code.
# Note that we define no equivalent for the C language. Note that if the
# version of the compiler doesn't support the flag to set the standard or
# the value passed in is invalid or the compiler version is not defined,
# this function is a NOOP.
_has_warned_set_compiler_flag = 0 ;
rule C++FLAGS+STD
{
local std = $(1) ;
local rv = $(C++_VERSION_BASELINE:E) ;
local result = [ FRemoveAny $(C++FLAGS) : -std=$(rv) /std:$(rv) ] ;
# c++N -> N
local stdl = [ FStringToList $(std) ] ;
local vsl = $(stdl[4-]) ;
local vs = $(vsl:J="") ;
# todo: cc is 'cl /nologo' on Windows
# Assume an incompatible compiler if the version isn't declared.
if $(CC) = clang && ! $(CLANGVER) || $(CC) = gcc && ! $(GCCVER)
|| $(CC) = cl && ! $(MSVSVER)
{
if $(_has_warned_set_compiler_flag) = 0
{ echo "Please define CLANGVER/GCCVER/MSVSVER." ; }
_has_warned_set_compiler_flag = 1 ;
return $(result) ;
}
# GCC/VS didn't always support setting the language
# standard, and at least in GCC's case, the name of the
# standard used by one version doesn't always match what
# the standard is called in later versions - e.g. c++0x vs
# c++11.
#
# https://gcc.gnu.org/onlinedocs/
# https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/C-Dialect-Options.html#lndex-ISO-support-95 -std=c++98
# https://msdn.microsoft.com/en-us/library/mt490614.aspx
#
# The std flag was unavailable in these versions:
if $(GCCVER) && [ FVersionCmp $(GCCVER) : 4.2.0 ] < 0 ||
$(MSVSVER) && [ FVersionCmp $(MSVSVER) : 14 ] < 0
{ return $(result) ; }
if $(CLANGVER)
{
# Just handle this version for now since it's what's on
# the build host.
if [ FVersionCmp $(CLANGVER) : 6.0.0 ] < 0 && $(vs) > 14
{ return $(result) ; }
}
if $(GCCVER)
{
if [ FVersionCmp $(GCCVER) : 4.6.0 ] < 0 && $(vs) < 98 ||
[ FVersionCmp $(GCCVER) : 4.7.0 ] < 0 && $(vs) > 11 ||
[ FVersionCmp $(GCCVER) : 6.4.0 ] < 0 && $(vs) > 14 ||
[ FVersionCmp $(GCCVER) : 7.3.0 ] < 0 && $(vs) > 17
{ return $(result) ; }
}
if $(MSVSVER)
{
if [ FVersionCmp $(MSVSVER) : 14 ] <= 0 && $(vs) > 14 ||
[ FVersionCmp $(MSVSVER) : 15 ] <= 0 && $(vs) > 17 ||
$(vs) < 14
{ return $(result) ; }
}
if $(OS) = NT && $(MSVSVER)
{
result += /std:$(std) ;
}
else
{
result += -std=$(std) ;
}
return $(result) ;
}
# Encapsulate the version checks used to detect whether or not the source
# is being built with the compilers we updated to in 18.2 (more or less
# "modern").
rule CompilerIsModern
{
# Assume an incompatible compiler if the version isn't declared.
if $(CC) = clang && ! $(CLANGVER) || $(CC) = gcc && ! $(GCCVER)
|| $(CC) = cl && ! $(MSVSVER)
{
return 0 ;
}
if $(CLANGVER) && [ FVersionCmp $(CLANGVER) : 6.0.0 ] >= 0
{
return 1 ;
}
if $(GCCVER) && [ FVersionCmp $(GCCVER) : 7.3.0 ] >= 0
{
return 1 ;
}
if $(MSVSVER) && [ FVersionCmp $(MSVSVER) : 15 ] >= 0
{
return 1 ;
}
return 0 ;
}
rule CompilerSupportsZlibOptim
{
if $(GCCVER) && [ FVersionCmp $(GCCVER) : 6.0.0 ] >= 0
{
return 1 ;
}
return [ CompilerIsModern ] ;
}
#################################################
#
# Section 1. Global variable settings.
#
#################################################
if $(JAMBASEDATE) < 2002.05.09 {
Exit Jamrules requires Jambase 2002.05.09 ($(JAMBASEDATE)) ;
}
# Variables you shouldn't set:
#
# OS - operating system ("FreeBSD")
# OSPLAT - OS platform ("sparc")
#
# Variables you can set:
#
# OSVER - version of OS ("102" for MACOSX)
# TYPE - controls compile flags (see below)
# BUILD - subdirectory for special named builds ("nightly")
# Variables that activate certain build features
# DEV_VERSION - replaces the default version with a bogus one
# WARN_FOR_DEPRECATED - enables deprecated warnings
# FULL_PATH_DIAGNOSTICS - full path Source Code File in Diagnostics (visual studio only)
# INCREMENTAL_BUILD - disable removing of temporary artifacts
# BUILD_WITH_SUB_DIRECTORIES - locates the object files in a subtree
BUILD_WITH_SUB_DIRECTORIES ?= true ;
# Variables that activate certain build features per group
# P4DEVELOPER - enables set of features appropriate for p4 dev environment
# P4VDEVELOPER - enables set of features appropriate for p4v dev environment
if $(P4DEVELOPER) = true
{
FULL_PATH_DIAGNOSTICS = true ;
INCREMENTAL_BUILD = true ;
}
if $(P4VDEVELOPER) = true
{
WARN_FOR_DEPRECATED = true ;
DEV_VERSION = true ;
FULL_PATH_DIAGNOSTICS = true ;
INCREMENTAL_BUILD = true ;
}
# Variables that shouldn't be set in PRODUCTION build environment
if $(PRODUCTION)
{
if $(P4DEVELOPER) = true { exit ERROR - P4DEVELOPER and PRODUCTION defined at the same time ; }
if $(P4VDEVELOPER) = true { exit ERROR - P4VDEVELOPER and PRODUCTION defined at the same time ; }
if $(DEV_VERSION) = true { exit ERROR - DEV_VERSION and PRODUCTION defined at the same time ; }
}
# For convenience of historical compatibility, the OSPLAT value
# "AMD64" will be changed to "X86_64", which is the canonical name
# we are now using for that platform. Please get into the habit of
# using it directly, as this may go away someday.
if $(OSPLAT:U) = AMD64 { OSPLAT = X86_64 ; }
OSVERLONG = $(OSVER:E=0) ;
if $(OS) = "MACOSX"
{
local dot = "" ;
for i in [ FStringToList $(OSVER) ] { dot = $(dot)"." ; }
if $(dot) = ".."
{
OSVERLONG = $(OSVER)"00" ;
}
}
# This is jam idiomatic, but the result is that
# P4BIN is set to ../p4-bin (relative to P4)
SubDir AllP4 p4 ; # where we are
SubDir AllP4 p4-bin ; # where we want to be
SubDir P4BIN ; # name is that
SubDir AllP4 p4 ; # back to where we started
EXEC_SUB_TOKENS =
$(OS:L)$(OSVER:EL)$(OSPLAT:EL)
$(BUILD)
$(TYPE:L) ;
EXEC_LIB ?= [ FSubDirPath P4BIN lib.$(EXEC_SUB_TOKENS[1]) ] ;
EXEC_INC ?= [ FSubDirPath P4BIN inc.$(EXEC_SUB_TOKENS[1]) ] ;
EXEC_LIBEXEC ?= [ FSubDirPath P4BIN libexec.$(EXEC_SUB_TOKENS[1]) ] ;
# Build dir: p4-bin/bin.xxx[/build][/type]
EXEC_TOKENS =
P4BIN
bin.$(EXEC_SUB_TOKENS[1])
$(EXEC_SUB_TOKENS[2])
$(EXEC_SUB_TOKENS[3])
;
EXEC ?= [ FSubDirPath $(EXEC_TOKENS) ] ;
ALL_LOCATE_TARGET = $(EXEC) ;
if $(BUILD_WITH_SUB_DIRECTORIES) = true
{
# Override the default Objects
rule Objects
{
local _i ;
for _i in [ FGristFiles $(<) ]
{
Object $(_i:S=$(SUFOBJ)) : $(_i) ;
Depends obj : $(_i:S=$(SUFOBJ)) ;
if $(INCREMENTAL_BUILD) != true
{
NotFile protobuf ;
Depends $(_i:S=$(SUFOBJ)) : protobuf ;
}
MakeLocateWithSubDirectory $(_i:S=$(SUFOBJ)) : [ FDirName $(LOCATE_SOURCE[1]) objects $(SUBDIR_TOKENS) ] ;
}
}
}
# version file
# Ident'ed executables depend on this
SEARCH on Version = $(P4) ;
include Version ;
if $(DEV_VERSION) = true
{
# Add local-dev-build marker to the revision
RELEASE = $(RELEASE[1]) $(RELEASE[2]) $(RELEASE[3])-local-dev-build ;
# Change the version to bogus one
# TODO: This could be improved to grab the version from perforce
# but is it going to be better. Developers may have
# old revision, cherry picking, un-submitted changes, etc.
PATCHLEVEL = 9999999 ;
SUPPDATE = 2100 01 01 ;
}
STRIP = strip ;
COMPRESS = gzip -9 ;
ZIP ?= zip -9 -r -q ;
# symbolic flags with no user/group/other specifier will default to
# ANDing with the user's umask.
# Thus, if the user's umask is 022,
# files will be -rw-r--r-- and executables will be -rwxr-xr-x
# If a user's umask is 002,
# files will be -rw-rw-r-- and executables will be -rwxrwxr-x
# and so on.
if $(UNIX)
{
FILEMODE = "+r,go-w" ;
EXEMODE = "+rx,go-w" ;
}
DEFINES +=
OS_$(OS)
OS_$(OS)$(OSVER)
OS_$(OS)$(OSPLAT:U)
OS_$(OS)$(OSVER)$(OSPLAT:U)
"OS_VER=$(OSVERLONG)" ;
HDRS +=
[ FSubDirPath P4 msgs ]
[ FSubDirPath P4 support ]
[ FSubDirPath P4 sys ] ;
# For production builds we customize the names of our Qt shared
# libaries on some platforms to avoid naming/version conflicts with
# system libraries on numerous platforms. The main exception is
# OSX, where it isn't needed.
#
# Developers don't necessarily bother to add this infix to their
# builds, but these variables allow one to use them if desired even
# for non-production builds.
if $(PRODUCTION) && $(OS) != MACOSX
{
QT_LIBINFIX ?= P4 ;
}
# The default, if linking with stdc++, is to dynamically link unless a
# specific platform overrides as static. Note that this is overloaded
# to include LLVM/Clang's libc++.
STATIC_LIBSTDC++ = no ;
# This really ought to be renamed LINK_WITH_STL since some operating systems use a different name.
LINK_WITH_STDC++ = p4 p4d p4p p4broker p4zk p4sandbox p4sandbox_ja p4vc browsechild mkconf perfmerge perfsplit p4migrate license p4dctl ;
# Some parts of libsupp now require symbols from pthread
LINK_WITH_PTHREAD = p4 p4d p4p p4broker p4sandbox p4sandbox_ja p4ftpd browsechild mkconf p4dctl license ;
# SSL configuration:
# Define SSL to include netssl* source code into the libraries and executables
# Define SSLSTUB to link in a stubbed version of the SSL libraries rather than linking
# to the OpenSSL libraries.
# Expected build configurations:
# 1. All in-house executables compiled with SSL = yes and SSLSTUB = no
# (i.e., link with OpenSSL libraries)
# 2. C/C++ Client API built with SSL = yes and SSLSTUB = yes
# SSL is defined but libraries not released with code.
SSL ?= yes ;
SSLSTUB ?= no ;
SSLVER ?= 1.0.2 ;
SetDefaultDirName SSLPREFIX : [ FSubDirPath P4BIN ] ;
# 2014-10-23 temporary backward compatibility for transition.
# Don't use SSLINCLUDE anymore.
if $(SSLINCLUDE) { SSLINCDIR ?= $(SSLINCLUDE) ; }
if $(SSLSTUB) = yes
{
SSL = yes ;
SSLINCDIR ?= [ FSubDirPath AllP4 p4 sslstub ]
[ FDirName $(SSLPREFIX) inc.$(EXEC_SUB_TOKENS[1]) ] ;
SetDefaultDirName SSLINCDIR ;
} else {
SetDefaultDirName SSLINCDIR : [ FDirName $(SSLPREFIX) inc.$(EXEC_SUB_TOKENS[1]) ] ;
}
# Zookeeper configuration
# Define ZK to include zkservice client network code into the server process.
# The ZKS client network code should be used only with the Perforce Clustered Servers.
# The Clustered Servers are only being released on Linux varients.
# Expected build configurations:
# 1. Only the p4d and p4broker executables on Linux 32 and 64 bit platforms. Non-clustered
# servers and brokers on Linux will have support for Zookeeper built in but will not use
# the service.
# 2. All non-linux OS p4d and p4brokers will not compile in support for Zookeeper.
# 3. The proxy and perforce client will not compile in support for Zookeeper
ZK ?= no ;
# LDAP configuration:
# Define LDAPSTUB to link in a stubbed version of the LDAP libraries
# rather than linking to either the OpenLDAP or WinLDAP libraries.
# Expected build configurations:
# 1. NT P4D binaries built with LDAPSTUB = no and linked against WinLDAP
# in the Windows SDK.
# 2. Linux P4D binaries built with LDAPSTUB = no and linked against the
# OpenLDAP and CyrusSASL libraries
# 3. All other P4D binaries built with LDAPSTUB = yes
LDAPSTUB ?= yes ;
SetDefaultDirName OPENLDAPINCDIR : $(EXEC_INC) ;
SetDefaultDirName OPENLDAPLIBDIR : $(EXEC_LIB) ;
SetDefaultDirName CYRUSSASLPINCDIR : $(EXEC_INC) ;
SetDefaultDirName CYRUSSASLPLIBDIR : $(EXEC_LIB) ;
#
# X3 configuration
#
X3 ?= no ;
UDT ?= no ;
ASPERA ?= no ;
SCP ?= no ;
# UDT configuration
SetDefaultDirName UDTINCDIR : $(EXEC_INC) ;
SetDefaultDirName UDTLIBDIR : $(EXEC_LIB) ;
# Aspera configuration
SetDefaultDirName ASPINCDIR : $(EXEC_INC) ;
SetDefaultDirName ASPLIBDIR : $(EXEC_LIB) ;
# SCP configuration
SetDefaultDirName SCPINCDIR : $(EXEC_INC) ;
SetDefaultDirName SCPLIBDIR : $(EXEC_LIB) ;
# Disable variadic templates in boost because this requires -std=c++11 or later
# (which then requires -Wno-deprecated-declarations to avoid complaints
# about auto_ptr being deprecated).
#
# But don't define BOOST_NO_CXX11_VARIADIC_TEMPLATES before g++ 5.x
# because boost pre-defines it with g++ older than that.
#
# Without this rule both p4-cluster and gconn trigger this warning:
# warning: variadic templates only available with -std=c++11 or -std=gnu++11
#
# We might (or might not) need to do this for clang as well.
#
# NB: This requires passing -sGCCVER=5 (or other version, as appropriate)
# on the jam invocation.
rule NoBoostVariadicTemplates
{
if [ FVersionCmp $(GCCVER) : 5.0.0 ] >= 0
{
SubDirC++Flags -DBOOST_NO_CXX11_VARIADIC_TEMPLATES ;
}
}
#################################################
#
# Section 2. Library names.
#
#################################################
rule SetLibName
{
$(1) = $(2:S=$(SUFLIB)) ;
LOCATE on $($(1)) = $(EXEC) ;
}
SetLibName CLIENTLIB : libclient ;
SetLibName DMLIB : libdm ;
SetLibName FTPLIB : libp4ftp ;
SetLibName LBRLIB : liblbr ;
SetLibName P4MEMORYMGR : libp4mmgr ;
SetLibName P4MEMORYMGR_STUB : libp4mmgr_stub ;
SetLibName P4EXPLIB : libp4exp ;
SetLibName P4TD : libp4thumb ;
SetLibName P4LIB : libp4 ;
SetLibName P4SCCLIB : libp4scc ;
SetLibName P4SSLLIB : libp4sslstub ;
SetLibName P4WINLIB : libp4win ;
SetLibName P4WINCMNLIB : libp4wcmn ;
SetLibName P4WINDIFFLIB : libp4wdf ;
SetLibName P4WINMRGLIB : libp4wmrg ;
SetLibName PLUGINLIB : libplugin ;
SetLibName PROXYLIB : libproxy ;
SetLibName QTADMINAPPLIB : libqtadminapp ;
SetLibName QTADMINLIB : libqtadmin ;
SetLibName QTCMDLIB : libqtcmd ;
SetLibName QTCORELIB : libqtcore ;
SetLibName QTP4APILIB : libqtp4api ;
SetLibName QTIMGMAXLIB : libqtmaxfmt ;
SetLibName QTIMGMAYALIB : libqtmayafmt ;
SetLibName QTIMGPHOTOLIB : libqtphotofmt ;
SetLibName QTIMGTGALIB : libqttgafmt ;
SetLibName QTMERGELIB : libqtmerge ;
SetLibName QTMERGEAPPLIB : libqtmergeapp ;
SetLibName QTPLATLIB : libqtplat ;
SetLibName QTPREFLIB : libqtpref ;
SetLibName QTUTILLIB : libqtutil ;
SetLibName QTREELIB : libqtree ;
SetLibName RPCLIB : librpc ;
SetLibName SANDSTORM : libstorm ;
SetLibName P4VSHELL : libp4vshell ;
SetLibName P4ALIB : libp4a ;
SetLibName P4APILIB : libp4api ;
SetLibName P4SCRIPT : libp4script ;
SetLibName P4SCRIPT_C : libp4script_c ;
SetLibName P4SCRIPT_CSTUB : libp4script_cstub ;
SetLibName P4SCRIPT_S : libp4script_s ;
SetLibName P4SCRIPT_CURL : libp4script_curl ;
SetLibName P4SCRIPT_SQLITE : libp4script_sqlite ;
SetLibName P4TRACELIB : libp4trace ;
SetLibName P4V : libp4v ;
SetLibName P4VPRIMITIVES : libp4vprimitives ;
SetLibName P4VC : libp4vc ;
SetLibName P4VTEST : libp4vtest ;
SetLibName SCCDLLLIB : p4scc2 ;
SetLibName SERVERLIB : libserver ;
SetLibName SUPPORTLIB : libsupp ;
SetLibName SHSTUBLIB : libshstub ;
SetLibName WEBGIZMOLIB : libp4web ;
SetLibName P4SANDBOXLIB : libp4sandbox_$(P4SBLANG:E=en) ;
SetLibName ZKSLIB : libzks ;
SetLibName P4SHAREDLIB : libp4shared ;
SetLibName ZKUILIB : libzkui ;
SetLibName ASPLIB : libasp ; # maybe
#################################################
#
# Section 3. Per-build type variable settings.
#
#################################################
TYPE ?= opt ;
switch $(TYPE)
{
# These are official builds
#
# dyn: windows guis must be dynamic
# opt: our standard, optimized build
# pic: for API and some client applications
case dyn : OPTIM = -O2 ;
case opt : OPTIM = -O2 ;
case pic : OPTIM = -O2 -fPIC ;
# These are for internal testing/playing
#
# g/dyng/optg: debugging