| 1 | #! /bin/bash |
|---|
| 2 | SELF="$0" |
|---|
| 3 | |
|---|
| 4 | if test -e prepare.devel.inc ; then |
|---|
| 5 | . prepare.devel.inc |
|---|
| 6 | else |
|---|
| 7 | echo prepare.devel.inc is required, see prepare.devel.inc.example >&2 |
|---|
| 8 | exit |
|---|
| 9 | fi |
|---|
| 10 | |
|---|
| 11 | CTAGS=`which ctags 2>/dev/null || which exuberant-ctags 2>/dev/null ` |
|---|
| 12 | AWK=`which gawk 2>/dev/null || which awk 2>/dev/null ` |
|---|
| 13 | |
|---|
| 14 | make_all() { |
|---|
| 15 | make_opcode_spec_def.h |
|---|
| 16 | make_const_string |
|---|
| 17 | test -e tags && echo tags exists, skipping. use \""$0" tags\" to rebuild || make_tags |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | make_clean() { |
|---|
| 21 | make_clean_const_string |
|---|
| 22 | echo "*" rm -f tags opcode_spec_def.h |
|---|
| 23 | rm -f tags opcode_spec_def.h |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | make_const_string() { |
|---|
| 27 | make_const_string_opcodes_php4.x.h |
|---|
| 28 | make_const_string_opcodes_php5.0.h |
|---|
| 29 | make_const_string_opcodes_php5.1.h |
|---|
| 30 | make_const_string_opcodes_php6.x.h |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | make_clean_const_string() { |
|---|
| 34 | echo "*" rm -f const_string_opcodes_php*.h{,.tmp} |
|---|
| 35 | rm -f const_string_opcodes_php*.h |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | make_const_string_opcodes_php4.x.h() { |
|---|
| 39 | precheck const_string_opcodes_php4.x.h "${PHP4_x_DIR}/Zend/zend_compile.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O" |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | make_const_string_opcodes_php5.0.h() { |
|---|
| 43 | precheck const_string_opcodes_php5.0.h "${PHP5_0_DIR}/Zend/zend_compile.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O" |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | make_const_string_opcodes_php5.1.h() { |
|---|
| 47 | precheck const_string_opcodes_php5.1.h "${PHP5_1_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O" |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | make_const_string_opcodes_php6.x.h() { |
|---|
| 51 | precheck const_string_opcodes_php6.x.h "${PHP6_x_DIR}/Zend/zend_vm_def.h" && "$AWK" -f ./mkopcode.awk < "$I" > "$O.tmp" && mv "$O.tmp" "$O" |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | make_opcode_spec_def.h() { |
|---|
| 55 | precheck "opcode_spec_def.h" "${EA_DIR}/opcodes.c" && "$AWK" -f ./mkopcode_spec.awk < "$I" > "$O" |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | make_tags() { |
|---|
| 59 | if test -z "$CTAGS" ; then |
|---|
| 60 | echo tool ctags not found, skip building tags >&2 |
|---|
| 61 | return |
|---|
| 62 | fi |
|---|
| 63 | |
|---|
| 64 | if test -d "${PHP_DEVEL_DIR}" ; then |
|---|
| 65 | echo "* Making tags with ${PHP_DEVEL_DIR}" |
|---|
| 66 | "$CTAGS" -R . "${PHP_DEVEL_DIR}/main" "${PHP_DEVEL_DIR}/Zend" "${PHP_DEVEL_DIR}/TSRM" "${PHP_DEVEL_DIR}/ext/standard" |
|---|
| 67 | else |
|---|
| 68 | echo "* Making tags without php source files" |
|---|
| 69 | "$CTAGS" -R . |
|---|
| 70 | fi |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | error() { |
|---|
| 74 | echo "$@" >&2 |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | precheck() { |
|---|
| 78 | if test -e "$2" ; then :; else |
|---|
| 79 | error X skipping "$1" because "$2" not found |
|---|
| 80 | return 1 |
|---|
| 81 | fi |
|---|
| 82 | if test "$1" -ot "$2" ; then :; else |
|---|
| 83 | echo O "$1" is up to date. |
|---|
| 84 | return 1 |
|---|
| 85 | fi |
|---|
| 86 | O="$1" |
|---|
| 87 | I="$2" |
|---|
| 88 | echo "* Making $1 from $2" |
|---|
| 89 | return 0 |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | if test -z "$1" ; then |
|---|
| 93 | make_all |
|---|
| 94 | else |
|---|
| 95 | while ! test -z "$1" ; do |
|---|
| 96 | eval "make_$1" |
|---|
| 97 | shift |
|---|
| 98 | done |
|---|
| 99 | fi |
|---|