Jamfile 8.5 KB

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