1# Copyright (c) 2012 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5{
6  'variables': {
7    'use_system_libsrtp%': 0,
8  },
9  'target_defaults': {
10    'defines': [
11      'HAVE_STDLIB_H',
12      'HAVE_STRING_H',
13    ],
14    'include_dirs': [
15      './config',
16      'srtp/include',
17      'srtp/crypto/include',
18    ],
19    'conditions': [
20      ['os_posix==1', {
21        'defines': [
22          'HAVE_INT16_T',
23          'HAVE_INT32_T',
24          'HAVE_INT8_T',
25          'HAVE_UINT16_T',
26          'HAVE_UINT32_T',
27          'HAVE_UINT64_T',
28          'HAVE_UINT8_T',
29          'HAVE_STDINT_H',
30          'HAVE_INTTYPES_H',
31          'HAVE_NETINET_IN_H',
32          'INLINE=inline',
33        ],
34      }],
35      ['OS=="win"', {
36        'defines': [
37          'INLINE=__inline',
38          'HAVE_BYTESWAP_METHODS_H',
39          # All Windows architectures are this way.
40          'SIZEOF_UNSIGNED_LONG=4',
41          'SIZEOF_UNSIGNED_LONG_LONG=8',
42         ],
43      }],
44      ['target_arch=="x64" or target_arch=="ia32"', {
45        'defines': [
46          'CPU_CISC',
47        ],
48      }],
49      ['target_arch=="arm" or target_arch=="armv7" or target_arch=="arm64"', {
50        'defines': [
51          # TODO(leozwang): CPU_RISC doesn't work properly on android/arm
52          # platform for unknown reasons, need to investigate the root cause
53          # of it. CPU_RISC is used for optimization only, and CPU_CISC should
54          # just work just fine, it has been tested on android/arm with srtp
55          # test applications and libjingle.
56          'CPU_CISC',
57        ],
58      }],
59      ['target_arch=="mipsel" or target_arch=="mips64el"', {
60        'defines': [
61          'CPU_RISC',
62        ],
63      }],
64      ['target_arch=="mipsel" or target_arch=="arm" or target_arch=="armv7" or target_arch=="ia32"', {
65        'defines': [
66          # Define FORCE_64BIT_ALIGN to avoid alignment-related-crashes like
67          # crbug/414919. Without this, aes_cbc_alloc will allocate an
68          # aes_cbc_ctx_t not 64-bit aligned and the v128_t members of
69          # aes_cbc_ctx_t will not be 64-bit aligned, which breaks the
70          # compiler optimizations that assume 64-bit alignment of v128_t.
71          'FORCE_64BIT_ALIGN',
72        ],
73      }],
74    ],
75    'direct_dependent_settings': {
76      'include_dirs': [
77        './config',
78        'srtp/include',
79        'srtp/crypto/include',
80      ],
81      'conditions': [
82        ['os_posix==1', {
83          'defines': [
84            'HAVE_INT16_T',
85            'HAVE_INT32_T',
86            'HAVE_INT8_T',
87            'HAVE_UINT16_T',
88            'HAVE_UINT32_T',
89            'HAVE_UINT64_T',
90            'HAVE_UINT8_T',
91            'HAVE_STDINT_H',
92            'HAVE_INTTYPES_H',
93            'HAVE_NETINET_IN_H',
94            'INLINE=inline',
95          ],
96        }],
97        ['OS=="win"', {
98          'defines': [
99            'INLINE=__inline',
100            'HAVE_BYTESWAP_METHODS_H',
101            # All Windows architectures are this way.
102            'SIZEOF_UNSIGNED_LONG=4',
103            'SIZEOF_UNSIGNED_LONG_LONG=8',
104           ],
105        }],
106        ['target_arch=="x64" or target_arch=="ia32"', {
107          'defines': [
108            'CPU_CISC',
109          ],
110        }],
111        ['target_arch=="mipsel" or target_arch=="mips64el"', {
112          'defines': [
113            'CPU_RISC',
114          ],
115        }],
116      ],
117    },
118  },
119  'conditions': [
120    ['use_system_libsrtp==0', {
121      'targets': [
122        {
123          'target_name': 'libsrtp',
124          'type': 'static_library',
125          'sources': [
126            # includes
127            'srtp/include/ekt.h',
128            'srtp/include/getopt_s.h',
129            'srtp/include/rtp.h',
130            'srtp/include/rtp_priv.h',
131            'srtp/include/srtp.h',
132            'srtp/include/srtp_priv.h',
133            'srtp/include/ut_sim.h',
134
135            # headers
136            'srtp/crypto/include/aes_cbc.h',
137            'srtp/crypto/include/aes.h',
138            'srtp/crypto/include/aes_icm.h',
139            'srtp/crypto/include/alloc.h',
140            'srtp/crypto/include/auth.h',
141            'srtp/crypto/include/cipher.h',
142            'srtp/crypto/include/cryptoalg.h',
143            'srtp/crypto/include/crypto.h',
144            'srtp/crypto/include/crypto_kernel.h',
145            'srtp/crypto/include/crypto_math.h',
146            'srtp/crypto/include/crypto_types.h',
147            'srtp/crypto/include/datatypes.h',
148            'srtp/crypto/include/err.h',
149            'srtp/crypto/include/gf2_8.h',
150            'srtp/crypto/include/hmac.h',
151            'srtp/crypto/include/integers.h',
152            'srtp/crypto/include/kernel_compat.h',
153            'srtp/crypto/include/key.h',
154            'srtp/crypto/include/null_auth.h',
155            'srtp/crypto/include/null_cipher.h',
156            'srtp/crypto/include/prng.h',
157            'srtp/crypto/include/rand_source.h',
158            'srtp/crypto/include/rdb.h',
159            'srtp/crypto/include/rdbx.h',
160            'srtp/crypto/include/sha1.h',
161            'srtp/crypto/include/stat.h',
162            'srtp/crypto/include/xfm.h',
163
164            # sources
165            'srtp/srtp/ekt.c',
166            'srtp/srtp/srtp.c',
167
168            'srtp/crypto/cipher/aes.c',
169            'srtp/crypto/cipher/aes_cbc.c',
170            'srtp/crypto/cipher/aes_icm.c',
171            'srtp/crypto/cipher/cipher.c',
172            'srtp/crypto/cipher/null_cipher.c',
173            'srtp/crypto/hash/auth.c',
174            'srtp/crypto/hash/hmac.c',
175            'srtp/crypto/hash/null_auth.c',
176            'srtp/crypto/hash/sha1.c',
177            'srtp/crypto/kernel/alloc.c',
178            'srtp/crypto/kernel/crypto_kernel.c',
179            'srtp/crypto/kernel/err.c',
180            'srtp/crypto/kernel/key.c',
181            'srtp/crypto/math/datatypes.c',
182            'srtp/crypto/math/gf2_8.c',
183            'srtp/crypto/math/stat.c',
184            'srtp/crypto/replay/rdb.c',
185            'srtp/crypto/replay/rdbx.c',
186            'srtp/crypto/replay/ut_sim.c',
187            'srtp/crypto/rng/ctr_prng.c',
188            'srtp/crypto/rng/prng.c',
189            'srtp/crypto/rng/rand_source.c',
190          ],
191        }, # target libsrtp
192        {
193          'target_name': 'rdbx_driver',
194          'type': 'executable',
195          'dependencies': [
196            'libsrtp',
197          ],
198          'sources': [
199            'srtp/include/getopt_s.h',
200            'srtp/test/getopt_s.c',
201            'srtp/test/rdbx_driver.c',
202          ],
203        },
204        {
205          'target_name': 'srtp_driver',
206          'type': 'executable',
207          'dependencies': [
208            'libsrtp',
209          ],
210          'sources': [
211            'srtp/include/getopt_s.h',
212            'srtp/include/srtp_priv.h',
213            'srtp/test/getopt_s.c',
214            'srtp/test/srtp_driver.c',
215          ],
216        },
217        {
218          'target_name': 'roc_driver',
219          'type': 'executable',
220          'dependencies': [
221            'libsrtp',
222          ],
223          'sources': [
224            'srtp/crypto/include/rdbx.h',
225            'srtp/include/ut_sim.h',
226            'srtp/test/roc_driver.c',
227          ],
228        },
229        {
230          'target_name': 'replay_driver',
231          'type': 'executable',
232          'dependencies': [
233            'libsrtp',
234          ],
235          'sources': [
236            'srtp/crypto/include/rdbx.h',
237            'srtp/include/ut_sim.h',
238            'srtp/test/replay_driver.c',
239          ],
240        },
241        {
242          'target_name': 'rtpw',
243          'type': 'executable',
244          'dependencies': [
245            'libsrtp',
246          ],
247          'sources': [
248            'srtp/include/getopt_s.h',
249            'srtp/include/rtp.h',
250            'srtp/include/srtp.h',
251            'srtp/crypto/include/datatypes.h',
252            'srtp/test/getopt_s.c',
253            'srtp/test/rtp.c',
254            'srtp/test/rtpw.c',
255          ],
256          'conditions': [
257            ['OS=="android"', {
258              'defines': [
259                'HAVE_SYS_SOCKET_H',
260              ],
261            }],
262          ],
263        },
264        {
265          'target_name': 'srtp_test_cipher_driver',
266          'type': 'executable',
267          'dependencies': [
268            'libsrtp',
269          ],
270          'sources': [
271            'srtp/crypto/test/cipher_driver.c',
272          ],
273        },
274        {
275          'target_name': 'srtp_test_datatypes_driver',
276          'type': 'executable',
277          'dependencies': [
278            'libsrtp',
279          ],
280          'sources': [
281            'srtp/crypto/test/datatypes_driver.c',
282          ],
283        },
284        {
285          'target_name': 'srtp_test_stat_driver',
286          'type': 'executable',
287          'dependencies': [
288            'libsrtp',
289          ],
290          'sources': [
291            'srtp/crypto/test/stat_driver.c',
292          ],
293        },
294        {
295          'target_name': 'srtp_test_sha1_driver',
296          'type': 'executable',
297          'dependencies': [
298            'libsrtp',
299          ],
300          'sources': [
301            'srtp/crypto/test/sha1_driver.c',
302          ],
303        },
304        {
305          'target_name': 'srtp_test_kernel_driver',
306          'type': 'executable',
307          'dependencies': [
308            'libsrtp',
309          ],
310          'sources': [
311            'srtp/crypto/test/kernel_driver.c',
312          ],
313        },
314        {
315          'target_name': 'srtp_test_aes_calc',
316          'type': 'executable',
317          'dependencies': [
318            'libsrtp',
319          ],
320          'sources': [
321            'srtp/crypto/test/aes_calc.c',
322          ],
323        },
324        {
325          'target_name': 'srtp_test_rand_gen',
326          'type': 'executable',
327          'dependencies': [
328            'libsrtp',
329          ],
330          'sources': [
331            'srtp/crypto/test/rand_gen.c',
332          ],
333        },
334        {
335          'target_name': 'srtp_test_env',
336          'type': 'executable',
337          'dependencies': [
338            'libsrtp',
339          ],
340          'sources': [
341            'srtp/crypto/test/env.c',
342          ],
343        },
344        {
345          'target_name': 'srtp_runtest',
346          'type': 'none',
347          'dependencies': [
348            'rdbx_driver',
349            'srtp_driver',
350            'roc_driver',
351            'replay_driver',
352            'rtpw',
353            'srtp_test_cipher_driver',
354            'srtp_test_datatypes_driver',
355            'srtp_test_stat_driver',
356            'srtp_test_sha1_driver',
357            'srtp_test_kernel_driver',
358            'srtp_test_aes_calc',
359            'srtp_test_rand_gen',
360            'srtp_test_env',
361          ],
362        },
363      ], # targets
364    }, { # use_system_libsrtp==1
365      'targets': [
366        {
367          'target_name': 'libsrtp',
368          'type': 'none',
369          'direct_dependent_settings': {
370            'defines': [
371              'USE_SYSTEM_LIBSRTP',
372            ],
373            'include_dirs': [
374              '/usr/include/srtp',
375            ],
376          },
377          'link_settings': {
378            'libraries': [
379              '-lsrtp',
380            ],
381          },
382        }, # target libsrtp
383      ], # targets
384    }],
385  ],
386}
387