2 ######################## START osg2-config PART III ########################
6 ################################################
8 ################################################
20 if "win32" == sys.platform:
24 def_libpathprefix = "/LIBPATH:"
29 def_libpathprefix = "-L"
32 parser = OptionParser(usage="%prog [LIBRARY] [OPTIONS]", description="OpenSG config options.")
34 parser.add_option("--prefix", action="store_true",
35 help="Print the installation prefix.")
36 parser.add_option("--libdir", action="store_true",
37 help="Print the library installation directory")
38 parser.add_option("--includedir", action="store_true",
39 help="Print the header installation directory")
40 parser.add_option("--cflags", action="store_true",
41 help="Print OpenSG specific cflags.")
42 parser.add_option("--lflags", action="store_true",
43 help="Print library flags.")
44 parser.add_option("--llibs", action="store_true",
45 help="Print library list.")
46 parser.add_option("--libs", action="store_true",
47 help="Print libraries and flags.")
48 parser.add_option("--no-prefix-flags", action="store_true",
49 help="When printing list of libraries and paths, don't include compiler prefix flags (-I,-l,-L)")
50 parser.add_option("--inc-prefix", default=def_incprefix,
51 help="Compiler include path prefix to use. (%s)" % def_incprefix)
52 parser.add_option("--lib-prefix", default=def_libprefix,
53 help="Linker lib prefix to use. (%s)"%def_libprefix)
54 parser.add_option("--lib-ext", default=def_libext,
55 help="Linker lib subfix to use. (%s)"%def_libext)
56 parser.add_option("--libpath-prefix", default=def_libpathprefix,
57 help="Linker library path prefix to use. (%s)"%def_libpathprefix)
58 parser.add_option("--version", action="store_true",
59 help="Print the OpenSG version and exit.")
61 parser.set_defaults(build_type=inst_build_type)
62 parser.add_option("--opt", action="store_const", const="Release", dest="build_type",
63 help = "Use library search path patterns for optimized OpenSG libraries " + \
64 "(NOTE: This does not affect external dependencies, those always use the build time settings!).")
65 parser.add_option("--dbg", action="store_const", const="Debug", dest="build_type",
66 help = "Use library search path patterns for debug OpenSG libraries " + \
67 "(NOTE: This does not affect external dependencies, those always use the build time settings!).")
68 parser.add_option("--dbgrt", action="store_const", const="DebugRT", dest="build_type",
69 help = "Use library search path patterns for debug-runtime OpenSG libraries " + \
70 "(NOTE: This does not affect external dependencies, those always use the build time settings!).")
73 (options, pos_args) = parser.parse_args()
79 elif inst_platform_64:
82 if options.build_type == "Release":
83 spez_lib_dir = pj(inst_prefix, lib_part)
84 spez_inc_dir = pj(inst_prefix, "include")
85 elif options.build_type == "Debug":
86 spez_lib_dir = pj(inst_prefix, lib_part, "debug")
87 spez_inc_dir = pj(inst_prefix, "include")
88 elif options.build_type == "DebugRT":
89 spez_lib_dir = pj(inst_prefix, lib_part, "debugrt")
90 spez_inc_dir = pj(inst_prefix, "include")
93 # paths for different build type requested, overwrite defaults
94 if options.build_type != inst_build_type:
95 lib_dir = spez_lib_dir
96 inc_dir = spez_inc_dir
98 # Process simple single options
105 elif options.includedir:
108 elif options.version:
109 print "${OSG_VERSION}"
112 # Try to find libname
113 # - Try given name and name with OSG or OSGWindow prefix
117 for name_alt in [n, "OSG"+n, "OSGWindow"+n, None]:
119 print "Error: Can not find library named: ", n
120 elif lib_map.has_key(name_alt):
121 libraries.append(name_alt)
124 # Make sure we have libraries
125 if len(libraries) == 0:
126 print "Error: No libraries given."
130 # If set to no prefix flags, then clear all defaults
131 if options.no_prefix_flags:
132 options.inc_prefix = ""
133 options.lib_prefix = ""
135 options.libpath_prefix = ""
138 print string_inc_dir(collect_inc_dir(libraries, lib_map))
140 print string_lib(collect_lib(libraries, lib_map))
142 print string_lib_dir(collect_lib_dir(libraries, lib_map))
144 lib_dir = string_lib_dir(collect_lib_dir(libraries, lib_map))
145 lib = string_lib (collect_lib (libraries, lib_map))
146 print lib_dir + ' ' + lib
154 global parser, lib_map
156 print "\nLibraries: "
157 for lib_name in lib_map.keys():
160 ################################################
162 ################################################
166 # generate a list of all OpenSG libraries needed by those in LIBRARIES
168 def collect_osg_libs(libraries, lib_map):
169 out_list = copy.copy(libraries)
170 len_list = len(out_list)
173 for j in lib_map[i]['dep_osg_lib']:
174 if not j in out_list:
175 out_list.insert(len_list, j)
180 def collect_inc_dir(libraries, lib_map):
182 osg_libs = collect_osg_libs(libraries, lib_map)
185 for j in lib_map[i]['dep_inc_dir']:
186 if not j in inc_dir_list:
187 inc_dir_list.append(j)
189 for i in [inc_dir, pj(inc_dir, "OpenSG")]:
190 if not i in inc_dir_list:
191 inc_dir_list.append(i)
195 def string_inc_dir(inc_dir):
196 return " ".join(["%s%s" % (options.inc_prefix, i) for i in inc_dir])
199 def collect_lib(libraries, lib_map):
201 osg_libs = collect_osg_libs(libraries, lib_map)
204 for j in lib_map[i]['dep_lib']:
205 if not j in lib_list:
208 return osg_libs + lib_list
211 return " ".join(["%s%s%s" % (options.lib_prefix, l, options.lib_ext) for l in lib])
214 def collect_lib_dir(libraries, lib_map):
216 osg_libs = collect_osg_libs(libraries, lib_map)
219 for j in lib_map[i]['dep_lib_dir']:
220 if not j in lib_dir_list:
221 lib_dir_list.append(j)
223 if not lib_dir in lib_dir_list:
224 lib_dir_list.append(lib_dir)
228 def string_lib_dir(lib_dir):
229 return " ".join(["%s%s" % (options.libpath_prefix, l) for l in lib_dir])
232 ################################################
234 ################################################
238 ######################## END osg2-config PART III ########################