blob: 7f599a9a935334b9b03e89d6ea216d464bcce275 [file] [log] [blame]
akmhoque05d5fcf2014-04-15 14:58:45 -05001#! /usr/bin/env python
2# encoding: utf-8
3
4'''
5
6When using this tool, the wscript will look like:
7
8 def options(opt):
9 opt.tool_options('openssl')
10
11 def configure(conf):
12 conf.load('compiler_c openssl')
13
14 conf.check_openssl()
15
16 def build(bld):
17 bld(source='main.cpp', target='app', use='OPENSSL')
18
19'''
20
21from waflib import Options
22from waflib.Configure import conf
23
24@conf
25def check_openssl(self,*k,**kw):
26 root = k and k[0] or kw.get('path',None) or Options.options.with_openssl
27 mandatory = kw.get('mandatory', True)
28 var = kw.get('var', 'OPENSSL')
29
30 CODE = """
31#include <openssl/crypto.h>
32#include <stdio.h>
33
34int main(int argc, char **argv) {
35 (void)argc;
36 printf ("%s", argv[0]);
37
38 return 0;
39}
40"""
41 if root:
42 libcrypto = self.check_cc (lib=['ssl', 'crypto'],
43 header_name='openssl/crypto.h',
44 define_name='HAVE_%s' % var,
45 uselib_store=var,
46 mandatory = mandatory,
47 cflags="-I%s/include" % root,
48 linkflags="-L%s/lib" % root,
49 execute = True, fragment = CODE, define_ret = True)
50 else:
51 libcrypto = self.check_cc (lib=['ssl', 'crypto'],
52 header_name='openssl/crypto.h',
53 define_name='HAVE_%s' % var,
54 uselib_store=var,
55 mandatory = mandatory,
56 execute = True, fragment = CODE, define_ret = True)
57
58def options(opt):
59 opt.add_option('--with-openssl',type='string',default='',dest='with_openssl',help='''Path to OpenSSL''')