Jamfile 8.3 KB

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