| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2007 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/gnustep-base.eclass,v 1.2 2007/08/19 18:15:04 grobian Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/gnustep-base.eclass,v 1.17 2011/06/06 19:17:38 voyageur Exp $ |
| 4 | |
4 | |
| 5 | inherit eutils flag-o-matic |
5 | # @ECLASS: gnustep-base.eclass |
| 6 | |
6 | # @MAINTAINER: |
|
|
7 | # GNUstep Herd <gnustep@gentoo.org> |
|
|
8 | # @BLURB: Internal handling of GNUstep pacakges |
|
|
9 | # @DESCRIPTION: |
| 7 | # Inner gnustep eclass, should only be inherited directly by gnustep-base |
10 | # Inner gnustep eclass, should only be inherited directly by gnustep-base |
| 8 | # packages |
11 | # packages |
| 9 | # |
12 | |
| 10 | # maintainer: GNUstep Herd <gnustep@gentoo.org> |
13 | inherit eutils flag-o-matic |
| 11 | |
14 | |
| 12 | # IUSE variables across all GNUstep packages |
15 | # IUSE variables across all GNUstep packages |
| 13 | # "debug": enable code for debugging |
16 | # "debug": enable code for debugging |
| 14 | # "doc": build and install documentation, if available |
17 | # "doc": build and install documentation, if available |
| 15 | IUSE="debug doc" |
18 | IUSE="debug doc" |
| 16 | |
19 | |
| 17 | # packages needed to build any base gnustep package |
20 | # packages needed to build any base gnustep package |
| 18 | GNUSTEP_CORE_DEPEND="virtual/libc |
21 | GNUSTEP_CORE_DEPEND="doc? ( virtual/texi2dvi dev-tex/latex2html app-text/texi2html )" |
| 19 | doc? ( virtual/tetex =dev-tex/latex2html-2002* >=app-text/texi2html-1.64 )" |
|
|
| 20 | |
22 | |
| 21 | # Where to install GNUstep |
23 | # New layout is used when ${EPREFIX}/usr/share/GNUstep/Makefiles exists |
|
|
24 | # Where to install GNUstep (with old layout) |
| 22 | GNUSTEP_PREFIX="/usr/GNUstep" |
25 | GNUSTEP_PREFIX="${EPREFIX}/usr/GNUstep" |
| 23 | |
26 | |
| 24 | # GNUstep environment array |
27 | # GNUstep environment array |
| 25 | typeset -a GS_ENV |
28 | typeset -a GS_ENV |
| 26 | |
29 | |
| 27 | # Ebuild function overrides |
30 | # Ebuild function overrides |
| … | |
… | |
| 39 | |
42 | |
| 40 | gnustep-base_src_unpack() { |
43 | gnustep-base_src_unpack() { |
| 41 | unpack ${A} |
44 | unpack ${A} |
| 42 | cd "${S}" |
45 | cd "${S}" |
| 43 | |
46 | |
|
|
47 | gnustep-base_src_prepare |
|
|
48 | } |
|
|
49 | |
|
|
50 | gnustep-base_src_prepare() { |
| 44 | if [[ -f ./GNUmakefile ]] ; then |
51 | if [[ -f ./GNUmakefile ]] ; then |
| 45 | # Kill stupid includes that are simply overdone or useless on normal |
52 | # Kill stupid includes that are simply overdone or useless on normal |
| 46 | # Gentoo, but (may) cause major headaches on Prefixed Gentoo. If this |
53 | # Gentoo, but (may) cause major headaches on Prefixed Gentoo. If this |
| 47 | # only removes a part of a path it's good that it bails out, as we want |
54 | # only removes a part of a path it's good that it bails out, as we want |
| 48 | # to know when they use some direct include. |
55 | # to know when they use some direct include. |
| … | |
… | |
| 55 | GNUmakefile |
62 | GNUmakefile |
| 56 | eend $? |
63 | eend $? |
| 57 | fi |
64 | fi |
| 58 | } |
65 | } |
| 59 | |
66 | |
| 60 | gnustep-base_src_compile() { |
67 | gnustep-base_src_configure() { |
| 61 | egnustep_env |
68 | egnustep_env |
| 62 | if [[ -x ./configure ]] ; then |
69 | if [[ -x ./configure ]] ; then |
| 63 | econf || die "configure failed" |
70 | econf || die "configure failed" |
| 64 | fi |
71 | fi |
|
|
72 | } |
|
|
73 | |
|
|
74 | gnustep-base_src_compile() { |
|
|
75 | egnustep_env |
|
|
76 | case ${EAPI:-0} in |
|
|
77 | 0|1) gnustep-base_src_configure ;; |
|
|
78 | esac |
|
|
79 | |
| 65 | egnustep_make |
80 | egnustep_make |
| 66 | } |
81 | } |
| 67 | |
82 | |
| 68 | gnustep-base_src_install() { |
83 | gnustep-base_src_install() { |
| 69 | egnustep_env |
84 | egnustep_env |
| … | |
… | |
| 76 | } |
91 | } |
| 77 | |
92 | |
| 78 | gnustep-base_pkg_postinst() { |
93 | gnustep-base_pkg_postinst() { |
| 79 | [[ $(type -t gnustep_config_script) != "function" ]] && return 0 |
94 | [[ $(type -t gnustep_config_script) != "function" ]] && return 0 |
| 80 | |
95 | |
|
|
96 | local SCRIPT_PATH |
|
|
97 | if [[ -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then |
|
|
98 | SCRIPT_PATH="/usr/bin" |
|
|
99 | else |
|
|
100 | SCRIPT_PATH=${GNUSTEP_SYSTEM_TOOLS}/Gentoo |
|
|
101 | fi |
| 81 | elog "To use this package, as *user* you should run:" |
102 | elog "To use this package, as *user* you should run:" |
| 82 | elog " ${GNUSTEP_SYSTEM_TOOLS}/Gentoo/config-${PN}.sh" |
103 | elog " ${SCRIPT_PATH}/config-${PN}.sh" |
| 83 | } |
104 | } |
| 84 | |
105 | |
| 85 | # Clean/reset an ebuild to the installed GNUstep environment |
106 | # Clean/reset an ebuild to the installed GNUstep environment |
| 86 | egnustep_env() { |
107 | egnustep_env() { |
| 87 | # Get additional variables |
108 | # Get additional variables |
| 88 | GNUSTEP_SH_EXPORT_ALL_VARIABLES="true" |
109 | GNUSTEP_SH_EXPORT_ALL_VARIABLES="true" |
| 89 | |
110 | |
| 90 | if [[ -f ${GNUSTEP_PREFIX}/System/Library/Makefiles/GNUstep.sh ]] ; then |
111 | # Makefiles path |
|
|
112 | local GS_MAKEFILES |
|
|
113 | if [[ -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then |
|
|
114 | GS_MAKEFILES=${EPREFIX}/usr/share/GNUstep/Makefiles |
|
|
115 | else |
|
|
116 | GS_MAKEFILES=${GNUSTEP_PREFIX}/System/Library/Makefiles |
|
|
117 | fi |
|
|
118 | if [[ -f ${GS_MAKEFILES}/GNUstep.sh ]] ; then |
| 91 | # Reset GNUstep variables |
119 | # Reset GNUstep variables |
| 92 | source "${GNUSTEP_PREFIX}"/System/Library/Makefiles/GNUstep-reset.sh |
120 | source "${GS_MAKEFILES}"/GNUstep-reset.sh |
| 93 | source "${GNUSTEP_PREFIX}"/System/Library/Makefiles/GNUstep.sh |
121 | source "${GS_MAKEFILES}"/GNUstep.sh |
| 94 | |
122 | |
| 95 | # Needed to run installed GNUstep apps in sandbox |
123 | # Create compilation GNUstep.conf if it does not exist yet |
| 96 | addpredict "/root/GNUstep" |
124 | if [[ ! -f ${T}/GNUstep.conf ]]; then |
|
|
125 | cp "${EPREFIX}"/etc/GNUstep/GNUstep.conf "${T}" \ |
|
|
126 | || die "GNUstep.conf copy failed" |
|
|
127 | sed -e "s#\(GNUSTEP_USER_DIR=\).*#\1${T}#" \ |
|
|
128 | -e "s#\(GNUSTEP_USER_DEFAULTS_DIR=\).*#\1${T}/Defaults#" \ |
|
|
129 | -i "${T}"/GNUstep.conf || die "GNUstep.conf sed failed" |
|
|
130 | fi |
| 97 | |
131 | |
|
|
132 | |
|
|
133 | if [[ ! -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then |
| 98 | # Set rpath in ldflags when available |
134 | # Set rpath in ldflags when available |
| 99 | case ${CHOST} in |
135 | case ${CHOST} in |
| 100 | *-linux-gnu|*-solaris*) |
136 | *-linux-gnu|*-solaris*) |
|
|
137 | is-ldflagq -Wl,-rpath="${GNUSTEP_SYSTEM_LIBRARIES}" \ |
| 101 | append-ldflags \ |
138 | || append-ldflags \ |
| 102 | -Wl,-rpath="${GNUSTEP_SYSTEM_LIBRARIES}" \ |
139 | -Wl,-rpath="${GNUSTEP_SYSTEM_LIBRARIES}" |
| 103 | -L"${GNUSTEP_SYSTEM_LIBRARIES}" |
|
|
| 104 | ;; |
140 | ;; |
| 105 | *) |
|
|
| 106 | append-ldflags \ |
|
|
| 107 | -L"${GNUSTEP_SYSTEM_LIBRARIES}" |
|
|
| 108 | ;; |
|
|
| 109 | esac |
141 | esac |
|
|
142 | fi |
| 110 | |
143 | |
| 111 | # Set up env vars for make operations |
144 | # Set up env vars for make operations |
| 112 | GS_ENV=( AUXILIARY_LDFLAGS="${LDFLAGS}" \ |
145 | GS_ENV=( AUXILIARY_LDFLAGS="${LDFLAGS}" \ |
|
|
146 | ADDITIONAL_NATIVE_LIB_DIRS="${GNUSTEP_SYSTEM_LIBRARIES}" \ |
| 113 | DESTDIR="${D}" \ |
147 | DESTDIR="${D}" \ |
| 114 | HOME="${T}" \ |
148 | HOME="${T}" \ |
|
|
149 | GNUSTEP_CONFIG_FILE="${T}"/GNUstep.conf \ |
| 115 | GNUSTEP_USER_DIR="${T}" \ |
150 | GNUSTEP_USER_DIR="${T}" \ |
| 116 | GNUSTEP_USER_DEFAULTS_DIR="${T}"/Defaults \ |
151 | GNUSTEP_USER_DEFAULTS_DIR="${T}"/Defaults \ |
| 117 | GNUSTEP_INSTALLATION_DOMAIN=SYSTEM \ |
152 | GNUSTEP_INSTALLATION_DOMAIN=SYSTEM \ |
| 118 | TAR_OPTIONS="${TAR_OPTIONS} --no-same-owner" \ |
153 | TAR_OPTIONS="${TAR_OPTIONS} --no-same-owner" \ |
| 119 | messages=yes \ |
154 | messages=yes \ |
| 120 | -j1 ) |
155 | -j1 ) |
| 121 | # -j1 is needed as gnustep-make is not parallel-safe |
|
|
| 122 | |
156 | |
| 123 | use debug \ |
157 | use debug \ |
| 124 | && GS_ENV=( "${GS_ENV[@]}" "debug=yes" ) \ |
158 | && GS_ENV=( "${GS_ENV[@]}" "debug=yes" ) \ |
| 125 | || GS_ENV=( "${GS_ENV[@]}" "debug=no" ) |
159 | || GS_ENV=( "${GS_ENV[@]}" "debug=no" ) |
| 126 | |
160 | |
| … | |
… | |
| 129 | die "gnustep-make not installed!" |
163 | die "gnustep-make not installed!" |
| 130 | } |
164 | } |
| 131 | |
165 | |
| 132 | # Make utilizing GNUstep Makefiles |
166 | # Make utilizing GNUstep Makefiles |
| 133 | egnustep_make() { |
167 | egnustep_make() { |
| 134 | if [[ -f ./[mM]akefile || -f ./GNUmakefile ]] ; then |
168 | if [[ -f ./Makefile || -f ./makefile || -f ./GNUmakefile ]] ; then |
| 135 | emake ${*} "${GS_ENV[@]}" all || die "package make failed" |
169 | emake ${*} "${GS_ENV[@]}" all || die "package make failed" |
| 136 | return 0 |
170 | return 0 |
| 137 | fi |
171 | fi |
| 138 | die "no Makefile found" |
172 | die "no Makefile found" |
| 139 | } |
173 | } |
| 140 | |
174 | |
| 141 | # Make-install utilizing GNUstep Makefiles |
175 | # Make-install utilizing GNUstep Makefiles |
| 142 | egnustep_install() { |
176 | egnustep_install() { |
|
|
177 | if [[ ! -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then |
| 143 | # avoid problems due to our "weird" prefix, make sure it exists |
178 | # avoid problems due to our "weird" prefix, make sure it exists |
| 144 | mkdir -p "${D}"${GNUSTEP_SYSTEM_TOOLS} |
179 | mkdir -p "${D}"${GNUSTEP_SYSTEM_TOOLS} |
|
|
180 | fi |
| 145 | if [[ -f ./[mM]akefile || -f ./GNUmakefile ]] ; then |
181 | if [[ -f ./[mM]akefile || -f ./GNUmakefile ]] ; then |
| 146 | emake ${*} "${GS_ENV[@]}" install || die "package install failed" |
182 | emake ${*} "${GS_ENV[@]}" install || die "package install failed" |
| 147 | return 0 |
183 | return 0 |
| 148 | fi |
184 | fi |
| 149 | die "no Makefile found" |
185 | die "no Makefile found" |
| … | |
… | |
| 165 | egnustep_install_config() { |
201 | egnustep_install_config() { |
| 166 | [[ $(type -t gnustep_config_script) != "function" ]] && return 0 |
202 | [[ $(type -t gnustep_config_script) != "function" ]] && return 0 |
| 167 | |
203 | |
| 168 | local cfile=config-${PN}.sh |
204 | local cfile=config-${PN}.sh |
| 169 | |
205 | |
| 170 | echo '#!/usr/bin/env bash' > "${T}"/${cfile} |
206 | cat << 'EOF' > "${T}"/${cfile} |
|
|
207 | #!/usr/bin/env bash |
|
|
208 | gnustep_append_default() { |
|
|
209 | if [[ -z $1 || -z $2 || -z $3 ]]; then |
|
|
210 | echo "warning: invalid script invocation" |
|
|
211 | return |
|
|
212 | fi |
|
|
213 | dom=$1 |
|
|
214 | key=$2 |
|
|
215 | val=$3 |
|
|
216 | cur=$(defaults read ${dom} ${key}) 2> /dev/null |
|
|
217 | if [[ -z $cur ]] ; then |
|
|
218 | echo " * setting ${dom} ${key}" |
|
|
219 | defaults write ${dom} ${key} "( ${val} )" |
|
|
220 | elif [[ ${cur} != *${val}* ]] ; then |
|
|
221 | echo " * adding ${val} to ${dom} ${key}" |
|
|
222 | echo "${cur%)\'}, \"${val}\" )'" | defaults write |
|
|
223 | else |
|
|
224 | echo " * ${val} already present in ${dom} ${key}" |
|
|
225 | fi |
|
|
226 | } |
|
|
227 | |
|
|
228 | gnustep_set_default() { |
|
|
229 | if [[ -z $1 || -z $2 || -z $3 ]]; then |
|
|
230 | echo "warning: invalid script invocation" |
|
|
231 | return |
|
|
232 | fi |
|
|
233 | dom=$1 |
|
|
234 | key=$2 |
|
|
235 | val=$3 |
|
|
236 | echo " * setting ${dom} ${key}" |
|
|
237 | defaults write ${dom} ${key} ${val} |
|
|
238 | } |
|
|
239 | |
|
|
240 | EOF |
|
|
241 | |
| 171 | echo "echo Applying ${P} default configuration ..." >> "${T}"/${cfile} |
242 | echo "echo \"Applying ${P} default configuration ...\"" >> "${T}"/${cfile} |
|
|
243 | |
| 172 | gnustep_config_script | \ |
244 | gnustep_config_script | \ |
| 173 | while read line ; do |
245 | while read line ; do |
| 174 | echo "${line}" >> "${T}"/${cfile} |
246 | echo "${line}" >> "${T}"/${cfile} |
| 175 | done |
247 | done |
| 176 | echo 'echo "done"' >> "${T}"/${cfile} |
248 | echo 'echo "done"' >> "${T}"/${cfile} |
| 177 | |
249 | |
|
|
250 | if [[ -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then |
|
|
251 | exeinto /usr/bin |
|
|
252 | else |
| 178 | exeinto ${GNUSTEP_SYSTEM_TOOLS}/Gentoo |
253 | exeinto ${GNUSTEP_SYSTEM_TOOLS#${EPREFIX}}/Gentoo |
|
|
254 | fi |
| 179 | doexe "${T}"/${cfile} |
255 | doexe "${T}"/${cfile} |
| 180 | } |
256 | } |
| 181 | |
257 | |
|
|
258 | case ${EAPI:-0} in |
| 182 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst |
259 | 0|1) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst ;; |
|
|
260 | *) EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile src_install pkg_postinst ;; |
|
|
261 | esac |