dev-libs/libusb: stable 1.0.21 for sparc, bug #630342
[gentoo.git] / eclass / dotnet.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: dotnet.eclass
5 # @MAINTAINER: cynede@gentoo.org
6 # @BLURB: common settings and functions for mono and dotnet related packages
7 # @DESCRIPTION:
8 # The dotnet eclass contains common environment settings that are useful for
9 # dotnet packages.  Currently, it provides no functions, just exports
10 # MONO_SHARED_DIR and sets LC_ALL in order to prevent errors during compilation
11 # of dotnet packages.
12
13 case ${EAPI:-0} in
14         0) die "this eclass doesn't support EAPI 0" ;;
15         1|2|3) ;;
16         *) ;; #if [[ ${USE_DOTNET} ]]; then REQUIRED_USE="|| (${USE_DOTNET})"; fi;;
17 esac
18
19 inherit eutils versionator mono-env
20
21 # @ECLASS-VARIABLE: USE_DOTNET
22 # @DESCRIPTION:
23 # Use flags added to IUSE
24
25 DEPEND+=" dev-lang/mono"
26
27 # SET default use flags according on DOTNET_TARGETS
28 for x in ${USE_DOTNET}; do
29         case ${x} in
30                 net45) if [[ ${DOTNET_TARGETS} == *net45* ]]; then IUSE+=" +net45"; else IUSE+=" net45"; fi;;
31                 net40) if [[ ${DOTNET_TARGETS} == *net40* ]]; then IUSE+=" +net40"; else IUSE+=" net40"; fi;;
32                 net35) if [[ ${DOTNET_TARGETS} == *net35* ]]; then IUSE+=" +net35"; else IUSE+=" net35"; fi;;
33                 net20) if [[ ${DOTNET_TARGETS} == *net20* ]]; then IUSE+=" +net20"; else IUSE+=" net20"; fi;;
34         esac
35 done
36
37 # @FUNCTION: dotnet_pkg_setup
38 # @DESCRIPTION:
39 # This function set FRAMEWORK.
40 dotnet_pkg_setup() {
41         for x in ${USE_DOTNET} ; do
42                 case ${x} in
43                         net45) if use net45; then F="4.5"; fi;;
44                         net40) if use net40; then F="4.0"; fi;;
45                         net35) if use net35; then F="3.5"; fi;;
46                         net20) if use net20; then F="2.0"; fi;;
47                 esac
48                 if [[ -z ${FRAMEWORK} ]]; then
49                         if [[ ${F} ]]; then
50                                 FRAMEWORK="${F}";
51                         fi
52                 else
53                         version_is_at_least "${F}" "${FRAMEWORK}" || FRAMEWORK="${F}"
54                 fi
55         done
56         if [[ -z ${FRAMEWORK} ]]; then
57                 FRAMEWORK="4.0"
58         fi
59         einfo " -- USING .NET ${FRAMEWORK} FRAMEWORK -- "
60 }
61
62 # >=mono-0.92 versions using mcs -pkg:foo-sharp require shared memory, so we set the
63 # shared dir to ${T} so that ${T}/.wapi can be used during the install process.
64 export MONO_SHARED_DIR="${T}"
65
66 # Building mono, nant and many other dotnet packages is known to fail if LC_ALL
67 # variable is not set to C. To prevent this all mono related packages will be
68 # build with LC_ALL=C (see bugs #146424, #149817)
69 export LC_ALL=C
70
71 # Monodevelop-using applications need this to be set or they will try to create config
72 # files in the user's ~ dir.
73
74 export XDG_CONFIG_HOME="${T}"
75
76 # Fix bug 83020:
77 # "Access Violations Arise When Emerging Mono-Related Packages with MONO_AOT_CACHE"
78
79 unset MONO_AOT_CACHE
80
81 # @FUNCTION: exbuild
82 # @DESCRIPTION:
83 # Run xbuild with Release configuration and configurated FRAMEWORK.
84 exbuild() {
85         elog "xbuild ""$@"" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v""${FRAMEWORK}"" || die"
86         xbuild "$@" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v"${FRAMEWORK}" || die
87 }
88
89 # @FUNCTION: egacinstall
90 # @DESCRIPTION:
91 # Install package to GAC.
92 egacinstall() {
93         use !prefix && has "${EAPI:-0}" 0 1 2 && ED="${D}"
94         gacutil -i "${1}" \
95                 -root "${ED}"/usr/$(get_libdir) \
96                 -gacdir /usr/$(get_libdir) \
97                 -package ${2:-${GACPN:-${PN}}} \
98                 || die "installing ${1} into the Global Assembly Cache failed"
99 }
100
101 # @FUNCTION: dotnet_multilib_comply
102 # @DESCRIPTION:
103 # multilib comply
104 dotnet_multilib_comply() {
105         use !prefix && has "${EAPI:-0}" 0 1 2 && ED="${D}"
106         local dir finddirs=() mv_command=${mv_command:-mv}
107         if [[ -d "${ED}/usr/lib" && "$(get_libdir)" != "lib" ]]
108         then
109                 if ! [[ -d "${ED}"/usr/"$(get_libdir)" ]]
110                 then
111                         mkdir "${ED}"/usr/"$(get_libdir)" || die "Couldn't mkdir ${ED}/usr/$(get_libdir)"
112                 fi
113                 ${mv_command} "${ED}"/usr/lib/* "${ED}"/usr/"$(get_libdir)"/ || die "Moving files into correct libdir failed"
114                 rm -rf "${ED}"/usr/lib
115                 for dir in "${ED}"/usr/"$(get_libdir)"/pkgconfig "${ED}"/usr/share/pkgconfig
116                 do
117
118                         if [[ -d "${dir}" && "$(find "${dir}" -name '*.pc')" != "" ]]
119                         then
120                                 pushd "${dir}" &> /dev/null
121                                 sed  -i -r -e 's:/(lib)([^a-zA-Z0-9]|$):/'"$(get_libdir)"'\2:g' \
122                                         *.pc \
123                                         || die "Sedding some sense into pkgconfig files failed."
124                                 popd "${dir}" &> /dev/null
125                         fi
126                 done
127                 if [[ -d "${ED}/usr/bin" ]]
128                 then
129                         for exe in "${ED}/usr/bin"/*
130                         do
131                                 if [[ "$(file "${exe}")" == *"shell script text"* ]]
132                                 then
133                                         sed -r -i -e ":/lib(/|$): s:/lib(/|$):/$(get_libdir)\1:" \
134                                                 "${exe}" || die "Sedding some sense into ${exe} failed"
135                                 fi
136                         done
137                 fi
138
139         fi
140 }
141
142 EXPORT_FUNCTIONS pkg_setup