1 /*
2  * gtkD is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU Lesser General Public License
4  * as published by the Free Software Foundation; either version 3
5  * of the License, or (at your option) any later version, with
6  * some exceptions, please read the COPYING file.
7  * 
8  * gtkD is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  * 
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with gtkD; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
16  *
17  * paths.d  -- list of libraries that will be dynamically linked with gtkD
18  *
19  * Added:	John Reimer	-- 2004-12-20
20  * Updated: 2005-02-21 changed names; added version(linux)
21  * Updated: 2005-05-05 updated Linux support
22  * Updated: 2008-02-16 Tango support
23  */
24 
25 module gtkc.paths;
26 
27 //version(Tango) private alias char[] string;
28 version(Tango) import gtkc.glibtypes;
29 
30 /*
31  * Define the Libraries that gtkD will be using.
32  *   This is a growable list, as long as the programmer
33  *   also adds to the importLibs list.
34  */
35 
36 enum LIBRARY
37 {
38 	ATK,
39 	CAIRO,
40 	GDK,
41 	GDKPIXBUF,
42 	GLIB,
43 	GMODULE,
44 	GOBJECT,
45 	GIO,
46 	GTHREAD,
47 	GTK,
48 	PANGO,
49 	PANGOCAIRO,
50 	GLGDK,
51 	GLGTK,
52 	GL,
53 	GLU,
54 	GLEXT,
55 	GDA,
56 	GLADE,
57 	GSV,
58 	GSTREAMER,
59 	GSTINTERFACES
60 }
61 
62 version (Windows)
63 {
64 const string[LIBRARY.max+1] importLibs =
65 	[
66 	LIBRARY.ATK:           "libatk-1.0-0.dll",
67 	LIBRARY.CAIRO:         "libcairo-2.dll",
68 	LIBRARY.GDK:           "libgdk-win32-2.0-0.dll",
69 	LIBRARY.GDKPIXBUF:     "libgdk_pixbuf-2.0-0.dll",
70 	LIBRARY.GLIB:          "libglib-2.0-0.dll",
71 	LIBRARY.GMODULE:       "libgmodule-2.0-0.dll",
72 	LIBRARY.GOBJECT:       "libgobject-2.0-0.dll",
73 	LIBRARY.GIO:           "libgio-2.0-0.dll",
74 	LIBRARY.GTHREAD:       "libgthread-2.0-0.dll",
75 	LIBRARY.GTK:           "libgtk-win32-2.0-0.dll",
76 	LIBRARY.PANGO:         "libpango-1.0-0.dll",
77 	LIBRARY.PANGOCAIRO:    "libpangocairo-1.0-0.dll",
78 	LIBRARY.GLGDK:         "libgdkglext-win32-1.0-0.dll",
79 	LIBRARY.GLGTK:         "libgtkglext-win32-1.0-0.dll",
80 	LIBRARY.GL:            "opengl32.dll",
81 	LIBRARY.GLU:           "glu32.dll",
82 	LIBRARY.GDA:           "libgda-4.0-4.dll",
83 	LIBRARY.GLADE:         "libglade-2.0-0.dll",
84 	LIBRARY.GSV:           "libgtksourceview-2.0-0.dll",
85 	LIBRARY.GSTREAMER:     "libgstreamer-0.10.dll",
86 	LIBRARY.GSTINTERFACES: "libgstinterfaces-0.10.dll"
87 	];
88 }
89 else version(darwin)
90 {
91 /**
92 * On OS X, currently there are (atleast) two places where
93 * GTK+ might be installed. The default for gtkD is the native
94 * Quartz port. The other one is the X11 version, which runs
95 * under the separate X11 environment of OS X. You can
96 * uncomment the version=darwinX11 in the gtkD toplevel dsss.conf file
97 * to build gtkD for X11.
98 * Currently gtkDgl (which uses gtkglext) is only available under X11,
99 * because gtkglext is not yet ported to the Quartz backend.
100 */
101 
102 version(darwinX11)
103 {
104 	//This version is for the non-native OS X, X11 port
105 	//of GTK+. This directory is according to the Macports http://www.macports.org
106 	//default installation location. There should be installation instructions
107 	//in the gtkD wiki at DSource.
108 	const string DIRECTORY = "/opt/local/lib/";
109 	const string INTERFACE = "x11";
110 
111 	const string[LIBRARY.max+1] importLibs =
112 	[
113 		LIBRARY.ATK:           DIRECTORY~"libatk-1.0.dylib",
114 		LIBRARY.CAIRO:         DIRECTORY~"libcairo.dylib",
115 		LIBRARY.GDK:           DIRECTORY~"libgdk-"~INTERFACE~"-2.0.dylib",
116 		LIBRARY.GDKPIXBUF:     DIRECTORY~"libgdk_pixbuf-2.0.dylib",
117 		LIBRARY.GLIB:          DIRECTORY~"libglib-2.0.dylib",
118 		LIBRARY.GMODULE:       DIRECTORY~"libgmodule-2.0.dylib",
119 		LIBRARY.GOBJECT:       DIRECTORY~"libgobject-2.0.dylib",
120 		LIBRARY.GIO:           DIRECTORY~"libgio-2.0.dylib",
121 		LIBRARY.GTHREAD:       DIRECTORY~"libgthread-2.0.dylib",
122 		LIBRARY.GTK:           DIRECTORY~"libgtk-"~INTERFACE~"-2.0.dylib",
123 		LIBRARY.PANGO:         DIRECTORY~"libpango-1.0.dylib",
124 		LIBRARY.PANGOCAIRO:    DIRECTORY~"libpangocairo-1.0.dylib",
125 		LIBRARY.GLGDK:         DIRECTORY~"libgdkglext-"~INTERFACE~"-1.0.dylib",
126 		LIBRARY.GLGTK:         DIRECTORY~"libgtkglext-"~INTERFACE~"-1.0.dylib",
127 		LIBRARY.GL:            "/System/Library/Frameworks/OpenGL.framework/OpenGL",
128 		LIBRARY.GLU:           "/System/Library/Frameworks/OpenGL.framework/OpenGL",
129 		LIBRARY.GLEXT:         "/System/Library/Frameworks/OpenGL.framework/OpenGL",
130 		LIBRARY.GDA:           DIRECTORY~"libgda-2.dylib",
131 		LIBRARY.GLADE:         DIRECTORY~"libglade-2.0.dylib",
132 		LIBRARY.GSV:           DIRECTORY~"libgtksourceview-1.0.dylib",
133 		LIBRARY.GSTREAMER:     DIRECTORY~"libgstreamer-0.10.dylib",
134 		LIBRARY.GSTINTERFACES: DIRECTORY~"libgstinterfaces-0.10.dylib"
135 	];
136 }
137 else //default version (The Quartz GTK+):
138 {
139 	//This version is for the native Quartz port of GTK+
140 	//which can be found from http://www.gtk-osx.org/
141 	//The libraries in the /opt/ directory are not part of
142 	//that package and need to be installed separately,
143 	//possibly through Macports.
144 
145 	const string INTERFACE = "quartz";
146 	const string DIRECTORY = "/opt/local/lib/";
147 
148 	const string[LIBRARY.max+1] importLibs =
149 	[
150 		LIBRARY.ATK:           DIRECTORY~"libatk-1.0.dylib",
151 		LIBRARY.CAIRO:         DIRECTORY~"libcairo.dylib",
152 		LIBRARY.GDK:           DIRECTORY~"libgdk-"~INTERFACE~"-2.0.dylib",
153 		LIBRARY.GDKPIXBUF:     DIRECTORY~"libgdk_pixbuf-2.0.dylib",
154 		LIBRARY.GLIB:          DIRECTORY~"libglib-2.0.dylib",
155 		LIBRARY.GMODULE:       DIRECTORY~"libgmodule-2.0.dylib",
156 		LIBRARY.GOBJECT:       DIRECTORY~"libgobject-2.0.dylib",
157 		LIBRARY.GIO:           DIRECTORY~"libgio-2.0.dylib",
158 		LIBRARY.GTHREAD:       DIRECTORY~"libgthread-2.0.dylib",
159 		LIBRARY.GTK:           DIRECTORY~"libgtk-"~INTERFACE~"-2.0.dylib",
160 		LIBRARY.PANGO:         DIRECTORY~"libpango-1.0.dylib",
161 		LIBRARY.PANGOCAIRO:    DIRECTORY~"libpangocairo-1.0.dylib",
162 		LIBRARY.GLGDK:         DIRECTORY~"libgdkglext-"~INTERFACE~"-1.0.dylib",
163 		LIBRARY.GLGTK:         DIRECTORY~"libgtkglext-"~INTERFACE~"-1.0.dylib",
164 		LIBRARY.GL:            "/System/Library/Frameworks/OpenGL.framework/OpenGL",
165 		LIBRARY.GLU:           "/System/Library/Frameworks/OpenGL.framework/OpenGL",
166 		LIBRARY.GLEXT:         "/System/Library/Frameworks/OpenGL.framework/OpenGL",
167 		LIBRARY.GDA:           DIRECTORY~"libgda-2.dylib",
168 		LIBRARY.GLADE:         DIRECTORY~"libglade-2.0.dylib",
169 		LIBRARY.GSV:           DIRECTORY~"libgtksourceview-1.0.dylib",
170 		LIBRARY.GSTREAMER:     DIRECTORY~"libgstreamer-0.10.dylib",
171 		LIBRARY.GSTINTERFACES: DIRECTORY~"libgstinterfaces-0.10.dylib"
172 	];
173 }}
174 else
175 {
176 const string[LIBRARY.max+1] importLibs =
177 	[
178 	LIBRARY.ATK:           "libatk-1.0.so.0",
179 	LIBRARY.CAIRO:         "libcairo.so.2",
180 	LIBRARY.GDK:           "libgdk-x11-2.0.so.0",
181 	LIBRARY.GDKPIXBUF:     "libgdk_pixbuf-2.0.so.0",
182 	LIBRARY.GLIB:          "libglib-2.0.so.0",
183 	LIBRARY.GMODULE:       "libgmodule-2.0.so.0",
184 	LIBRARY.GOBJECT:       "libgobject-2.0.so.0",
185 	LIBRARY.GIO:           "libgio-2.0.so.0",
186 	LIBRARY.GTHREAD:       "libgthread-2.0.so.0",
187 	LIBRARY.GTK:           "libgtk-x11-2.0.so.0",
188 	LIBRARY.PANGO:         "libpango-1.0.so.0",
189 	LIBRARY.PANGOCAIRO:    "libpangocairo-1.0.so.0",
190 	LIBRARY.GLGDK:         "libgdkglext-x11-1.0.so.0",
191 	LIBRARY.GLGTK:         "libgtkglext-x11-1.0.so.0",
192 	LIBRARY.GL:            "libGL.so.1",
193 	LIBRARY.GLU:           "libGLU.so.1",
194 	LIBRARY.GLEXT:         "libGL.so.1",
195 	LIBRARY.GDA:           "libgda-4.0.so.4",
196 	LIBRARY.GLADE:         "libglade-2.0.so.0",
197 	LIBRARY.GSV:           "libgtksourceview-2.0.so.0",
198 	LIBRARY.GSTREAMER:     "libgstreamer-0.10.so.0",
199 	LIBRARY.GSTINTERFACES: "libgstinterfaces-0.10.so.0"
200 	];
201 }
202 
203 version(Windows)
204 {
205 	//version(Phobos)
206 	version(Tango){} else
207 	{
208 		import std.windows.registry;
209 		import std.stdio;
210 	}
211 
212 	extern (Windows)
213 	{
214 		private uint GetEnvironmentVariableA(char*, char*, uint);
215 	}
216 
217 	//Based on tango.sys.Environment.Environment.get
218 	static string GetEnvironmentVariable(string variable)
219 	{
220 		char[] var = variable ~ "\0".dup;
221 		uint size = GetEnvironmentVariableA(var.ptr, cast(char*)null, 0);
222 	
223 		if (size == 0) return "";
224 
225 		char[] buf = new char[size];
226 		size = GetEnvironmentVariableA(var.ptr, buf.ptr, size);
227 
228 		if (size == 0) return "";
229 
230 		return cast(string)buf[0 .. size];
231 	}
232 
233 	string libPath()
234 	{
235 		string libPath;
236 
237 		libPath = GetEnvironmentVariable("GTK_BASEPATH");
238 
239 		if ( libPath.length > 5 )
240 		{
241 			if ( libPath[$-5..$] == "\\bin\\" )
242 				return libPath;
243 			else if ( libPath[$-4..$] == "\\bin" )
244 				return libPath ~ "\\";
245 			else
246 				return libPath ~ "\\bin\\";
247 		}
248 
249 		// Returns the found location or an empty string
250 		// to load the libraries from the path.
251 		// see http://msdn2.microsoft.com/en-us/library/ms682586(VS.85).aspx
252 		return libPath;
253 	}
254 }
255 else
256 {
257 	// empty for Linux, Unix and Mac because default path is known by ld
258 	string libPath()
259 	{
260 		return "";
261 	}
262 }