| 1 | import feature : feature ;
|
|---|
| 2 | import project ;
|
|---|
| 3 | import "class" : new ;
|
|---|
| 4 | import targets ;
|
|---|
| 5 | import property-set ;
|
|---|
| 6 | import common ;
|
|---|
| 7 | import type ;
|
|---|
| 8 | import toolset : flags ;
|
|---|
| 9 |
|
|---|
| 10 | # Make this module into a project.
|
|---|
| 11 | project.initialize $(__name__) ;
|
|---|
| 12 | project openssl ;
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
|
|---|
| 16 | {
|
|---|
| 17 | .debug-configuration = true ;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | rule initialized ( )
|
|---|
| 21 | {
|
|---|
| 22 | return $(.initialized) ;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | rule isEnabled ( )
|
|---|
| 26 | {
|
|---|
| 27 | return $(.enabled) ;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | rule isDebug ( )
|
|---|
| 31 | {
|
|---|
| 32 | return $(.debug-configuration) ;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | rule getHeaders ( ) {
|
|---|
| 37 | return $(.headers) ;
|
|---|
| 38 | }
|
|---|
| 39 | rule getLibraries ( ) {
|
|---|
| 40 | return $(.libraries) ;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | rule printEnv ( )
|
|---|
| 44 | {
|
|---|
| 45 | echo "OPENSSL LIBRARIES : $(.libraries) change with --with-openssl-lib=<path>" ;
|
|---|
| 46 | echo "OPENSSL HEADERS : $(.headers) change with --with-openssl=<path>" ;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | # Initialize openssl support.
|
|---|
| 51 | rule init (
|
|---|
| 52 | version ? :
|
|---|
| 53 | headers # Location of header files
|
|---|
| 54 | libraries * # Location of libraries, lib and bin subdirs of STLport.
|
|---|
| 55 | )
|
|---|
| 56 | {
|
|---|
| 57 |
|
|---|
| 58 | if $(.initialized)
|
|---|
| 59 | {
|
|---|
| 60 | errors.error "Attempt the reinitialize openssl!" ;
|
|---|
| 61 | }
|
|---|
| 62 | else
|
|---|
| 63 | {
|
|---|
| 64 |
|
|---|
| 65 | .initialized = true ;
|
|---|
| 66 | .headers = $(headers) ;
|
|---|
| 67 | .libraries = $(libraries) ;
|
|---|
| 68 |
|
|---|
| 69 | local has-openssl = [ MATCH "^--with-openssl=(.*)" : [ modules.peek : ARGV ] ] ;
|
|---|
| 70 | if $(has-openssl) {
|
|---|
| 71 | .headers = $(has-openssl) ;
|
|---|
| 72 | }
|
|---|
| 73 | local has-openssl-lib = [ MATCH "^--with-openssl-lib=(.*)" : [ modules.peek : ARGV ] ] ;
|
|---|
| 74 | local has-generic-lib = [ MATCH "^--library-path=(.*)" : [ modules.peek : ARGV ] ] ;
|
|---|
| 75 | if $(has-openssl-lib) {
|
|---|
| 76 | .libraries = $(has-openssl-lib) ;
|
|---|
| 77 | } else if $(has-generic-lib) {
|
|---|
| 78 | .libraries = $(has-generic-lib) ;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | import toolset : flags ;
|
|---|
| 82 |
|
|---|
| 83 | if ( ( --with-openssl in [ modules.peek : ARGV ] ) || $(has-openssl) || $(has-openssl-lib) )
|
|---|
| 84 | && ! ( --without-openssl in [ modules.peek : ARGV ] ) {
|
|---|
| 85 | .enabled = true ;
|
|---|
| 86 | } else {
|
|---|
| 87 | .enabled = false ;
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | local project = [ project.current ] ;
|
|---|
| 91 | project.pop-current ;
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | rule generate-lib-usage-requirements ( properties * )
|
|---|
| 96 | {
|
|---|
| 97 | local result ;
|
|---|
| 98 | result += <include>$(.headers) ;
|
|---|
| 99 | result += <library-path>$(.libraries) ;
|
|---|
| 100 | result += <threading>multi ;
|
|---|
| 101 | result += <allow>openssl ;
|
|---|
| 102 | return $(result) ;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | lib libeay32 : $(main)
|
|---|
| 107 | : # requirements
|
|---|
| 108 | <name>libeay32
|
|---|
| 109 | : # default-build
|
|---|
| 110 | : # usage-requirements
|
|---|
| 111 | <conditional>@generate-lib-usage-requirements
|
|---|
| 112 | ;
|
|---|
| 113 | lib ssleay32 : $(main)
|
|---|
| 114 | : # requirements
|
|---|
| 115 | <name>ssleay32
|
|---|
| 116 | : # default-build
|
|---|
| 117 | : # usage-requirements
|
|---|
| 118 | <conditional>@generate-lib-usage-requirements
|
|---|
| 119 | ;
|
|---|
| 120 | lib gdi32 ;
|
|---|
| 121 |
|
|---|
| 122 | alias openssl
|
|---|
| 123 | : # source
|
|---|
| 124 | : # requirements
|
|---|
| 125 | <conditional>@requirements
|
|---|
| 126 | #<name>openssl
|
|---|
| 127 | : # default-build
|
|---|
| 128 | : # usage-requirements
|
|---|
| 129 | <conditional>@usage-requirements
|
|---|
| 130 | ;
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | rule requirements ( properties * )
|
|---|
| 134 | {
|
|---|
| 135 | local result ;
|
|---|
| 136 | if ( $(.enabled) = true ) {
|
|---|
| 137 | result += <source>libeay32 ;
|
|---|
| 138 | result += <source>ssleay32 ;
|
|---|
| 139 | result += <source>gdi32 ;
|
|---|
| 140 | }
|
|---|
| 141 | return $(result) ;
|
|---|
| 142 | }
|
|---|
| 143 | rule usage-requirements ( properties * )
|
|---|
| 144 | {
|
|---|
| 145 | local result ;
|
|---|
| 146 | if ( $(.enabled) = true ) {
|
|---|
| 147 | result += <define>USE_OPENSSL ;
|
|---|
| 148 | result += <define>USE_SSL ;
|
|---|
| 149 | }
|
|---|
| 150 | return $(result) ;
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | alias socket
|
|---|
| 154 | : # source
|
|---|
| 155 | : # requirements
|
|---|
| 156 | <conditional>@socket-requirements
|
|---|
| 157 | #<name>openssl
|
|---|
| 158 | : # default-build
|
|---|
| 159 | : # usage-requirements
|
|---|
| 160 | ;
|
|---|
| 161 |
|
|---|
| 162 | rule socket-requirements ( properties * )
|
|---|
| 163 | {
|
|---|
| 164 | local result ;
|
|---|
| 165 | result += <source>include/Socket.cpp ;
|
|---|
| 166 | if ( $(.enabled) = true ) {
|
|---|
| 167 | result += <source>include/sslSocket.cpp ;
|
|---|
| 168 | result += <source>openssl ;
|
|---|
| 169 | }
|
|---|
| 170 | return $(result) ;
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|