| 1 | #!/usr/bin/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 | # package patch number
|
|---|
| 21 | # e.g. 'r65400-1' for daily builds, '-1' for release
|
|---|
| 22 | if [ -z $PACKAGE_PATCH ]; then
|
|---|
| 23 | PACKAGE_PATCH=1
|
|---|
| 24 | fi
|
|---|
| 25 |
|
|---|
| 26 | # package name
|
|---|
| 27 | # eg. '-daily' -> 'grass-daily', empty for release
|
|---|
| 28 | if [ -z $PACKAGE_POSTFIX ]; then
|
|---|
| 29 | PACKAGE_POSTFIX=""
|
|---|
| 30 | fi
|
|---|
| 31 |
|
|---|
| 32 | # OSGeo4W directory postfix
|
|---|
| 33 | # eg. '64' for 64bit, empty for 32bit
|
|---|
| 34 | if [ -z $OSGEO4W_POSTFIX ]; then
|
|---|
| 35 | OSGEO4W_POSTFIX=""
|
|---|
| 36 | fi
|
|---|
| 37 | if [ "$OSGEO4W_POSTFIX" = "64" ]; then
|
|---|
| 38 | MINGW_POSTFIX=64
|
|---|
| 39 | else
|
|---|
| 40 | MINGW_POSTFIX=32
|
|---|
| 41 | fi
|
|---|
| 42 |
|
|---|
| 43 | export OSGEO4W_ROOT_MSYS="/c/OSGeo4W${OSGEO4W_POSTFIX}"
|
|---|
| 44 | export OSGEO4W_ROOT="C:\\\OSGeo4W${OSGEO4W_POSTFIX}"
|
|---|
| 45 |
|
|---|
| 46 | export PATH=/usr/bin:/mingw${MINGW_POSTFIX}/bin/:$OSGEO4W_ROOT_MSYS/bin:$PWD/mswindows/osgeo4w/lib:$PWD/mswindows/osgeo4w
|
|---|
| 47 |
|
|---|
| 48 | # Force Python3
|
|---|
| 49 | # alias python=python3
|
|---|
| 50 | export PYTHONPATH=
|
|---|
| 51 | export PYTHONHOME=$OSGEO4W_ROOT_MSYS/apps/Python37
|
|---|
| 52 | export PATH=$OSGEO4W_ROOT_MSYS/apps/Python37:$PATH
|
|---|
| 53 |
|
|---|
| 54 | T0=$(date +%s)
|
|---|
| 55 | LT=$T0
|
|---|
| 56 | CS=""
|
|---|
| 57 |
|
|---|
| 58 | log() {
|
|---|
| 59 | local D T
|
|---|
| 60 | NOW=$(date)
|
|---|
| 61 | T=$(date +%s)
|
|---|
| 62 |
|
|---|
| 63 | if [ -n "$CS" ]; then
|
|---|
| 64 | local D H M S
|
|---|
| 65 | S=$(( $T-$LT ))
|
|---|
| 66 | M=$(( S/60 )); S=$(( S%60 ))
|
|---|
| 67 | H=$(( M/60 )); M=$(( M%60 ))
|
|---|
| 68 | D=$(( H/24 )); H=$(( H%24 ))
|
|---|
| 69 |
|
|---|
| 70 | echo -n "$NOW: FINISHED $CS AFTER "
|
|---|
| 71 | (( D>0 )) && echo -n "${D}d"
|
|---|
| 72 | (( H>0 )) && echo -n "${H}h"
|
|---|
| 73 | (( M>0 )) && echo -n "${M}m"
|
|---|
| 74 | echo "${S}s"
|
|---|
| 75 | fi
|
|---|
| 76 |
|
|---|
| 77 | CS="$@"
|
|---|
| 78 | LT=$T
|
|---|
| 79 | if [ -n "$CS" ]; then
|
|---|
| 80 | echo $NOW: STARTING $CS
|
|---|
| 81 | elif [ -n "$T0" ]; then
|
|---|
| 82 | CS="COMPLETE RUN"
|
|---|
| 83 | LT=$T0
|
|---|
| 84 | T0=""
|
|---|
| 85 | log
|
|---|
| 86 | fi
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | exec 3<include/VERSION
|
|---|
| 90 | read MAJOR <&3
|
|---|
| 91 | read MINOR <&3
|
|---|
| 92 | read PATCH <&3
|
|---|
| 93 |
|
|---|
| 94 | export VERSION=${MAJOR}.${MINOR}.${PATCH}
|
|---|
| 95 | export POSTFIX=${MAJOR}${MINOR}
|
|---|
| 96 |
|
|---|
| 97 | if [[ "$PATCH" == *svn* ]] ; then
|
|---|
| 98 | GRASS_EXECUTABLE=grass${MAJOR}${MINOR}svn
|
|---|
| 99 | else
|
|---|
| 100 | GRASS_EXECUTABLE=grass${MAJOR}${MINOR}
|
|---|
| 101 | fi
|
|---|
| 102 |
|
|---|
| 103 | if [ -f mswindows/osgeo4w/package.log ]; then
|
|---|
| 104 | i=0
|
|---|
| 105 | while [ -f mswindows/osgeo4w/package.log.$i ]; do
|
|---|
| 106 | (( i+=1 ))
|
|---|
| 107 | done
|
|---|
| 108 | mv mswindows/osgeo4w/package.log mswindows/osgeo4w/package.log.$i
|
|---|
| 109 | fi
|
|---|
| 110 |
|
|---|
| 111 | exec 3>&1 >> mswindows/osgeo4w/package.log 2>&1
|
|---|
| 112 |
|
|---|
| 113 | dll_to_a() {
|
|---|
| 114 | # http://sourceforge.net/apps/trac/mingw-w64/wiki/Answer%2064%20bit%20MSVC-generated%20x64%20.lib
|
|---|
| 115 | echo "$1 => $2"
|
|---|
| 116 | gendef - $1 >$2.def
|
|---|
| 117 | if [ "$MINGW_POSTFIX" = "64" ]; then
|
|---|
| 118 | dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib $2.dll.a --input-def $2.def
|
|---|
| 119 | else
|
|---|
| 120 | dlltool -k --output-lib $2.dll.a --input-def $2.def
|
|---|
| 121 | fi
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | log dll.to.a
|
|---|
| 125 | [ -d mswindows/osgeo4w/lib ] || mkdir mswindows/osgeo4w/lib
|
|---|
| 126 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/proj_5_2.dll mswindows/osgeo4w/lib/libproj
|
|---|
| 127 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/iconv.dll mswindows/osgeo4w/lib/libiconv
|
|---|
| 128 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/gdal204.dll mswindows/osgeo4w/lib/libgdal
|
|---|
| 129 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/liblas_c.dll mswindows/osgeo4w/lib/liblas_c
|
|---|
| 130 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/geos_c.dll mswindows/osgeo4w/lib/libgeos_c
|
|---|
| 131 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/libtiff.dll mswindows/osgeo4w/lib/libtiff
|
|---|
| 132 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/libpq.dll mswindows/osgeo4w/lib/libpq
|
|---|
| 133 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/libmysql.dll mswindows/osgeo4w/lib/libmysqlclient
|
|---|
| 134 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/sqlite3.dll mswindows/osgeo4w/lib/libsqlite3
|
|---|
| 135 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/cairo.dll mswindows/osgeo4w/lib/libcairo
|
|---|
| 136 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/libfftw3-3.dll mswindows/osgeo4w/lib/libfftw3
|
|---|
| 137 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/pdcurses.dll mswindows/osgeo4w/lib/libpdcurses
|
|---|
| 138 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/zstd.dll mswindows/osgeo4w/lib/libzstd
|
|---|
| 139 | if [ "$MINGW_POSTFIX" = "64" ]; then
|
|---|
| 140 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/zlib1.dll mswindows/osgeo4w/lib/libz
|
|---|
| 141 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/libpng16.dll mswindows/osgeo4w/lib/libpng
|
|---|
| 142 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/jpeg.dll mswindows/osgeo4w/lib/libjpeg
|
|---|
| 143 | else
|
|---|
| 144 | # TODO (related to dependencies)
|
|---|
| 145 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/zlib_osgeo.dll mswindows/osgeo4w/lib/libz
|
|---|
| 146 | # dll_to_a $OSGEO4W_ROOT_MSYS/bin/libpng12-0.dll mswindows/osgeo4w/lib/libpng
|
|---|
| 147 | dll_to_a $OSGEO4W_ROOT_MSYS/bin/jpeg_osgeo.dll mswindows/osgeo4w/lib/libjpeg
|
|---|
| 148 | fi
|
|---|
| 149 |
|
|---|
| 150 | cp -uv $OSGEO4W_ROOT_MSYS/lib/libxdr.a mswindows/osgeo4w/lib
|
|---|
| 151 | #cp -uv $OSGEO4W_ROOT_MSYS/lib/libregex.a mswindows/osgeo4w/lib
|
|---|
| 152 | cp -uv $OSGEO4W_ROOT_MSYS/lib/libfreetype.dll.a mswindows/osgeo4w/lib
|
|---|
| 153 |
|
|---|
| 154 | if ! [ -f mswindows/osgeo4w/configure-stamp ]; then
|
|---|
| 155 |
|
|---|
| 156 | if [ -e include/Make/Platform.make ] ; then
|
|---|
| 157 | log make distclean
|
|---|
| 158 | make distclean
|
|---|
| 159 | fi
|
|---|
| 160 |
|
|---|
| 161 | log remove old logs
|
|---|
| 162 | rm -f mswindows/osgeo4w/package.log.[0-9][0-9][0-9]
|
|---|
| 163 |
|
|---|
| 164 | if [ "$MINGW_POSTFIX" = "64" ]; then
|
|---|
| 165 | conf_host=x86_64-w64-mingw32
|
|---|
| 166 | # https://trac.osgeo.org/osgeo4w/ticket/550
|
|---|
| 167 | conf_opts="--with-liblas=$PWD/mswindows/osgeo4w/liblas-config"
|
|---|
| 168 | else
|
|---|
| 169 | conf_host=i386-w64-mingw32
|
|---|
| 170 | # https://trac.osgeo.org/osgeo4w/ticket/539
|
|---|
| 171 | # LAS support hopefully only temporarily disabled on 32bit
|
|---|
| 172 | conf_opts=
|
|---|
| 173 | fi
|
|---|
| 174 |
|
|---|
| 175 | log configure
|
|---|
| 176 | LDFLAGS="-L$PWD/mswindows/osgeo4w/lib -lz" ./configure \
|
|---|
| 177 | --host=$conf_host \
|
|---|
| 178 | --with-libs="$PWD/mswindows/osgeo4w/lib "\
|
|---|
| 179 | --with-includes=$OSGEO4W_ROOT_MSYS/include \
|
|---|
| 180 | --libexecdir=$OSGEO4W_ROOT_MSYS/bin \
|
|---|
| 181 | --prefix=$OSGEO4W_ROOT_MSYS/apps/grass \
|
|---|
| 182 | --bindir=$OSGEO4W_ROOT_MSYS/bin \
|
|---|
| 183 | --includedir=$OSGEO4W_ROOT_MSYS/include \
|
|---|
| 184 | --without-x \
|
|---|
| 185 | --with-cxx \
|
|---|
| 186 | --enable-shared \
|
|---|
| 187 | --enable-largefile \
|
|---|
| 188 | --with-fftw \
|
|---|
| 189 | --with-freetype \
|
|---|
| 190 | --with-proj-share=$OSGEO4W_ROOT_MSYS/share/proj \
|
|---|
| 191 | --with-gdal=$PWD/mswindows/osgeo4w/gdal-config \
|
|---|
| 192 | --with-geos=$PWD/mswindows/osgeo4w/geos-config \
|
|---|
| 193 | --with-sqlite \
|
|---|
| 194 | --with-regex \
|
|---|
| 195 | --with-nls \
|
|---|
| 196 | --with-freetype-includes=$OSGEO4W_ROOT_MSYS/include/freetype2 \
|
|---|
| 197 | --with-zstd \
|
|---|
| 198 | --with-odbc \
|
|---|
| 199 | --with-cairo \
|
|---|
| 200 | --with-postgres \
|
|---|
| 201 | --with-opengl=windows \
|
|---|
| 202 | --with-bzlib $conf_opts
|
|---|
| 203 | # see #3047
|
|---|
| 204 | # --with-mysql
|
|---|
| 205 | touch mswindows/osgeo4w/configure-stamp
|
|---|
| 206 | fi
|
|---|
| 207 |
|
|---|
| 208 | log make
|
|---|
| 209 | make -k || ( cat error.log >&3 && false )
|
|---|
| 210 |
|
|---|
| 211 | log make install
|
|---|
| 212 | make install
|
|---|
| 213 |
|
|---|
| 214 | log cleanup
|
|---|
| 215 | rm -f diib*
|
|---|
| 216 |
|
|---|
| 217 | log prepare packaging
|
|---|
| 218 | mv $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/include/grass/config.h \
|
|---|
| 219 | $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/include/grass/config.h.mingw
|
|---|
| 220 | cp mswindows/osgeo4w/config.h.switch $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/include/grass/config.h
|
|---|
| 221 | cp mswindows/osgeo4w/config.h.vc $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/include/grass
|
|---|
| 222 | mkdir -p $OSGEO4W_ROOT_MSYS/etc/preremove $OSGEO4W_ROOT_MSYS/etc/postinstall
|
|---|
| 223 | sed -e "s#@POSTFIX@#$POSTFIX#g" \
|
|---|
| 224 | mswindows/osgeo4w/grass.bat.tmpl >$OSGEO4W_ROOT_MSYS/bin/${GRASS_EXECUTABLE}.bat
|
|---|
| 225 | sed -e "s#@POSTFIX@#$POSTFIX#g" \
|
|---|
| 226 | mswindows/osgeo4w/env.bat.tmpl >$OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/etc/env.bat
|
|---|
| 227 | sed -e "s#@POSTFIX@#$POSTFIX#g" -e "s#@VERSION@#$VERSION#g" -e "s#@GRASS_EXECUTABLE@#$GRASS_EXECUTABLE#g" \
|
|---|
| 228 | mswindows/osgeo4w/postinstall.bat >$OSGEO4W_ROOT_MSYS/etc/postinstall/grass${PACKAGE_POSTFIX}.bat
|
|---|
| 229 | sed -e "s#@POSTFIX@#$POSTFIX#g" -e "s#@VERSION@#$VERSION#g" -e "s#@GRASS_EXECUTABLE@#$GRASS_EXECUTABLE#g" \
|
|---|
| 230 | mswindows/osgeo4w/preremove.bat >$OSGEO4W_ROOT_MSYS/etc/preremove/grass${PACKAGE_POSTFIX}.bat
|
|---|
| 231 |
|
|---|
| 232 | if [ -n "$PACKAGE_PATCH" ]; then
|
|---|
| 233 | log building vc libraries
|
|---|
| 234 | OSGEO4W_POSTFIX=$OSGEO4W_POSTFIX sh \
|
|---|
| 235 | mswindows/osgeo4w/mklibs.sh $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/lib/*.${MAJOR}.${MINOR}.dll
|
|---|
| 236 | mv mswindows/osgeo4w/vc/grass*.lib $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/lib
|
|---|
| 237 |
|
|---|
| 238 | log creating package
|
|---|
| 239 | mkdir -p mswindows/osgeo4w/package
|
|---|
| 240 |
|
|---|
| 241 | PDIR=$PWD/mswindows/osgeo4w/package
|
|---|
| 242 | SRC=$PWD
|
|---|
| 243 | cd $OSGEO4W_ROOT_MSYS
|
|---|
| 244 |
|
|---|
| 245 | # update startup script
|
|---|
| 246 | sed -e "s#@POSTFIX@#$POSTFIX#g" \
|
|---|
| 247 | $SRC/mswindows/osgeo4w/grass.bat.tmpl > bin/${GRASS_EXECUTABLE}.bat.tmpl
|
|---|
| 248 |
|
|---|
| 249 | # bat files - unix2dos
|
|---|
| 250 | unix2dos bin/${GRASS_EXECUTABLE}.bat.tmpl
|
|---|
| 251 | unix2dos etc/postinstall/grass${PACKAGE_POSTFIX}.bat
|
|---|
| 252 | unix2dos etc/preremove/grass${PACKAGE_POSTFIX}.bat
|
|---|
| 253 |
|
|---|
| 254 | # copy dependencies (TODO: to be reduced)
|
|---|
| 255 | if [ "$MINGW_POSTFIX" = "64" ]; then
|
|---|
| 256 | mingw_libgcc=libgcc_s_seh-1.dll
|
|---|
| 257 | else
|
|---|
| 258 | mingw_libgcc=libgcc_s_dw2-1.dll
|
|---|
| 259 | fi
|
|---|
| 260 | cp -uv /mingw${MINGW_POSTFIX}/bin/libintl-8.dll \
|
|---|
| 261 | /mingw${MINGW_POSTFIX}/bin/libiconv-2.dll \
|
|---|
| 262 | /mingw${MINGW_POSTFIX}/bin/libfontconfig-1.dll \
|
|---|
| 263 | /mingw${MINGW_POSTFIX}/bin/$mingw_libgcc \
|
|---|
| 264 | /mingw${MINGW_POSTFIX}/bin/libwinpthread-1.dll \
|
|---|
| 265 | /mingw${MINGW_POSTFIX}/bin/libexpat-1.dll \
|
|---|
| 266 | /mingw${MINGW_POSTFIX}/bin/libfreetype-6.dll \
|
|---|
| 267 | /mingw${MINGW_POSTFIX}/bin/libbz2-1.dll \
|
|---|
| 268 | /mingw${MINGW_POSTFIX}/bin/libharfbuzz-0.dll \
|
|---|
| 269 | /mingw${MINGW_POSTFIX}/bin/libglib-2.0-0.dll \
|
|---|
| 270 | /mingw${MINGW_POSTFIX}/bin/libpng16-16.dll \
|
|---|
| 271 | /mingw${MINGW_POSTFIX}/bin/libsystre-0.dll \
|
|---|
| 272 | /mingw${MINGW_POSTFIX}/bin/libtre-5.dll \
|
|---|
| 273 | /mingw${MINGW_POSTFIX}/bin/zlib1.dll \
|
|---|
| 274 | /mingw${MINGW_POSTFIX}/bin/libstdc++-6.dll \
|
|---|
| 275 | apps/grass/grass$POSTFIX/bin
|
|---|
| 276 | cp -uv /mingw${MINGW_POSTFIX}/etc/fonts/fonts.conf \
|
|---|
| 277 | apps/grass/grass$POSTFIX/etc
|
|---|
| 278 |
|
|---|
| 279 | # creating grass package
|
|---|
| 280 | tar -cjf $PDIR/grass$PACKAGE_POSTFIX-$VERSION-$PACKAGE_PATCH.tar.bz2 \
|
|---|
| 281 | apps/grass/grass$POSTFIX \
|
|---|
| 282 | bin/${GRASS_EXECUTABLE}.bat.tmpl \
|
|---|
| 283 | etc/postinstall/grass${PACKAGE_POSTFIX}.bat \
|
|---|
| 284 | etc/preremove/grass${PACKAGE_POSTFIX}.bat
|
|---|
| 285 |
|
|---|
| 286 | # clean up
|
|---|
| 287 | rm bin/${GRASS_EXECUTABLE}.bat.tmpl
|
|---|
| 288 | fi
|
|---|
| 289 |
|
|---|
| 290 | log
|
|---|
| 291 |
|
|---|
| 292 | exit 0
|
|---|