From: Rob Norris Date: Mon, 21 Dec 2015 11:41:27 +0000 (+0000) Subject: [WINDOWS] Cross build X-Git-Url: https://git.street.me.uk/andy/viking.git/commitdiff_plain/0edf62b8deee098d5791721eb39788ae193828fc [WINDOWS] Cross build Enable cross build with an RPM set-up (using OpenSUSE Tumbleweed) Tested in a VM dedicated to the build. This is now the supported build method for generating the Window executable. This version is only 32bit (no different than before) however scope for adding a 64bit version should now be relatively straight-forward. --- diff --git a/.gitignore b/.gitignore index 475abbec..20cc9f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ gnome-doc-utils.m4 /mkinstalldirs /omf.make /viking.spec +/mingw-viking.spec /xmldocs.make /test-driver /compile diff --git a/Makefile.am b/Makefile.am index 6882a891..4d374e25 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,7 @@ EXTRA_DIST = \ gnome-doc-utils.make \ ChangeLog.0 \ viking.spec \ + mingw-viking.spec \ $(INTLTOOL) .PHONY: generate-changelog diff --git a/configure.ac b/configure.ac index b266b943..3f51d850 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,10 @@ AC_PREREQ(2.64) AC_INIT(viking, 1.6.1, , viking, http://viking.sf.net/) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + AM_INIT_AUTOMAKE([dist-bzip2 dist-zip subdir-objects]) dnl AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([src/config.h]) @@ -21,6 +25,15 @@ AC_PROG_MAKE_SET AC_PROG_RANLIB AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums) +ac_mingw32=no +case $target_os in + *mingw32*) + ac_mingw32=yes + ;; + *) + ;; +esac + # I18N GETTEXT_PACKAGE=viking AC_SUBST(GETTEXT_PACKAGE) @@ -298,7 +311,16 @@ AC_CACHE_CHECK([whether to enable bzip2 Support], case $ac_cv_enable_bzip2 in yes) AC_CHECK_HEADERS([bzlib.h],[],[AC_MSG_ERROR([bzlib.h is needed but not found - you will need to install package 'libbz2-dev' or similar. The feature can be disabled with --disable-bzip2])]) - AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffDecompress, [], [AC_MSG_ERROR([libbz2 is needed but not found.])]) + if test "$ac_mingw32" = "yes"; then + # Using the cross compiler it bizarrely fails to detect BZ2_bzRead during the configure stage + # I SWEAR THIS WORKED AT SOME POINT - BUT ON A DIFFERENT DAY IT DOESN'T = MORE SWEARING + BZ2FUNC=main + AC_CHECK_LIB(bz2, [$BZ2FUNC], [], [LIBS="-lbz2 $LIBS" + AC_MSG_WARN([libbz2 not found! Forcing it anyway!])]) + else + BZ2FUNC=BZ2_bzRead + AC_CHECK_LIB(bz2, [$BZ2FUNC], [], [AC_MSG_ERROR([libbz2 is needed but not found.])]) + fi ;; esac AM_CONDITIONAL([BZIP2], [test x$ac_cv_enable_bzip2 = xyes]) @@ -441,6 +463,7 @@ AC_DEFINE_UNQUOTED(THEYEAR, "`date +%Y`", [The Year]) # Configuration AC_CONFIG_FILES([ viking.spec + mingw-viking.spec Makefile src/Makefile src/icons/Makefile diff --git a/mingw-viking.spec.in b/mingw-viking.spec.in new file mode 100644 index 00000000..b2d89aa8 --- /dev/null +++ b/mingw-viking.spec.in @@ -0,0 +1,115 @@ +# Public Domain CC0 +%{?mingw_package_header} +%define _pkg_name viking +Name: mingw32-%{_pkg_name} +Version: @VERSION@ +Release: 1 +Summary: GPS data editor and analyzer +Group: Applications/Productivity +License: GPLv2 +URL: http://sourceforge.net/projects/viking/ +Source0: %{_pkg_name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildArch: noarch + +# Only 32bit ATM + +# Programs to enable the cross build +BuildRequires: mingw32-filesystem +BuildRequires: mingw32-binutils +BuildRequires: mingw32-runtime +BuildRequires: mingw32-cross-binutils +BuildRequires: mingw32-cross-gcc +BuildRequires: mingw32-cross-pkg-config +BuildRequires: mingw32-gettext-tools +BuildRequires: mingw32-gnome-doc-utils-devel +BuildRequires: intltool +BuildRequires: gdk-pixbuf-devel +# ^For gdk-pixbuf-csource + +# Code +# Not worried about versions ATM +BuildRequires: mingw32-gtk2-devel +# ATM gtk2-devel auto includes at least devel versions of glib2, gobject, zlib and more + +# Mandatory libraries +BuildRequires: mingw32-libexpat-devel +BuildRequires: mingw32-libcurl-devel +# Optional libraries +BuildRequires: mingw32-libexif-devel +BuildRequires: mingw32-libbz2-devel +BuildRequires: mingw32-file-devel +BuildRequires: mingw32-libmagic1 +BuildRequires: mingw32-libbz2-1 +BuildRequires: mingw32-sqlite-devel +BuildRequires: mingw32-libzip-devel + +# Libs for runtime (and thus also available for the NSIS installer to include the dependencies) +Requires: mingw32-gtk2 +Requires: mingw32-libexpat1 +Requires: mingw32-libcurl4 +Requires: mingw32-libexif12 +Requires: mingw32-libsqlite3-0 +Requires: mingw32-libzip4 +# Currently running makensis in seperate script - so you will need it then +#Requires: mingw32-cross-nsis + + +%description +Viking is a free/open source program to manage GPS data. +You can import, plot and create tracks, routes and waypoints, show OSM and other maps, see real-time GPS position, control items, etc. +Other advanced capabilities include Geotagging Images, generate Maps (using Mapnik), Upload and Download tracks from OSM, Routing from OSRM or Google, Name Searches from OSM Nominatim or Google and more. +It is written in mainly in C with some C++ and uses the GTK+2 toolkit. + +# +# TODO 64bit version - possibly like this... +# +#%package -n mingw64-%{_pkg_name} +#Summary: %{summary} +# +#%description -n mingw64-%{_pkg_name} +#%{description} +%prep +%setup -q -n %{_pkg_name}-%{version} + +%build +# Create Icon +pushd win32/installer/pixmaps +%{_mingw32_windres} viking_icon.rc -o viking_icon.o +popd + +# +# Specifics for Windows build - i.e. no Mapnik, no gexiv2 & no GPSD +%{_mingw32_configure}\ + --with-libexif \ + --disable-realtime-gps-tracking \ + --disable-mapnik \ + --disable-scrollkeeper \ + --enable-windows \ + CFLAGS="-DWINDOWS -DWIN32 -mwindows" + +%{_mingw32_make} %{?_smp_mflags} + +%install +pushd src +%{_mingw32_strip} -g %{_pkg_name}.exe +popd + +%make_install + +%find_lang %{_pkg_name} + +%clean +#rm -rf %{buildroot} + +%files -f %{_pkg_name}.lang +%defattr(-,root,root) +%doc AUTHORS ChangeLog COPYING NEWS README doc/ +%{_mingw32_bindir}/*%{_pkg_name}.exe +%{_mingw32_datadir}/applications/%{_pkg_name}.desktop +%{_mingw32_datadir}/%{_pkg_name} +%{_mingw32_datadir}/icons/hicolor/*/apps/%{_pkg_name}.* +%exclude %{_mingw32_datadir}/icons/hicolor/icon-theme.cache +#%{_mingw32_mandir}/man1/* + +%changelog diff --git a/win32/.gitignore b/win32/.gitignore index 06cf6539..7c078434 100644 --- a/win32/.gitignore +++ b/win32/.gitignore @@ -1 +1,2 @@ cache +installer/bin diff --git a/win32/Makefile.am b/win32/Makefile.am index c1cbece9..fc0c5b4e 100644 --- a/win32/Makefile.am +++ b/win32/Makefile.am @@ -1,5 +1,6 @@ # License: CC0 EXTRA_DIST = \ + installer-mingw.sh \ prepare.bat \ configure_and_make.bat \ make.bat \ diff --git a/win32/README.txt b/win32/README.txt index 2fac07fd..4c2ffb6e 100644 --- a/win32/README.txt +++ b/win32/README.txt @@ -1,5 +1,80 @@ # License: CC0 -# + +# Cross Build # + +## Using OpenSUSE Tumbleweed in a VM ## + +### Host Preparation ### + +On the host need to ensure the viking-1.X.tar.gz file is available: + cd code/viking + make dist + +Generate help PDF + dblatex help/C/viking.xml +This could be done in the VM but installing dblatex requires ~650Mb install (so a waste if already available on the host). + +### Guest Preparation (root) ### + +In the guest ensure availability of build dependent mingw32 packages (not in standard Tumbleweed repo ATM) + # As root + zypper ar -f http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Tumbleweed windows + zypper ar -f http://download.opensuse.org/repositories/home:/ecsos/openSUSE_Tumbleweed windows-extra-ecsos + zypper ar -f http://download.opensuse.org/repositories/home:/ecsos:/pipelight/openSUSE_Tumbleweed windows-extra-ecsos + # Ensure a standard user account is available for the build e.g: + #useradd -m build + #passwd build + +Install build packages as listed in the .spec file or when running the rpmbuild it will tell you what packages are required + zypper install mingw32-cross-gcc + #etc... + +For the MSI generation you will need + zypper install mingw32-cross-nsis + +And ensure FindProcDLL is available for NSIS +if [ ! -e /usr/share/nsis/Plugins/FindProcDLL.dll ]; + wget http://nsis.sourceforge.net/mediawiki/images/3/3c/FindProc.zip + unzip FindProc.zip FindProcDLL.dll -d /usr/share/nsis/Plugins/ +fi + +Make code accessible via a shared folder +So add a suitable Shared Folder to the virtual machine +Remember the build user will need mount access priviledges - if using VirtualBox then: + #As root + #usermod -a -G vboxsf + +### Guest Preparation (builduser) ### + +Go to the code location + cd /media/sf_Code/viking + +Copy source package as generated by make dist on the host to the package build area, or even just link to it e.g.: + ln -s /media/sf_Code/viking/viking-1.6.1.tar.gz /home/build/rpmbuild/SOURCES/viking-1.6.1.tar.gz + +### Build / Install / Run on Guest ### + +Now perform the build + rpmbuild -ba mingw-viking.spec + +Install locally + rpm -i /home/build/rpmbuild/RPMS/noarch/viking-*.noarch.rpm + +Generate .msi + cd win32 + ./installer-mingw.sh + +Install .msi + wine install/viking-*.exe + +Run viking.exe with wine + cd ~/.wine/drive_c/Program\ Files/Viking/ + wine viking.exe + +######################################################################### + +# Native Build # + The build under Windows follows the same process as the traditional Linux build: cd ../src @@ -32,4 +107,7 @@ This setup is for dedicated usage to build Viking, primarily under Wine with: Such that any Windows system (or of course a Virtual Machine) can be simply deleted (e.g. rm -rf /.wine) and recreated fully via the scripts. -From Viking 1.4 onwards this is how the Windows viking-W.X.Y.Z.exe installer file is produced. +From Viking 1.4 to 1.6.X this was how the Windows viking-W.X.Y.Z.exe installer file was produced. + +Notionally the standard configure + make stages should still work, but the Cross build is now the supported method. +Thus the prepare + installer scripts are no longer maintained and are for reference only. diff --git a/win32/installer-mingw.sh b/win32/installer-mingw.sh new file mode 100755 index 00000000..996d79f2 --- /dev/null +++ b/win32/installer-mingw.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# License: CC0 +# +# A version of the installer.bat for mingw build +# Similarily basily copy all dependent files from the host system +# to be available for the NSIS stage +# +# Remember to have installed the generated mingw-viking package first so the +# binaries are available from the default location +# (e.g. as root rpm -i mingw32-viking-1.7-1.noarch.rpm) +# +# 'MINGW' and 'DESTINATION' values can be defined to override inbuilt defaults +# + +if [ -z "$DESTINATION" ]; then + DESTINATION=installer/bin +fi +mkdir -p $DESTINATION + +if [ -z "$MINGW" ]; then + MINGW=/usr/i686-w64-mingw32/sys-root/mingw +fi +MINGW_BIN=$MINGW/bin +echo MINGW=$MINGW + +echo Make language copies +for x in $(ls ../po/*.gmo); do + mkdir -p $DESTINATION/locale/$(basename -s .gmo $x)/LC_MESSAGES + cp $MINGW/share/locale/$(basename -s .gmo $x)/LC_MESSAGES/viking.mo $DESTINATION/locale/$(basename -s .gmo $x)/LC_MESSAGES/ +done + +echo Copying Viking +cp $MINGW_BIN/*viking.exe $DESTINATION/viking.exe +cp ../COPYING $DESTINATION/COPYING_GPL.txt +cp ../AUTHORS $DESTINATION/AUTHORS.txt +cp ../NEWS $DESTINATION/NEWS.txt +cp ../README $DESTINATION/README.txt +# PDF generation if required +if [ ! -e ../help/C/viking.pdf ]; then + pushd ../help/C + dblatex viking.xml + if [ $? != 0 ]; then + echo "Help PDF generation failed." + exit + fi +fi +cp ../help/C/viking.pdf $DESTINATION +cp ../tools/viking-cache.py $DESTINATION +cp installer/translations/*nsh $DESTINATION +cp installer/pixmaps/viking_icon.ico $DESTINATION + +echo Copying Extension Configuration Data +mkdir $DESTINATION/data +cp ../data/*.xml $DESTINATION/data +cp ../data/latlontz.txt $DESTINATION/data + +echo Copying Helper Apps +# Needed when spawning other programs (e.g. when invoking GPSBabel) +cp $MINGW_BIN/gspawn-win32-helper.exe $DESTINATION + +echo Copying Libraries +# Core libs +cp $MINGW_BIN/libatk*.dll $DESTINATION +cp $MINGW_BIN/libcairo*.dll $DESTINATION +cp $MINGW_BIN/libgcc*.dll $DESTINATION +cp $MINGW_BIN/libgcrypt*.dll $DESTINATION +cp $MINGW_BIN/libgdk*.dll $DESTINATION +cp $MINGW_BIN/libgettext*.dll $DESTINATION +cp $MINGW_BIN/libgio*.dll $DESTINATION +cp $MINGW_BIN/libglib*.dll $DESTINATION +cp $MINGW_BIN/libgmodule*.dll $DESTINATION +cp $MINGW_BIN/libgnurx*.dll $DESTINATION +cp $MINGW_BIN/libgobject*.dll $DESTINATION +cp $MINGW_BIN/libgpg*.dll $DESTINATION +cp $MINGW_BIN/libgtk*.dll $DESTINATION +cp $MINGW_BIN/libintl*.dll $DESTINATION +cp $MINGW_BIN/libffi*.dll $DESTINATION +cp $MINGW_BIN/libfontconfig*.dll $DESTINATION +cp $MINGW_BIN/libfreetype*.dll $DESTINATION +cp $MINGW_BIN/libharfbuzz*.dll $DESTINATION +cp $MINGW_BIN/libjasper*.dll $DESTINATION +cp $MINGW_BIN/libjpeg*.dll $DESTINATION +cp $MINGW_BIN/liblzma*.dll $DESTINATION +cp $MINGW_BIN/libpng*.dll $DESTINATION +cp $MINGW_BIN/libpango*.dll $DESTINATION +cp $MINGW_BIN/libpixman*.dll $DESTINATION +cp $MINGW_BIN/libtiff*.dll $DESTINATION +cp $MINGW_BIN/libxml2*.dll $DESTINATION +cp $MINGW_BIN/zlib1.dll $DESTINATION +cp $MINGW_BIN/libzip*.dll $DESTINATION + +# Extras +cp $MINGW_BIN/libexpat*.dll $DESTINATION +# Curl 7.17+ has quite a few dependencies for SSL support +cp $MINGW_BIN/libcurl*.dll $DESTINATION +cp $MINGW_BIN/libssh*.dll $DESTINATION +cp $MINGW_BIN/libidn*.dll $DESTINATION +cp $MINGW_BIN/libnspr*.dll $DESTINATION +cp $MINGW_BIN/libplc*.dll $DESTINATION +cp $MINGW_BIN/libplds*.dll $DESTINATION +cp $MINGW_BIN/nss*.dll $DESTINATION +cp $MINGW_BIN/ssl*.dll $DESTINATION +cp /usr/share/doc/packages/mingw32-libcurl-devel/COPYING $DESTINATION/COPYING_curl.txt + +cp $MINGW_BIN/libexif*.dll $DESTINATION +cp $MINGW_BIN/libbz*.dll $DESTINATION +cp $MINGW_BIN/libmagic*.dll $DESTINATION +cp $MINGW/share/misc/magic* $DESTINATION +cp $MINGW_BIN/libsqlite3*.dll $DESTINATION + +echo Copying GPSBabel Installer +mkdir $DESTINATION/Optional +# ATM GPSBabel needs to be in 'cache' dir +cp cache/GPSBabel-1.5.2-Setup.exe $DESTINATION/Optional + +pushd installer +if [ -z "$DEBUG" ]; then + makensis -X"SetCompressor lzma" viking-installer.nsi +else + # Speedier install generation when testing + makensis -X"SetCompress off" viking-installer.nsi +fi +popd diff --git a/win32/installer.bat b/win32/installer.bat index 699019ad..9df95e03 100644 --- a/win32/installer.bat +++ b/win32/installer.bat @@ -140,7 +140,7 @@ if ERRORLEVEL 1 goto Error echo Running NSIS (command line version) pushd installer if exist "%ProgramFiles%\NSIS" ( - "%ProgramFiles%\NSIS\makensis.exe" viking-installer.nsi + "%ProgramFiles%\NSIS\makensis.exe" /X"SetCompressor /SOLID lzma" viking-installer.nsi ) else ( echo NSIS Not installed in known location ) diff --git a/win32/installer/Makefile.am b/win32/installer/Makefile.am index 03cc1ce4..60f99163 100644 --- a/win32/installer/Makefile.am +++ b/win32/installer/Makefile.am @@ -1,5 +1,6 @@ EXTRA_DIST = \ + FileAssociation.nsh \ viking-installer.nsi \ langmacros.nsh diff --git a/win32/installer/viking-installer.nsi b/win32/installer/viking-installer.nsi index c31f05ca..98ebf789 100644 --- a/win32/installer/viking-installer.nsi +++ b/win32/installer/viking-installer.nsi @@ -15,9 +15,16 @@ Var name ;The name var is set in .onInit Name $name +;Allow overiding location of binary components for the install +!ifndef BINARIES + !define BINARIES ".\bin" +!endif + OutFile "viking-${VIKING_VERSION}.exe" -SetCompressor /SOLID lzma +;NB Using /SOLID method on a mingw32 setup seems to generate an exe that fails the CRC check +;So now don't set the compressor here - it can be set by the calling command/script if necessary. +;SetCompressor /SOLID bzip2 ShowInstDetails show ShowUninstDetails show SetDateSave on @@ -90,7 +97,7 @@ VIAddVersionKey "FileDescription" "Viking Installer" ;Pages !insertmacro MUI_PAGE_WELCOME - !insertmacro MUI_PAGE_LICENSE ".\bin\COPYING_GPL.txt" + !insertmacro MUI_PAGE_LICENSE "${BINARIES}\COPYING_GPL.txt" !insertmacro MUI_PAGE_COMPONENTS ; Viking install dir page @@ -139,7 +146,7 @@ VIAddVersionKey "FileDescription" "Viking Installer" ;; Start Install Sections ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -LicenseData ".\bin\COPYING_GPL.txt" +LicenseData "${BINARIES}\COPYING_GPL.txt" LicenseForceSelection checkbox ;-------------------------------- @@ -250,18 +257,13 @@ Section $(VIKING_SECTION_TITLE) SecViking ; Copy only specific items as now some components (e.g. GPSBabel) are optional. ; This is mostly to get a more accurate install size value (especially as saved into the registry) - File .\bin\viking* - ; Not sure we really need any of the gtk executables but copy them anyway: - File .\bin\*.exe - File .\bin\*.dll - File .\bin\*.txt - File .\bin\magic.mgc - File /r .\bin\data - File /r .\bin\etc - File /r .\bin\gtk2-runtime - File /r .\bin\lib - File /r .\bin\locale - File /r .\bin\share + File ${BINARIES}\viking* + File ${BINARIES}\g*.exe + File ${BINARIES}\*.dll + File ${BINARIES}\*.txt + File ${BINARIES}\magic.mgc + File /r ${BINARIES}\data + File /r ${BINARIES}\locale ; Estimate install size based on files in $INSTDIR ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 @@ -314,7 +316,7 @@ SectionEnd ; GPSBabel Install Section ; Section $(VIKING_GPSBABEL_SECTION_TITLE) SecGPSBabel - File "bin\Optional\GPSBabel-1.5.2-Setup.exe" + File "${BINARIES}\Optional\GPSBabel-1.5.2-Setup.exe" ExecWait '"$INSTDIR\GPSBabel-1.5.2-Setup.exe" /SILENT' Delete "$INSTDIR\GPSBabel-1.5.2-Setup.exe" SectionEnd @@ -369,11 +371,7 @@ Section Uninstall Delete "$INSTDIR\data\*txt" Delete "$INSTDIR\data\*xml" RMDir "$INSTDIR\data" - RMDir /r "$INSTDIR\etc" - RMDir /r "$INSTDIR\gtk2-runtime" - RMDir /r "$INSTDIR\lib" RMDir /r "$INSTDIR\locale" - RMDir /r "$INSTDIR\share" RMDir "$INSTDIR" ; Shortcuts.. @@ -470,8 +468,8 @@ Function ${UN}RunCheck FunctionEnd !macroend -!insertmacro RunCheckMacro "" -!insertmacro RunCheckMacro "un." +;!insertmacro RunCheckMacro "" +;!insertmacro RunCheckMacro "un." ;Installer extra configuration at execution time: language, path, ... Function .onInit @@ -481,7 +479,7 @@ Function .onInit Push $R2 ;Check if viking is running - Call RunCheck + ;Call RunCheck StrCpy $name "Viking ${VIKING_VERSION}" ClearErrors @@ -565,7 +563,7 @@ FunctionEnd Function un.onInit ;Check if viking is running - Call un.RunCheck + ;Call un.RunCheck StrCpy $name "Viking ${VIKING_VERSION}" ; Get stored language preference