source: autobuild/scripts/generateMakefile @ 912

Last change on this file since 912 was 912, checked in by moo, 3 years ago

compatibility

  • 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        "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
40rule "$develDir/.stamp-unpack unpackphp" "$(printf " $develDir/php-%s/.stamp-unpack" "${phpVersions[@]}")"
41
42rulePhpVersion() {
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
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
113        local extDll="$buildDirVersioned/php/Release${_TS}/php_${ext}.dll"
114        rule "$extDll" "$buildDirVersioned/php/Makefile" \
115            "cd $buildDirVersioned/php && MAKEFLAGS= ${compiler}${arch}env.cmd nmake.exe /nologo php_${ext}.dll" \
116
117        addAllRule "$extDll"
118    }; end
119}
120
121forExtVersion() {
122    local extVersionedStamp
123    extVersionedStamp="$extDir/.stamp.${extVersion}"
124
125    rule "update-$ext" "update-$ext-$extVersion"
126    rule "update-$ext-$extVersion $extVersionedStamp" "" \
127        "$scriptsDir/extupdate $ext $extVersion"
128}
129
130forExt() {
131    begin "Generating svn update rule for $ext-$extVersion"; {
132        rule update update-$ext
133        foreachExtVersion forExtVersion
134    }; end
135    foreachExtVersion foreachPhpVersion foreachPhpReleaseVersion ruleBuild
136}
137
138foreachExt forExt
139
140rule "package" "all" "scripts/updatepackage"
141
142exec 4>&-
143rule alltargets "$(cat all.tmp)"
144rm -f all.tmp
145
146exec 5>&-
147rule clean "$(cat clean.tmp)"
148rm -f clean.tmp
149
150exec 3>&-
151{
152    echo "topdir=$topdir"
153    echo "scriptsDir=$scriptsDir"
154    sed Makefile.tmp \
155        -e "s#$scriptsDir#\$(scriptsDir)#g" \
156        -e "s#$topdir#\$(topdir)#g"
157    rm -f Makefile.tmp
158} > Makefile
Note: See TracBrowser for help on using the repository browser.