Jamfile 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import feature : feature ;
  2. project libdatachannel ;
  3. path-constant CWD : . ;
  4. feature gnutls : off on : composite propagated ;
  5. feature.compose <gnutls>off
  6. : <define>USE_GNUTLS=0 ;
  7. feature.compose <gnutls>on
  8. : <define>USE_GNUTLS=1 ;
  9. lib libdatachannel
  10. : # sources
  11. [ glob ./src/*.cpp ]
  12. [ glob ./src/impl/*.cpp ]
  13. : # requirements
  14. <cxxstd>17
  15. <include>./include
  16. <include>./include/rtc
  17. <include>./src
  18. <define>RTC_ENABLE_MEDIA=0
  19. <define>RTC_ENABLE_WEBSOCKET=0
  20. <define>USE_NICE=0
  21. <define>RTC_EXPORTS
  22. <define>RTC_STATIC
  23. <toolset>msvc:<define>WIN32_LEAN_AND_MEAN
  24. <toolset>msvc:<define>NOMINMAX
  25. <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
  26. <library>/libdatachannel//usrsctp
  27. <library>/libdatachannel//juice
  28. <library>/libdatachannel//plog
  29. <gnutls>on:<library>gnutls/<link>shared
  30. <gnutls>off:<library>ssl
  31. <gnutls>off:<library>crypto
  32. : # default build
  33. <link>static
  34. : # usage requirements
  35. <include>./include
  36. <define>RTC_ENABLE_MEDIA=0
  37. <define>RTC_ENABLE_WEBSOCKET=0
  38. <define>RTC_STATIC
  39. <library>/libdatachannel//plog
  40. <toolset>gcc:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
  41. <toolset>clang:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
  42. ;
  43. alias plog
  44. : # no sources
  45. : # no build requirements
  46. : # no default build
  47. : # usage requirements
  48. <include>./deps/plog/include
  49. ;
  50. alias usrsctp
  51. : # no sources
  52. : # no build requirements
  53. : # no default build
  54. : # usage requirements
  55. <include>./deps/usrsctp/usrsctplib
  56. <library>libusrsctp.a
  57. ;
  58. alias usrsctp
  59. : # no sources
  60. : <toolset>msvc
  61. : # no default build
  62. : # usage requirements
  63. <include>./deps/usrsctp/usrsctplib
  64. <library>usrsctp.lib
  65. ;
  66. alias juice
  67. : # no sources
  68. : # no build requirements
  69. : # no default build
  70. : # usage requirements
  71. <include>./deps/libjuice/include
  72. <define>JUICE_STATIC
  73. <gnutls>on:<library>libjuice-gnutls.a
  74. <gnutls>on:<library>nettle/<link>shared
  75. <gnutls>off:<library>libjuice-openssl.a
  76. ;
  77. alias juice
  78. : # no sources
  79. : <toolset>msvc
  80. : # no default build
  81. : # usage requirements
  82. <include>./deps/libjuice/include
  83. <define>JUICE_STATIC
  84. <library>juice-static.lib
  85. ;
  86. make libusrsctp.a : : @make_libusrsctp ;
  87. make usrsctp.lib : : @make_libusrsctp_msvc ;
  88. rule make_libusrsctp ( targets * : sources * : properties * )
  89. {
  90. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  91. VARIANT on $(targets) = $(VARIANT) ;
  92. BUILD_DIR on $(targets) = "build-$(VARIANT)" ;
  93. }
  94. actions make_libusrsctp
  95. {
  96. (cd $(CWD)/deps/usrsctp && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake -DCMAKE_BUILD_TYPE=$(VARIANT) -DCMAKE_C_FLAGS="-fPIC" -Dsctp_werror=0 -Dsctp_build_shared_lib=0 -Dsctp_build_programs=0 -Dsctp_inet=0 -Dsctp_inet6=0 .. && make -j2 usrsctp)
  97. cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/libusrsctp.a $(<)
  98. }
  99. rule make_libusrsctp_msvc ( targets * : sources * : properties * )
  100. {
  101. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  102. VARIANT on $(targets) = $(VARIANT) ;
  103. BUILD_DIR on $(targets) = "build-$(VARIANT)" ;
  104. }
  105. actions make_libusrsctp_msvc
  106. {
  107. SET OLDD=%CD%
  108. cd $(CWD)/deps/usrsctp
  109. mkdir $(BUILD_DIR)
  110. cd $(BUILD_DIR)
  111. cmake -G "Visual Studio 16 2019" -Dsctp_werror=0 -Dsctp_build_shared_lib=0 -Dsctp_build_programs=0 -Dsctp_inet=0 -Dsctp_inet6=0 ..
  112. msbuild usrsctplib.sln /property:Configuration=$(VARIANT)
  113. cd %OLDD%
  114. cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/Release/usrsctp.lib $(<)
  115. }
  116. make libjuice-gnutls.a : : @make_libjuice_gnutls ;
  117. make libjuice-openssl.a : : @make_libjuice_openssl ;
  118. make juice-static.lib : : @make_libjuice_msvc ;
  119. rule make_libjuice_gnutls ( targets * : sources * : properties * )
  120. {
  121. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  122. BUILD_DIR on $(targets) = "build-gnutls-$(VARIANT)" ;
  123. CMAKEOPTS on $(targets) = "-DCMAKE_C_FLAGS=\"-fPIC\" -DCMAKE_BUILD_TYPE=$(VARIANT) -DUSE_NETTLE=1" ;
  124. }
  125. actions make_libjuice_gnutls
  126. {
  127. (cd $(CWD)/deps/libjuice && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(CMAKEOPTS) .. && make -j2 juice-static)
  128. cp $(CWD)/deps/libjuice/$(BUILD_DIR)/libjuice-static.a $(<)
  129. }
  130. rule make_libjuice_openssl ( targets * : sources * : properties * )
  131. {
  132. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  133. BUILD_DIR on $(targets) = "build-openssl-$(VARIANT)" ;
  134. CMAKEOPTS on $(targets) = "-DCMAKE_C_FLAGS=\"-fPIC\" -DCMAKE_BUILD_TYPE=$(VARIANT) -DUSE_NETTLE=0" ;
  135. local OPENSSL_INCLUDE = [ feature.get-values <openssl-include> : $(properties) ] ;
  136. if <target-os>darwin in $(properties) && $(OPENSSL_INCLUDE) = ""
  137. {
  138. # on macOS, default to pick up openssl from the homebrew installation
  139. # brew install openssl
  140. OPENSSL_INCLUDE = /opt/homebrew/opt/openssl /usr/local/opt/openssl/include ;
  141. }
  142. if $(OPENSSL_INCLUDE) != ""
  143. { CMAKEOPTS on $(targets) += " -DOPENSSL_ROOT_DIR=$(OPENSSL_INCLUDE)/.." ; }
  144. }
  145. actions make_libjuice_openssl
  146. {
  147. (cd $(CWD)/deps/libjuice && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(CMAKEOPTS) .. && make -j2 juice-static)
  148. cp $(CWD)/deps/libjuice/$(BUILD_DIR)/libjuice-static.a $(<)
  149. }
  150. rule make_libjuice_msvc ( targets * : sources * : properties * )
  151. {
  152. local VARIANT = [ feature.get-values <variant> : $(properties) ] ;
  153. VARIANT on $(targets) = $(VARIANT) ;
  154. if <gnutls>on in $(properties)
  155. {
  156. BUILD_DIR on $(targets) += "build-gnutls-$(VARIANT)" ;
  157. CMAKEOPTS on $(targets) = "-DUSE_NETTLE=1" ;
  158. }
  159. else
  160. {
  161. BUILD_DIR on $(targets) += "build-openssl-$(VARIANT)" ;
  162. CMAKEOPTS on $(targets) = "-DUSE_NETTLE=0" ;
  163. }
  164. }
  165. actions make_libjuice_msvc
  166. {
  167. SET OLDD=%CD%
  168. cd $(CWD)/deps/libjuice
  169. mkdir $(BUILD_DIR)
  170. cd $(BUILD_DIR)
  171. cmake -G "Visual Studio 16 2019" $(CMAKEOPTS) ..
  172. msbuild libjuice.sln /property:Configuration=$(VARIANT)
  173. cd %OLDD%
  174. cp $(CWD)/deps/libjuice/$(BUILD_DIR)/Release/juice-static.lib $(<)
  175. }
  176. # the search path to pick up the openssl libraries from. This is the <search>
  177. # property of those libraries
  178. rule openssl-lib-path ( properties * )
  179. {
  180. local OPENSSL_LIB = [ feature.get-values <openssl-lib> : $(properties) ] ;
  181. if <target-os>darwin in $(properties) && $(OPENSSL_LIB) = ""
  182. {
  183. # on macOS, default to pick up openssl from the homebrew installation
  184. # brew install openssl
  185. OPENSSL_LIB = /opt/homebrew/opt/openssl/lib /usr/local/opt/openssl/lib ;
  186. }
  187. else if <target-os>windows in $(properties) && $(OPENSSL_LIB) = ""
  188. {
  189. # on windows, assume openssl is installed to c:\OpenSSL-Win32
  190. if <address-model>64 in $(properties)
  191. { OPENSSL_LIB = c:\\OpenSSL-Win64\\lib ; }
  192. else
  193. { OPENSSL_LIB = c:\\OpenSSL-Win32\\lib ; }
  194. }
  195. local result ;
  196. result += <search>$(OPENSSL_LIB) ;
  197. return $(result) ;
  198. }
  199. # the include path to pick up openssl headers from. This is the
  200. # usage-requirement for the openssl-related libraries
  201. rule openssl-include-path ( properties * )
  202. {
  203. local OPENSSL_INCLUDE = [ feature.get-values <openssl-include> : $(properties) ] ;
  204. if <target-os>darwin in $(properties) && $(OPENSSL_INCLUDE) = ""
  205. {
  206. # on macOS, default to pick up openssl from the homebrew installation
  207. # brew install openssl
  208. OPENSSL_INCLUDE = /opt/homebrew/opt/openssl/include /usr/local/opt/openssl/include ;
  209. }
  210. else if <target-os>windows in $(properties) && $(OPENSSL_INCLUDE) = ""
  211. {
  212. # on windows, assume openssl is installed to c:\OpenSSL-Win32
  213. if <address-model>64 in $(properties)
  214. { OPENSSL_INCLUDE = c:\\OpenSSL-Win64\\include ; }
  215. else
  216. { OPENSSL_INCLUDE = c:\\OpenSSL-Win32\\include ; }
  217. }
  218. local result ;
  219. result += <include>$(OPENSSL_INCLUDE) ;
  220. return $(result) ;
  221. }
  222. # libraries for OpenSSL on Windows
  223. lib advapi32 : : <name>advapi32 ;
  224. lib user32 : : <name>user32 ;
  225. lib shell32 : : <name>shell32 ;
  226. lib gdi32 : : <name>gdi32 ;
  227. lib bcrypt : : <name>bcrypt ;
  228. lib z : : <link>shared <name>z ;
  229. alias ssl-deps : advapi32 user32 shell32 gdi32 ;
  230. # OpenSSL on Windows
  231. lib crypto : ssl-deps : <toolset>msvc <openssl-version>1.1 <name>libcrypto
  232. <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
  233. lib ssl : ssl-deps : <toolset>msvc <openssl-version>1.1 <name>libssl <use>crypto
  234. <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
  235. # OpenSSL on other platforms
  236. lib crypto : : <name>crypto <use>z <conditional>@openssl-lib-path : :
  237. <conditional>@openssl-include-path ;
  238. lib ssl : : <name>ssl <use>crypto <conditional>@openssl-lib-path : :
  239. <conditional>@openssl-include-path ;
  240. # GnuTLS
  241. lib gnutls : : <link>shared <name>gnutls ;
  242. lib nettle : : <link>shared <name>nettle ;