summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9862753c49412001f800e3099296f3fc1a078353 (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Maintainer:

## useful urls
# https://www.lazarus-ide.org/
# https://gitlab.com/freepascal.org/lazarus/lazarus
# https://www.freepascal.org/docs-html/user/usersu15.html

## options
: ${_debug:=true}
: ${_runtime_checks:=true}

: ${_build_gtk2:=true}
: ${_build_gtk3:=true}
: ${_build_qt5:=true}
: ${_build_qt6:=true}

: ${_build_git:=true}

unset _pkgtype
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

## basic info
_pkgbase="lazarus"
pkgbase="$_pkgbase${_pkgtype:-}"
pkgver=3.2.r1624.gc971eaa
pkgrel=1
pkgdesc='Delphi-like IDE for FreePascal'
url="https://gitlab.com/freepascal.org/lazarus/lazarus"
arch=('x86_64')
license=(
  # ide, designer, codetools, etc
  'GPL-2.0-only'

  # synedit
  'Apache-2.0'

  # component library
  'LGPL-2.0-only'
  'LicenseRef-LGPL-exception'

  # documentation
  'CC-BY-SA-4.0'
)

pkgname=("$pkgbase")
[[ "${_build_gtk2::1}" == "t" ]] && pkgname+=("$_pkgbase-gtk2${_pkgtype:-}")
[[ "${_build_gtk3::1}" == "t" ]] && pkgname+=("$_pkgbase-gtk3${_pkgtype:-}")
[[ "${_build_qt5::1}" == "t" ]] && pkgname+=("$_pkgbase-qt5${_pkgtype:-}")
[[ "${_build_qt6::1}" == "t" ]] && pkgname+=("$_pkgbase-qt6${_pkgtype:-}")

makedepends=(
  'git'
  'fpc'
  'fpc-src'
  'gtk2'
  'gtk3'
  'qt5pas'
  'qt6pas'
  'rsync'
)

options=(!makeflags libtool staticlibs !strip)

_pkgsrc="$_pkgbase"
source=("$_pkgsrc"::"git+$url.git")
sha256sums=('SKIP')

pkgver() {
  cd "$_pkgsrc"

  local _tag=$(git tag | grep '^lazarus' | grep -Ev '[A-Z]{2}' | sort -rV | head -1)
  local _pkgver=$(echo "${_tag:?}" | sed -E 's&^[^0-9]+&&; s&_&.&g')
  local _revision=$(git rev-list --count --cherry-pick "$_tag"...HEAD)
  local _hash=$(git rev-parse --short=7 HEAD)
  printf '%s.r%s.g%s' "${_pkgver:?}" "${_revision:?}" "${_hash:?}"
}

_package_lazarus() {
  cd "$_pkgsrc"

  # skip the 'make install' mess completely and do everything manually
  mkdir -p "$pkgdir"/usr/lib/lazarus "$pkgdir"/usr/bin "$pkgdir"/usr/share/man/man1 "$pkgdir"/usr/share/doc
  rsync -a \
    --exclude="CVS"     --exclude=".cvsignore" \
    --exclude="*.ppw"   --exclude="*.ppl" \
    --exclude="*.ow"    --exclude="*.a"\
    --exclude="*.rst"   --exclude=".#*" \
    --exclude="*.~*"    --exclude="*.bak" \
    --exclude="*.orig"  --exclude="*.rej" \
    --exclude=".xvpics" \
    --exclude="killme*" --exclude=".gdb_hist*" \
    --exclude="debian"  --exclude="COPYING*" \
    --exclude="*.app"   --exclude="tools/install" \
    --exclude=".git*" \
    . "$pkgdir"/usr/lib/lazarus

  #remove some stuff, not needed or in other package
  pushd "$pkgdir"/usr/lib/lazarus
  rm lazarus-*
  rm startlazarus-*
  popd

  ln -s /usr/lib/lazarus/lazbuild "$pkgdir"/usr/bin/lazbuild
  cp -R install/man/man1/* "$pkgdir"/usr/share/man/man1/
  mv "$pkgdir"/usr/lib/lazarus/docs "$pkgdir"/usr/share/doc/lazarus
  mkdir -p "$pkgdir"/usr/lib/lazarus/docs
  ln -s /usr/share/doc/lazarus/chm "$pkgdir"/usr/lib/lazarus/docs/html
  ln -s /usr/share/doc/lazarus/lazdoc.css "$pkgdir"/usr/lib/lazarus/docs/lazdoc.css

  rm -r "$pkgdir"/usr/lib/lazarus/install

  _package_licenses
}

_package_platform() {
  _platform="${1:?}"

  cd "$_pkgsrc"

  # install binaries
  install -Dm755 lazarus-"$_platform" "$pkgdir"/usr/lib/lazarus/lazarus
  install -Dm755 startlazarus-"$_platform" "$pkgdir"/usr/lib/lazarus/startlazarus
  install -dm755 "$pkgdir"/usr/bin

  # symlinks
  ln -s /usr/lib/lazarus/lazarus "$pkgdir"/usr/bin/lazarus
  ln -s /usr/lib/lazarus/startlazarus "$pkgdir"/usr/bin/startlazarus

  # make 'desktop-file-validate' happy
  sed -e 's|\(Categories\).*|\1=IDE;Development;|' -i install/lazarus.desktop
  install -Dm644 install/lazarus.desktop "$pkgdir"/usr/share/applications/lazarus.desktop
  install -Dm644 images/ide_icon48x48.png "$pkgdir"/usr/share/pixmaps/lazarus.png

  _package_licenses
}

_package_licenses() {
  install -Dm644 COPYING.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.overview
  install -Dm644 COPYING.modifiedLGPL.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.LGPL-exception
}

build() {
  cd "$_pkgsrc"

  local _fpc_options=(-O2)

  if [[ "${_debug::1}" == "t" ]] ; then
    _fpc_options+=(-gl -gw)
  fi

  if [[ "${_runtime_checks::1}" == "t" ]] ; then
    _fpc_options+=(-Crtoi)
  fi

  for _p in "${pkgname[@]}"; do
    local _q=$(cut -d'-' -f2 <<< "$_p")
    if [ "$_q" != 'git' ] ; then
      local _platform="${_q}"

      # build ide
      echo "Building for platform: ${_q}"
      make FPC=/usr/bin/fpc OPT="${_fpc_options[*]}" LCL_PLATFORM="$_platform" bigide

      # move binaries
      mv lazarus lazarus-$_platform
      mv startlazarus startlazarus-$_platform
    fi
  done
}

# package
for _p in "${pkgname[@]}"; do
  local _q=$(cut -d'-' -f2 <<< "$_p")

  case "${_q:?}" in
    gtk2|gtk3)
      eval "package_$_p() {
        pkgdesc+=' - ${_q:?} version'
        depends=('lazarus${pkgtype:-}' 'desktop-file-utils' '${_q:?}')
        provides=(lazarus-${_q:?}${_pkgtype:-}=${pkgver%%.r*})
        conflicts=('lazarus-gtk2' 'lazarus-gtk3' 'lazarus-qt5' 'lazarus-qt6')

        _package_platform ${_q:?}
      }"
      ;;
    qt5|qt6)
      eval "package_$_p() {
        pkgdesc+=' - ${_q:?} version'
        depends=('lazarus-git' '${_q:?}pas')
        provides=(lazarus-${_q:?}${_pkgtype:-}=${pkgver%%.r*})
        conflicts=('lazarus-gtk2' 'lazarus-gtk3' 'lazarus-qt5' 'lazarus-qt6')

        _package_platform ${_q:?}
      }"
      ;;
    *) # lazarus-git
      eval "package_$_p() {
        pkgdesc+=' - common files'
        depends=('fpc' 'fpc-src' 'gdb')
        optdepends=(
          'perl: to run some scripts in the tools directory'
          'gtk2: to compile gtk2 apps'
          'gtk3: to compile gtk3 apps'
          'qt5pas: to compile Qt5 apps'
          'qt6pas: to compile Qt6 apps'
        )

        provides=(lazarus=${pkgver%%.r*})
        conflicts=(lazarus)

        $(declare -f "_package_lazarus")
        _package_lazarus
      }"
      ;;
  esac
done