Jamfile 8.2 KB

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