/[gentoo-alt]/trunk/prefix/eclass/gnustep-funcs.eclass
Gentoo

Contents of /trunk/prefix/eclass/gnustep-funcs.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 10570 byte(s)
Initial eclass import from gentoo-x86
1 # Copyright 1999-2004 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/gnustep-funcs.eclass,v 1.10 2005/07/11 15:08:06 swegener Exp $
4
5 inherit toolchain-funcs eutils
6
7 ###########################################################################
8 # IUSE="debug profile verbose"
9 # - These USE variables are utilized here, but set in gnustep.eclass IUSE.
10 # - Packages that inherit this gnustep-funcs.eclass file to gain information
11 # and access as to how GNUstep is deployed on the system can safely do so.
12 # - Packages built on the GNUstep libraries should inherit gnustep.eclass
13 # directly (it inherits from this eclass as well)
14 ###########################################################################
15
16 DESCRIPTION="EClass that centralizes access to GNUstep environment information."
17
18 ###########################################################################
19 # Functions
20 # ---------
21
22 # Prints out the dirname of GNUSTEP_SYSTEM_ROOT, i.e., "System" is installed
23 # in egnustep_prefix
24 egnustep_prefix() {
25 # Generally, only gnustep-make should be the one setting this value
26 #if [ "$1" ] && [ ! -f /etc/conf.d/net ]; then
27 if [ "$1" ]; then
28 __GS_PREFIX="$(dirname $1/prune)"
29 return 0
30 fi
31
32 if [ -f /etc/conf.d/gnustep.env ]; then
33 . /etc/conf.d/gnustep.env
34 if [ -z "${GNUSTEP_SYSTEM_ROOT}" ] || [ "/" != "${GNUSTEP_SYSTEM_ROOT:0:1}" ]; then
35 die "Please check /etc/conf.d/gnustep.env for consistency or remove it."
36 fi
37 __GS_PREFIX=$(dirname ${GNUSTEP_SYSTEM_ROOT})
38 elif [ -z "${__GS_PREFIX}" ]; then
39 __GS_PREFIX="/usr/GNUstep"
40 __GS_SYSTEM_ROOT="/usr/GNUstep/System"
41 fi
42
43 echo "${__GS_PREFIX}"
44 }
45
46 # Prints/sets the GNUstep install domain; Generally, this will only be
47 # "System" or "Local"
48 egnustep_install_domain() {
49 if [ -z "$1" ]; then
50 if [ -z "$__GS_INSTALL_DOMAIN" ]; then
51 # backwards comapatbility for older ebuilds
52 __GS_INSTALL_DOMAIN="GNUSTEP_SYSTEM_ROOT"
53 fi
54 echo ${!__GS_INSTALL_DOMAIN}
55 return 0
56 else
57 if [ "$1" == "System" ]; then
58 __GS_INSTALL_DOMAIN="GNUSTEP_SYSTEM_ROOT"
59 elif [ "$1" == "Local" ]; then
60 __GS_INSTALL_DOMAIN="GNUSTEP_LOCAL_ROOT"
61 # elif [ "$1" == "Network" ]; then
62 # __GS_INSTALL_DOMAIN="GNUSTEP_NETWORK_ROOT"
63 else
64 die "An invalid parameter has been passed to ${FUNCNAME}"
65 fi
66 fi
67 }
68
69 # Clean/reset an ebuild to the installed GNUstep evironment; generally,
70 # this is called once an ebuild (at least), and packages that will
71 # inherit from gnustep.eclass already do this
72 egnustep_env() {
73 GNUSTEP_SYSTEM_ROOT="$(egnustep_prefix)/System"
74 if [ -f ${GNUSTEP_SYSTEM_ROOT}/Library/Makefiles/GNUstep.sh ] ; then
75 . ${GNUSTEP_SYSTEM_ROOT}/Library/Makefiles/GNUstep-reset.sh
76 if [ -f /etc/conf.d/gnustep.env ]; then
77 . /etc/conf.d/gnustep.env
78 else
79 GNUSTEP_SYSTEM_ROOT="/usr/GNUstep/System"
80 fi
81 . ${GNUSTEP_SYSTEM_ROOT}/Library/Makefiles/GNUstep.sh
82
83 __GS_SYSTEM_ROOT=${GNUSTEP_SYSTEM_ROOT}
84 __GS_LOCAL_ROOT=${GNUSTEP_LOCAL_ROOT}
85 __GS_NETWORK_ROOT=${GNUSTEP_NETWORK_ROOT}
86 __GS_USER_ROOT=${GNUSTEP_USER_ROOT}
87 __GS_USER_ROOT_SUFFIX=$(dirname ${GNUSTEP_USER_ROOT#*$USER}/prune)/
88
89 # "gs_prefix" is the prefix that GNUstep is installed into, e.g.
90 # gs_prefix=/usr/GNUstep => GNUSTEP_SYSTEM_ROOT=${gs_prefix}/System
91 local gs_prefix=`egnustep_prefix`
92 echo ${gs_prefix//\//XXX_SED_FSLASH} > ${TMP}/sed.gs_prefix
93
94 # "gs_user_root_suffix" what is left over from the difference of
95 # GNUSTEP_USER_ROOT and HOME, e.g.:
96 # "/home/something/whatever/.config/GNUstep" => ".config/GNUstep"
97 echo ${__GS_USER_ROOT_SUFFIX//\//XXX_SED_FSLASH} > ${TMP}/sed.gs_user_root_suffix
98
99 # Set up common env vars for make operations
100 __GS_MAKE_EVAL="HOME=\${TMP} \
101 GNUSTEP_USER_ROOT=\${TMP} \
102 GNUSTEP_DEFAULTS_ROOT=\${TMP}/\${__GS_USER_ROOT_SUFFIX} \
103 INSTALL_ROOT_DIR=\${D} \
104 GNUSTEP_INSTALLATION_DIR=\${D}/\$(egnustep_install_domain)
105 GNUSTEP_MAKEFILES=\${GNUSTEP_SYSTEM_ROOT}/Library/Makefiles \
106 GNUSTEP_NETWORK_ROOT=\${GNUSTEP_NETWORK_ROOT} \
107 GNUSTEP_LOCAL_ROOT=\${GNUSTEP_LOCAL_ROOT} \
108 GNUSTEP_SYSTEM_ROOT=\${GNUSTEP_SYSTEM_ROOT} \
109 TAR_OPTIONS=\"\${TAR_OPTIONS} --no-same-owner\" \
110 -j1"
111 else
112 die "gnustep-make not installed!"
113 fi
114 }
115
116 # Get/Set the GNUstep system root
117 egnustep_system_root() {
118 if [ "$1" ]; then
119 __GS_SYSTEM_ROOT="$(dirname $1/prune)"
120 else
121 echo ${__GS_SYSTEM_ROOT}
122 fi
123 }
124
125 # Get/Set the GNUstep local root
126 egnustep_local_root() {
127 if [ "$1" ]; then
128 __GS_LOCAL_ROOT="$(dirname $1/prune)"
129 else
130 echo ${__GS_LOCAL_ROOT}
131 fi
132 }
133
134 # Get/Set the GNUstep network root
135 egnustep_network_root() {
136 if [ "$1" ]; then
137 __GS_NETWORK_ROOT="$(dirname $1/prune)"
138 else
139 echo ${__GS_NETWORK_ROOT}
140 fi
141 }
142
143 # Get/Set the GNUstep user root
144 # Note: watch out for this one -- ~ and such must be enclosed in single-quotes when passed in
145 egnustep_user_root() {
146 if [ "$1" ]; then
147 __GS_USER_ROOT="$(dirname $1/prune)"
148 else
149 echo ${__GS_USER_ROOT}
150 fi
151 }
152
153 # Print the "suffix" of the user_root, or simply
154 # e.g ~/GNUstep => GNUstep
155 egnustep_user_root_suffix() {
156 echo ${!__GS_USER_ROOT_SUFFIX}
157 }
158
159 # Make utilizing GNUstep Makefiles
160 egnustep_make() {
161 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
162 local gs_make_opts="${1}"
163 if use debug ; then
164 gs_make_opts="${gs_make_opts} debug=yes"
165 fi
166 if use profile; then
167 gs_make_opts="${gs_make_opts} profile=yes"
168 fi
169 if use verbose; then
170 gs_make_opts="${gs_make_opts} messages=yes"
171 fi
172 eval emake ${__GS_MAKE_EVAL} ${gs_make_opts} all || die "package make failed"
173 else
174 die "no Makefile found"
175 fi
176 return 0
177 }
178
179 # Copies "convenience scripts"
180 egnustep_package_config() {
181 if [ -f ${FILESDIR}/config-${PN}.sh ]; then
182 dodir `egnustep_install_domain`/Tools/Gentoo
183 exeinto `egnustep_install_domain`/Tools/Gentoo
184 doexe ${FILESDIR}/config-${PN}.sh
185 fi
186 }
187
188 # Informs user about existence of "convenience script"
189 egnustep_package_config_info() {
190 if [ -f ${FILESDIR}/config-${PN}.sh ]; then
191 einfo "Make sure to set happy defaults for this package by executing:"
192 einfo " `egnustep_install_domain`/Tools/Gentoo/config-${PN}.sh"
193 einfo "as the user you will run the package as."
194 fi
195 }
196
197 # Make-install utilizing GNUstep Makefiles
198 egnustep_install() {
199 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
200 local gs_make_opts="${1}"
201 if use debug ; then
202 gs_make_opts="${gs_make_opts} debug=yes"
203 fi
204 if use profile; then
205 gs_make_opts="${gs_make_opts} profile=yes"
206 fi
207 if use verbose; then
208 gs_make_opts="${gs_make_opts} messages=yes"
209 fi
210 eval emake ${__GS_MAKE_EVAL} ${gs_make_opts} install || die "package install failed"
211 else
212 die "no Makefile found"
213 fi
214 return 0
215 }
216
217 # Make and install docs utilzing GNUstep Makefiles
218 # Note: docs installed with this from a GNUMakefile,
219 # not just some files in a Documentation directory
220 egnustep_doc() {
221 cd ${S}/Documentation
222 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
223 local gs_make_opts="${1}"
224 if use debug ; then
225 gs_make_opts="${gs_make_opts} debug=yes"
226 fi
227 if use profile; then
228 gs_make_opts="${gs_make_opts} profile=yes"
229 fi
230 if use verbose; then
231 gs_make_opts="${gs_make_opts} messages=yes"
232 fi
233 eval emake ${__GS_MAKE_EVAL} ${gs_make_opts} all || die "doc make failed"
234 eval emake ${__GS_MAKE_EVAL} ${gs_make_opts} install || die "doc install failed"
235 #XXX: I have no idea why this is called by ebuilds that don't have 'doc' in the
236 # USE flags, but user has 'doc' in global USE in make.conf
237 # else
238 # die "no Makefile found"
239 fi
240 cd ..
241 return 0
242 }
243
244 ###########################################################################
245 # Tests
246 # -----
247
248 objc_available() {
249 export OBJC_TEST="${TMP}/objc_test.m"
250 cat > "${OBJC_TEST}" << EOF
251 /**
252 * This example taken from the tutorial at:
253 * http://gnustep.made-it.com/GSPT/xml/Tutorial_en.html
254 <quote>
255 A GNUstep Programming Tutorial
256 Time is on our side...
257 Yen-Ju Chen
258 Dennis Leeuw
259
260 Copyright © 2003 Yen-Ju Chen, Dennis Leeuw
261
262 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
263 </quote>
264 */
265 #include <objc/Object.h>
266 @interface Greeter:Object
267 {
268 /* This is left empty on purpose:
269 * Normally instance variables would be declared here,
270 * but these are not used in our example.
271 */
272 }
273 - (void)greet;
274 @end
275
276 #include <stdio.h>
277 @implementation Greeter
278 - (void)greet
279 {
280 printf("Hello, World!\n");
281 }
282 @end
283
284 #include <stdlib.h>
285 int main(void)
286 {
287 id myGreeter;
288 myGreeter=[Greeter new];
289 [myGreeter greet];
290 [myGreeter free];
291 return EXIT_SUCCESS;
292 }
293 EOF
294
295 local available
296 available="yes"
297 eval $(tc-getCC) ${OBJC_TEST} -o ${OBJC_TEST}-out -lobjc || available="no"
298
299 echo ${available}
300 }
301
302 objc_not_available_info() {
303 einfo "gcc must be compiled with Objective-C support! See the objc USE flag."
304 einfo "NOTE: if you have to recompile gcc anyway, now may be the time to also add the 'gcj' use flag, so that libffi will also be compiled. Any gcc-3 version with 'gcj' should work, however, if you are testing >=gcc-3.4.3-r1 'objc' USE flag on should also install libffi."
305 }
306
307 ffi_available() {
308 export FFI_TEST="${TMP}/ffi_test.m"
309 cat > "${FFI_TEST}" << EOF
310 #include <ffi.h>
311
312 int main(int argc, char *argv[])
313 {
314 int n = argc;
315
316 return 0;
317 }
318 EOF
319
320 local available
321 available="yes"
322 # XXX
323 # Support dev-libs/libffi until it is deprecate
324 # (not that these -I and -L really matter
325 eval $(tc-getCC) ${FFI_TEST} -o ${FFI_TEST}-out -lffi || available="no"
326
327 echo ${available}
328 }
329
330 ffi_not_available_info() {
331 einfo "Your FFI libraries and headers seem to be installed incorrectly."
332 einfo "This is not as bad as it sounds -- not many projects use libffi at the moment, and gcc may have installed the headers in an inavailable place. Especially check for 'ffi.h' in your /usr/lib/gcc/\"\$CHOST\"/\"gcc-version\"/include directory, and that any other ffi related files it #include's (e.g. 'ffitarget.h') are in that directory as well; this can be solved by moving the files, or with a symlink. This is a quick fix, and newer ebuilds of gcc should install the files in the correct places, but for now, it could save you a recompilation of gcc."
333 einfo "If this still fails for you, consider not using the 'gcc-libffi' USE flag and letting dev-libs/libffi build as a dependency. It is important that either 'gcj' is a USE flag for gcc, or 'gcj' or 'objc' for >=gcc-3.4.3-r1."
334 }
335
336 ###########################################################################

  ViewVC Help
Powered by ViewVC 1.1.20