| 1 | #!/bin/sh |
|---|
| 2 | # vim:syntax=sh:sw=2:ts=2 |
|---|
| 3 | . scripts/common |
|---|
| 4 | |
|---|
| 5 | exec 3>Makefile.tmp |
|---|
| 6 | exec 4>all.tmp |
|---|
| 7 | exec 5>clean.tmp |
|---|
| 8 | |
|---|
| 9 | rule() { |
|---|
| 10 | local target="$1" |
|---|
| 11 | local source="$2" |
|---|
| 12 | shift 2 |
|---|
| 13 | echo "$target: $source" >&3 |
|---|
| 14 | local command |
|---|
| 15 | for command in "$@"; do |
|---|
| 16 | echo -ne "\t" >&3 |
|---|
| 17 | echo "$command" >&3 |
|---|
| 18 | done |
|---|
| 19 | echo >&3 |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | addAllRule() { |
|---|
| 23 | echo -n " $@" >&4 |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | addCleanRule() { |
|---|
| 27 | echo -n " $@" >&5 |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | rule all 'Makefile unpackphp alltargets' |
|---|
| 31 | begin "Generating rule for download"; { |
|---|
| 32 | rule "$sourceDir/.stamp-download download" '' \ |
|---|
| 33 | "mkdir -p $sourceDir/" \ |
|---|
| 34 | "$scriptsDir/download \$(PHP_VERSION)" \ |
|---|
| 35 | "touch $sourceDir/.stamp-download" |
|---|
| 36 | rule "Makefile" ".config $sourceDir/.stamp-download $(echo "$scriptsDir"/{common,utils,autobuild,generateMakefile})" \ |
|---|
| 37 | "$scriptsDir/generateMakefile" |
|---|
| 38 | }; end |
|---|
| 39 | |
|---|
| 40 | rule "$develDir/.stamp-unpack unpackphp" "$(printf " $develDir/php-%s/.stamp-unpack" "${phpVersions[@]}")" |
|---|
| 41 | |
|---|
| 42 | rulePhpVersion() { |
|---|
| 43 | begin "Generating rule for devel/$phpVersion"; { |
|---|
| 44 | cleararray binaryPackageStamp |
|---|
| 45 | local binaryPackage |
|---|
| 46 | for binaryPackage in "$sourceDir/php-$phpVersion"*Win32*.zip; do |
|---|
| 47 | if [[ -s $binaryPackage ]]; then |
|---|
| 48 | local binaryPackageDir="$develDir/$(basename "$binaryPackage" .zip)" |
|---|
| 49 | local stampFile="$binaryPackageDir/.stamp-unpack" |
|---|
| 50 | rule "$stampFile" "$binaryPackage" \ |
|---|
| 51 | "mkdir -p $binaryPackageDir" \ |
|---|
| 52 | "$scriptsDir/unpackphpbinary $phpVersion $binaryPackage $binaryPackageDir" \ |
|---|
| 53 | "touch $stampFile" |
|---|
| 54 | pushv binaryPackageStamp "$stampFile" |
|---|
| 55 | fi |
|---|
| 56 | done |
|---|
| 57 | |
|---|
| 58 | rule "$develDirVersioned/.stamp-unpack" "$phpSourcePackage ${binaryPackageStamps[*]}" \ |
|---|
| 59 | "mkdir -p $develDirVersioned" \ |
|---|
| 60 | "$scriptsDir/unpackphpsource $phpVersion $phpSourcePackage $develDirVersioned" \ |
|---|
| 61 | "touch $develDirVersioned/.stamp-unpack" |
|---|
| 62 | }; end |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | foreachPhpVersion rulePhpVersion |
|---|
| 66 | |
|---|
| 67 | ruleBuild() { |
|---|
| 68 | local extVersionedStamp |
|---|
| 69 | extVersionedStamp="$extDir/.stamp.${extVersion}" |
|---|
| 70 | local name |
|---|
| 71 | local buildDirVersioned |
|---|
| 72 | |
|---|
| 73 | begin "Generating rule for $ext-$extVersion build for $phpReleaseVersion"; { |
|---|
| 74 | name="$extNiceName-$extVersion-$phpReleaseVersion" |
|---|
| 75 | buildDirVersioned="$buildDir/$name" |
|---|
| 76 | |
|---|
| 77 | local _TS= |
|---|
| 78 | [[ ! -z $nts ]] && _TS= |
|---|
| 79 | [[ -z $nts ]] && _TS=_TS |
|---|
| 80 | |
|---|
| 81 | rule "$buildDirVersioned/.stamp-update" "$develDirVersioned/.stamp-unpack $extVersionedStamp" \ |
|---|
| 82 | "rm -rf $buildDirVersioned/" \ |
|---|
| 83 | "mkdir -p $buildDirVersioned/php" \ |
|---|
| 84 | "rsync $VERBOSE -au $develDirVersioned/ $buildDirVersioned/php/" \ |
|---|
| 85 | "test -f $buildDirVersioned/php/win32/build/ || rsync $VERBOSE -au $develDir/win32build/build/ $buildDirVersioned/php/win32/build/" \ |
|---|
| 86 | "$scriptsDir/fixsource $buildDirVersioned/php/" \ |
|---|
| 87 | "mkdir -p $buildDirVersioned/php/Release${_TS}/" \ |
|---|
| 88 | "cp $VERBOSE -au $phpReleaseDir/php*.lib $buildDirVersioned/php/Release${_TS}/" \ |
|---|
| 89 | "mkdir -p $buildDirVersioned/$ext" \ |
|---|
| 90 | "rsync $VERBOSE -Cau $extDirVersioned/ $buildDirVersioned/$ext/" \ |
|---|
| 91 | "touch $buildDirVersioned/.stamp-update" |
|---|
| 92 | |
|---|
| 93 | rule "$buildDirVersioned/php/configure.js" "$buildDirVersioned/.stamp-update" \ |
|---|
| 94 | "cd $buildDirVersioned/php && ${compiler}${arch}env.cmd cscript /nologo win32/build/buildconf.js --add-modules-dir=../" \ |
|---|
| 95 | "mv -f $buildDirVersioned/php/configure.js $buildDirVersioned/php/configure.js.tmp" \ |
|---|
| 96 | "$scriptsDir/fixconfigure $buildDirVersioned/php/configure.js.tmp" \ |
|---|
| 97 | "mv -f $buildDirVersioned/php/configure.js.tmp $buildDirVersioned/php/configure.js" |
|---|
| 98 | |
|---|
| 99 | local args=("${configureFlags[@]}") |
|---|
| 100 | local phpMajorVersion=$(getVersionPart 0 "$phpVersion") |
|---|
| 101 | [[ $phpMajorVersion -ge 6 ]] && pushv arg --with-static-icu |
|---|
| 102 | [[ ! -z $nts ]] && pushv arg --disable-zts |
|---|
| 103 | [[ -z $nts ]] && pushv arg --enable-zts |
|---|
| 104 | rule "$buildDirVersioned/php/Makefile" "$buildDirVersioned/php/configure.js" \ |
|---|
| 105 | "cd $buildDirVersioned/php && ${compiler}${arch}env.cmd cscript.exe /nologo configure.js ${args[*]} \\ |
|---|
| 106 | --with-php-build=\"\$\$(cygpath -wa $topdir/win32build)\" \\ |
|---|
| 107 | --disable-all --enable-object-out-dir=. --enable-debug-pack \\ |
|---|
| 108 | --enable-$ext=yes,shared" \ |
|---|
| 109 | "mv -f $buildDirVersioned/php/Makefile $buildDirVersioned/php/Makefile.tmp" \ |
|---|
| 110 | "$scriptsDir/fixmakefile $buildDirVersioned/php/Makefile.tmp" \ |
|---|
| 111 | "mv -f $buildDirVersioned/php/Makefile.tmp $buildDirVersioned/php/Makefile" |
|---|
| 112 | |
|---|
| 113 | xcachetmp=$TMP/$name |
|---|
| 114 | local extDll="$buildDirVersioned/php/Release${_TS}/php_${ext}.dll" |
|---|
| 115 | rule "$extDll" "$buildDirVersioned/php/Makefile" \ |
|---|
| 116 | "mkdir -p $xcachetmp" \ |
|---|
| 117 | "cd $buildDirVersioned/php && MAKEFLAGS= TMP=$xcachetmp TEMP=$xcachetmp ${compiler}${arch}env.cmd nmake.exe /nologo php_${ext}.dll" \ |
|---|
| 118 | "rmdir $xcachetmp" |
|---|
| 119 | |
|---|
| 120 | addAllRule "$extDll" |
|---|
| 121 | }; end |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | forExtVersion() { |
|---|
| 125 | local extVersionedStamp |
|---|
| 126 | extVersionedStamp="$extDir/.stamp.${extVersion}" |
|---|
| 127 | |
|---|
| 128 | rule "update-$ext" "update-$ext-$extVersion" |
|---|
| 129 | rule "update-$ext-$extVersion $extVersionedStamp" "" \ |
|---|
| 130 | "$scriptsDir/extupdate $ext $extVersion" |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | forExt() { |
|---|
| 134 | begin "Generating svn update rule for $ext-$extVersion"; { |
|---|
| 135 | rule update update-$ext |
|---|
| 136 | $@ forExtVersion |
|---|
| 137 | }; end |
|---|
| 138 | $@ foreachPhpVersion foreachPhpReleaseVersion ruleBuild |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | if [[ $# -gt 0 ]]; then |
|---|
| 142 | loadExt $1 |
|---|
| 143 | shift |
|---|
| 144 | if [[ $# -gt 0 ]]; then |
|---|
| 145 | loadExtVersion $1 |
|---|
| 146 | forExt |
|---|
| 147 | else |
|---|
| 148 | forExt foreachExtVersion |
|---|
| 149 | fi |
|---|
| 150 | else |
|---|
| 151 | foreachExt forExt foreachExtVersion |
|---|
| 152 | fi |
|---|
| 153 | |
|---|
| 154 | rule "package" "all" "scripts/updatepackage" |
|---|
| 155 | |
|---|
| 156 | exec 4>&- |
|---|
| 157 | rule alltargets "$(cat all.tmp)" |
|---|
| 158 | rm -f all.tmp |
|---|
| 159 | |
|---|
| 160 | exec 5>&- |
|---|
| 161 | rule clean "$(cat clean.tmp)" |
|---|
| 162 | rm -f clean.tmp |
|---|
| 163 | |
|---|
| 164 | exec 3>&- |
|---|
| 165 | { |
|---|
| 166 | echo "topdir=$topdir" |
|---|
| 167 | echo "scriptsDir=$scriptsDir" |
|---|
| 168 | sed Makefile.tmp \ |
|---|
| 169 | -e "s#$scriptsDir#\$(scriptsDir)#g" \ |
|---|
| 170 | -e "s#$topdir#\$(topdir)#g" |
|---|
| 171 | rm -f Makefile.tmp |
|---|
| 172 | } > Makefile |
|---|