source: autobuild/scripts/generateMakefile

Last change on this file was 1464, checked in by moo, 5 months ago

strip ext prefix for ext versions dir

  • Property svn:executable set to *
File size: 5.3 KB
RevLine 
[905]1#!/bin/sh
2# vim:syntax=sh:sw=2:ts=2
3. scripts/common
4
5exec 3>Makefile.tmp
6exec 4>all.tmp
7exec 5>clean.tmp
8
9rule() {
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
22addAllRule() {
23    echo -n " $@" >&4
24}
25
26addCleanRule() {
27    echo -n " $@" >&5
28}
29
30rule all 'Makefile unpackphp alltargets'
31begin "Generating rule for download"; {
32    rule "$sourceDir/.stamp-download download" '' \
[912]33        "mkdir -p $sourceDir/" \
[905]34        "$scriptsDir/download \$(PHP_VERSION)" \
35        "touch $sourceDir/.stamp-download"
[912]36    rule "Makefile" ".config $sourceDir/.stamp-download $(echo "$scriptsDir"/{common,utils,autobuild,generateMakefile})" \
[905]37        "$scriptsDir/generateMakefile"
38}; end
39
40rule "$develDir/.stamp-unpack unpackphp" "$(printf " $develDir/php-%s/.stamp-unpack" "${phpVersions[@]}")"
41
42rulePhpVersion() {
[1464]43    begin "Generating rule for devel/php-$phpVersion"; {
[905]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
65foreachPhpVersion rulePhpVersion
66
67ruleBuild() {
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
[970]113        xcachetmp=$TMP/$name
[905]114        local extDll="$buildDirVersioned/php/Release${_TS}/php_${ext}.dll"
115        rule "$extDll" "$buildDirVersioned/php/Makefile" \
[970]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"
[905]119
120        addAllRule "$extDll"
121    }; end
122}
123
124forExtVersion() {
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
133forExt() {
[1358]134    begin "Generating svn update rule for $ext"; {
[905]135        rule update update-$ext
[1167]136        $@ forExtVersion
[905]137    }; end
[1167]138    $@ foreachPhpVersion foreachPhpReleaseVersion ruleBuild
[905]139}
140
[1167]141if [[ $# -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
150else
[1180]151    foreachExt forExt foreachExtVersion
[1167]152fi
[905]153
154rule "package" "all" "scripts/updatepackage"
155
156exec 4>&-
157rule alltargets "$(cat all.tmp)"
158rm -f all.tmp
159
160exec 5>&-
161rule clean "$(cat clean.tmp)"
162rm -f clean.tmp
163
164exec 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
Note: See TracBrowser for help on using the repository browser.