summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e1077c10e4a7a6cca91b9ef2aadb94cbf6766231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Maintainer: Donald Carr <sirspudd@gmail.com>

# Documentation

# Set up the pi for Qt compilation. On Arch I just install chromium which pulls in all the deps
# Removed xcomposite as code path breaks

# Remove 2 (mesa) pkgconfig files we allow screw our mkspec
# rm /usr/lib/pkgconfig/glesv2.pc
# rm /usr/lib/pkgconfig/egl.pc

# You are gonna want to export the following vars in /etc/profile.d
# if you intend to primarily use Wayland

#export QT_QPA_PLATFORM=wayland
#export QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=brcm

# Mount/copy this prepped rasp rootfs somewhere and set this path as the sysroot below
# I use NFS personally: sudo mount qpii.local:/ /mnt/pi

# comment this turkey out in any circumstance when you need to regenate .SRCINFO
echo "Set your sysroot prior to build" && exit 1
_sysroot=/mnt/pi

_packaginguser=$(whoami)
pkgname=qpii
_libspkgname="${pkgname}-libs"
_piver=2
_mkspec="linux-rpi${_piver}-g++"
pkgver=5.6.0
_pkgver=${pkgver}-beta
_baseprefix=/opt
_installprefix=${_baseprefix}/qt-${_pkgver}-rpi${_piver}
_pipkgname=qt-everywhere-opensource-src-${_pkgver}
pkgrel=4
pkgdesc="Cross compile Qt for the Raspberry Pi${_piver}"
arch=("x86_64")
url="http://www.qt.io"
license=("LGPL3")
makedepends=("git" "pkgconfig" "gcc" "qpi-toolchain")
source=("git://github.com/sirspudd/mkspecs.git" "https://download.qt.io/development_releases/qt/5.6/${_pkgver}/single/${_pipkgname}.tar.gz")
sha256sums=("SKIP" "d69103ec34b3775edfa47581b14ee9a20789d4b0d7d26220fb92f2cd32eb06f9")
options=('!strip')

build() {
  local _srcdir="${srcdir}/${_pipkgname}"
  local _bindir="${_srcdir}-build"

  # Qt tries to do the right thing and stores these, breaking cross compilation
  unset LDFLAGS
  unset CFLAGS
  unset CXXFLAGS

  # Get our mkspec
  cp -r "${srcdir}/mkspecs/${_mkspec}" ${_srcdir}/qtbase/mkspecs/devices

  mkdir -p ${_bindir}
  cd ${_bindir}

  # skipping on principle: qtscript, xcb
  # skipping because of the target in question: widgets qtwebchannel
  # TODO: qtwebengine, a little bulky but useful

  # Too bleeding big
  # -developer-build \
  # -separate-debug-info \

  ${_srcdir}/configure \
    -release \
    -silent \
    -confirm-license \
    -opensource \
    -hostprefix ${_installprefix} \
    -prefix ${_installprefix} \
    -opengl es2 \
    -egl \
    \
    -no-widgets \
    -make libs \
    -no-xcb \
    \
    -skip qtscript \
    -skip qtwebengine \
    -skip qtwebchannel \
    -skip qtwayland \
    \
    -sysroot ${_sysroot} \
    -device ${_mkspec} \
    -device-option CROSS_COMPILE=/opt/arm-sirspuddarch-linux-gnueabihf/bin/arm-sirspuddarch-linux-gnueabihf-

  make

  # regrettably required, as qtwayland barfs on shadow builds
  # as private header paths not included: no clue how to fix, bypassing

  cp -r ${_srcdir}/qtwayland .
  cd qtwayland
  ../qtbase/bin/qmake CONFIG+=wayland-compositor
  make
}

package() {
  local _srcdir="${srcdir}/${_pipkgname}"
  local _bindir="${_srcdir}-build"

  # cleanup
  rm -Rf ${pkgdir}
  mkdir -p ${pkgdir}

  # FIXME: installs both host/target bin/libs to pi path
  cd "${_bindir}"
  INSTALL_ROOT="$pkgdir" make install

  # regrettably required
  cd "${_bindir}"/qtwayland
  INSTALL_ROOT="$pkgdir" make install

  # Qt is now installed to $pkgdir/$sysroot/$prefix
  # manually generate/decompose host/target
  local _libsdir="${startdir}/${_libspkgname}"
  local _libspkgdir="${_libsdir}/topkg"
  local _libspkgbuild="${_libsdir}/PKGBUILD"

  rm -Rf ${_libspkgdir}
  mkdir -p ${_libspkgdir}

  cp ${startdir}/${_libspkgname}-PKGBUILD ${_libspkgbuild}
  mv "${pkgdir}/${_sysroot}/${_baseprefix}" ${_libspkgdir}

  # set correct libs version
  sed -i "s/6.6.6/${pkgver}/" ${_libspkgbuild}

  cd ${_libsdir}
  runuser -l ${_packaginguser} -c 'makepkg -f'

  echo "the libs package for the Raspberry Pi${_piver} is in the ${_packaginguser} home directory awaiting deployment"

  mv ${_libsdir}/${_libspkgname}-${pkgver}-1-any.pkg.tar.xz ${HOME}
}