Magellan Linux

Contents of /branches/R11-unstable/include/meson.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32899 - (show annotations) (download)
Mon Apr 29 14:06:55 2019 UTC (4 years, 11 months ago) by niro
File size: 4290 byte(s)
-release unstable
1 # $Id$
2 # meson config tools
3
4 SDEPEND="${SDEPEND}
5 >= dev-util/meson-0.43
6 >= dev-util/ninja-1.8"
7
8 # enables features like --enable-blah with make
9 meson_enable()
10 {
11 local feature="$1"
12 local option="$2"
13 [[ -z ${option} ]] && option="true"
14
15 echo "-Denable-${feature}=${option}"
16 }
17
18 # disables features like --disable-blah with make
19 meson_disable()
20 {
21 local feature="$1"
22 echo "-Denable-${feature}=false"
23 }
24
25 # enables features like --with-blah with make
26 meson_with()
27 {
28 local feature="$1"
29 local option="$2"
30 [[ -z ${option} ]] && option="true"
31
32 echo "-Dwith-${feature}=${option}"
33 }
34
35 # enables features like --with-blah with make
36 meson_without()
37 {
38 local feature="$1"
39 echo "-Dwith-${feature}=false"
40 }
41
42 meson_bool_true()
43 {
44 local feature="$1"
45 meson_opt "${feature}" "true"
46 }
47
48 meson_bool_false()
49 {
50 local feature="$1"
51 meson_opt "${feature}" "false"
52 }
53
54 # generic meson opts
55 meson_opt()
56 {
57 local feature="$1"
58 local option="$2"
59 echo "-D${feature}=${option}"
60 }
61
62 meson_src_prepare()
63 {
64 munpack ${SRCFILE} || die
65 }
66
67 meson_configure()
68 {
69 local configure_opts="$@"
70 local default_opts
71
72 default_opts+=" --buildtype=release"
73 default_opts+=" --prefix=/usr"
74 default_opts+=" --sysconfdir=/etc"
75 default_opts+=" --localstatedir=/var/lib"
76
77 if [[ ${MULTILIB_BUILD} = true ]]
78 then
79 # must be escaped so the mlibdir variable gets evaluated later
80 default_opts+=' --libdir=/usr/$(mlibdir)'
81 default_opts+=' --libexecdir=/usr/$(mlibdir)/${PNAME}'
82 all-abis meson setup ${default_opts} ${configure_opts} ${SRCDIR}-$(mabi)/${SRCSUBDIR} ${BUILDDIR}/build-$(mabi) || die
83 else
84 # the mlibdir variable gets right now evaluated
85 default_opts+=" --libdir=/usr/$(mlibdir)"
86 default_opts+=" --libexecdir=/usr/$(mlibdir)/${PNAME}"
87 meson setup ${default_opts} ${configure_opts} ${SRCDIR}/${SRCSUBDIR} ${BUILDDIR}/build || die
88 fi
89 }
90
91 mninja()
92 {
93 local abi
94 local abis_to_run="${MULTILIB_ABIS}"
95
96 # respect MULTILIB_ONLY_ABI variable
97 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
98
99 if [[ ${MULTILIB_BUILD} = true ]]
100 then
101 for abi in ${abis_to_run}
102 do
103 echo -e "${COLBLUE}*** ${COLGREEN}running ninja for ABI -${abi}${COLDEFAULT}"
104 abi-${abi} ninja -C ${SRCDIR}-$(mabi)/${SRCSUBDIR} -C ${BUILDDIR}/build-$(mabi) -v ${MAKEOPTS} "$@"
105 done
106 else
107 ninja -C ${SRCDIR}/${SRCSUBDIR} -C ${BUILDDIR}/build -v ${MAKEOPTS} "$@"
108 fi
109 }
110
111 meson_setup_builddir()
112 {
113 local abi
114 local abis_to_run="${MULTILIB_ABIS}"
115
116 # respect MULTILIB_ONLY_ABI variable
117 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
118
119 if [[ ${MULTILIB_BUILD} = true ]]
120 then
121 for abi in ${abis_to_run}
122 do
123 echo -e "${COLBLUE}*** ${COLGREEN}running ninja for ABI -${abi}${COLDEFAULT}"
124 abi-${abi} install -d ${BUILDDIR}/build-$(mabi) || die
125 done
126 else
127 install -d ${BUILDDIR}/build || die
128 fi
129 }
130
131 meson_src_compile()
132 {
133 if [[ ${MULTILIB_BUILD} != true ]]
134 then
135 cd ${SRCDIR}
136 fi
137
138 meson_setup_builddir || die
139 meson_configure "$@" || die
140 mninja || die
141 }
142
143 meson_src_check()
144 {
145 cd ${BUILDDIR}/build
146 meson test || die
147 }
148
149 meson_multilib_src_check()
150 {
151 local abi
152 local abis_to_run="${MULTILIB_ABIS}"
153
154 # respect MULTILIB_ONLY_ABI variable
155 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
156 for abi in ${abis_to_run}
157 do
158 cd ${BUILDDIR}/build-${abi}
159 meson test || die
160 done
161 }
162
163 meson_src_install()
164 {
165 cd ${BUILDDIR}/build
166 DESTDIR=${BINDIR} ninja install || die
167
168 cd ${SRCDIR}
169 local i
170 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
171 FAQ LICENSE NEWS README TODO
172 do
173 if [ -f ${SRCDIR}/${i} ]
174 then
175 minstalldocs ${i} || die
176 fi
177 done
178 }
179
180 meson_multilib_src_install()
181 {
182 local abi
183 local abis_to_run="${MULTILIB_ABIS}"
184
185 # respect MULTILIB_ONLY_ABI variable
186 [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
187 for abi in ${abis_to_run}
188 do
189 cd ${BUILDDIR}/build-${abi}
190 DESTDIR=${BINDIR} ninja install || die
191
192 cd ${SRCDIR}-${abi}
193 local i
194 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
195 FAQ LICENSE NEWS README TODO
196 do
197 if [ -f ${SRCDIR}-${abi}/${i} ]
198 then
199 minstalldocs ${i} || die
200 fi
201 done
202 done
203 }
204
205 export_inherits meson src_prepare src_compile
206 if [[ ${MULTILIB_BUILD} = true ]]
207 then
208 export_inherits meson_multilib src_check src_install
209 else
210 export_inherits meson src_check src_install
211 fi