tuxedo-drivers: update to 4.12.0
[void-pkg.git] / common / hooks / pre-configure / 02-script-wrapper.sh
blob3d5d6c2ab3b8f36aa33cb744ca8afa4eb949d4af
1 # This hook creates wrappers for foo-config scripts in cross builds.
3 # Wrappers are created in ${wrksrc}/.xbps/bin and this path is appended
4 # to make configure scripts find them.
6 generic_wrapper() {
7 local wrapper="$1"
8 [ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
9 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
11 cat >>${XBPS_WRAPPERDIR}/${wrapper}<<_EOF
12 #!/bin/sh
13 exec ${XBPS_CROSS_BASE}/usr/bin/${wrapper} --prefix=${XBPS_CROSS_BASE}/usr "\$@"
14 _EOF
16 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
19 generic_wrapper2() {
20 local wrapper="$1"
22 [ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
23 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
25 cat >>${XBPS_WRAPPERDIR}/${wrapper}<<_EOF
26 #!/bin/sh
27 if [ "\$1" = "--prefix" ]; then
28 echo "${XBPS_CROSS_BASE}/usr"
29 elif [ "\$1" = "--cflags" ]; then
30 ${XBPS_CROSS_BASE}/usr/bin/${wrapper} --cflags | sed -e "s,-I/usr/include,-I${XBPS_CROSS_BASE}/usr/include,g"
31 elif [ "\$1" = "--libs" ]; then
32 ${XBPS_CROSS_BASE}/usr/bin/${wrapper} --libs | sed -e "s,-L/usr/lib,-L${XBPS_CROSS_BASE}/usr/lib,g"
33 else
34 exec ${XBPS_CROSS_BASE}/usr/bin/${wrapper} "\$@"
36 exit \$?
37 _EOF
38 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
41 generic_wrapper3() {
42 local wrapper="$1"
43 [ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
44 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
46 cp ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ${XBPS_WRAPPERDIR}
47 sed -e "s,^libdir=.*,libdir=${XBPS_CROSS_BASE}/usr/lib,g" -i ${XBPS_WRAPPERDIR}/${wrapper}
48 sed -e "s,^prefix=.*,prefix=${XBPS_CROSS_BASE}/usr," -i ${XBPS_WRAPPERDIR}/${wrapper}
50 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
53 qemu_wrapper() {
54 local wrapper="$1"
55 [ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
56 [ -x ${XBPS_WRAPPERDIR}/${wrapper}-qemu ] && return 0
58 cat >>${XBPS_WRAPPERDIR}/${wrapper}-qemu<<_EOF
59 #!/bin/sh
60 export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
61 exec qemu-${XBPS_TARGET_QEMU_MACHINE} ${XBPS_CROSS_BASE}/usr/bin/${wrapper} "\$@"
62 _EOF
63 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}-qemu
66 apr_apu_wrapper() {
67 local wrapper="$1"
69 [ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
70 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
72 cat >>${XBPS_WRAPPERDIR}/${wrapper}<<_EOF
73 #!/bin/sh
74 ${XBPS_CROSS_BASE}/usr/bin/${wrapper} "\$@" | sed -e "s,/usr/,${XBPS_CROSS_BASE}/usr/,g"
75 exit \$?
76 _EOF
77 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
80 python_wrapper() {
81 local wrapper="$1" version="$2"
83 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
84 cat >>${XBPS_WRAPPERDIR}/${wrapper}<<_EOF
85 #!/bin/sh
86 case "\$1" in
87 --includes|--cflags)
88 echo "-I${XBPS_CROSS_BASE}/usr/include/python${version}" ;;
89 esac
90 exit 0
91 _EOF
92 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
95 pkgconfig_wrapper() {
96 if [ ! -x /usr/bin/pkg-config ]; then
97 return 0
99 [ -x ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-pkg-config ] && return 0
100 cat >>${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-pkg-config<<_EOF
101 #!/bin/sh
103 export PKG_CONFIG_SYSROOT_DIR="$XBPS_CROSS_BASE"
104 export PKG_CONFIG_PATH="$XBPS_CROSS_BASE/usr/lib/pkgconfig:$XBPS_CROSS_BASE/usr/share/pkgconfig\${PKG_CONFIG_PATH:+:\${PKG_CONFIG_PATH}}"
105 export PKG_CONFIG_LIBDIR="$XBPS_CROSS_BASE/usr/lib/pkgconfig\${PKG_CONFIG_LIBDIR:+:\${PKG_CONFIG_LIBDIR}}"
106 exec /usr/bin/pkg-config "\$@"
107 _EOF
108 chmod 755 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-pkg-config
109 if [ -z "$no_generic_pkgconfig_link" ]; then
110 ln -sf ${XBPS_CROSS_TRIPLET}-pkg-config ${XBPS_WRAPPERDIR}/pkg-config
114 vapigen_wrapper() {
115 local _vala_version _file
116 if [ ! -x /usr/bin/vapigen ]; then
117 return 0
119 [ -x ${XBPS_WRAPPERDIR}/vapigen ] && return 0
120 for _file in /usr/bin/vapigen-*; do
121 if [ -x "${_file}" ]; then
122 _vala_version=${_file#*-}
124 done
125 cat >>${XBPS_WRAPPERDIR}/vapigen<<_EOF
126 #!/bin/sh
127 exec /usr/bin/vapigen \\
128 "\$@" \\
129 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala/vapi \\
130 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala-${_vala_version}/vapi \\
131 --girdir=${XBPS_CROSS_BASE}/usr/share/gir-1.0
132 _EOF
133 chmod 755 ${XBPS_WRAPPERDIR}/vapigen
134 ln -sf vapigen ${XBPS_WRAPPERDIR}/vapigen-${_vala_version}
137 valac_wrapper() {
138 local _vala_version _file
139 if [ ! -x /usr/bin/valac ]; then
140 return 0
142 [ -x ${XBPS_WRAPPERDIR}/valac ] && return 0
143 for _file in /usr/bin/valac-*; do
144 if [ -x "${_file}" ]; then
145 _vala_version=${_file#*-}
147 done
148 cat >>${XBPS_WRAPPERDIR}/valac<<_EOF
149 #!/bin/sh
150 exec /usr/bin/valac \\
151 "\$@" \\
152 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala/vapi \\
153 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala-${_vala_version}/vapi \\
154 --girdir=${XBPS_CROSS_BASE}/usr/share/gir-1.0
155 _EOF
156 chmod 755 ${XBPS_WRAPPERDIR}/valac
157 ln -sf valac ${XBPS_WRAPPERDIR}/valac-${_vala_version}
160 install_wrappers() {
161 local fname
163 for f in ${XBPS_COMMONDIR}/wrappers/*.sh; do
164 fname=${f##*/}
165 fname=${fname%.sh}
166 install -p -m0755 ${f} ${XBPS_WRAPPERDIR}/${fname}
167 done
170 install_cross_wrappers() {
171 local fname prefix
173 if [ -n "$XBPS_CCACHE" ]; then
174 [ -x "/usr/bin/ccache" ] && prefix="/usr/bin/ccache "
175 elif [ -n "$XBPS_DISTCC" ]; then
176 [ -x "/usr/bin/distcc" ] && prefix="/usr/bin/distcc "
179 for fname in cc gcc; do
180 sed -e "s,@BIN@,${prefix}/usr/bin/$XBPS_CROSS_TRIPLET-gcc,g" \
181 ${XBPS_COMMONDIR}/wrappers/cross-cc > \
182 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
183 chmod 755 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
184 done
185 for fname in c++ g++; do
186 sed -e "s,@BIN@,${prefix}/usr/bin/$XBPS_CROSS_TRIPLET-g++,g" \
187 ${XBPS_COMMONDIR}/wrappers/cross-cc > \
188 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
189 chmod 755 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
190 done
193 link_wrapper() {
194 local wrapper="$1"
195 [ ! -x "${XBPS_CROSS_BASE}/usr/bin/${wrapper}" ] && return 0
196 [ -L "${XBPS_WRAPPERDIR}/${wrapper}" ] && return 0
197 ln -sf "${XBPS_CROSS_BASE}/usr/bin/${wrapper}" "${XBPS_WRAPPERDIR}"
200 hook() {
201 export PATH="$XBPS_WRAPPERDIR:$PATH"
203 install_wrappers
205 [ -z "$CROSS_BUILD" ] && return 0
207 install_cross_wrappers
208 pkgconfig_wrapper
209 vapigen_wrapper
210 valac_wrapper
212 if [ -x /usr/bin/pkg-config ]; then
213 link_wrapper freetype-config
214 else
215 generic_wrapper freetype-config
218 generic_wrapper icu-config
219 generic_wrapper libgcrypt-config
220 generic_wrapper sdl-config
221 generic_wrapper sdl2-config
222 generic_wrapper gpgme-config
223 generic_wrapper gphoto2-config
224 generic_wrapper gphoto2-port-config
225 generic_wrapper imlib2-config
226 generic_wrapper libmikmod-config
227 generic_wrapper pcre-config
228 generic_wrapper net-snmp-config
229 generic_wrapper wx-config
230 generic_wrapper wx-config-3.0
231 generic_wrapper wx-config-gtk3
232 generic_wrapper2 curl-config
233 generic_wrapper2 gpg-error-config
234 generic_wrapper2 libassuan-config
235 generic_wrapper2 mysql_config
236 generic_wrapper2 taglib-config
237 generic_wrapper2 nspr-config
238 generic_wrapper2 gdal-config
239 generic_wrapper3 libpng-config
240 generic_wrapper3 xmlrpc-c-config
241 generic_wrapper3 krb5-config
242 generic_wrapper3 cups-config
243 generic_wrapper3 Magick-config
244 generic_wrapper3 fltk-config
245 generic_wrapper3 xslt-config
246 generic_wrapper3 xml2-config
247 generic_wrapper3 fox-config
248 generic_wrapper3 xapian-config
249 generic_wrapper3 ncurses5-config
250 generic_wrapper3 ncursesw5-config
251 generic_wrapper3 libetpan-config
252 generic_wrapper3 giblib-config
253 python_wrapper python-config 2.7
254 python_wrapper python3-config 3.13
255 apr_apu_wrapper apu-1-config
256 qemu_wrapper llvm-config