1# This Source Code Form is subject to the terms of the Mozilla Public
2# License, v. 2.0. If a copy of the MPL was not distributed with this
3# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4{
5  'includes': [
6    '../../coreconf/config.gypi'
7  ],
8  'targets': [
9    {
10      'target_name': 'intel-gcm-s_lib',
11      'type': 'static_library',
12      'sources': [
13        'intel-aes.s',
14        'intel-gcm.s',
15      ],
16      'dependencies': [
17        '<(DEPTH)/exports.gyp:nss_exports'
18      ],
19      'conditions': [
20        [ 'cc_is_clang==1 and force_integrated_as!=1', {
21          'cflags': [
22            '-no-integrated-as',
23          ],
24          'cflags_mozilla': [
25            '-no-integrated-as',
26          ],
27          'asflags_mozilla': [
28            '-no-integrated-as',
29          ],
30        }],
31      ],
32    },
33    {
34      'target_name': 'intel-gcm-wrap_c_lib',
35      'type': 'static_library',
36      'sources': [
37        'intel-gcm-wrap.c',
38      ],
39      'dependencies': [
40        '<(DEPTH)/exports.gyp:nss_exports'
41      ],
42      'conditions': [
43        [ '(OS=="linux" or OS=="android") and target_arch=="x64"', {
44          'dependencies': [
45            'intel-gcm-s_lib',
46          ],
47        }],
48      ],
49      'cflags': [
50        '-mssse3',
51      ],
52      'cflags_mozilla': [
53        '-mssse3'
54      ],
55    },
56    {
57      'target_name': 'hw-acc-crypto-avx',
58      'type': 'static_library',
59      # 'sources': [
60      #   All AVX hardware accelerated crypto currently requires x64
61      # ],
62      'dependencies': [
63        '<(DEPTH)/exports.gyp:nss_exports'
64      ],
65      'conditions': [
66        [ 'target_arch=="x64"', {
67          'cflags': [
68            '-mssse3',
69            '-msse4.1',
70            '-msse4.2'
71          ],
72          'cflags_mozilla': [
73            '-mssse3',
74            '-msse4.1',
75            '-msse4.2',
76            '-mpclmul',
77            '-maes',
78            '-mavx',
79          ],
80          # GCC doesn't define this.
81          'defines': [
82            '__SSSE3__',
83          ],
84        }],
85        [ 'OS=="linux" or OS=="android" or OS=="dragonfly" or OS=="freebsd" or \
86           OS=="netbsd" or OS=="openbsd"', {
87          'cflags': [
88            '-mpclmul',
89            '-maes',
90            '-mavx',
91          ],
92        }],
93        # macOS build doesn't use cflags.
94        [ 'OS=="mac" or OS=="ios"', {
95          'xcode_settings': {
96            'OTHER_CFLAGS': [
97              '-mssse3',
98              '-msse4.1',
99              '-msse4.2',
100              '-mpclmul',
101              '-maes',
102              '-mavx',
103            ],
104          },
105        }],
106        [ 'target_arch=="arm"', {
107          # Gecko doesn't support non-NEON platform on Android, but tier-3
108          # platform such as Linux/arm will need it
109          'cflags_mozilla': [
110            '-mfpu=neon'
111          ],
112        }],
113        [ 'target_arch=="x64"', {
114          'sources': [
115            'verified/Hacl_Poly1305_128.c',
116            'verified/Hacl_Chacha20_Vec128.c',
117            'verified/Hacl_Chacha20Poly1305_128.c',
118          ],
119        }],
120      ],
121    },
122    {
123      'target_name': 'hw-acc-crypto-avx2',
124      'type': 'static_library',
125      # 'sources': [
126      #   All AVX2 hardware accelerated crypto currently requires x64
127      # ],
128      'dependencies': [
129        '<(DEPTH)/exports.gyp:nss_exports'
130      ],
131      'conditions': [
132        [ 'target_arch=="x64"', {
133          'cflags': [
134            '-mssse3',
135            '-msse4.1',
136            '-msse4.2'
137          ],
138          'cflags_mozilla': [
139            '-mssse3',
140            '-msse4.1',
141            '-msse4.2',
142            '-mpclmul',
143            '-maes',
144            '-mavx',
145            '-mavx2',
146          ],
147          # GCC doesn't define this.
148          'defines': [
149            '__SSSE3__',
150          ],
151        }],
152        [ 'OS=="linux" or OS=="android" or OS=="dragonfly" or OS=="freebsd" or \
153           OS=="netbsd" or OS=="openbsd"', {
154          'cflags': [
155            '-mpclmul',
156            '-maes',
157            '-mavx',
158            '-mavx2',
159          ],
160        }],
161        # macOS build doesn't use cflags.
162        [ 'OS=="mac" or OS=="ios"', {
163          'xcode_settings': {
164            'OTHER_CFLAGS': [
165              '-mssse3',
166              '-msse4.1',
167              '-msse4.2',
168              '-mpclmul',
169              '-maes',
170              '-mavx',
171              '-mavx2',
172            ],
173          },
174        }],
175        [ 'target_arch=="arm"', {
176          # Gecko doesn't support non-NEON platform on Android, but tier-3
177          # platform such as Linux/arm will need it
178          'cflags_mozilla': [
179            '-mfpu=neon'
180          ],
181        }],
182        [ 'target_arch=="x64"', {
183          'sources': [
184            'verified/Hacl_Poly1305_256.c',
185            'verified/Hacl_Chacha20_Vec256.c',
186            'verified/Hacl_Chacha20Poly1305_256.c',
187          ],
188        }],
189      ],
190    },
191    {
192      'target_name': 'gcm-aes-x86_c_lib',
193      'type': 'static_library',
194      'sources': [
195        'gcm-x86.c', 'aes-x86.c'
196      ],
197      'dependencies': [
198        '<(DEPTH)/exports.gyp:nss_exports'
199      ],
200      # Enable isa option for pclmul and aes-ni; supported since gcc 4.4.
201      # This is only supported by x84/x64. It's not needed for Windows,
202      # unless clang-cl is used.
203      'cflags_mozilla': [
204        '-mpclmul', '-maes'
205      ],
206      'conditions': [
207        [ 'OS=="linux" or OS=="android" or OS=="dragonfly" or OS=="freebsd" or OS=="netbsd" or OS=="openbsd"', {
208          'cflags': [
209            '-mpclmul', '-maes'
210          ],
211        }],
212        # macOS build doesn't use cflags.
213        [ 'OS=="mac" or OS=="ios"', {
214          'xcode_settings': {
215            'OTHER_CFLAGS': [
216              '-mpclmul', '-maes'
217            ],
218          },
219        }]
220      ]
221    },
222    {
223      'target_name': 'sha-x86_c_lib',
224      'type': 'static_library',
225      'sources': [
226        'sha256-x86.c'
227      ],
228      'dependencies': [
229        '<(DEPTH)/exports.gyp:nss_exports'
230      ],
231      'cflags': [
232        '-msha',
233        '-mssse3',
234        '-msse4.1'
235      ],
236      'cflags_mozilla': [
237        '-msha',
238        '-mssse3',
239        '-msse4.1'
240      ],
241      'conditions': [
242        # macOS build doesn't use cflags.
243        [ 'OS=="mac" or OS=="ios"', {
244          'xcode_settings': {
245            'OTHER_CFLAGS': [
246              '-msha',
247              '-mssse3',
248              '-msse4.1'
249            ],
250          },
251        }]
252      ]
253    },
254    {
255      'target_name': 'gcm-aes-arm32-neon_c_lib',
256      'type': 'static_library',
257      'sources': [
258        'gcm-arm32-neon.c'
259      ],
260      'dependencies': [
261        '<(DEPTH)/exports.gyp:nss_exports'
262      ],
263      'cflags': [
264        '-march=armv7',
265        '-mfpu=neon',
266        '<@(softfp_cflags)',
267      ],
268      'cflags_mozilla': [
269        '-mfpu=neon',
270        '<@(softfp_cflags)',
271      ]
272    },
273    {
274      'target_name': 'gcm-aes-aarch64_c_lib',
275      'type': 'static_library',
276      'sources': [
277        'gcm-aarch64.c'
278      ],
279      'dependencies': [
280        '<(DEPTH)/exports.gyp:nss_exports'
281      ],
282      'cflags': [
283        '-march=armv8-a+crypto'
284      ],
285      'cflags_mozilla': [
286        '-march=armv8-a+crypto'
287      ]
288    },
289    {
290      'target_name': 'gcm-aes-ppc_c_lib',
291      'type': 'static_library',
292      'sources': [
293        'gcm-ppc.c',
294        'sha512-p8.s',
295      ],
296      'dependencies': [
297        '<(DEPTH)/exports.gyp:nss_exports'
298      ],
299      'conditions': [
300        [ 'disable_crypto_vsx==0', {
301          'cflags': [
302            '-mcrypto',
303            '-maltivec'
304           ],
305           'cflags_mozilla': [
306             '-mcrypto',
307             '-maltivec'
308           ],
309        }, 'disable_crypto_vsx==1', {
310          'cflags': [
311            '-maltivec'
312          ],
313          'cflags_mozilla': [
314            '-maltivec'
315          ],
316        }]
317      ]
318    },
319    {
320      'target_name': 'gcm-aes-ppc_lib',
321      'type': 'static_library',
322      'sources': [
323        'ppc-gcm.s',
324      ],
325      'dependencies': [
326        '<(DEPTH)/exports.gyp:nss_exports'
327      ],
328      'conditions': [
329        [ 'cc_is_clang==1 and force_integrated_as!=1', {
330          'cflags': [
331            '-no-integrated-as',
332          ],
333          'cflags_mozilla': [
334            '-no-integrated-as',
335          ],
336          'asflags_mozilla': [
337            '-no-integrated-as',
338          ],
339        }],
340      ],
341    },
342    {
343      'target_name': 'ppc-gcm-wrap-nodepend_c_lib',
344      'type': 'static_library',
345      'sources': [
346        'ppc-gcm-wrap.c',
347      ],
348      'dependencies': [
349        '<(DEPTH)/exports.gyp:nss_exports',
350        'gcm-aes-ppc_lib',
351      ],
352    },
353    {
354      'target_name': 'ppc-gcm-wrap_c_lib',
355      'type': 'static_library',
356      'sources': [
357        'ppc-gcm-wrap.c',
358      ],
359      'dependencies': [
360        '<(DEPTH)/exports.gyp:nss_exports',
361        'gcm-aes-ppc_lib',
362      ],
363      'defines!': [
364        'FREEBL_NO_DEPEND',
365      ],
366    },
367    {
368      'target_name': 'gcm-sha512-nodepend-ppc_c_lib',
369      'type': 'static_library',
370      'sources': [
371        'sha512.c',
372      ],
373      'dependencies': [
374        '<(DEPTH)/exports.gyp:nss_exports'
375      ],
376      'conditions': [
377        [ 'disable_crypto_vsx==0', {
378          'cflags': [
379            '-mcrypto',
380            '-maltivec',
381            '-mvsx',
382            '-funroll-loops',
383            '-fpeel-loops'
384           ],
385           'cflags_mozilla': [
386            '-mcrypto',
387            '-maltivec',
388            '-mvsx',
389            '-funroll-loops',
390            '-fpeel-loops'
391           ],
392        }, 'disable_crypto_vsx==1', {
393          'cflags': [
394            '-maltivec',
395            '-funroll-loops',
396            '-fpeel-loops'
397          ],
398          'cflags_mozilla': [
399            '-maltivec',
400            '-funroll-loops',
401            '-fpeel-loops'
402          ],
403        }]
404      ]
405    },
406    {
407      'target_name': 'gcm-sha512-ppc_c_lib',
408      'type': 'static_library',
409      'sources': [
410        'sha512.c',
411      ],
412      'dependencies': [
413        '<(DEPTH)/exports.gyp:nss_exports'
414      ],
415      'conditions': [
416        [ 'disable_crypto_vsx==0', {
417          'cflags': [
418            '-mcrypto',
419            '-maltivec',
420            '-mvsx',
421            '-funroll-loops',
422            '-fpeel-loops'
423           ],
424           'cflags_mozilla': [
425            '-mcrypto',
426            '-maltivec',
427            '-mvsx',
428            '-funroll-loops',
429            '-fpeel-loops'
430           ],
431        }, 'disable_crypto_vsx==1', {
432          'cflags': [
433            '-maltivec',
434            '-funroll-loops',
435            '-fpeel-loops'
436          ],
437          'cflags_mozilla': [
438            '-maltivec',
439            '-funroll-loops',
440            '-fpeel-loops'
441          ],
442        }]
443      ],
444      'defines!': [
445        'FREEBL_NO_DEPEND',
446      ],
447    },
448    {
449      'target_name': 'chacha20-ppc_lib',
450      'type': 'static_library',
451      'sources': [
452        'chacha20poly1305-ppc.c',
453        'chacha20-ppc64le.S',
454      ]
455    },
456    {
457      'target_name': 'armv8_c_lib',
458      'type': 'static_library',
459      'sources': [
460        'aes-armv8.c',
461        'sha1-armv8.c',
462        'sha256-armv8.c',
463      ],
464      'dependencies': [
465        '<(DEPTH)/exports.gyp:nss_exports'
466      ],
467      'conditions': [
468        [ 'target_arch=="arm"', {
469          'cflags': [
470            '-march=armv8-a',
471            '-mfpu=crypto-neon-fp-armv8',
472            '<@(softfp_cflags)',
473          ],
474          'cflags_mozilla': [
475            '-march=armv8-a',
476            '-mfpu=crypto-neon-fp-armv8',
477            '<@(softfp_cflags)',
478          ],
479        }, 'target_arch=="arm64" or target_arch=="aarch64"', {
480          'cflags': [
481            '-march=armv8-a+crypto'
482          ],
483          'cflags_mozilla': [
484            '-march=armv8-a+crypto'
485          ],
486        }]
487      ]
488    },
489    {
490      'target_name': 'freebl',
491      'type': 'static_library',
492      'sources': [
493        'loader.c'
494      ],
495      'dependencies': [
496        '<(DEPTH)/exports.gyp:nss_exports'
497      ]
498    },
499    # Build a static freebl library so we can statically link it into
500    # the binary. This way we don't have to dlopen() the shared lib
501    # but can directly call freebl functions.
502    {
503      'target_name': 'freebl_static',
504      'type': 'static_library',
505      'includes': [
506        'freebl_base.gypi',
507      ],
508      'dependencies': [
509        '<(DEPTH)/exports.gyp:nss_exports',
510        'hw-acc-crypto-avx',
511        'hw-acc-crypto-avx2',
512      ],
513      'conditions': [
514        [ 'target_arch=="ia32" or target_arch=="x64"', {
515          'dependencies': [
516            'gcm-aes-x86_c_lib',
517          ],
518        }, '(disable_arm_hw_aes==0 or disable_arm_hw_sha1==0 or disable_arm_hw_sha2==0) and (target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64")', {
519          'dependencies': [
520            'armv8_c_lib'
521          ],
522        }],
523        [ '(target_arch=="ia32" or target_arch=="x64") and disable_intel_hw_sha==0', {
524          'dependencies': [
525            'sha-x86_c_lib',
526          ],
527        }],
528        [ 'disable_arm32_neon==0 and target_arch=="arm"', {
529          'dependencies': [
530            'gcm-aes-arm32-neon_c_lib',
531          ],
532        }],
533        [ 'disable_arm32_neon==1 and target_arch=="arm"', {
534          'defines!': [
535            'NSS_DISABLE_ARM32_NEON',
536          ],
537        }],
538        [ 'target_arch=="arm64" or target_arch=="aarch64"', {
539          'dependencies': [
540            'gcm-aes-aarch64_c_lib',
541          ],
542        }],
543        [ 'disable_altivec==0 and target_arch=="ppc64"', {
544          'dependencies': [
545            'gcm-aes-ppc_c_lib',
546            'gcm-sha512-ppc_c_lib',
547          ],
548        }],
549        [ 'disable_altivec==0 and target_arch=="ppc64le"', {
550          'dependencies': [
551            'gcm-aes-ppc_c_lib',
552            'gcm-sha512-ppc_c_lib',
553            'chacha20-ppc_lib',
554            'ppc-gcm-wrap_c_lib',
555          ],
556        }],
557        [ 'disable_altivec==1 and (target_arch=="ppc64" or target_arch=="ppc64le")', {
558          'defines!': [
559            'NSS_DISABLE_ALTIVEC',
560          ],
561        }],
562        [ 'disable_crypto_vsx==1 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
563          'defines!': [
564            'NSS_DISABLE_CRYPTO_VSX',
565          ],
566        }],
567        [ 'OS=="linux"', {
568          'defines!': [
569            'FREEBL_NO_DEPEND',
570            'FREEBL_LOWHASH',
571            'USE_HW_AES',
572            'INTEL_GCM',
573            'PPC_GCM',
574          ],
575          'conditions': [
576            [ 'target_arch=="x64"', {
577              # The AES assembler code doesn't work in static builds.
578              # The linker complains about non-relocatable code, and I
579              # currently don't know how to fix this properly.
580              'sources!': [
581                'intel-aes.s',
582                'intel-gcm.s',
583              ],
584            }],
585          ],
586        }],
587      ],
588    },
589    {
590      'target_name': '<(freebl_name)',
591      'type': 'shared_library',
592      'includes': [
593        'freebl_base.gypi',
594      ],
595      'dependencies': [
596        '<(DEPTH)/exports.gyp:nss_exports',
597        'hw-acc-crypto-avx',
598        'hw-acc-crypto-avx2',
599      ],
600      'conditions': [
601        [ 'target_arch=="ia32" or target_arch=="x64"', {
602          'dependencies': [
603            'gcm-aes-x86_c_lib',
604          ]
605        }, 'target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64"', {
606          'dependencies': [
607            'armv8_c_lib',
608          ],
609        }],
610        [ '(target_arch=="ia32" or target_arch=="x64") and disable_intel_hw_sha==0', {
611          'dependencies': [
612            'sha-x86_c_lib',
613          ],
614        }],
615        [ 'disable_arm32_neon==0 and target_arch=="arm"', {
616          'dependencies': [
617            'gcm-aes-arm32-neon_c_lib',
618          ],
619        }],
620        [ 'disable_arm32_neon==1 and target_arch=="arm"', {
621          'defines!': [
622            'NSS_DISABLE_ARM32_NEON',
623          ],
624        }],
625        [ 'target_arch=="arm64" or target_arch=="aarch64"', {
626          'dependencies': [
627            'gcm-aes-aarch64_c_lib',
628          ],
629        }],
630        [ 'disable_altivec==0', {
631          'conditions': [
632            [ 'target_arch=="ppc64"', {
633              'dependencies': [
634                'gcm-aes-ppc_c_lib',
635                'gcm-sha512-nodepend-ppc_c_lib',
636              ],
637            }, 'target_arch=="ppc64le"', {
638               'dependencies': [
639                 'gcm-aes-ppc_c_lib',
640                 'gcm-sha512-nodepend-ppc_c_lib',
641                 'ppc-gcm-wrap-nodepend_c_lib',
642               ],
643            }],
644          ],
645        }],
646        [ 'disable_altivec==1 and (target_arch=="ppc64" or target_arch=="ppc64le")', {
647          'defines!': [
648            'NSS_DISABLE_ALTIVEC',
649          ],
650        }],
651        [ 'disable_crypto_vsx==1 and (target_arch=="ppc" or target_arch=="ppc64" or target_arch=="ppc64le")', {
652          'defines!': [
653            'NSS_DISABLE_CRYPTO_VSX',
654          ],
655        }],
656        [ 'OS!="linux"', {
657          'conditions': [
658            [ 'moz_fold_libs==0', {
659              'dependencies': [
660                '<(DEPTH)/lib/util/util.gyp:nssutil3',
661              ],
662            }, {
663              'libraries': [
664                '<(moz_folded_library_name)',
665              ],
666            }],
667          ],
668        }],
669        [ '(OS=="linux" or OS=="android") and target_arch=="x64"', {
670          'dependencies': [
671            'intel-gcm-wrap_c_lib',
672          ],
673        }],
674        [ 'OS=="win" and (target_arch=="ia32" or target_arch=="x64") and cc_is_clang==1', {
675          'dependencies': [
676            'intel-gcm-wrap_c_lib',
677          ],
678        }],
679        [ 'OS=="linux"', {
680          'sources': [
681            'nsslowhash.c',
682            'stubs.c',
683          ],
684        }],
685      ],
686      'variables': {
687       'conditions': [
688         [ 'OS=="linux"', {
689           'mapfile': 'freebl_hash_vector.def',
690         }, {
691           'mapfile': 'freebl.def',
692         }],
693       ]
694      },
695    },
696    {
697      'target_name': 'freebl_64int_3',
698      'includes': [
699        'freebl_base.gypi',
700      ],
701      'type': 'shared_library',
702      'dependencies': [
703        '<(DEPTH)/exports.gyp:nss_exports',
704        'hw-acc-crypto-avx',
705        'hw-acc-crypto-avx2',
706      ],
707    },
708    {
709      'target_name': 'freebl_64fpu_3',
710      'includes': [
711        'freebl_base.gypi',
712      ],
713      'type': 'shared_library',
714      'sources': [
715        'mpi/mpi_sparc.c',
716        'mpi/mpv_sparcv9.s',
717        'mpi/montmulfv9.s',
718      ],
719      'dependencies': [
720        '<(DEPTH)/exports.gyp:nss_exports',
721        'hw-acc-crypto-avx',
722        'hw-acc-crypto-avx2',
723      ],
724      'asflags_mozilla': [
725        '-mcpu=v9', '-Wa,-xarch=v9a'
726      ],
727      'defines': [
728        'MP_NO_MP_WORD',
729        'MP_USE_UINT_DIGIT',
730        'MP_ASSEMBLY_MULTIPLY',
731        'MP_USING_MONT_MULF',
732        'MP_MONT_USE_MP_MUL',
733      ],
734    },
735  ],
736  'conditions': [
737    [ 'OS=="linux"', {
738      # stub build
739      'targets': [
740        {
741          'target_name': 'freebl3',
742          'type': 'shared_library',
743          'defines': [
744            'FREEBL_NO_DEPEND',
745          ],
746          'sources': [
747            'lowhash_vector.c'
748          ],
749          'dependencies': [
750            '<(DEPTH)/exports.gyp:nss_exports'
751          ],
752          'variables': {
753            'mapfile': 'freebl_hash.def'
754          }
755        },
756      ],
757    }],
758  ],
759  'target_defaults': {
760    'include_dirs': [
761      'mpi',
762      'ecl',
763      'verified',
764      'verified/kremlin/include',
765      'verified/kremlin/kremlib/dist/minimal',
766      'deprecated',
767    ],
768    'defines': [
769      'SHLIB_SUFFIX=\"<(dll_suffix)\"',
770      'SHLIB_PREFIX=\"<(dll_prefix)\"',
771      'SHLIB_VERSION=\"3\"',
772      'SOFTOKEN_SHLIB_VERSION=\"3\"',
773      'RIJNDAEL_INCLUDE_TABLES',
774      'MP_API_COMPATIBLE'
775    ],
776    'conditions': [
777      [ 'OS=="win" and target_arch=="ia32"', {
778        'msvs_settings': {
779          'VCCLCompilerTool': {
780            #TODO: -Ox optimize flags
781            'PreprocessorDefinitions': [
782              'MP_ASSEMBLY_MULTIPLY',
783              'MP_ASSEMBLY_SQUARE',
784              'MP_ASSEMBLY_DIV_2DX1D',
785              'MP_USE_UINT_DIGIT',
786              'MP_NO_MP_WORD',
787              'USE_HW_AES',
788              'INTEL_GCM',
789            ],
790          },
791        },
792      }],
793      [ 'OS=="win" and target_arch=="x64"', {
794        'msvs_settings': {
795          'VCCLCompilerTool': {
796            #TODO: -Ox optimize flags
797            'PreprocessorDefinitions': [
798              # Should be copied to mingw defines below
799              'MP_IS_LITTLE_ENDIAN',
800              'NSS_BEVAND_ARCFOUR',
801              'MPI_AMD64',
802              'MP_ASSEMBLY_MULTIPLY',
803              'NSS_USE_COMBA',
804              'USE_HW_AES',
805              'INTEL_GCM',
806            ],
807          },
808        },
809      }],
810      [ '(OS=="win" or OS=="mac" or OS=="ios") and (target_arch=="ia32" or target_arch=="x64") and disable_intel_hw_sha==0', {
811        'defines': [
812          'USE_HW_SHA2',
813        ],
814      }],
815      [ '(OS=="win" or OS=="mac" or OS=="ios") and (target_arch=="arm64" or target_arch=="aarch64") and disable_arm_hw_aes==0', {
816        'defines': [
817          'USE_HW_AES',
818        ],
819      }],
820      [ '(OS=="win" or OS=="mac" or OS=="ios") and (target_arch=="arm64" or target_arch=="aarch64") and disable_arm_hw_sha1==0', {
821        'defines': [
822          'USE_HW_SHA1',
823        ],
824      }],
825      [ '(OS=="win" or OS=="mac" or OS=="ios") and (target_arch=="arm64" or target_arch=="aarch64") and disable_arm_hw_sha2==0', {
826        'defines': [
827          'USE_HW_SHA2',
828        ],
829      }],
830      [ 'cc_use_gnu_ld==1 and OS=="win" and target_arch=="x64"', {
831        # mingw x64
832        'defines': [
833          'MP_IS_LITTLE_ENDIAN',
834         ],
835      }],
836      # MSVC has no __int128 type. Use emulated int128 and leave
837      # have_int128_support as-is for Curve25519 impl. selection.
838      [ 'have_int128_support==1 and (OS!="win" or cc_is_clang==1 or cc_is_gcc==1)', {
839        'defines': [
840          # The Makefile does version-tests on GCC, but we're not doing that here.
841          'HAVE_INT128_SUPPORT',
842        ],
843      }, {
844        'defines': [
845          'KRML_VERIFIED_UINT128',
846        ],
847      }],
848      [ 'OS=="linux"', {
849        'defines': [
850          'FREEBL_LOWHASH',
851          'FREEBL_NO_DEPEND',
852        ],
853        'conditions': [
854          [ 'disable_altivec==0 and target_arch=="ppc64le"', {
855            'defines': [
856              'PPC_GCM',
857            ],
858          }],
859        ],
860      }],
861      [ 'OS=="linux" or OS=="android"', {
862        'conditions': [
863          [ 'target_arch=="x64"', {
864            'defines': [
865              'MP_IS_LITTLE_ENDIAN',
866              'NSS_BEVAND_ARCFOUR',
867              'MPI_AMD64',
868              'MP_ASSEMBLY_MULTIPLY',
869              'NSS_USE_COMBA',
870            ],
871          }],
872          [ 'target_arch=="x64"', {
873            'defines': [
874              'USE_HW_AES',
875              'INTEL_GCM',
876            ],
877          }],
878          [ 'target_arch=="ia32"', {
879            'defines': [
880              'MP_IS_LITTLE_ENDIAN',
881              'MP_ASSEMBLY_MULTIPLY',
882              'MP_ASSEMBLY_SQUARE',
883              'MP_ASSEMBLY_DIV_2DX1D',
884              'MP_USE_UINT_DIGIT',
885            ],
886          }],
887          [ 'target_arch=="arm"', {
888            'defines': [
889              'MP_ASSEMBLY_MULTIPLY',
890              'MP_ASSEMBLY_SQUARE',
891              'MP_USE_UINT_DIGIT',
892              'SHA_NO_LONG_LONG',
893              'ARMHF',
894            ],
895          }],
896          [ 'disable_intel_hw_sha==0 and (target_arch=="ia32" or target_arch=="x64")', {
897            'defines': [
898              'USE_HW_SHA2',
899            ],
900          }],
901          [ 'disable_arm_hw_aes==0 and (target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64")', {
902            'defines': [
903              'USE_HW_AES',
904            ],
905          }],
906          [ 'disable_arm_hw_sha1==0 and (target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64")', {
907            'defines': [
908              'USE_HW_SHA1',
909            ],
910          }],
911          [ 'disable_arm_hw_sha2==0 and (target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64")', {
912            'defines': [
913              'USE_HW_SHA2',
914            ],
915          }],
916        ],
917      }],
918    ],
919  },
920  'variables': {
921    'module': 'nss',
922    'conditions': [
923      [ 'target_arch=="x64" or target_arch=="arm64" or target_arch=="aarch64"', {
924        'have_int128_support%': 1,
925      }, {
926        'have_int128_support%': 0,
927      }],
928      [ 'target_arch=="arm"', {
929        # When the compiler uses the softfloat ABI, we want to use the compatible softfp ABI when enabling NEON for these objects.
930        # Confusingly, __SOFTFP__ is the name of the define for the softfloat ABI, not for the softfp ABI.
931        'softfp_cflags': '<!(${CC:-cc} -o - -E -dM - ${CFLAGS} < /dev/null | grep __SOFTFP__ > /dev/null && echo -mfloat-abi=softfp || true)',
932      }],
933    ],
934  }
935}
936