rio: update to 0.2.0
[void-pkg.git] / common / hooks / pre-configure / 02-script-wrapper.sh
blob004c68442c061cd2baaff1d4232c673414a43018
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 apr_apu_wrapper() {
54 local wrapper="$1"
56 [ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
57 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
59 cat >>${XBPS_WRAPPERDIR}/${wrapper}<<_EOF
60 #!/bin/sh
61 ${XBPS_CROSS_BASE}/usr/bin/${wrapper} "\$@" | sed -e "s,/usr/,${XBPS_CROSS_BASE}/usr/,g"
62 exit \$?
63 _EOF
64 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
67 python_wrapper() {
68 local wrapper="$1" version="$2"
70 [ -x ${XBPS_WRAPPERDIR}/${wrapper} ] && return 0
71 cat >>${XBPS_WRAPPERDIR}/${wrapper}<<_EOF
72 #!/bin/sh
73 case "\$1" in
74 --includes|--cflags)
75 echo "-I${XBPS_CROSS_BASE}/usr/include/python${version}" ;;
76 esac
77 exit 0
78 _EOF
79 chmod 755 ${XBPS_WRAPPERDIR}/${wrapper}
82 pkgconfig_wrapper() {
83 if [ ! -x /usr/bin/pkg-config ]; then
84 return 0
86 [ -x ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-pkg-config ] && return 0
87 cat >>${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-pkg-config<<_EOF
88 #!/bin/sh
90 export PKG_CONFIG_SYSROOT_DIR="$XBPS_CROSS_BASE"
91 export PKG_CONFIG_PATH="$XBPS_CROSS_BASE/usr/lib/pkgconfig:$XBPS_CROSS_BASE/usr/share/pkgconfig\${PKG_CONFIG_PATH:+:\${PKG_CONFIG_PATH}}"
92 export PKG_CONFIG_LIBDIR="$XBPS_CROSS_BASE/usr/lib/pkgconfig\${PKG_CONFIG_LIBDIR:+:\${PKG_CONFIG_LIBDIR}}"
93 exec /usr/bin/pkg-config "\$@"
94 _EOF
95 chmod 755 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-pkg-config
96 if [ -z "$no_generic_pkgconfig_link" ]; then
97 ln -sf ${XBPS_CROSS_TRIPLET}-pkg-config ${XBPS_WRAPPERDIR}/pkg-config
101 vapigen_wrapper() {
102 local _vala_version _file
103 if [ ! -x /usr/bin/vapigen ]; then
104 return 0
106 [ -x ${XBPS_WRAPPERDIR}/vapigen ] && return 0
107 for _file in /usr/bin/vapigen-*; do
108 if [ -x "${_file}" ]; then
109 _vala_version=${_file#*-}
111 done
112 cat >>${XBPS_WRAPPERDIR}/vapigen<<_EOF
113 #!/bin/sh
114 exec /usr/bin/vapigen \\
115 "\$@" \\
116 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala/vapi \\
117 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala-${_vala_version}/vapi \\
118 --girdir=${XBPS_CROSS_BASE}/usr/share/gir-1.0
119 _EOF
120 chmod 755 ${XBPS_WRAPPERDIR}/vapigen
121 ln -sf vapigen ${XBPS_WRAPPERDIR}/vapigen-${_vala_version}
124 valac_wrapper() {
125 local _vala_version _file
126 if [ ! -x /usr/bin/valac ]; then
127 return 0
129 [ -x ${XBPS_WRAPPERDIR}/valac ] && return 0
130 for _file in /usr/bin/valac-*; do
131 if [ -x "${_file}" ]; then
132 _vala_version=${_file#*-}
134 done
135 cat >>${XBPS_WRAPPERDIR}/valac<<_EOF
136 #!/bin/sh
137 exec /usr/bin/valac \\
138 "\$@" \\
139 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala/vapi \\
140 --vapidir=${XBPS_CROSS_BASE}/usr/share/vala-${_vala_version}/vapi \\
141 --girdir=${XBPS_CROSS_BASE}/usr/share/gir-1.0
142 _EOF
143 chmod 755 ${XBPS_WRAPPERDIR}/valac
144 ln -sf valac ${XBPS_WRAPPERDIR}/valac-${_vala_version}
147 install_wrappers() {
148 local fname
150 for f in ${XBPS_COMMONDIR}/wrappers/*.sh; do
151 fname=${f##*/}
152 fname=${fname%.sh}
153 install -p -m0755 ${f} ${XBPS_WRAPPERDIR}/${fname}
154 done
157 install_cross_wrappers() {
158 local fname prefix
160 if [ -n "$XBPS_CCACHE" ]; then
161 [ -x "/usr/bin/ccache" ] && prefix="/usr/bin/ccache "
162 elif [ -n "$XBPS_DISTCC" ]; then
163 [ -x "/usr/bin/distcc" ] && prefix="/usr/bin/distcc "
166 for fname in cc gcc; do
167 sed -e "s,@BIN@,${prefix}/usr/bin/$XBPS_CROSS_TRIPLET-gcc,g" \
168 ${XBPS_COMMONDIR}/wrappers/cross-cc > \
169 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
170 chmod 755 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
171 done
172 for fname in c++ g++; do
173 sed -e "s,@BIN@,${prefix}/usr/bin/$XBPS_CROSS_TRIPLET-g++,g" \
174 ${XBPS_COMMONDIR}/wrappers/cross-cc > \
175 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
176 chmod 755 ${XBPS_WRAPPERDIR}/${XBPS_CROSS_TRIPLET}-${fname}
177 done
180 link_wrapper() {
181 local wrapper="$1"
182 [ ! -x "${XBPS_CROSS_BASE}/usr/bin/${wrapper}" ] && return 0
183 [ -L "${XBPS_WRAPPERDIR}/${wrapper}" ] && return 0
184 ln -sf "${XBPS_CROSS_BASE}/usr/bin/${wrapper}" "${XBPS_WRAPPERDIR}"
187 hook() {
188 export PATH="$XBPS_WRAPPERDIR:$PATH"
190 install_wrappers
192 [ -z "$CROSS_BUILD" ] && return 0
194 install_cross_wrappers
195 pkgconfig_wrapper
196 vapigen_wrapper
197 valac_wrapper
199 if [ -x /usr/bin/pkg-config ]; then
200 link_wrapper freetype-config
201 else
202 generic_wrapper freetype-config
205 generic_wrapper icu-config
206 generic_wrapper libgcrypt-config
207 generic_wrapper sdl-config
208 generic_wrapper sdl2-config
209 generic_wrapper gpgme-config
210 generic_wrapper gphoto2-config
211 generic_wrapper gphoto2-port-config
212 generic_wrapper imlib2-config
213 generic_wrapper libmikmod-config
214 generic_wrapper pcre-config
215 generic_wrapper net-snmp-config
216 generic_wrapper wx-config
217 generic_wrapper wx-config-3.0
218 generic_wrapper wx-config-gtk3
219 generic_wrapper2 curl-config
220 generic_wrapper2 gpg-error-config
221 generic_wrapper2 libassuan-config
222 generic_wrapper2 mysql_config
223 generic_wrapper2 taglib-config
224 generic_wrapper2 nspr-config
225 generic_wrapper2 gdal-config
226 generic_wrapper3 libpng-config
227 generic_wrapper3 xmlrpc-c-config
228 generic_wrapper3 krb5-config
229 generic_wrapper3 cups-config
230 generic_wrapper3 Magick-config
231 generic_wrapper3 fltk-config
232 generic_wrapper3 xslt-config
233 generic_wrapper3 xml2-config
234 generic_wrapper3 fox-config
235 generic_wrapper3 xapian-config
236 generic_wrapper3 ncurses5-config
237 generic_wrapper3 ncursesw5-config
238 generic_wrapper3 libetpan-config
239 generic_wrapper3 giblib-config
240 python_wrapper python-config 2.7
241 python_wrapper python3-config 3.12
242 apr_apu_wrapper apu-1-config