summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 037963adfc6f967db5b4f6df2841b94b45481745 (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
#
# Maintainer: Michael Rynn <michael.rynn@parracan.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jonathan Wiersma <arch aur at jonw dot org>
# Contributor: Thore Bödecker <me [at] foxxx0 [dot] de>
# 
# Credit to all other past PHP version AUR packages

php_suffix="70" # This mutation
php_ext="xdebug"
pkgname="php${php_suffix}-${php_ext}"
pkgver="2.6.0"
pkgrel=1


pkgdesc="PHP extension module that aids debugging and profiling"
arch=('i686' 'x86_64')
url="http://www.xdebug.org"
license=('GPL')
depends=("php${php_suffix}")

pkg_src="${php_ext}-${pkgver}"

source=("https://www.xdebug.org/files/${pkg_src}.tgz"  'xdebug.ini')

sha256sums=(
  'b5264cc03bf68fcbb04b97229f96dca505d7b87ec2fb3bd4249896783d29cbdc'
  '7c66883dc2ade69069ef84e30188b25630748aa9c8b0dd123727c00505421205')


# locate php-config[suffix], get options
# xdebug build uses phpize[suffix]

php_select()
{
    declare -a php_configy # paths
    

    # pass a folder to be searched for any php-config*
    findconfig()
    {
      local _myglob="$1/php-config${php_suffix}*"
      for f in $_myglob; 
      do
        if [ "$f" != "$_myglob" ]; then
          php_configy+=("$f")
        fi
      done
    }

    binpath="${PATH}"

    re='([^:]+):(.*)'
    while [[ $binpath =~ $re ]]
    do
      bindir="${BASH_REMATCH[1]}"
      binpath="${BASH_REMATCH[2]}"
      findconfig $bindir
    done
    if [[ -n $binpath ]]; then
      findconfig $binpath
    fi

    # see how many we have
    optct="${#php_configy[@]}"

    # if only one, do automatic??
    if [[ $optct -lt "1" ]]; then
        echo "No php-config* found"
        exit -1
    elif [[ $optct -eq "1" ]]; then
        php_config="${php_configy[0]}"
    else 
      declare -a php_options # assemble user menu
      optct=0
      php_options+=("0) Get me out of here!")
      for cfg in "${php_configy[@]}"; 
      do
        let optct='((optct+1))'
        PHP_FULL_VERSION=`${cfg} --version`
        php_options+=("${optct}) ${cfg}  (php-${PHP_FULL_VERSION})")
      done
      echo
      echo "More than one php-config found. Select:"
      echo
      for opt in "${php_options[@]}"; do
        echo $opt
      done
      echo
      read -p "Which php-config do you want? " choice
      numbers='[0-9]+$'
      if ! [[ "${choice}" =~ $numbers ]]; then
        echo "bye"
        exit
      fi
      if [[ ( "${choice}" -gt "$optct" ) || ( "${choice}" -lt  "1" ) ]]; then
        echo "OK"
        exit
      fi
      let choice='((choice-1))'
      php_config="${php_configy[$choice]}"
    fi
    
    #get some config options,  assumable from php70
    all_options=`${php_config} --configure-options`

    declare -A config_options # AA for key lookup
    attre='--([^=]+)=(.*)'
    for option in $all_options; do
        [[ $option =~ $attre ]] && vname="${BASH_REMATCH[1]}" && nvalue="${BASH_REMATCH[2]}"
        config_options[$vname]=$nvalue
    done

    # export so makepkg remembers. PHP-build dependent
    export PHPCONFIG_SCANDIR="${config_options[with-config-file-scan-dir]#/*}"
    export PHPIZE_CMD="phpize${config_options[program-suffix]}"
    export PHPCONFIG_CMD="${php_config}"

}

prepare()
{
    echo "PHPIZE path is ${PHPIZE_CMD}"
    echo "PHP scan directory is $PHPCONFIG_SCANDIR"  
}
build() {
  cd "$srcdir"/$pkg_src
  "$PHPIZE_CMD"
  echo "Using php-config=${PHPCONFIG_CMD}"
  ./configure --prefix=/usr --enable-xdebug --with-php-config="${PHPCONFIG_CMD}"
  make

  cd "$srcdir"/$pkg_src/debugclient
  ./configure --prefix=/usr --program-suffix="$_pkg_suffix"
  make
}

package() {
  backup=("${PHPCONFIG_SCANDIR}/xdebug.ini")
  cd "$srcdir"/$pkg_src/debugclient
  make DESTDIR="$pkgdir" install

  cd "$srcdir"/$pkg_src
  make INSTALL_ROOT="$pkgdir" install
  install -D -m 644 "$srcdir"/xdebug.ini "$pkgdir/${PHPCONFIG_SCANDIR}/xdebug.ini"
}
# Run this  before the backup file variables get evaluated
if [[ -z $PHPIZE_CMD ]]; then
    php_select
fi