| 1 | #!sh
|
|---|
| 2 |
|
|---|
| 3 | set -e
|
|---|
| 4 |
|
|---|
| 5 | PWD="$(pwd)"
|
|---|
| 6 |
|
|---|
| 7 | if ! [ -d mswindows ]; then
|
|---|
| 8 | echo Start from GRASS toplevel dir
|
|---|
| 9 | exit 1
|
|---|
| 10 | fi
|
|---|
| 11 |
|
|---|
| 12 | if ! [ -d /tmp ]; then
|
|---|
| 13 | mkdir /tmp
|
|---|
| 14 | if ! [ -d /tmp ]; then
|
|---|
| 15 | echo /tmp does not exists
|
|---|
| 16 | exit 1
|
|---|
| 17 | fi
|
|---|
| 18 | fi
|
|---|
| 19 |
|
|---|
| 20 | export PACKAGE=${1:-1}
|
|---|
| 21 | # package name for osgeo4w
|
|---|
| 22 | # eg. 64-dev -> grass64-dev, empty for release
|
|---|
| 23 | export PACKAGE_NAME=$2
|
|---|
| 24 | # OSGeo4W directory postfix, separate OSGeo4W installations are used
|
|---|
| 25 | # for building GRASS 6.x and 7.x
|
|---|
| 26 | if test -z "$3" ; then
|
|---|
| 27 | OSGEO4W_ROOT_POSTFIX=""
|
|---|
| 28 | else
|
|---|
| 29 | OSGEO4W_ROOT_POSTFIX="$3"
|
|---|
| 30 | fi
|
|---|
| 31 | export OSGEO4W_ROOT_MSYS="/c/OSGeo4W${OSGEO4W_ROOT_POSTFIX}"
|
|---|
| 32 | export OSGEO4W_ROOT="C:\\\OSGeo4W${OSGEO4W_ROOT_POSTFIX}"
|
|---|
| 33 |
|
|---|
| 34 | export PATH=.:/usr/local/bin:/bin:$OSGEO4W_ROOT_MSYS/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/Subversion/bin:$PWD/mswindows/osgeo4w
|
|---|
| 35 |
|
|---|
| 36 | T0=$(date +%s)
|
|---|
| 37 | LT=$T0
|
|---|
| 38 | CS=""
|
|---|
| 39 |
|
|---|
| 40 | log() {
|
|---|
| 41 | local D T
|
|---|
| 42 | NOW=$(date)
|
|---|
| 43 | T=$(date +%s)
|
|---|
| 44 |
|
|---|
| 45 | if [ -n "$CS" ]; then
|
|---|
| 46 | local D H M S
|
|---|
| 47 | (( S=T-$LT ))
|
|---|
| 48 | (( M=S/60 )); (( S=S%60 ))
|
|---|
| 49 | (( H=M/60 )); (( M=M%60 ))
|
|---|
| 50 | (( D=H/24 )); (( H=H%24 ))
|
|---|
| 51 |
|
|---|
| 52 | echo -n "$NOW: FINISHED $CS AFTER "
|
|---|
| 53 | (( D>0 )) && echo -n "${D}d"
|
|---|
| 54 | (( H>0 )) && echo -n "${H}h"
|
|---|
| 55 | (( M>0 )) && echo -n "${M}m"
|
|---|
| 56 | echo "${S}s"
|
|---|
| 57 | fi
|
|---|
| 58 |
|
|---|
| 59 | CS="$@"
|
|---|
| 60 | LT=$T
|
|---|
| 61 | if [ -n "$CS" ]; then
|
|---|
| 62 | echo $NOW: STARTING $CS
|
|---|
| 63 | elif [ -n "$T0" ]; then
|
|---|
| 64 | CS="COMPLETE RUN"
|
|---|
| 65 | LT=$T0
|
|---|
| 66 | T0=""
|
|---|
| 67 | log
|
|---|
| 68 | fi
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | exec 3<include/VERSION
|
|---|
| 72 | read MAJOR <&3
|
|---|
| 73 | read MINOR <&3
|
|---|
| 74 | read PATCH <&3
|
|---|
| 75 |
|
|---|
| 76 | export VERSION=$MAJOR.$MINOR.$PATCH
|
|---|
| 77 |
|
|---|
| 78 | if [[ "$PATCH" == *svn* ]] ; then
|
|---|
| 79 | GRASS_EXECUTABLE=grass${MAJOR}${MINOR}svn
|
|---|
| 80 | else
|
|---|
| 81 | GRASS_EXECUTABLE=grass${MAJOR}${MINOR}
|
|---|
| 82 | fi
|
|---|
| 83 |
|
|---|
| 84 | export GRASS_PYTHON="$OSGEO4W_ROOT_MSYS/bin/python.exe"
|
|---|
| 85 | export PYTHONHOME="$OSGEO4W_ROOT_MSYS/apps/Python27"
|
|---|
| 86 |
|
|---|
| 87 | if [ -f mswindows/osgeo4w/package.log ]; then
|
|---|
| 88 | i=0
|
|---|
| 89 | while [ -f mswindows/osgeo4w/package.log.$i ]; do
|
|---|
| 90 | (( i++ ))
|
|---|
| 91 | done
|
|---|
| 92 | mv mswindows/osgeo4w/package.log mswindows/osgeo4w/package.log.$i
|
|---|
| 93 | fi
|
|---|
| 94 |
|
|---|
| 95 | exec 3>&1 >> mswindows/osgeo4w/package.log 2>&1
|
|---|
| 96 |
|
|---|
| 97 | [ -d mswindows/osgeo4w/lib ] || mkdir mswindows/osgeo4w/lib
|
|---|
| 98 | cp -uv $OSGEO4W_ROOT_MSYS/lib/sqlite3_i.lib mswindows/osgeo4w/lib/libsqlite3.a
|
|---|
| 99 | cp -uv $OSGEO4W_ROOT_MSYS/lib/proj_i.lib mswindows/osgeo4w/lib/libproj_i.a
|
|---|
| 100 | cp -uv $OSGEO4W_ROOT_MSYS/lib/libtiff_i.lib mswindows/osgeo4w/lib/libtiff.a
|
|---|
| 101 | cp -uv $OSGEO4W_ROOT_MSYS/lib/libpq.lib mswindows/osgeo4w/lib/libpq.a
|
|---|
| 102 | cp -uv $OSGEO4W_ROOT_MSYS/lib/jpeg_i.lib mswindows/osgeo4w/lib/libjpeg.a
|
|---|
| 103 | cp -uv $OSGEO4W_ROOT_MSYS/lib/zlib.lib mswindows/osgeo4w/lib/libz.a
|
|---|
| 104 |
|
|---|
| 105 | if ! [ -f mswindows/osgeo4w/configure-stamp ]; then
|
|---|
| 106 |
|
|---|
| 107 | if [ -e include/Make/Grass.make ] ; then
|
|---|
| 108 | log make distclean
|
|---|
| 109 | make distclean
|
|---|
| 110 | fi
|
|---|
| 111 |
|
|---|
| 112 | log remove old logs
|
|---|
| 113 | rm -f mswindows/osgeo4w/package.log.[0-9][0-9][0-9]
|
|---|
| 114 |
|
|---|
| 115 | log configure
|
|---|
| 116 | ./configure \
|
|---|
| 117 | --with-libs="$OSGEO4W_ROOT_MSYS/lib $OSGEO4W_ROOT_MSYS/apps/msys/lib $PWD/mswindows/osgeo4w/lib" \
|
|---|
| 118 | --with-includes="$OSGEO4W_ROOT_MSYS/include $OSGEO4W_ROOT_MSYS/apps/msys/include" \
|
|---|
| 119 | --libexecdir=$OSGEO4W_ROOT_MSYS/bin \
|
|---|
| 120 | --prefix=$OSGEO4W_ROOT_MSYS/apps/grass \
|
|---|
| 121 | --bindir=$OSGEO4W_ROOT_MSYS/bin \
|
|---|
| 122 | --includedir=$OSGEO4W_ROOT_MSYS/include \
|
|---|
| 123 | --disable-x --without-x \
|
|---|
| 124 | --with-cxx \
|
|---|
| 125 | --enable-shared \
|
|---|
| 126 | --with-opengl=windows \
|
|---|
| 127 | --with-fftw \
|
|---|
| 128 | --with-freetype \
|
|---|
| 129 | --with-proj-share=$OSGEO4W_ROOT_MSYS/share/proj \
|
|---|
| 130 | --with-gdal=$PWD/mswindows/osgeo4w/gdal-config \
|
|---|
| 131 | --with-geos=$PWD/mswindows/osgeo4w/geos-config \
|
|---|
| 132 | --with-tcltk \
|
|---|
| 133 | --with-sqlite \
|
|---|
| 134 | --with-postgres \
|
|---|
| 135 | --with-curses \
|
|---|
| 136 | --with-regex \
|
|---|
| 137 | --with-nls \
|
|---|
| 138 | --with-freetype-includes=$OSGEO4W_ROOT_MSYS/include/freetype2 \
|
|---|
| 139 | --with-odbc \
|
|---|
| 140 | --with-cairo \
|
|---|
| 141 | --with-cairo-includes=$OSGEO4W_ROOT_MSYS/include/cairo
|
|---|
| 142 |
|
|---|
| 143 | touch mswindows/osgeo4w/configure-stamp
|
|---|
| 144 | fi
|
|---|
| 145 |
|
|---|
| 146 | log make
|
|---|
| 147 | make -k || ( cat error.log >&3 && false )
|
|---|
| 148 |
|
|---|
| 149 | log make install
|
|---|
| 150 | make install
|
|---|
| 151 |
|
|---|
| 152 | log cleanup
|
|---|
| 153 | mv $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/include/grass/config.h \
|
|---|
| 154 | $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/include/grass/config.h.mingw
|
|---|
| 155 | cp mswindows/osgeo4w/config.h.switch $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/include/grass/config.h
|
|---|
| 156 | cp mswindows/osgeo4w/config.h.vc $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/include/grass
|
|---|
| 157 | mkdir -p $OSGEO4W_ROOT_MSYS/etc/preremove $OSGEO4W_ROOT_MSYS/etc/postinstall
|
|---|
| 158 | sed -e "s#@VERSION@#$VERSION#g" -e "s#@osgeo4w@#$OSGEO4W_ROOT#g" \
|
|---|
| 159 | mswindows/osgeo4w/grass.bat.tmpl >$OSGEO4W_ROOT_MSYS/bin/${GRASS_EXECUTABLE}.bat
|
|---|
| 160 | sed -e "s#@VERSION@#$VERSION#g" -e "s#@OSGEO4W_ROOT_MSYS@#$OSGEO4W_ROOT_MSYS#g" -e "s#@POSTFIX@#$MAJOR$MINOR#g" \
|
|---|
| 161 | mswindows/osgeo4w/grass.tmpl >$OSGEO4W_ROOT_MSYS/bin/${GRASS_EXECUTABLE}
|
|---|
| 162 | sed -e "s#@VERSION@#$VERSION#g" -e "s#@OSGEO4W_ROOT_MSYS@#$OSGEO4W_ROOT#g" \
|
|---|
| 163 | mswindows/osgeo4w/env.bat.tmpl >$OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/etc/env.bat
|
|---|
| 164 | sed -e "s#@VERSION@#$VERSION#g" -e "s#@GRASS_EXECUTABLE@#$GRASS_EXECUTABLE#g" \
|
|---|
| 165 | mswindows/osgeo4w/postinstall.bat >$OSGEO4W_ROOT_MSYS/etc/postinstall/${GRASS_EXECUTABLE}.bat
|
|---|
| 166 | sed -e "s#@VERSION@#$VERSION#g" -e "s#@GRASS_EXECUTABLE@#$GRASS_EXECUTABLE#g" \
|
|---|
| 167 | mswindows/osgeo4w/preremove.bat >$OSGEO4W_ROOT_MSYS/etc/preremove/${GRASS_EXECUTABLE}.bat
|
|---|
| 168 |
|
|---|
| 169 | if [ -n "$PACKAGE" ]; then
|
|---|
| 170 | log building vc libraries
|
|---|
| 171 | sh mswindows/osgeo4w/mklibs.sh $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/lib/*.$VERSION.dll
|
|---|
| 172 | mv mswindows/osgeo4w/vc/grass*.lib $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/lib
|
|---|
| 173 | # rm $OSGEO4W_ROOT_MSYS/apps/grass/grass-$VERSION/lib/*.dll
|
|---|
| 174 |
|
|---|
| 175 | # log BUILDING GDAL GRASS plugins
|
|---|
| 176 | # $COMSPEC /c "mswindows\\osgeo4w\\gdalplugins.cmd $VERSION"
|
|---|
| 177 |
|
|---|
| 178 | log CREATING PACKAGES
|
|---|
| 179 | mkdir -p mswindows/osgeo4w/package
|
|---|
| 180 |
|
|---|
| 181 | PDIR=$PWD/mswindows/osgeo4w/package
|
|---|
| 182 | SRC=$PWD
|
|---|
| 183 | cd $OSGEO4W_ROOT_MSYS
|
|---|
| 184 |
|
|---|
| 185 | sed -e "s#@VERSION@#$VERSION#g" \
|
|---|
| 186 | $SRC/mswindows/osgeo4w/grass.bat.tmpl >$OSGEO4W_ROOT_MSYS/bin/${GRASS_EXECUTABLE}.bat.tmpl
|
|---|
| 187 | sed -e "s#@VERSION@#$VERSION#g" \
|
|---|
| 188 | $SRC/mswindows/osgeo4w/grass.tmpl >$OSGEO4W_ROOT_MSYS/bin/${GRASS_EXECUTABLE}.tmpl
|
|---|
| 189 |
|
|---|
| 190 | # bat files - unix2dos
|
|---|
| 191 | unix2dos bin/${GRASS_EXECUTABLE}.bat.tmpl
|
|---|
| 192 | unix2dos bin/${GRASS_EXECUTABLE}.tmpl
|
|---|
| 193 | unix2dos etc/postinstall/${GRASS_EXECUTABLE}.bat
|
|---|
| 194 | unix2dos etc/preremove/${GRASS_EXECUTABLE}.bat
|
|---|
| 195 |
|
|---|
| 196 | # grass package
|
|---|
| 197 | tar -cjf $PDIR/grass$PACKAGE_NAME-$VERSION-$PACKAGE.tar.bz2 \
|
|---|
| 198 | apps/grass/grass-$VERSION \
|
|---|
| 199 | bin/${GRASS_EXECUTABLE}.bat.tmpl \
|
|---|
| 200 | bin/${GRASS_EXECUTABLE}.tmpl \
|
|---|
| 201 | etc/postinstall/${GRASS_EXECUTABLE}.bat \
|
|---|
| 202 | etc/preremove/${GRASS_EXECUTABLE}.bat
|
|---|
| 203 |
|
|---|
| 204 | rm bin/${GRASS_EXECUTABLE}.tmpl
|
|---|
| 205 | rm bin/${GRASS_EXECUTABLE}.bat.tmpl
|
|---|
| 206 |
|
|---|
| 207 | # grass-devel package (obsolete)
|
|---|
| 208 | ###tar -cjf $PDIR/grass-devel-$VERSION-$PACKAGE.tar.bz2 \
|
|---|
| 209 | ###apps/grass/grass-$VERSION/include
|
|---|
| 210 |
|
|---|
| 211 | # grass-devel-mingw package (obsolete)
|
|---|
| 212 | ###tar -cjf $PDIR/grass-devel-mingw-$VERSION-$PACKAGE.tar.bz2 \
|
|---|
| 213 | ###apps/grass/grass-$VERSION/lib/*.a
|
|---|
| 214 |
|
|---|
| 215 | # grass-devel-vc package (obsolete)
|
|---|
| 216 | ###tar -cjf $PDIR/grass-devel-vc-$VERSION-$PACKAGE.tar.bz2 \
|
|---|
| 217 | ###apps/grass/grass-$VERSION/lib/*.lib
|
|---|
| 218 |
|
|---|
| 219 | # grass-locale package (obsolete)
|
|---|
| 220 | ###tar -cjf $PDIR/grass-locale-$VERSION-$PACKAGE.tar.bz2 \
|
|---|
| 221 | ###apps/grass/grass-$VERSION/locale
|
|---|
| 222 | fi
|
|---|
| 223 |
|
|---|
| 224 | log
|
|---|
| 225 |
|
|---|
| 226 | exit 0
|
|---|