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): |
| 12 | conf.load('compiler_c openssl') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 13 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 14 | conf.check_openssl() |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 15 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 16 | def build(bld): |
| 17 | bld(source='main.cpp', target='app', use='OPENSSL') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 18 | |
| 19 | ''' |
| 20 | |
| 21 | from waflib import Options |
| 22 | from waflib.Configure import conf |
| 23 | |
| 24 | @conf |
| 25 | def check_openssl(self,*k,**kw): |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 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') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 30 | CODE = """ |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 31 | #include <openssl/crypto.h> |
| 32 | #include <stdio.h> |
| 33 | |
| 34 | int main(int argc, char **argv) { |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 35 | (void)argc; |
| 36 | printf("%s", argv[0]); |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 37 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 38 | return 0; |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 39 | } |
| 40 | """ |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 41 | 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 Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 57 | |
| 58 | def options(opt): |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 59 | opt.add_option('--with-openssl', type='string', default='', |
| 60 | dest='with_openssl', help='''Path to OpenSSL''') |