Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | # encoding: utf-8 |
| 3 | |
| 4 | ''' |
| 5 | |
| 6 | When using this tool, the wscript will look like: |
| 7 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 8 | def options(opt): |
| 9 | opt.tool_options('openssl') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 11 | def configure(conf): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 12 | conf.load('compiler_cxx openssl') |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 13 | conf.check_openssl() |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 14 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 15 | def build(bld): |
| 16 | bld(source='main.cpp', target='app', use='OPENSSL') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 17 | |
| 18 | ''' |
| 19 | |
| 20 | from waflib import Options |
| 21 | from waflib.Configure import conf |
| 22 | |
| 23 | @conf |
| 24 | def check_openssl(self,*k,**kw): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 25 | root = k and k[0] or kw.get('path', None) or Options.options.with_openssl |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 26 | mandatory = kw.get('mandatory', True) |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 27 | var = kw.get('uselib_store', 'OPENSSL') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 28 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 29 | if root: |
| 30 | libcrypto = self.check_cxx(lib=['ssl', 'crypto'], |
| 31 | msg='Checking for OpenSSL library', |
| 32 | define_name='HAVE_%s' % var, |
| 33 | uselib_store=var, |
| 34 | mandatory=mandatory, |
Alexander Afanasyev | 96d523b | 2014-04-10 16:03:49 -0700 | [diff] [blame] | 35 | cxxflags="-I%s/include" % root, |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 36 | linkflags="-L%s/lib" % root) |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 37 | else: |
| 38 | libcrypto = self.check_cxx(lib=['ssl', 'crypto'], |
| 39 | msg='Checking for OpenSSL library', |
| 40 | define_name='HAVE_%s' % var, |
| 41 | uselib_store=var, |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 42 | mandatory=mandatory) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 43 | |
| 44 | def options(opt): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 45 | opt.add_option('--with-openssl', type='string', default=None, |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 46 | dest='with_openssl', help='''Path to OpenSSL''') |