Added support for pkg-config
This commit is contained in:
parent
83803724e6
commit
094b2ab118
|
|
@ -292,18 +292,11 @@ if (COMPILER=="LINUX"):
|
|||
IncDirectory("GLUT", "/usr/X11R6/include")
|
||||
else:
|
||||
if (PkgSkip("FREETYPE")==0): IncDirectory("FREETYPE", "/usr/include/freetype2")
|
||||
IncDirectory("GTK2", "/usr/include/gtk-2.0")
|
||||
IncDirectory("GTK2", "/usr/include/cairo")
|
||||
IncDirectory("GTK2", "/usr/include/glib-2.0")
|
||||
IncDirectory("GTK2", "/usr/lib/glib-2.0/include")
|
||||
IncDirectory("GTK2", "/usr/include/pango-1.0")
|
||||
IncDirectory("GTK2", "/usr/lib/gtk-2.0/include")
|
||||
IncDirectory("GTK2", "/usr/include/atk-1.0")
|
||||
if (platform.architecture()[0] == "64bit"):
|
||||
if (os.path.exists("/usr/lib64")):
|
||||
IncDirectory("GTK2", "/usr/lib64/glib-2.0/include")
|
||||
IncDirectory("GTK2", "/usr/lib64/gtk-2.0/include")
|
||||
LibName("GTK2", "-lgtk-x11-2.0")
|
||||
|
||||
PkgConfigEnable("GTK2", "gtk+-2.0")
|
||||
|
||||
if (sys.platform == "darwin"):
|
||||
pkgs = ["VRPN", "FFTW", "FMOD", "FMODEX", "ARTOOLKIT", "ODE", "OPENCV", "FCOLLADA", "FFMPEG", "PNG", "JPEG", "TIFF"]
|
||||
else:
|
||||
|
|
@ -3360,7 +3353,7 @@ if (PkgSkip("PANDATOOL")==0):
|
|||
# DIRECTORY: pandatool/src/gtk-stats/
|
||||
#
|
||||
|
||||
if (PkgSkip("PANDATOOL")==0 and sys.platform != "darwin"):
|
||||
if (PkgSkip("PANDATOOL")==0 and (sys.platform == "win32" or PkgConfigHavePkg("gtk+-2.0"))):
|
||||
if (sys.platform == "win32"):
|
||||
OPTS=['DIR:pandatool/src/win-stats']
|
||||
TargetAdd('pstats_composite1.obj', opts=OPTS, input='winstats_composite1.cxx')
|
||||
|
|
|
|||
|
|
@ -176,6 +176,26 @@ def GetDirectoryContents(dir, filters="*", skip=[]):
|
|||
results.sort()
|
||||
return results
|
||||
|
||||
########################################################################
|
||||
##
|
||||
## LocateBinary
|
||||
##
|
||||
## This function searches the system PATH for the binary. Returns its
|
||||
## full path when it is found, or None when it was not found.
|
||||
##
|
||||
########################################################################
|
||||
|
||||
def LocateBinary(binary):
|
||||
if not os.environ.has_key("PATH") or os.environ["PATH"] == "":
|
||||
p = os.defpath
|
||||
else:
|
||||
p = os.environ["PATH"]
|
||||
|
||||
for path in p.split(os.pathsep):
|
||||
if os.access(os.path.join(path, binary), os.X_OK):
|
||||
return os.path.abspath(os.path.realpath(os.path.join(path, binary)))
|
||||
return None
|
||||
|
||||
########################################################################
|
||||
##
|
||||
## The Timestamp Cache
|
||||
|
|
@ -623,6 +643,68 @@ def PkgSelected(pkglist, pkg):
|
|||
if (PKG_LIST_OMIT[pkg]): return 0
|
||||
return 1
|
||||
|
||||
########################################################################
|
||||
##
|
||||
## These functions are for libraries which use pkg-config.
|
||||
##
|
||||
########################################################################
|
||||
|
||||
def PkgConfigHavePkg(pkgname):
|
||||
"""Returns a bool whether the pkg-config package is installed."""
|
||||
if (sys.platform == "win32" or not LocateBinary("pkg-config")):
|
||||
return False
|
||||
handle = os.popen(LocateBinary("pkg-config") + " --silence-errors --modversion " + pkgname)
|
||||
result = handle.read().strip()
|
||||
handle.close()
|
||||
return bool(len(result) > 0)
|
||||
|
||||
def PkgConfigGetLibs(pkgname):
|
||||
"""Returns a list of libs for the package, prefixed by -l."""
|
||||
if (sys.platform == "win32" or not LocateBinary("pkg-config")):
|
||||
return []
|
||||
handle = os.popen(LocateBinary("pkg-config") + " --silence-errors --libs-only-l " + pkgname)
|
||||
result = handle.read().strip()
|
||||
handle.close()
|
||||
libs = []
|
||||
for l in result.split(" "):
|
||||
libs.append(l)
|
||||
return libs
|
||||
|
||||
def PkgConfigGetIncDirs(pkgname):
|
||||
"""Returns a list of includes for the package, NOT prefixed by -I."""
|
||||
if (sys.platform == "win32" or not LocateBinary("pkg-config")):
|
||||
return []
|
||||
handle = os.popen(LocateBinary("pkg-config") + " --silence-errors --cflags-only-I " + pkgname)
|
||||
result = handle.read().strip()
|
||||
handle.close()
|
||||
if len(result) == 0: return []
|
||||
libs = []
|
||||
for l in result.split(" "):
|
||||
libs.append(l.replace("-I", "").replace("\"", "").strip())
|
||||
return libs
|
||||
|
||||
def PkgConfigGetLibDirs(pkgname):
|
||||
"""Returns a list of library paths for the package, NOT prefixed by -L."""
|
||||
if (sys.platform == "win32" or not LocateBinary("pkg-config")):
|
||||
return []
|
||||
handle = os.popen(LocateBinary("pkg-config") + " --silence-errors --libs-only-L " + pkgname)
|
||||
result = handle.read().strip()
|
||||
handle.close()
|
||||
if len(result) == 0: return []
|
||||
libs = []
|
||||
for l in result.split(" "):
|
||||
libs.append(l.replace("-L", "").replace("\"", "").strip())
|
||||
return libs
|
||||
|
||||
def PkgConfigEnable(opt, pkgname):
|
||||
"""Adds the libraries and includes to IncDirectory, LibName and LibDirectory."""
|
||||
for i in PkgConfigGetIncDirs(pkgname):
|
||||
IncDirectory(opt, i)
|
||||
for i in PkgConfigGetLibDirs(pkgname):
|
||||
LibDirectory(opt, i)
|
||||
for i in PkgConfigGetLibs(pkgname):
|
||||
LibName(opt, i)
|
||||
|
||||
########################################################################
|
||||
##
|
||||
## SDK Location
|
||||
|
|
|
|||
Loading…
Reference in New Issue