1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: gnustep-base.eclass
6 # GNUstep Herd <gnustep@gentoo.org>
7 # @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
8 # @BLURB: Internal handling of GNUstep pacakges
10 # Inner gnustep eclass, should only be inherited directly by gnustep-base
13 inherit eutils flag-o-matic
15 # IUSE variables across all GNUstep packages
16 # "debug": enable code for debugging
17 # "doc": build and install documentation, if available
20 # packages needed to build any base gnustep package
21 GNUSTEP_CORE_DEPEND="doc? ( virtual/texi2dvi dev-tex/latex2html app-text/texi2html )"
23 # New layout is used when ${EPREFIX}/usr/share/GNUstep/Makefiles exists
24 # Where to install GNUstep (with old layout)
25 GNUSTEP_PREFIX="${EPREFIX}/usr/GNUstep"
27 # GNUstep environment array
30 # Ebuild function overrides
31 gnustep-base_pkg_setup() {
32 if test_version_info 3.3 ; then
33 strip-unsupported-flags
34 elif test_version_info 3.4 ; then
35 # strict-aliasing is known to break obj-c stuff in gcc-3.4*
36 filter-flags -fstrict-aliasing
39 # known to break ObjC (bug 86089)
40 filter-flags -fomit-frame-pointer
43 gnustep-base_src_unpack() {
47 gnustep-base_src_prepare
50 gnustep-base_src_prepare() {
51 if [[ -f ./GNUmakefile ]] ; then
52 # Kill stupid includes that are simply overdone or useless on normal
53 # Gentoo, but (may) cause major headaches on Prefixed Gentoo. If this
54 # only removes a part of a path it's good that it bails out, as we want
55 # to know when they use some direct include.
56 ebegin "Cleaning paths from GNUmakefile"
58 -e 's|-I/usr/X11R6/include/\?||g' \
59 -e 's|-I/usr/include/\?||g' \
60 -e 's|-L/usr/X11R6/lib/\?||g' \
61 -e 's|-L/usr/lib/\?||g' \
66 ! has ${EAPI:-0} 0 1 2 3 4 5 && default
69 gnustep-base_src_configure() {
71 if [[ -x ./configure ]] ; then
72 econf || die "configure failed"
76 gnustep-base_src_compile() {
79 0|1) gnustep-base_src_configure ;;
85 gnustep-base_src_install() {
92 egnustep_install_config
95 gnustep-base_pkg_postinst() {
96 [[ $(type -t gnustep_config_script) != "function" ]] && return 0
99 if [[ -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then
100 SCRIPT_PATH="/usr/bin"
102 SCRIPT_PATH=${GNUSTEP_SYSTEM_TOOLS}/Gentoo
104 elog "To use this package, as *user* you should run:"
105 elog " ${SCRIPT_PATH}/config-${PN}.sh"
108 # Clean/reset an ebuild to the installed GNUstep environment
110 # Get additional variables
111 GNUSTEP_SH_EXPORT_ALL_VARIABLES="true"
115 if [[ -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then
116 GS_MAKEFILES=${EPREFIX}/usr/share/GNUstep/Makefiles
118 GS_MAKEFILES=${GNUSTEP_PREFIX}/System/Library/Makefiles
120 if [[ -f ${GS_MAKEFILES}/GNUstep.sh ]] ; then
121 # Reset GNUstep variables
122 source "${GS_MAKEFILES}"/GNUstep-reset.sh
123 source "${GS_MAKEFILES}"/GNUstep.sh
125 # Create compilation GNUstep.conf if it does not exist yet
126 if [[ ! -f ${WORKDIR}/GNUstep.conf ]]; then
127 cp "${EPREFIX}"/etc/GNUstep/GNUstep.conf "${WORKDIR}" \
128 || die "GNUstep.conf copy failed"
129 sed -e "s#\(GNUSTEP_USER_.*DIR.*=\)#\1${WORKDIR}/#" \
130 -i "${WORKDIR}"/GNUstep.conf || die "GNUstep.conf sed failed"
134 if [[ ! -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then
135 # Set rpath in ldflags when available
137 *-linux-gnu|*-solaris*)
138 is-ldflagq -Wl,-rpath="${GNUSTEP_SYSTEM_LIBRARIES}" \
140 -Wl,-rpath="${GNUSTEP_SYSTEM_LIBRARIES}"
145 # Set up env vars for make operations
146 GS_ENV=( AUXILIARY_LDFLAGS="${LDFLAGS}" \
147 ADDITIONAL_NATIVE_LIB_DIRS="${GNUSTEP_SYSTEM_LIBRARIES}" \
150 GNUSTEP_CONFIG_FILE="${WORKDIR}"/GNUstep.conf \
151 GNUSTEP_INSTALLATION_DOMAIN=SYSTEM \
152 TAR_OPTIONS="${TAR_OPTIONS} --no-same-owner" \
156 && GS_ENV=( "${GS_ENV[@]}" VARTEXFONTS="${T}"/fonts )
159 && GS_ENV=( "${GS_ENV[@]}" "debug=yes" ) \
160 || GS_ENV=( "${GS_ENV[@]}" "debug=no" )
162 if has_version "gnustep-base/gnustep-make[libobjc2]";
164 # Set clang for packages that do not respect gnustep-make
165 # settings (gnustep-base's configure for example)
166 export CC=clang CXX=clang CPP="clang -E" LD="clang"
171 die "gnustep-make not installed!"
174 # Make utilizing GNUstep Makefiles
176 if [[ -f ./Makefile || -f ./makefile || -f ./GNUmakefile ]] ; then
177 emake ${*} "${GS_ENV[@]}" all || die "package make failed"
180 die "no Makefile found"
183 # Make-install utilizing GNUstep Makefiles
185 if [[ ! -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then
186 # avoid problems due to our "weird" prefix, make sure it exists
187 mkdir -p "${D}"${GNUSTEP_SYSTEM_TOOLS}
189 if [[ -f ./[mM]akefile || -f ./GNUmakefile ]] ; then
190 emake ${*} "${GS_ENV[@]}" install || die "package install failed"
193 die "no Makefile found"
196 # Make and install docs using GNUstep Makefiles
198 if [[ -d "${S}"/Documentation ]] ; then
199 # Check documentation presence
200 pushd "${S}"/Documentation || die
201 if [[ -f ./[mM]akefile || -f ./GNUmakefile ]] ; then
202 emake "${GS_ENV[@]}" all || die "doc make failed"
203 emake "${GS_ENV[@]}" install || die "doc install failed"
209 egnustep_install_config() {
210 [[ $(type -t gnustep_config_script) != "function" ]] && return 0
212 local cfile=config-${PN}.sh
214 cat << 'EOF' > "${T}"/${cfile}
216 gnustep_append_default() {
217 if [[ -z $1 || -z $2 || -z $3 ]]; then
218 echo "warning: invalid script invocation"
224 cur=$(defaults read ${dom} ${key}) 2> /dev/null
225 if [[ -z $cur ]] ; then
226 echo " * setting ${dom} ${key}"
227 defaults write ${dom} ${key} "( ${val} )"
228 elif [[ ${cur} != *${val}* ]] ; then
229 echo " * adding ${val} to ${dom} ${key}"
230 echo "${cur%)\'}, \"${val}\" )'" | defaults write
232 echo " * ${val} already present in ${dom} ${key}"
236 gnustep_set_default() {
237 if [[ -z $1 || -z $2 || -z $3 ]]; then
238 echo "warning: invalid script invocation"
244 echo " * setting ${dom} ${key}"
245 defaults write ${dom} ${key} ${val}
250 echo "echo \"Applying ${P} default configuration ...\"" >> "${T}"/${cfile}
252 gnustep_config_script | \
254 echo "${line}" >> "${T}"/${cfile}
256 echo 'echo "done"' >> "${T}"/${cfile}
258 if [[ -d ${EPREFIX}/usr/share/GNUstep/Makefiles ]]; then
261 exeinto ${GNUSTEP_SYSTEM_TOOLS#${EPREFIX}}/Gentoo
263 doexe "${T}"/${cfile}
267 0|1) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst ;;
268 *) EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile src_install pkg_postinst ;;