Jamroot 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. import docutils ;
  2. import os ;
  3. import errors ;
  4. import notfile ;
  5. import package ;
  6. import path ;
  7. import virtual-target ;
  8. VERSION = 0.9.0 ;
  9. BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
  10. rule debug-message ( txt * )
  11. {
  12. if --debug-build in [ modules.peek : ARGV ]
  13. {
  14. echo [luabind DEBUG] $(txt) ;
  15. }
  16. }
  17. debug-message figuring out which libraries to link to... ;
  18. debug-message os.name is [ os.name ] ;
  19. if [ os.name ] = NT
  20. {
  21. if ! $(BOOST_ROOT)
  22. {
  23. errors.user-error "*** BOOST_ROOT must be set to a Boost installation." ;
  24. }
  25. LUA_PATH = [ os.environ LUA_PATH ] ;
  26. if ! $(LUA_PATH)
  27. {
  28. errors.user-error "*** LUA_PATH must be set." ;
  29. }
  30. local includes = [ GLOB $(LUA_PATH)/include $(LUA_PATH)/src : lua.h ] ;
  31. if ! $(includes)
  32. {
  33. errors.user-error "*** Unable to determine Lua include directory." ;
  34. }
  35. includes = $(includes:D) ;
  36. debug-message found include directory in $(includes) ;
  37. if [ GLOB $(LUA_PATH) : lib ]
  38. {
  39. lib lua : : <link>static <name>lua5.1 <search>$(LUA_PATH)/lib/static : : <include>$(includes) ;
  40. lib lua : : <link>shared <name>lua5.1 <search>$(LUA_PATH)/lib : : <include>$(includes) ;
  41. }
  42. else if [ GLOB $(LUA_PATH) : lua5.1.dll ]
  43. {
  44. lib lua : : <name>lua5.1 <search>$(LUA_PATH) : : <include>$(includes) ;
  45. }
  46. }
  47. else if [ os.name ] in LINUX MACOSX FREEBSD
  48. {
  49. LUA_PATH = [ os.environ LUA_PATH ] ;
  50. HOME = [ os.environ HOME ] ;
  51. local possible-prefixes =
  52. $(LUA_PATH) $(HOME)/Library/Frameworks /Library/Frameworks /usr /usr/local /opt/local /opt ;
  53. local possible-suffixes =
  54. include/lua5.1 include/lua51 include/lua include ;
  55. local includes = [ GLOB $(possible-prefixes)/$(possible-suffixes) : lua.h ] ;
  56. if ! $(includes)
  57. {
  58. errors.user-error "*** Unable to determine Lua include directory." ;
  59. }
  60. local includes = $(includes[1]:D) ;
  61. local prefix = $(includes:D) ;
  62. if $(prefix:B) = "include"
  63. {
  64. prefix = $(prefix:D) ;
  65. }
  66. local lib = $(prefix)/lib ;
  67. local names = liblua5.1 liblua51 liblua ;
  68. local extensions = .a .so ;
  69. library = [ GLOB $(lib)/lua51 $(lib)/lua5.1 $(lib)/lua $(lib) :
  70. $(names)$(extensions) ] ;
  71. lib-name = [ MATCH "lib(.*)" : $(library[1]:B) ] ;
  72. debug-message prefix: $(prefix) ;
  73. debug-message includes: $(includes) ;
  74. debug-message lib: $(library:D) ;
  75. debug-message candidates: $(library) ;
  76. debug-message linking to: $(lib-name) ;
  77. if ! $(lib-name)
  78. {
  79. errors.user-error "*** Unable to find Lua library." ;
  80. }
  81. lib m : : <link>shared ;
  82. if [ os.name ] = LINUX
  83. {
  84. lib dl : : <link>shared ;
  85. }
  86. else
  87. {
  88. alias dl ;
  89. }
  90. lib lua : m dl : <name>$(lib-name) <search>$(library:D) : : <include>$(includes) ;
  91. }
  92. rule tag-names ( name : type ? : property-set )
  93. {
  94. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB &&
  95. [ $(property-set).get <variant> ] = debug
  96. {
  97. name = $(name)d ;
  98. }
  99. local result = [ virtual-target.add-prefix-and-suffix $(name) : $(type) : $(property-set) ] ;
  100. if $(type) = SHARED_LIB &&
  101. ( ! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix ) &&
  102. ! ( [ $(property-set).get <toolset> ] in pgi ) )
  103. {
  104. result = $(result).$(VERSION) ;
  105. }
  106. return $(result) ;
  107. }
  108. SOURCES =
  109. class.cpp
  110. class_info.cpp
  111. class_registry.cpp
  112. class_rep.cpp
  113. create_class.cpp
  114. error.cpp
  115. exception_handler.cpp
  116. function.cpp
  117. inheritance.cpp
  118. link_compatibility.cpp
  119. object_rep.cpp
  120. open.cpp
  121. pcall.cpp
  122. scope.cpp
  123. stack_content_by_name.cpp
  124. weak_ref.cpp
  125. wrapper_base.cpp ;
  126. usage-requirements =
  127. <library>lua
  128. <toolset>msvc,<link>shared:<cxxflags>/wd4251
  129. <link>shared:<define>LUABIND_DYNAMIC_LINK
  130. <tag>@tag-names ;
  131. lib luabind
  132. : src/$(SOURCES)
  133. # requirements
  134. : <include>. <include>$(BOOST_ROOT)
  135. $(usage-requirements)
  136. # default-build
  137. :
  138. # usage-requirements
  139. : <include>. <include>$(BOOST_ROOT)
  140. $(usage-requirements)
  141. ;
  142. alias test
  143. : test//test
  144. # requirements
  145. :
  146. # default-build
  147. : <link>static <link>shared release debug ;
  148. explicit test ;
  149. rule git-describe ( )
  150. {
  151. local result = [ SHELL "git describe HEAD 2>&1" : exit-status ] ;
  152. if $(result[2]) = 0
  153. {
  154. return [ MATCH "^v([a-zA-Z.0-9\\-]+)" : $(result[1]) ] ;
  155. }
  156. }
  157. version-tag = [ git-describe ] ;
  158. if $(version-tag)
  159. {
  160. actions make-version-file
  161. {
  162. echo ".. |version| replace:: $(version-tag)" > doc/version.rst
  163. }
  164. notfile make-version-file : @make-version-file ;
  165. }
  166. else
  167. {
  168. alias make-version-file ;
  169. }
  170. if docs in [ modules.peek : ARGV ]
  171. {
  172. local result = [ SHELL "rst2html.py --version 2>&1" : exit-status ] ;
  173. if $(result[2]) = 0
  174. {
  175. found-rst2html = rst2html.py ;
  176. }
  177. }
  178. html docs.html
  179. : doc/docs.rst
  180. : <dependency>make-version-file
  181. <docutils-cmd>$(found-rst2html)
  182. <docutils-html>"--traceback -gdt --stylesheet=style.css --link-stylesheet" ;
  183. stage docs : docs.html : <location>doc ;
  184. explicit docs docs.html make-version-file ;
  185. headers = [ path.glob-tree luabind : *.hpp ] ;
  186. package.install install
  187. : <install-header-subdir>luabind
  188. <install-source-root>luabind
  189. <install-no-version-symlinks>on
  190. :
  191. : luabind
  192. : $(headers)
  193. ;
  194. local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ;
  195. stage-locate ?= stage ;
  196. install stage
  197. : luabind
  198. : <location>$(stage-locate)
  199. <install-no-version-symlinks>on
  200. <install-dependencies>on
  201. <install-type>LIB
  202. ;
  203. explicit stage ;