blob: 4a5c01f45bf4932f0929893d242716e136f1b537 [file] [log] [blame]
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -08001#! /usr/bin/env python
2# encoding: utf-8
3
4'''
5
6When using this tool, the wscript will look like:
7
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -07008 def options(opt):
9 opt.tool_options('openssl')
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080010
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070011 def configure(conf):
12 conf.load('compiler_c openssl')
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080013
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070014 conf.check_openssl()
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080015
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070016 def build(bld):
17 bld(source='main.cpp', target='app', use='OPENSSL')
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080018
19'''
20
21from waflib import Options
22from waflib.Configure import conf
23
24@conf
25def check_openssl(self,*k,**kw):
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070026 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')
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080029
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070030 CODE = """
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080031#include <openssl/crypto.h>
32#include <stdio.h>
33
34int main(int argc, char **argv) {
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070035 (void)argc;
36 printf("%s", argv[0]);
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080037
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070038 return 0;
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080039}
40"""
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070041 if root:
42 libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
43 msg='Checking for OpenSSL library',
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 fragment=CODE)
50 else:
51 libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
52 msg='Checking for OpenSSL library',
53 define_name='HAVE_%s' % var,
54 uselib_store=var,
55 mandatory=mandatory,
56 fragment=CODE)
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -080057
58def options(opt):
Alexander Afanasyev5e1288e2014-03-28 11:11:48 -070059 opt.add_option('--with-openssl', type='string', default='',
60 dest='with_openssl', help='''Path to OpenSSL''')