source: autobuild/scripts/generateMakefile @ 905

Last change on this file since 905 was 905, checked in by moo, 2 years ago

import auto build scripts

  • Property svn:executable set to *
File size: 5.1 KB
Line 
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" '' \
33        "$scriptsDir/download \$(PHP_VERSION)" \
34        "touch $sourceDir/.stamp-download"
35    rule "Makefile" ".config $sourceDir/.stamp-download $(echo "$scriptsDir"/{common,utils,autobuild})" \
36        "$scriptsDir/generateMakefile"
37}; end
38
39rule "$develDir/.stamp-unpack unpackphp" "$(printf " $develDir/php-%s/.stamp-unpack" "${phpVersions[@]}")"
40
41rulePhpVersion() {
42    begin "Generating rule for devel/$phpVersion"; {
43        cleararray binaryPackageStamp
44        local binaryPackage
45        for binaryPackage in "$sourceDir/php-$phpVersion"*Win32*.zip; do
46            if [[ -s $binaryPackage ]]; then
47                local binaryPackageDir="$develDir/$(basename "$binaryPackage" .zip)"
48                local stampFile="$binaryPackageDir/.stamp-unpack"
49                rule "$stampFile" "$binaryPackage" \
50                    "mkdir -p $binaryPackageDir" \
51                    "$scriptsDir/unpackphpbinary $phpVersion $binaryPackage $binaryPackageDir" \
52                    "touch $stampFile"
53                pushv binaryPackageStamp "$stampFile"
54            fi
55        done
56
57        rule "$develDirVersioned/.stamp-unpack" "$phpSourcePackage ${binaryPackageStamps[*]}" \
58            "mkdir -p $develDirVersioned" \
59            "$scriptsDir/unpackphpsource $phpVersion $phpSourcePackage $develDirVersioned" \
60            "touch $develDirVersioned/.stamp-unpack"
61    }; end
62}
63
64foreachPhpVersion rulePhpVersion
65
66ruleBuild() {
67    local extVersionedStamp
68    extVersionedStamp="$extDir/.stamp.${extVersion}"
69    local name
70    local buildDirVersioned
71
72    begin "Generating rule for $ext-$extVersion build for $phpReleaseVersion"; {
73        name="$extNiceName-$extVersion-$phpReleaseVersion"
74        buildDirVersioned="$buildDir/$name"
75
76        local _TS=
77        [[ ! -z $nts ]] && _TS=
78        [[ -z $nts ]] && _TS=_TS
79
80        rule "$buildDirVersioned/.stamp-update" "$develDirVersioned/.stamp-unpack $extVersionedStamp" \
81            "rm -rf $buildDirVersioned/" \
82            "mkdir -p $buildDirVersioned/php" \
83            "rsync $VERBOSE -au $develDirVersioned/ $buildDirVersioned/php/" \
84            "test -f $buildDirVersioned/php/win32/build/ || rsync $VERBOSE -au $develDir/win32build/build/ $buildDirVersioned/php/win32/build/" \
85            "$scriptsDir/fixsource $buildDirVersioned/php/" \
86            "mkdir -p $buildDirVersioned/php/Release${_TS}/" \
87            "cp $VERBOSE -au $phpReleaseDir/php*.lib $buildDirVersioned/php/Release${_TS}/" \
88            "mkdir -p $buildDirVersioned/$ext" \
89            "rsync $VERBOSE -Cau $extDirVersioned/ $buildDirVersioned/$ext/" \
90            "touch $buildDirVersioned/.stamp-update"
91
92        rule "$buildDirVersioned/php/configure.js" "$buildDirVersioned/.stamp-update" \
93            "cd $buildDirVersioned/php && ${compiler}${arch}env.cmd cscript /nologo win32/build/buildconf.js --add-modules-dir=../" \
94            "mv -f $buildDirVersioned/php/configure.js $buildDirVersioned/php/configure.js.tmp" \
95            "$scriptsDir/fixconfigure $buildDirVersioned/php/configure.js.tmp" \
96            "mv -f $buildDirVersioned/php/configure.js.tmp $buildDirVersioned/php/configure.js"
97
98        local args=("${configureFlags[@]}")
99        local phpMajorVersion=$(getVersionPart 0 "$phpVersion")
100        [[ $phpMajorVersion -ge 6 ]] && pushv arg --with-static-icu
101        [[ ! -z $nts ]] && pushv arg --disable-zts
102        [[ -z $nts ]] && pushv arg --enable-zts
103        rule "$buildDirVersioned/php/Makefile" "$buildDirVersioned/php/configure.js" \
104            "cd $buildDirVersioned/php && ${compiler}${arch}env.cmd cscript.exe /nologo configure.js ${args[*]} \\
105                --with-php-build=\"\$\$(cygpath -wa $topdir/win32build)\" \\
106                --disable-all --enable-object-out-dir=. --enable-debug-pack \\
107                --enable-$ext=yes,shared" \
108            "mv -f $buildDirVersioned/php/Makefile $buildDirVersioned/php/Makefile.tmp" \
109            "$scriptsDir/fixmakefile $buildDirVersioned/php/Makefile.tmp" \
110            "mv -f $buildDirVersioned/php/Makefile.tmp $buildDirVersioned/php/Makefile"
111
112        local extDll="$buildDirVersioned/php/Release${_TS}/php_${ext}.dll"
113        rule "$extDll" "$buildDirVersioned/php/Makefile" \
114            "cd $buildDirVersioned/php && MAKEFLAGS= ${compiler}${arch}env.cmd nmake.exe /nologo php_${ext}.dll" \
115
116        addAllRule "$extDll"
117    }; end
118}
119
120forExtVersion() {
121    local extVersionedStamp
122    extVersionedStamp="$extDir/.stamp.${extVersion}"
123
124    rule "update-$ext" "update-$ext-$extVersion"
125    rule "update-$ext-$extVersion $extVersionedStamp" "" \
126        "$scriptsDir/extupdate $ext $extVersion"
127}
128
129forExt() {
130    begin "Generating svn update rule for $ext-$extVersion"; {
131        rule update update-$ext
132        foreachExtVersion forExtVersion
133    }; end
134    foreachExtVersion foreachPhpVersion foreachPhpReleaseVersion ruleBuild
135}
136
137foreachExt forExt
138
139rule "package" "all" "scripts/updatepackage"
140
141exec 4>&-
142rule alltargets "$(cat all.tmp)"
143rm -f all.tmp
144
145exec 5>&-
146rule clean "$(cat clean.tmp)"
147rm -f clean.tmp
148
149exec 3>&-
150{
151    echo "topdir=$topdir"
152    echo "scriptsDir=$scriptsDir"
153    sed Makefile.tmp \
154        -e "s#$scriptsDir#\$(scriptsDir)#g" \
155        -e "s#$topdir#\$(topdir)#g"
156    rm -f Makefile.tmp
157} > Makefile
Note: See TracBrowser for help on using the repository browser.