jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

275 lines
8.0KB

  1. #!/usr/bin/python
  2. #
  3. # Copyright (C) 2007 Arnold Krille
  4. #
  5. # This file originates from FFADO (www.ffado.org)
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. #
  21. # Taken from http://www.scons.org/wiki/UsingPkgConfig
  22. # and heavily modified
  23. #
  24. #
  25. # Checks for pkg-config
  26. #
  27. def CheckForPKGConfig( context, version='0.0.0' ):
  28. context.Message( "Checking for pkg-config (at least version %s)... " % version )
  29. ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0]
  30. context.Result( ret )
  31. return ret
  32. #
  33. # Checks for the given package with an optional version-requirement
  34. #
  35. # The flags (which can be imported into the environment by env.MergeFlags(...)
  36. # are exported as env['NAME_FLAGS'] where name is built by removing all +,-,.
  37. # and upper-casing.
  38. #
  39. def CheckForPKG( context, name, version="" ):
  40. name2 = name.replace("+","").replace(".","").replace("-","")
  41. if version == "":
  42. context.Message( "Checking for %s... \t" % name )
  43. ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
  44. else:
  45. context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
  46. ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
  47. if ret:
  48. context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!pkg-config --cflags --libs %s" % name)
  49. context.Result( ret )
  50. return ret
  51. #
  52. # Checks for the existance of the package and returns the packages flags.
  53. #
  54. # This should allow caching of the flags so that pkg-config is called only once.
  55. #
  56. def GetPKGFlags( context, name, version="" ):
  57. import os
  58. if version == "":
  59. context.Message( "Checking for %s... \t" % name )
  60. ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
  61. else:
  62. context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
  63. ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
  64. if not ret:
  65. context.Result( ret )
  66. return ret
  67. out = os.popen2( "pkg-config --cflags --libs %s" % name )[1]
  68. ret = out.read()
  69. context.Result( True )
  70. return ret
  71. def GetPKGPrefix( context, name ):
  72. import os
  73. out = os.popen2( "pkg-config --variable=prefix %s" % name )[1]
  74. ret = out.read()
  75. ret = ret.replace ( "\n", "" )
  76. context.Message( " getting prefix... \t" )
  77. context.Result( True )
  78. return ret
  79. def GetPKGExecPrefix( context, name ):
  80. import os
  81. out = os.popen2( "pkg-config --variable=exec_prefix %s" % name )[1]
  82. ret = out.read()
  83. ret = ret.replace ( "\n", "" )
  84. context.Message( " getting exec prefix... \t" )
  85. context.Result( True )
  86. return ret
  87. def GetPKGIncludedir( context, name ):
  88. import os
  89. out = os.popen2( "pkg-config --variable=includedir %s" % name )[1]
  90. ret = out.read()
  91. ret = ret.replace ( "\n", "" )
  92. context.Message( " getting include dir... \t" )
  93. context.Result( True )
  94. return ret
  95. def GetPKGLibdir( context, name ):
  96. import os
  97. out = os.popen2( "pkg-config --variable=libdir %s" % name )[1]
  98. ret = out.read()
  99. ret = ret.replace ( "\n", "" )
  100. context.Message( " getting lib dir... \t" )
  101. context.Result( True )
  102. return ret
  103. def generate( env, **kw ):
  104. env['PKGCONFIG_TESTS' ] = {
  105. 'CheckForPKGConfig' : CheckForPKGConfig,
  106. 'CheckForPKG' : CheckForPKG,
  107. 'GetPKGFlags' : GetPKGFlags,
  108. 'GetPKGPrefix' : GetPKGPrefix,
  109. 'GetPKGExecPrefix' : GetPKGExecPrefix,
  110. 'GetPKGIncludedir' : GetPKGIncludedir,
  111. 'GetPKGLibdir' : GetPKGLibdir,
  112. }
  113. def exists( env ):
  114. return 1
  115. #!/usr/bin/python
  116. #
  117. # Copyright (C) 2007 Arnold Krille
  118. #
  119. # This file originates from FFADO (www.ffado.org)
  120. #
  121. # This program is free software: you can redistribute it and/or modify
  122. # it under the terms of the GNU General Public License as published by
  123. # the Free Software Foundation, either version 3 of the License, or
  124. # (at your option) any later version.
  125. #
  126. # This program is distributed in the hope that it will be useful,
  127. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  128. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  129. # GNU General Public License for more details.
  130. #
  131. # You should have received a copy of the GNU General Public License
  132. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  133. #
  134. #
  135. # Taken from http://www.scons.org/wiki/UsingPkgConfig
  136. # and heavily modified
  137. #
  138. #
  139. # Checks for pkg-config
  140. #
  141. def CheckForPKGConfig( context, version='0.0.0' ):
  142. context.Message( "Checking for pkg-config (at least version %s)... " % version )
  143. ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0]
  144. context.Result( ret )
  145. return ret
  146. #
  147. # Checks for the given package with an optional version-requirement
  148. #
  149. # The flags (which can be imported into the environment by env.MergeFlags(...)
  150. # are exported as env['NAME_FLAGS'] where name is built by removing all +,-,.
  151. # and upper-casing.
  152. #
  153. def CheckForPKG( context, name, version="" ):
  154. name2 = name.replace("+","").replace(".","").replace("-","")
  155. if version == "":
  156. context.Message( "Checking for %s... \t" % name )
  157. ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
  158. else:
  159. context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
  160. ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
  161. if ret:
  162. context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!pkg-config --cflags --libs %s" % name)
  163. context.Result( ret )
  164. return ret
  165. #
  166. # Checks for the existance of the package and returns the packages flags.
  167. #
  168. # This should allow caching of the flags so that pkg-config is called only once.
  169. #
  170. def GetPKGFlags( context, name, version="" ):
  171. import os
  172. if version == "":
  173. context.Message( "Checking for %s... \t" % name )
  174. ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
  175. else:
  176. context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
  177. ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
  178. if not ret:
  179. context.Result( ret )
  180. return ret
  181. out = os.popen2( "pkg-config --cflags --libs %s" % name )[1]
  182. ret = out.read()
  183. context.Result( True )
  184. return ret
  185. def GetPKGPrefix( context, name ):
  186. import os
  187. out = os.popen2( "pkg-config --variable=prefix %s" % name )[1]
  188. ret = out.read()
  189. ret = ret.replace ( "\n", "" )
  190. context.Message( " getting prefix... \t" )
  191. context.Result( True )
  192. return ret
  193. def GetPKGExecPrefix( context, name ):
  194. import os
  195. out = os.popen2( "pkg-config --variable=exec_prefix %s" % name )[1]
  196. ret = out.read()
  197. ret = ret.replace ( "\n", "" )
  198. context.Message( " getting exec prefix... \t" )
  199. context.Result( True )
  200. return ret
  201. def GetPKGIncludedir( context, name ):
  202. import os
  203. out = os.popen2( "pkg-config --variable=includedir %s" % name )[1]
  204. ret = out.read()
  205. ret = ret.replace ( "\n", "" )
  206. context.Message( " getting include dir... \t" )
  207. context.Result( True )
  208. return ret
  209. def GetPKGLibdir( context, name ):
  210. import os
  211. out = os.popen2( "pkg-config --variable=libdir %s" % name )[1]
  212. ret = out.read()
  213. ret = ret.replace ( "\n", "" )
  214. context.Message( " getting lib dir... \t" )
  215. context.Result( True )
  216. return ret
  217. def generate( env, **kw ):
  218. env['PKGCONFIG_TESTS' ] = {
  219. 'CheckForPKGConfig' : CheckForPKGConfig,
  220. 'CheckForPKG' : CheckForPKG,
  221. 'GetPKGFlags' : GetPKGFlags,
  222. 'GetPKGPrefix' : GetPKGPrefix,
  223. 'GetPKGExecPrefix' : GetPKGExecPrefix,
  224. 'GetPKGIncludedir' : GetPKGIncludedir,
  225. 'GetPKGLibdir' : GetPKGLibdir,
  226. }
  227. def exists( env ):
  228. return 1