Jelajahi Sumber

Apply patches from OSGeo4W upstreams (#1880)

* apply patches from jef-n/osgeo4w
* mklibs: -x flag not needed
* gisinit.c: keep version check also on Windows

Co-authored-by: Martin Landa <landa.martin@gmail.com>
Stefan Blumentrath 3 tahun lalu
induk
melakukan
345cf68b58
3 mengubah file dengan 81 tambahan dan 130 penghapusan
  1. 5 22
      mswindows/osgeo4w/mklibs.sh
  2. 47 81
      mswindows/osgeo4w/package.sh
  3. 29 27
      mswindows/osgeo4w/postinstall.bat

+ 5 - 22
mswindows/osgeo4w/mklibs.sh

@@ -2,30 +2,12 @@
 
 
 set -e
 set -e
 
 
-if [ -z "$OSGEO4W_POSTFIX" ]; then
-    OSGEO4W_POSTFIX=""
-fi
+[ -d mswindows/osgeo4w/vc ] || mkdir mswindows/osgeo4w/vc
 
 
-if [ "$OSGEO4W_POSTFIX" != "64" ]; then
-    MACHINE=x86
-else
-    MACHINE=x64
+if [ -n "$VCPATH" ]; then
+	PATH=$PATH:$VCPATH
 fi
 fi
 
 
-PROGRAMFILES="/c/Program Files (x86)"
-VSDIR="$PROGRAMFILES/Microsoft Visual Studio 14.0"
-# add example for MS Visual Studio 2017 Community 64 bit
-# VSDIR="$PROGRAMFILES/Microsoft Visual Studio/2017/Community"
-PATH="$VSDIR/Common7/IDE:$PATH"
-PATH="$VSDIR/VC/bin:$PATH"
-# add example for MS Visual Studio 2017 Community 64 bit
-# PATH="$VSDIR/VC/Tools/MSVC/14.12.25827/bin/Hostx64/x64:$PATH"
-PATH="$VSDIR/Common7/Tools:$PATH"
-PATH="$PATH:/c/OSGeo4W${OSGEO4W_POSTFIX}/bin"
-export PATH
-
-[ -d mswindows/osgeo4w/vc ] || mkdir mswindows/osgeo4w/vc
-
 for dllfile in "$@"; do
 for dllfile in "$@"; do
 	dlldir=${dllfile%/*}
 	dlldir=${dllfile%/*}
 	dllfile=${dllfile##*/}
 	dllfile=${dllfile##*/}
@@ -43,6 +25,7 @@ for dllfile in "$@"; do
 		egrep -v "^[	 ]*(_+IMPORT_DESCRIPTOR_.*|_+NULL_IMPORT_DESCRIPTOR)$" >mswindows/osgeo4w/vc/${defname%$VERSION}
 		egrep -v "^[	 ]*(_+IMPORT_DESCRIPTOR_.*|_+NULL_IMPORT_DESCRIPTOR)$" >mswindows/osgeo4w/vc/${defname%$VERSION}
 
 
 	(cd mswindows/osgeo4w/vc ;
 	(cd mswindows/osgeo4w/vc ;
-	    lib -nologo -def:${defname} -subsystem:windows -machine:${MACHINE}
+	    lib -nologo -def:${defname} -subsystem:windows -machine:x64
 	    lib -nologo $libname || exit)
 	    lib -nologo $libname || exit)
 done
 done
+

+ 47 - 81
mswindows/osgeo4w/package.sh

@@ -1,7 +1,5 @@
 #!/usr/bin/bash
 #!/usr/bin/bash
 
 
-# osgeo4w-setup -g -k -a x86_64 -q -P gdal -P proj -P geos -P fftw -P libjpeg -P liblas-devel -P libpng -P libpq -P libtiff -P libxdr -P pdcurses -P regex-devel -P sqlite3 -P zstd-devel -P zstd -P laszip2 -P python3-core -P python3-six
-
 set -e
 set -e
 
 
 PWD="$(pwd)"
 PWD="$(pwd)"
@@ -29,19 +27,8 @@ if [ -z $PACKAGE_POSTFIX ]; then
     PACKAGE_POSTFIX=""
     PACKAGE_POSTFIX=""
 fi
 fi
 
 
-# OSGeo4W directory postfix
-# eg. '64' for 64bit, empty for 32bit
-if [ -z $OSGEO4W_POSTFIX ]; then
-    OSGEO4W_POSTFIX=""
-fi
-if [ "$OSGEO4W_POSTFIX" = "64" ]; then
-    MINGW_POSTFIX=64
-else
-    MINGW_POSTFIX=32
-fi
-
-export OSGEO4W_ROOT_MSYS="/c/OSGeo4W${OSGEO4W_POSTFIX}"
-export OSGEO4W_ROOT=$(cygpath -w "$OSGEO4W_ROOT_MSYS")
+[ -n "$OSGEO4W_ROOT_MSYS" ]
+echo "OSGEO4W_ROOT_MSYS:$OSGEO4W_ROOT_MSYS OSGEO4W_ROOT:$OSGEO4W_ROOT"
 
 
 fetchenv() {
 fetchenv() {
     local IFS
     local IFS
@@ -53,22 +40,16 @@ fetchenv() {
     diffenv=$(mktemp /tmp/diffenv.XXXXXXXXXX)
     diffenv=$(mktemp /tmp/diffenv.XXXXXXXXXX)
     args="$@"
     args="$@"
     cmd.exe //c set >$srcenv
     cmd.exe //c set >$srcenv
-    cmd.exe //c "call `cygpath -w $batch` $args \>nul 2\>nul \& set" >$dstenv
+    cmd.exe //c "call `cygpath -sw $batch` $args \>nul 2\>nul \& set" >$dstenv
     diff -u $srcenv $dstenv | sed -f mswindows/osgeo4w/envdiff.sed >$diffenv
     diff -u $srcenv $dstenv | sed -f mswindows/osgeo4w/envdiff.sed >$diffenv
     . $diffenv
     . $diffenv
-    PATH=$PATH:/usr/bin:/mingw${MINGW_POSTFIX}/bin/:$PWD/mswindows/osgeo4w/lib:$PWD/mswindows/osgeo4w:/c/windows32/system32:/c/windows:/c/windows32/system32:/c/windows
+    PATH=$PATH:/usr/bin:/mingw64/bin/:$PWD/mswindows/osgeo4w/lib:$PWD/mswindows/osgeo4w:/c/windows32/system32:/c/windows:/c/windows32/system32:/c/windows
     rm -f $srcenv $dstenv $diffenv
     rm -f $srcenv $dstenv $diffenv
 }
 }
 
 
-# Avoid GRASS' old msys
-! [ -f $OSGEO4W_ROOT_MSYS/etc/ini/msys.bat ] || mv $OSGEO4W_ROOT_MSYS/etc/ini/msys.bat $OSGEO4W_ROOT_MSYS/etc/ini/msys.bat.off
-
 fetchenv $OSGEO4W_ROOT_MSYS/bin/o4w_env.bat
 fetchenv $OSGEO4W_ROOT_MSYS/bin/o4w_env.bat
-fetchenv $OSGEO4W_ROOT_MSYS/bin/py3_env.bat
 
 
-! [ -f $OSGEO4W_ROOT_MSYS/etc/ini/msys.bat.off ] || mv $OSGEO4W_ROOT_MSYS/etc/ini/msys.bat.off $OSGEO4W_ROOT_MSYS/etc/ini/msys.bat
-
-PATH=/mingw${MINGW_POSTFIX}/lib/ccache/bin:$PATH
+PATH=/mingw64/lib/ccache/bin:$PATH
 
 
 T0=$(date +%s)
 T0=$(date +%s)
 LT=$T0
 LT=$T0
@@ -125,42 +106,30 @@ fi
 
 
 exec 3>&1 > >(tee mswindows/osgeo4w/package.log) 2>&1
 exec 3>&1 > >(tee mswindows/osgeo4w/package.log) 2>&1
 
 
-if [ "$MINGW_POSTFIX" = "64" ]; then
-	mingw_libgcc=libgcc_s_seh-1.dll
-else
-	mingw_libgcc=libgcc_s_dw2-1.dll
-fi
-
-DLLS="/mingw${MINGW_POSTFIX}/bin/zlib1.dll
-	/mingw${MINGW_POSTFIX}/bin/libbz2-1.dll
-	/mingw${MINGW_POSTFIX}/bin/libiconv-2.dll
-	/mingw${MINGW_POSTFIX}/bin/libexpat-1.dll
-	/mingw${MINGW_POSTFIX}/bin/libfontconfig-1.dll
-	/mingw${MINGW_POSTFIX}/bin/libintl-8.dll
-	/mingw${MINGW_POSTFIX}/bin/libsystre-0.dll
-	/mingw${MINGW_POSTFIX}/bin/libtre-5.dll
-	/mingw${MINGW_POSTFIX}/bin/libwinpthread-1.dll
-	/mingw${MINGW_POSTFIX}/bin/libcairo-2.dll
-	/mingw${MINGW_POSTFIX}/bin/libpixman-1-0.dll
-	/mingw${MINGW_POSTFIX}/bin/libpng16-16.dll
-	/mingw${MINGW_POSTFIX}/bin/libfreetype-6.dll
-	/mingw${MINGW_POSTFIX}/bin/libharfbuzz-0.dll
-	/mingw${MINGW_POSTFIX}/bin/libglib-2.0-0.dll
-	/mingw${MINGW_POSTFIX}/bin/libgraphite2.dll
-	/mingw${MINGW_POSTFIX}/bin/libpcre-1.dll
-	/mingw${MINGW_POSTFIX}/bin/libstdc++-6.dll
-	/mingw${MINGW_POSTFIX}/bin/$mingw_libgcc"
-
-if [ "$MINGW_POSTFIX" = "64" ]; then
-	conf_host=x86_64-w64-mingw32
-	# https://trac.osgeo.org/osgeo4w/ticket/550
-	conf_opts="--with-liblas=$PWD/mswindows/osgeo4w/liblas-config"
-else
-	conf_host=i386-w64-mingw32
-	# https://trac.osgeo.org/osgeo4w/ticket/539
-	#  LAS support hopefully only temporarily disabled on 32bit
-	conf_opts=
-fi
+DLLS="
+	/mingw64/bin/zlib1.dll
+	/mingw64/bin/libbz2-1.dll
+	/mingw64/bin/libiconv-2.dll
+	/mingw64/bin/libexpat-1.dll
+	/mingw64/bin/libfontconfig-1.dll
+	/mingw64/bin/libbrotlidec.dll
+	/mingw64/bin/libbrotlicommon.dll
+	/mingw64/bin/libintl-8.dll
+	/mingw64/bin/libsystre-0.dll
+	/mingw64/bin/libtre-5.dll
+	/mingw64/bin/libwinpthread-1.dll
+	/mingw64/bin/libcairo-2.dll
+	/mingw64/bin/libpixman-1-0.dll
+	/mingw64/bin/libpng16-16.dll
+	/mingw64/bin/libfreetype-6.dll
+	/mingw64/bin/libharfbuzz-0.dll
+	/mingw64/bin/libglib-2.0-0.dll
+	/mingw64/bin/libgraphite2.dll
+	/mingw64/bin/libpcre-1.dll
+	/mingw64/bin/libstdc++-6.dll
+	/mingw64/bin/libgcc_s_seh-1.dll
+	/mingw64/bin/libfftw3-3.dll
+"
 
 
 if ! [ -f mswindows/osgeo4w/configure-stamp ]; then
 if ! [ -f mswindows/osgeo4w/configure-stamp ]; then
 	if [ -e include/Make/Platform.make ] ; then
 	if [ -e include/Make/Platform.make ] ; then
@@ -171,33 +140,32 @@ if ! [ -f mswindows/osgeo4w/configure-stamp ]; then
 	log remove old logs
 	log remove old logs
 	rm -f mswindows/osgeo4w/package.log.*
 	rm -f mswindows/osgeo4w/package.log.*
 
 
-	mkdir -p dist.$conf_host/bin
-	cp -uv $DLLS dist.$conf_host/bin
+	mkdir -p dist.x86_64-w64-mingw32/bin
+	cp -uv $DLLS dist.x86_64-w64-mingw32/bin
 
 
 	mkdir -p mswindows/osgeo4w/lib
 	mkdir -p mswindows/osgeo4w/lib
 	cp -uv $OSGEO4W_ROOT_MSYS/lib/libpq.lib mswindows/osgeo4w/lib/pq.lib
 	cp -uv $OSGEO4W_ROOT_MSYS/lib/libpq.lib mswindows/osgeo4w/lib/pq.lib
-	cp -uv $OSGEO4W_ROOT_MSYS/lib/proj_i.lib mswindows/osgeo4w/lib/proj.lib
 	cp -uv $OSGEO4W_ROOT_MSYS/lib/sqlite3_i.lib mswindows/osgeo4w/lib/sqlite3.lib
 	cp -uv $OSGEO4W_ROOT_MSYS/lib/sqlite3_i.lib mswindows/osgeo4w/lib/sqlite3.lib
 
 
 	log configure
 	log configure
 	./configure \
 	./configure \
-	        --host=$conf_host \
-		--with-libs="$OSGEO4W_ROOT/lib" \
+	    --host=x86_64-w64-mingw32 \
+		--with-libs="$OSGEO4W_ROOT_MSYS/lib" \
 		--with-includes=$OSGEO4W_ROOT_MSYS/include \
 		--with-includes=$OSGEO4W_ROOT_MSYS/include \
-                --libexecdir=$OSGEO4W_ROOT_MSYS/bin \
-                --prefix=$OSGEO4W_ROOT_MSYS/apps/grass \
-                --bindir=$OSGEO4W_ROOT_MSYS/bin \
-                --includedir=$OSGEO4W_ROOT_MSYS/include \
+        --libexecdir=$OSGEO4W_ROOT_MSYS/bin \
+        --prefix=$OSGEO4W_ROOT_MSYS/apps/grass \
+        --bindir=$OSGEO4W_ROOT_MSYS/bin \
+        --includedir=$OSGEO4W_ROOT_MSYS/include \
 		--without-x \
 		--without-x \
 		--with-cxx \
 		--with-cxx \
 		--enable-shared \
 		--enable-shared \
 		--enable-largefile \
 		--enable-largefile \
 		--with-fftw \
 		--with-fftw \
 		--with-freetype \
 		--with-freetype \
-		--with-freetype-includes=/mingw${MINGW_POSTFIX}/include/freetype2 \
+		--with-freetype-includes=/mingw64/include/freetype2 \
 		--with-proj-share=$OSGEO4W_ROOT_MSYS/share/proj \
 		--with-proj-share=$OSGEO4W_ROOT_MSYS/share/proj \
 		--with-proj-includes=$OSGEO4W_ROOT_MSYS/include \
 		--with-proj-includes=$OSGEO4W_ROOT_MSYS/include \
-		--with-proj-libs=$PWD/mswindows/osgeo4w/lib \
+		--with-proj-libs=$OSGEO4W_ROOT_MSYS/lib \
 		--with-postgres \
 		--with-postgres \
 		--with-postgres-includes=$OSGEO4W_ROOT_MSYS/include \
 		--with-postgres-includes=$OSGEO4W_ROOT_MSYS/include \
 		--with-postgres-libs=$PWD/mswindows/osgeo4w/lib \
 		--with-postgres-libs=$PWD/mswindows/osgeo4w/lib \
@@ -210,11 +178,12 @@ if ! [ -f mswindows/osgeo4w/configure-stamp ]; then
 		--with-nls \
 		--with-nls \
 		--with-zstd \
 		--with-zstd \
 		--with-odbc \
 		--with-odbc \
-	        --with-cairo \
-	        --with-opengl=windows \
-                --with-bzlib $conf_opts
-# see #3047
-#	        --with-mysql
+	    --with-cairo \
+		--with-cairo-includes=$OSGEO4W_ROOT_MSYS/include \
+		--with-cairo-ldflags="-L$PWD/mswindows/osgeo4w/lib -lcairo -lfontconfig" \
+	    --with-opengl=windows \
+		--with-bzlib \
+		--with-liblas=$PWD/mswindows/osgeo4w/liblas-config
 
 
 	touch mswindows/osgeo4w/configure-stamp
 	touch mswindows/osgeo4w/configure-stamp
 fi
 fi
@@ -248,8 +217,7 @@ sed -e "s#@POSTFIX@#$POSTFIX#g" -e "s#@VERSION@#$VERSION#g" -e "s#@GRASS_EXECUTA
 
 
 if [ -n "$PACKAGE_PATCH" ]; then
 if [ -n "$PACKAGE_PATCH" ]; then
     log building vc libraries
     log building vc libraries
-    OSGEO4W_POSTFIX=$OSGEO4W_POSTFIX sh \
-        mswindows/osgeo4w/mklibs.sh $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/lib/*.${MAJOR}.${MINOR}.dll
+    sh mswindows/osgeo4w/mklibs.sh $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/lib/*.${MAJOR}.${MINOR}.dll
     mv mswindows/osgeo4w/vc/grass*.lib $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/lib
     mv mswindows/osgeo4w/vc/grass*.lib $OSGEO4W_ROOT_MSYS/apps/grass/grass$POSTFIX/lib
 
 
     log creating package
     log creating package
@@ -267,8 +235,7 @@ if [ -n "$PACKAGE_PATCH" ]; then
 
 
     # copy dependencies (TODO: to be reduced)
     # copy dependencies (TODO: to be reduced)
     cp -uv $DLLS apps/grass/grass$POSTFIX/bin
     cp -uv $DLLS apps/grass/grass$POSTFIX/bin
-    cp -uv /mingw${MINGW_POSTFIX}/etc/fonts/fonts.conf \
-	apps/grass/grass$POSTFIX/etc
+    cp -uv /mingw64/etc/fonts/fonts.conf apps/grass/grass$POSTFIX/etc
 
 
     # creating grass package
     # creating grass package
     /bin/tar -cjf $PDIR/grass$PACKAGE_POSTFIX-$VERSION-$PACKAGE_PATCH.tar.bz2 \
     /bin/tar -cjf $PDIR/grass$PACKAGE_POSTFIX-$VERSION-$PACKAGE_PATCH.tar.bz2 \
@@ -277,7 +244,6 @@ if [ -n "$PACKAGE_PATCH" ]; then
 	bin/python-${GRASS_EXECUTABLE}.bat \
 	bin/python-${GRASS_EXECUTABLE}.bat \
 	etc/postinstall/grass${PACKAGE_POSTFIX}.bat \
 	etc/postinstall/grass${PACKAGE_POSTFIX}.bat \
 	etc/preremove/grass${PACKAGE_POSTFIX}.bat
 	etc/preremove/grass${PACKAGE_POSTFIX}.bat
-
 fi
 fi
 
 
 log
 log

+ 29 - 27
mswindows/osgeo4w/postinstall.bat

@@ -1,27 +1,29 @@
-set ICON=%OSGEO4W_ROOT%\apps\grass\grass@POSTFIX@\gui\icons\grass_osgeo.ico
-set BATCH=%OSGEO4W_ROOT%\bin\@GRASS_EXECUTABLE@.bat
-textreplace -std -t "%BATCH%"
-textreplace -std -t "%OSGEO4W_ROOT%"\apps\grass\grass@POSTFIX@\etc\fontcap
-
-if not %OSGEO4W_MENU_LINKS%==0 xxmklink "%OSGEO4W_STARTMENU%\GRASS GIS @VERSION@.lnk" "%BATCH%"  "--gui" \ "Launch GRASS GIS @VERSION@" 1 "%ICON%" 
-if not %OSGEO4W_DESKTOP_LINKS%==0 xxmklink "%OSGEO4W_DESKTOP%\GRASS GIS @VERSION@.lnk" "%BATCH%"  "--gui" \ "Launch GRASS GIS @VERSION@" 1 "%ICON%" 
-
-rem run g.mkfontcap outside a GRASS session during
-rem an OSGeo4W installation for updating paths to fonts
-
-rem set gisbase
-set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass@POSTFIX@
-
-rem set path to freetype dll and its dependencies
-set FREETYPEBASE=%OSGEO4W_ROOT%\bin;%OSGEO4W_ROOT%\apps\msys\bin;%GISBASE%\lib
-
-rem set dependencies to path
-set PATH=%FREETYPEBASE%;%PATH%
-
-rem GISRC must be set
-set GISRC=dummy
-
-rem run g.mkfontcap outside a GRASS session
-"%GISBASE%\bin\g.mkfontcap.exe" -o
-
-del "%BATCH%.tmpl
+set ICON=%OSGEO4W_ROOT%\apps\grass\grass@POSTFIX@\gui\icons\grass_osgeo.ico
+set BATCH=%OSGEO4W_ROOT%\bin\@GRASS_EXECUTABLE@.bat
+textreplace -std -t "%BATCH%"
+textreplace -std -t "%OSGEO4W_ROOT%\apps\grass\grass@POSTFIX@\etc\fontcap"
+
+for /F "tokens=* USEBACKQ" %%F IN (`getspecialfolder Documents`) do set DOCUMENTS=%%F
+
+if not %OSGEO4W_MENU_LINKS%==0 xxmklink "%OSGEO4W_STARTMENU%\GRASS GIS @VERSION@.lnk" "%BATCH%"  "--gui" "%DOCUMENTS%" "Launch GRASS GIS @VERSION@" 1 "%ICON%" 
+if not %OSGEO4W_DESKTOP_LINKS%==0 xxmklink "%OSGEO4W_DESKTOP%\GRASS GIS @VERSION@.lnk" "%BATCH%"  "--gui" "%DOCUMENTS%" "Launch GRASS GIS @VERSION@" 1 "%ICON%" 
+
+rem run g.mkfontcap outside a GRASS session during
+rem an OSGeo4W installation for updating paths to fonts
+
+rem set gisbase
+set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass@POSTFIX@
+
+rem set path to freetype dll and its dependencies
+set FREETYPEBASE=%OSGEO4W_ROOT%\bin;%OSGEO4W_ROOT%\apps\msys\bin;%GISBASE%\lib
+
+rem set dependencies to path
+set PATH=%FREETYPEBASE%;%PATH%
+
+rem GISRC must be set
+set GISRC=dummy
+
+rem run g.mkfontcap outside a GRASS session
+"%GISBASE%\bin\g.mkfontcap.exe" -o
+
+del "%BATCH%.tmpl