codeberg-cli: update to 0.4.6
[void-pkg.git] / common / build-style / sip-build.sh
blobd8b3bcea98bf094c355055172975d0f8999c699a
2 # This helper is for templates using sip-build.
5 do_configure() {
6 local _qt=
7 local _spec=
8 local _mkspec=
10 : "${sip_builddir:=build}"
11 mkdir -p "$sip_builddir"
13 if [ ! -d /$py3_sitelib/pyqtbuild ]; then
14 : "who uses sip-build without qmake anyway?"
15 elif [ -x /usr/lib/qt6/bin/qmake ]; then
16 _qt=qt6
17 elif [ -x /usr/lib/qt5/bin/qmake ]; then
18 _qt=qt5
19 else
20 msg_error 'qmake not found\n'
23 if [ ! "$_qt" ]; then
24 : "who use sip-build without qmake anyway?"
25 elif [ "$CROSS_BUILD" ]; then
26 _mkspec="usr/lib/$_qt/mkspecs"
27 _spec="$XBPS_WRAPPERDIR/sip-build/target-spec/linux-g++"
28 mkdir -p "$_spec"
29 cat >"$_spec/qmake.conf" <<-_EOF
30 MAKEFILE_GENERATOR = UNIX
31 CONFIG += incremental no_qt_rpath
32 QMAKE_INCREMENTAL_STYLE = sublib
34 include(/$_mkspec/common/linux.conf)
35 include(/$_mkspec/common/gcc-base-unix.conf)
36 include(/$_mkspec/common/g++-unix.conf)
38 QMAKE_TARGET_CONFIG = $XBPS_CROSS_BASE/$_mkspec/qconfig.pri
39 QMAKE_TARGET_MODULE = $XBPS_CROSS_BASE/$_mkspec/qmodule.pri
40 QMAKEMODULES = $XBPS_CROSS_BASE/$_mkspec/modules
41 QMAKE_CC = $CC
42 QMAKE_CXX = $CXX
43 QMAKE_LINK = $CXX
44 QMAKE_LINK_C = $CC
45 QMAKE_LINK_SHLIB = $CXX
47 QMAKE_AR = $XBPS_CROSS_TRIPLET-gcc-ar cqs
48 QMAKE_OBJCOPY = $OBJCOPY
49 QMAKE_NM = $NM -P
50 QMAKE_STRIP = $STRIP
52 QMAKE_CFLAGS = $CFLAGS -I$XBPS_CROSS_BASE/usr/include/python$py3_ver
53 QMAKE_CXXFLAGS = $CXXFLAGS -I$XBPS_CROSS_BASE/usr/include/python$py3_ver
54 QMAKE_LFLAGS = -L$XBPS_CROSS_BASE/usr/lib $LDFLAGS
55 load(qt_config)
56 _EOF
58 printf '#include "%s/%s/linux-g++/qplatformdefs.h"\n' \
59 "$XBPS_CROSS_BASE" "$_mkspec" >"$_spec/qplatformdefs.h"
60 cat >"$XBPS_WRAPPERDIR/sip-build/qt.conf" <<-_EOF
61 [Paths]
62 Sysroot=$XBPS_CROSS_BASE
63 Prefix=$XBPS_CROSS_BASE/usr
64 ArchData=$XBPS_CROSS_BASE/usr/lib/$_qt
65 Data=$XBPS_CROSS_BASE/usr/share/$_qt
66 Documentation=$XBPS_CROSS_BASE/usr/share/doc/$_qt
67 Headers=$XBPS_CROSS_BASE/usr/include/$_qt
68 Libraries=$XBPS_CROSS_BASE/usr/lib
69 LibraryExecutables=/usr/lib/$_qt/libexec
70 Binaries=/usr/lib/$_qt/bin
71 Tests=$XBPS_CROSS_BASE/usr/tests
72 Plugins=/usr/lib/$_qt/plugins
73 Imports=$XBPS_CROSS_BASE/usr/lib/$_qt/imports
74 Qml2Imports=$XBPS_CROSS_BASE/usr/lib/$_qt/qml
75 Translations=$XBPS_CROSS_BASE/usr/share/$_qt/translations
76 Settings=$XBPS_CROSS_BASE/etc/xdg
77 Examples=$XBPS_CROSS_BASE/usr/share/$_qt/examples
78 HostPrefix=/usr
79 HostData=/usr/lib/$_qt
80 HostBinaries=/usr/lib/$_qt/bin
81 HostLibraries=/usr/lib
82 HostLibraryExecutables=/usr/lib/$_qt/libexec
83 Spec=linux-g++
84 TargetSpec=$_spec
85 _EOF
86 # Call it sip-qmake to not override qmake build-helper
88 # XXX: Intentionally quote {C,CXX,LD}FLAGS here but not native.
89 # - Cross Build:
90 # + base flags will be picked up from QMAKE_{C,CXX,LD}FLAGS
91 # + hardening flags will be picked up from environment variables
92 # - Native Build:
93 # + hardening flags will be picked up first (Makefile, qt.conf?)
94 # + base flags will be picked up from QMAKE_{C,CXX,LD}FLAGS
95 # Maybe there're better workaround, I don't know.
96 cat >"$XBPS_WRAPPERDIR/sip-qmake" <<-_EOF
97 #!/bin/sh
98 exec /usr/lib/$_qt/bin/qmake "\$@" \\
99 -qtconf "$XBPS_WRAPPERDIR/sip-build/qt.conf" \\
100 PKG_CONFIG_EXECUTABLE=${XBPS_WRAPPERDIR}/${PKG_CONFIG} \\
101 QMAKE_CFLAGS+="\$CFLAGS" \\
102 QMAKE_CXXFLAGS+="\$CXXFLAGS" \\
103 QMAKE_LFLAGS+="\$LDFLAGS"
104 _EOF
105 chmod 755 ${XBPS_WRAPPERDIR}/sip-qmake
106 else
107 cat >"${XBPS_WRAPPERDIR}/sip-qmake" <<-_EOF
108 #!/bin/sh
109 exec /usr/lib/$_qt/bin/qmake \\
110 "\$@" \\
111 PREFIX=/usr \\
112 QT_INSTALL_PREFIX=/usr \\
113 LIB=/usr/lib \\
114 QMAKE_CC="$CC" QMAKE_CXX="$CXX" \\
115 QMAKE_LINK="$CXX" QMAKE_LINK_C="$CC" \\
116 QMAKE_CFLAGS+="$CFLAGS" \\
117 QMAKE_CXXFLAGS+="$CXXFLAGS" \\
118 QMAKE_LFLAGS+="$LDFLAGS" \\
119 CONFIG+=no_qt_rpath
120 _EOF
121 chmod 755 ${XBPS_WRAPPERDIR}/sip-qmake
124 sip-build --no-make \
125 ${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
126 --api-dir /usr/share/$_qt/qsci/api/python \
127 $configure_args \
128 --build-dir "$sip_builddir"
130 if [ "$CROSS_BUILD" ]; then
131 # -I/usr/include/python$py3_ver is set by sip-build :(
132 find "$sip_builddir" -name Makefile |
133 xargs sed -i "s,-I\\(/usr/include\\),-I$XBPS_CROSS_BASE\\1,g"
137 do_build() {
138 : "${sip_builddir:=build}"
139 make -C "${sip_builddir}" ${makejobs}
142 do_install() {
143 : "${sip_builddir:=build}"
144 make -C "${sip_builddir}" \
145 DESTDIR=${DESTDIR} INSTALL_ROOT=${DESTDIR} \
146 install