summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: bb70193f1f06bc414602b91cd64429ce2fcd9f21 (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
# Maintainer: wolftankk <wolftankk@gmail.com>
pkgname=zephir
pkgver=0.7.1
pkgrel=1
pkgdesc="Zephir is a compiled high level language aimed to the creation of C-extensions for PHP http://zephir-lang.com/"
url="https://github.com/phalcon/zephir"
arch=('x86_64' 'i686')
license=('GPL')
depends=('json-c' 're2c')
makedepends=('unzip' 'php' 'gcc' 'pcre')
backup=('etc/php/conf.d/zephir.ini')

if [[ $CARCH = "i686" ]]; then
  makedepends+=('lib32-pcre');
fi

source=(
	"https://github.com/phalcon/zephir/archive/$pkgver.zip"
)

sha256sums=('ea5161da9b02674c16f9d60fb5966b2576e431762f43834b5a3d7f7a2ce28943')

build() {
  cd "$srcdir/zephir-$pkgver/parser"

  if [ ! -f lemon ]; then
	gcc -w lemon.c -o lemon
  fi
  re2c -o scanner.c scanner.re && ./lemon -s parser.lemon && cat base.c >> parser.c
  sed s/"\#line"/"\/\/"/g scanner.c > xx && mv -f xx scanner.c
  sed s/"#line"/"\/\/"/g parser.c > xx && mv -f xx parser.c

  export CFLAGS="-g3 -O0"
  gcc -Wl,-rpath /usr/local/lib -I/usr/local/include -L/usr/local/lib -L/opt/local/lib -g3 -w parser.c scanner.c -ljson-c -o ../bin/zephir-parser
}

package() {
  ZEPHIRDIR=/opt/$pkgname
  cd "$srcdir/zephir-$pkgver"
  sed "s#%ZEPHIRDIR%#$ZEPHIRDIR#g" bin/zephir > bin/zephir-cmd

  #init
  install -d $pkgdir/{$ZEPHIRDIR,usr/bin}

  install -Dm777 bin/zephir-cmd "$pkgdir"/opt/zephir/bin/zephir
  install -Dm777 bin/zephir-parser "$pkgdir"/opt/zephir/bin/zephir-parser

  install -Dm777 compiler.php "$pkgdir"/opt/zephir/compiler.php
  install -Dm777 bootstrap.php "$pkgdir"/opt/zephir/bootstrap.php
  cp -a Library "$pkgdir"/opt/zephir/Library
  cp -a ext "$pkgdir"/opt/zephir/ext
  cp -a prototypes "$pkgdir"/opt/zephir/prototypes
  cp -a runtime "$pkgdir"/opt/zephir/runtime
  cp -a templates "$pkgdir"/opt/zephir/templates
  cp -a unit-tests "$pkgdir"/opt/zephir/unit-tests

  ln -s /opt/zephir/bin/zephir $pkgdir/usr/bin/zephir
  ln -s /opt/zephir/bin/zephir-parser $pkgdir/usr/bin/zephir-parser

  #echo open_basedir=$(php -r "echo ini_get('open_basedir');"):/opt/zephir > zephir.ini
  #install -Dm644 zephir.ini "$pkgdir"/etc/php/conf.d/zephir.ini

  if [ -d "/usr/share/bash-completion/completions" ]; then
	  install -Dm644 bin/bash_completion "$pkgdir"/usr/share/bash-completion/completions/zephir
  fi

  msg2 "Please add '/opt/zephir' into 'open_basedir' in 'php.ini'"
}