From 67e49d6480126968a1d87a12ae6e967b861e8909 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Sun, 6 Oct 2013 17:52:34 -0700
Subject: [PATCH 01/13] Implement a qmake-based build for Subsurface

This is working for me, but requires a bit more testing. To build,
run:
  qmake [options]

Where options might be:
  V=1               disable "silent" build
  LIBDCDEVEL=1      use side-by-side libdivecomputer
  INCLUDEPATH+=xxx  add -Ixxx (e.g., INCLUDEPATH+=/usr/local/marble/include)
  LIBS+=xxx         add xxx to the linker flags (e.g. LIBS+=-L/usr/local/marble/lib)
  or any other qmake option, including debug and release options

If your distribution is already using qtchooser in place of qmake, you
may need to pass an extra option to qmake to select the a
cross-build. For example:

  qmake -qt=i686-w64-mingw32-qt4

If your distribution is not yet using qtchooser, then you need to file
a bug report requesting it and you need to run the full path to qmake.

Note:
 - there are some ### left in the buildsystem

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 .gitignore                 |   6 ++
 Documentation/Makefile     |  10 +--
 subsurface-configure.pri   |  95 +++++++++++++++++++++++++++
 subsurface-gen-version.pri |  16 +++++
 subsurface.pro             | 129 +++++++++++++++++++++++++++++++++++++
 5 files changed, 251 insertions(+), 5 deletions(-)
 create mode 100644 subsurface-configure.pri
 create mode 100644 subsurface-gen-version.pri
 create mode 100644 subsurface.pro

diff --git a/.gitignore b/.gitignore
index 520248b58..5c1eae4b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,9 @@ ui_*
 /subsurface.includes
 *.kdev4
 callgrind.out.*
+
+.rcc
+.moc
+.uic
+.obj
+subsurface.pro.user*
diff --git a/Documentation/Makefile b/Documentation/Makefile
index c56b3efcb..67d2a0c73 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -7,20 +7,20 @@ BROWSER = firefox
 
 all: doc $(addprefix $(DOCNAME).,pdf text)
 
-doc: $(HTMLDOC)
+doc: $(OUT)$(HTMLDOC)
 
-$(DOCNAME).text: $(DOCSOURCE)
+$(OUT)$(DOCNAME).text: $(DOCSOURCE)
 	$(A2X) -f text $<
 
-$(DOCNAME).pdf: $(DOCSOURCE)
+$(OUT)$(DOCNAME).pdf: $(DOCSOURCE)
 	$(A2X) -f pdf $<
 
-$(HTMLDOC): $(DOCSOURCE)
+$(OUT)$(HTMLDOC): $(DOCSOURCE)
 	@echo "if asciidoc isn't found no HTML documentation is produced but Subsurface is still functional"
 	$(ASCIIDOC) $< || true
 
 # Alternatively::
-$(DOCNAME).xhtml: $(DOCSOURCE)
+$(OUT)$(DOCNAME).xhtml: $(DOCSOURCE)
 	$(A2X) --icons -f xhtml $<
 
 show: $(HTMLDOC)
diff --git a/subsurface-configure.pri b/subsurface-configure.pri
new file mode 100644
index 000000000..93f14003c
--- /dev/null
+++ b/subsurface-configure.pri
@@ -0,0 +1,95 @@
+#
+# Global settings
+#
+# Set some C constructs to be diagnosed as errors:
+#  - calling implicit functions
+#  - casting from integers to pointers or vice-versa without an explicit cast
+# Also turn on C99 mode with GNU extensions
+*-g++*: QMAKE_CFLAGS += -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=implicit-int
+!win32-msvc*: QMAKE_CFLAGS += -std=gnu99
+
+# Check if we have pkg-config
+equals($$QMAKE_HOST.os, "Windows"):NUL=NUL
+else:NUL=/dev/null
+system(pkg-config --version 2>$$NUL >$$NUL) {
+    CONFIG += link_pkgconfig
+} else {
+    message("pkg-config not found, no detection performed. See README for details")
+}
+
+#
+# Find libdivecomputer
+#
+!isEmpty(LIBDCDEVEL) {
+    # find it next to our sources
+    INCLUDEPATH += ../libdivecomputer/include
+    LIBS += -L../libdivecomputer/src/.libs -ldivecomputer
+} else:exists(/usr/local/lib/libdivecomputer.a) {
+    LIBS += -L/usr/local/lib -ldivecomputer
+} else:exists(/usr/local/lib64/libdivecomputer.a) {
+    LIBS += -L/usr/local/lib64 -ldivecomputer
+} else:link_pkgconfig {
+    # find it via pkg-config
+    PKGCONFIG += libdivecomputer
+}
+
+# Libusb-1.0 is only required if libdivecomputer was built with it.
+# And libdivecomputer is only built with it if libusb-1.0 is
+# installed. So get libusb if it exists, but don't complain
+# about it if it doesn't.
+#link_pkgconfig: packagesExist(libusb-1.0): PKGCONFIG += libusb-1.0
+
+#
+# Find libxml2 and libxslt
+#
+# They come with shell scripts that contain the information we need, so we just
+# run them. They also come with pkg-config files, but those are missing on
+# Mac (where they are part of the XCode-supplied tools).
+#
+XML2_CFLAGS = $$system(xml2-config --cflags 2>$$NUL)
+XSLT_CFLAGS = $$system(xslt-config --cflags 2>$$NUL)
+XML2_LIBS = $$system(xml2-config --libs 2>$$NUL)
+XSLT_LIBS = $$system(xslt-config --libs 2>$$NUL)
+link_pkgconfig {
+    isEmpty(XML2_CFLAGS)|isEmpty(XML2_LIBS): \
+        error("Could not find libxml2. Did you forget to install it?")
+    isEmpty(XSLT_CFLAGS)|isEmpty(XSLT_LIBS): \
+        error("Could not find libxslt. Did you forget to install it?")
+}
+
+QMAKE_CFLAGS *= $$XML2_CFLAGS $$XSLT_CFLAGS
+QMAKE_CXXFLAGS *= $$XML2_CFLAGS $$XSLT_CFLAGS
+LIBS *= $$XML2_LIBS $$XSLT_LIBS
+
+#
+# Find other pkg-config-based projects
+# We're searching for:
+#  libzip
+#  sqlite3
+link_pkgconfig: PKGCONFIG += libzip sqlite3
+
+#
+# Find libmarble
+#
+# Before Marble 4.9, the GeoDataTreeModel.h header wasn't installed
+# Check if it's present by trying to compile
+# ### FIXME: implement that
+win32: CONFIG(debug, debug|release): LIBS += -lmarblewidgetd
+else: LIBS += -lmarblewidget
+
+#
+# Platform-specific changes
+#
+win32 {
+    LIBS += -lwsock32
+    DEFINES -= UNICODE
+}
+
+#
+# misc
+#
+!equals(V, 1): CONFIG += silent
+MOC_DIR = .moc
+UI_DIR = .uic
+RCC_DIR = .rcc
+OBJECTS_DIR = .obj
diff --git a/subsurface-gen-version.pri b/subsurface-gen-version.pri
new file mode 100644
index 000000000..a94a65adb
--- /dev/null
+++ b/subsurface-gen-version.pri
@@ -0,0 +1,16 @@
+# Generate the version.h file
+VERSION_FILE = version.h
+exists(.git/HEAD): {
+    GIT_HEAD = .git/HEAD
+    VERSION_SCRIPT = $$PWD/scripts/get-version
+    version_h.depends = $$VERSION_SCRIPT
+    version_h.commands = echo \\$${LITERAL_HASH}define VERSION_STRING \\\"`$$VERSION_SCRIPT linux`\\\" > ${QMAKE_FILE_OUT}
+    version_h.input = GIT_HEAD
+    version_h.output = $$VERSION_FILE
+    version_h.variable_out = GENERATED_FILES
+    version_h.CONFIG = ignore_no_exist
+    QMAKE_EXTRA_COMPILERS += version_h
+} else {
+    # This is probably a package
+    system(echo \\$${LITERAL_HASH}define VERSION_STRING \\\"$$VERSION\\\" > $$VERSION_FILE)
+}
diff --git a/subsurface.pro b/subsurface.pro
new file mode 100644
index 000000000..8a4996385
--- /dev/null
+++ b/subsurface.pro
@@ -0,0 +1,129 @@
+include(subsurface-configure.pri)
+
+QT = core gui network webkit svg
+INCLUDEPATH += qt-ui $$PWD
+
+VERSION = 3.1
+
+HEADERS = \
+	color.h \
+	deco.h \
+	device.h \
+	display.h \
+	dive.h \
+	divelist.h \
+	file.h \
+	flag.h \
+	gettextfromc.h \
+	gettext.h \
+	helpers.h \
+	libdivecomputer.h \
+	planner.h \
+	pref.h \
+	profile.h \
+	qt-gui.h \
+	qthelper.h \
+	qt-ui/about.h \
+	qt-ui/completionmodels.h \
+	qt-ui/divecomputermanagementdialog.h \
+	qt-ui/divelistview.h \
+	qt-ui/diveplanner.h \
+	qt-ui/downloadfromdivecomputer.h \
+	qt-ui/globe.h \
+	qt-ui/graphicsview-common.h \
+	qt-ui/kmessagewidget.h \
+	qt-ui/maintab.h \
+	qt-ui/mainwindow.h \
+	qt-ui/modeldelegates.h \
+	qt-ui/models.h \
+	qt-ui/plotareascene.h \
+	qt-ui/preferences.h \
+	qt-ui/printdialog.h \
+	qt-ui/printlayout.h \
+	qt-ui/printoptions.h \
+	qt-ui/profilegraphics.h \
+	qt-ui/simplewidgets.h \
+	qt-ui/starwidget.h \
+	qt-ui/subsurfacewebservices.h \
+	qt-ui/tableview.h \
+	satellite.h \
+	sha1.h \
+	statistics.h \
+	subsurface-icon.h \
+	subsurfacestartup.h \
+	uemis.h \
+	webservice.h 
+
+SOURCES =  \
+	deco.c \
+	device.c \
+	dive.c \
+	divelist.c \
+	equipment.c \
+	file.c \
+	gettextfromc.cpp \
+	libdivecomputer.c \
+	main.cpp \
+	parse-xml.c \
+	planner.c \
+	profile.c \
+	qt-gui.cpp \
+	qthelper.cpp \
+	qt-ui/about.cpp \
+	qt-ui/completionmodels.cpp \
+	qt-ui/divecomputermanagementdialog.cpp \
+	qt-ui/divelistview.cpp \
+	qt-ui/diveplanner.cpp \
+	qt-ui/downloadfromdivecomputer.cpp \
+	qt-ui/globe.cpp \
+	qt-ui/graphicsview-common.cpp \
+	qt-ui/kmessagewidget.cpp \
+	qt-ui/maintab.cpp \
+	qt-ui/mainwindow.cpp \
+	qt-ui/modeldelegates.cpp \
+	qt-ui/models.cpp \
+	qt-ui/plotareascene.cpp \
+	qt-ui/preferences.cpp \
+	qt-ui/printdialog.cpp \
+	qt-ui/printlayout.cpp \
+	qt-ui/printoptions.cpp \
+	qt-ui/profilegraphics.cpp \
+	qt-ui/simplewidgets.cpp \
+	qt-ui/starwidget.cpp \
+	qt-ui/subsurfacewebservices.cpp \
+	qt-ui/tableview.cpp \
+	save-xml.c \
+	sha1.c \
+	statistics.c \
+	subsurfacestartup.c \
+	time.c \
+	uemis.c \
+	uemis-downloader.c
+
+linux*: SOURCES += linux.c
+mac: SOURCES += macos.c
+win32: SOURCES += windows.c
+
+FORMS = \
+	qt-ui/about.ui \
+	qt-ui/divecomputermanagementdialog.ui \
+	qt-ui/diveplanner.ui \
+	qt-ui/downloadfromdivecomputer.ui \
+	qt-ui/maintab.ui \
+	qt-ui/mainwindow.ui \
+	qt-ui/preferences.ui \
+	qt-ui/printoptions.ui \
+	qt-ui/renumber.ui \
+	qt-ui/subsurfacewebservices.ui \
+	qt-ui/tableview.ui
+
+RESOURCES = subsurface.qrc
+
+TRANSLATIONS = subsurface_de.ts 
+
+doc.commands = $(CHK_DIR_EXISTS) Documentation || $(MKDIR) Documentation
+doc.commands += $$escape_expand(\\n\\t)$(MAKE) -C $$PWD/Documentation OUT=$$OUT_PWD/Documentation doc
+all.depends += doc
+QMAKE_EXTRA_TARGETS += doc all
+
+include(subsurface-gen-version.pri)

From 1e7db5f77f01a0f091969c036b007165af35a509 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Sun, 6 Oct 2013 18:07:20 -0700
Subject: [PATCH 02/13] Remove the old buildsystem

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 .gitignore   |  15 +--
 Configure.mk | 183 --------------------------------
 Makefile     | 165 -----------------------------
 Rules.mk     | 289 ---------------------------------------------------
 4 files changed, 1 insertion(+), 651 deletions(-)
 delete mode 100644 Configure.mk
 delete mode 100644 Makefile
 delete mode 100644 Rules.mk

diff --git a/.gitignore b/.gitignore
index 5c1eae4b0..085323a37 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,19 +3,14 @@
 *.rej
 *.exe
 *.dmg
-*.moc
-*.moc.cpp
 *.patch
-*.ui.h
 *.xml
 version.h
 !dives/*.xml
 *~
 po/*.mo
-qt-ui/ui_*.h
 /subsurface
 /*.tar.gz
-.dep/
 share/
 Documentation/docbook-xsl.css
 Documentation/user-manual.html
@@ -23,19 +18,11 @@ Documentation/user-manual.pdf
 Documentation/user-manual.text
 packaging/windows/subsurface.nsi
 packaging/macos/Info.plist
-config.cache
-*.qrc.cpp
-ui_*
-/subsurface.config
-/subsurface.creator
-/subsurface.creator.user
-/subsurface.files
-/subsurface.includes
 *.kdev4
 callgrind.out.*
-
 .rcc
 .moc
 .uic
 .obj
+Makefile
 subsurface.pro.user*
diff --git a/Configure.mk b/Configure.mk
deleted file mode 100644
index 9e9a2ba0e..000000000
--- a/Configure.mk
+++ /dev/null
@@ -1,183 +0,0 @@
-# -*- Makefile -*-
-# This file contains the detection rules
-all:
-
-PKGCONFIG=pkg-config
-XML2CONFIG=xml2-config
-XSLCONFIG=xslt-config
-QMAKE=qmake
-MOC=moc
-UIC=uic
-TAR=tar
-
-CONFIGFILE = config.cache
-ifeq ($(CONFIGURING),1)
-
-# Detect the target system
-# Ask the compiler what OS it's producing files for
-UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win|gnu|kfreebsd")
-
-# find libdivecomputer
-# First deal with the cross compile environment and with Mac.
-# For the native case, Linus doesn't want to trust pkg-config given
-# how young libdivecomputer still is - so we check the typical
-# subdirectories of /usr/local and /usr and then we give up. You can
-# override by simply setting it here
-#
-ifeq ($(CC), i686-w64-mingw32-gcc)
-# ok, we are cross building for Windows
-	LIBDIVECOMPUTERINCLUDES = $(shell $(PKGCONFIG) --cflags libdivecomputer)
-	LIBDIVECOMPUTERARCHIVE = $(shell $(PKGCONFIG) --libs libdivecomputer)
-	RESFILE = packaging/windows/subsurface.res
-	LDFLAGS += -Wl,-subsystem,windows
-	LIBWINSOCK = -lwsock32
-else ifeq ($(UNAME), darwin)
-	LIBDIVECOMPUTERINCLUDES = $(shell $(PKGCONFIG) --cflags libdivecomputer)
-	LIBDIVECOMPUTERARCHIVE = $(shell $(PKGCONFIG) --libs libdivecomputer)
-else ifneq ($(LIBDCDEVEL),)
-	LIBDIVECOMPUTERDIR = ../libdivecomputer
-	LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include
-	LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/src/.libs/libdivecomputer.a
-else ifeq ($(shell $(PKGCONFIG) --exists libdivecomputer; echo $$?),0)
-	LIBDIVECOMPUTERINCLUDES = $(shell $(PKGCONFIG) --cflags libdivecomputer)
-	LIBDIVECOMPUTERARCHIVE = $(shell $(PKGCONFIG) --libs libdivecomputer)
-else
-libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
-libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
-libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
-libdc-usr64 := $(wildcard /usr/lib64/libdivecomputer.a)
-
-ifneq ($(strip $(libdc-local)),)
-	LIBDIVECOMPUTERDIR = /usr/local
-	LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include
-	LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
-else ifneq ($(strip $(libdc-local64)),)
-	LIBDIVECOMPUTERDIR = /usr/local
-	LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include
-	LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
-else ifneq ($(strip $(libdc-usr)),)
-	LIBDIVECOMPUTERDIR = /usr
-	LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include
-	LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
-else ifneq ($(strip $(libdc-usr64)),)
-	LIBDIVECOMPUTERDIR = /usr
-	LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include
-	LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
-else
-$(error Cannot find libdivecomputer - please edit Makefile)
-endif
-endif
-
-# Libusb-1.0 is only required if libdivecomputer was built with it.
-# And libdivecomputer is only built with it if libusb-1.0 is
-# installed. So get libusb if it exists, but don't complain
-# about it if it doesn't.
-LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
-
-# Find qmake. Rules are:
-#  - use qmake if it is in $PATH
-#    [qmake -query QT_VERSION  will fail if it's Qt 3's qmake]
-#  - if that fails, try qmake-qt4
-#  - if that fails, print an error
-# We specifically do not search for qmake-qt5 since that is not supposed
-# to exist.
-QMAKE = $(shell { qmake -query QT_VERSION >/dev/null 2>&1 && echo qmake; } || \
-		{ qmake-qt4 -v >/dev/null 2>&1 && echo qmake-qt4; })
-ifeq ($(strip $(QMAKE)),)
-$(error Could not find qmake or qmake-qt4 in $$PATH or they failed)
-endif
-
-# Use qmake to find out which Qt version we are building for.
-QT_VERSION_MAJOR = $(shell $(QMAKE) -query QT_VERSION | cut -d. -f1)
-ifeq ($(QT_VERSION_MAJOR), 5)
-#	QT_MODULES = Qt5Widgets Qt5Svg
-#	QT_CORE = Qt5Core
-#	QTBINDIR = $(shell $(QMAKE) -query QT_HOST_BINS)
-#	# Tool paths are not stored in .pc files in Qt 5.0
-#	MOC = $(QTBINDIR)/moc
-#	UIC = $(QTBINDIR)/uic
-#	RCC = $(QTBINDIR)/rcc
-# if qmake is qt5, try to get the qt4 one.
-	QMAKE = { qmake-qt4 -v >/dev/null 2>&1 && echo qmake-qt4; }
-#else
-endif
-
-ifeq ($(strip $(QMAKE)),)
-$(error Could not find qmake or qmake-qt4 in $$PATH for the Qt4 version they failed)
-endif
-
-	QT_MODULES = QtGui QtSvg QtNetwork QtWebKit
-	QT_CORE = QtCore
-	MOC = $(shell $(PKGCONFIG) --variable=moc_location QtCore)
-	UIC = $(shell $(PKGCONFIG) --variable=uic_location QtGui)
-	RCC = $(shell $(PKGCONFIG) --variable=rcc_location QtGui)
-#endif
-
-QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES))
-LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES))
-ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), )
-	QTCXXFLAGS += -fPIE
-endif
-
-ifeq ($(UNAME), darwin)
-	LDFLAGS += -framework CoreFoundation -framework CoreServices
-endif
-
-LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
-LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
-
-LIBXML2 = $(shell $(XML2CONFIG) --libs)
-LIBXSLT = $(shell $(XSLCONFIG) --libs)
-XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
-XSLCFLAGS = $(shell $(XSLCONFIG) --cflags)
-
-LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null)
-ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null))
-
-LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null)
-SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3))
-
-# Before Marble 4.9, the GeoDataTreeModel.h header wasn't installed
-# Check if it's present by trying to compile
-MARBLEFLAGS = $(shell $(CXX) $(QTCXXFLAGS) -E -include marble/GeoDataTreeModel.h -xc++ /dev/null > /dev/null 2>&1 || echo " -DINCOMPLETE_MARBLE")
-MARBLELIBS = -lmarblewidget
-
-# Write the configure file
-all: configure
-configure $(CONFIGURE): Configure.mk
-	@echo "\
-	CONFIGURED = 1\\\
-	UNAME = $(UNAME)\\\
-	LIBDIVECOMPUTERDIR = $(LIBDIVECOMPUTERDIR)\\\
-	LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERCFLAGS)\\\
-	LIBDIVECOMPUTER = $(LIBDIVECOMPUTER)\\\
-	LIBWINSOCK = $(LIBWINSOCK)\\\
-	LDFLAGS = $(LDFLAGS)\\\
-	RESFILE = $(RESFILE)\\\
-	LIBQT = $(LIBQT)\\\
-	QTCXXFLAGS = $(QTCXXFLAGS)\\\
-	MOC = $(MOC)\\\
-	UIC = $(UIC)\\\
-	RCC = $(RCC)\\\
-	LIBXML2 = $(LIBXML2)\\\
-	LIBXSLT = $(LIBXSLT)\\\
-	XML2CFLAGS = $(XML2CFLAGS)\\\
-	XSLCFLAGS = $(XSLCFLAGS)\\\
-	LIBZIP = $(LIBZIP)\\\
-	ZIPFLAGS = $(ZIPFLAGS)\\\
-	LIBSQLITE3 = $(LIBSQLITE3)\\\
-	SQLITE3FLAGS = $(SQLITE3FLAGS)\\\
-	MARBLEFLAGS = $(MARBLEFLAGS)\\\
-	MARBLELIBS = $(MARBLELIBS)\\\
-	" | tr '\\' '\n' > $(CONFIGFILE)
-
-else
-configure $(CONFIGFILE): Configure.mk
-	@test -e $(CONFIGFILE) && echo Reconfiguring.. || echo Configuring...
-	@$(MAKE) CONFIGURING=1 configure
-	@echo Done
-
--include $(CONFIGFILE)
-endif
-
-.PHONY: configure all
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 657309918..000000000
--- a/Makefile
+++ /dev/null
@@ -1,165 +0,0 @@
-NAME = subsurface
-CAPITALIZED_NAME = Subsurface
-TARGET = $(NAME)
-
-include Configure.mk
-VERSION=3.1
-
-CC=gcc
-CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE
-CXX=g++
-CXXFLAGS=-Wall -g $(CLCXXFLAGS) $(MARBLEFLAGS)
-INSTALL=install
-
-# these locations seem to work for SuSE and Fedora
-# prefix = $(HOME)
-prefix = $(DESTDIR)/usr
-BINDIR = $(prefix)/bin
-DATADIR = $(prefix)/share
-DOCDIR = $(DATADIR)/doc/$(NAME)
-DESKTOPDIR = $(DATADIR)/applications
-ICONPATH = $(DATADIR)/icons/hicolor
-ICONDIR = $(ICONPATH)/scalable/apps
-MANDIR = $(DATADIR)/man/man1
-XSLTDIR = $(DATADIR)/$(NAME)/xslt
-MARBLEDIR = marbledata/maps/earth/googlesat
-
-ICONFILE = $(NAME)-icon.svg
-DESKTOPFILE = $(NAME).desktop
-MANFILES = $(NAME).1
-XSLTFILES = xslt/*.xslt xslt/*.xsl
-
-EXTRA_FLAGS =  $(QTCXXFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \
-	       $(LIBDIVECOMPUTERCFLAGS) \
-	       $(LIBSOUPCFLAGS) -I. -DQT_NO_STL
-
-HEADERS = \
-	qt-ui/divelistview.h \
-	qt-ui/maintab.h \
-	qt-ui/mainwindow.h \
-	qt-ui/models.h \
-	qt-ui/plotareascene.h \
-	qt-ui/starwidget.h \
-	qt-ui/modeldelegates.h \
-	qt-ui/profilegraphics.h \
-	qt-ui/globe.h \
-	qt-ui/kmessagewidget.h \
-	qt-ui/downloadfromdivecomputer.h \
-	qt-ui/preferences.h \
-	qt-ui/simplewidgets.h \
-	qt-ui/subsurfacewebservices.h \
-	qt-ui/divecomputermanagementdialog.h \
-	qt-ui/diveplanner.h \
-	qt-ui/about.h \
-	qt-ui/graphicsview-common.h \
-	qt-ui/printdialog.h \
-	qt-ui/printoptions.h \
-	qt-ui/printlayout.h \
-	qt-ui/completionmodels.h \
-	qt-ui/tableview.h
-
-
-SOURCES = \
-	deco.c \
-	device.c \
-	dive.c \
-	divelist.c \
-	equipment.c \
-	file.c \
-	parse-xml.c \
-	planner.c \
-	subsurfacestartup.c \
-	profile.c \
-	save-xml.c \
-	sha1.c \
-	statistics.c \
-	time.c \
-	uemis.c \
-	uemis-downloader.c \
-	libdivecomputer.c \
-	gettextfromc.cpp \
-	qthelper.cpp \
-	qt-ui/simplewidgets.cpp \
-	qt-ui/tableview.cpp \
-	qt-ui/mainwindow.cpp \
-	qt-ui/models.cpp \
-	qt-ui/plotareascene.cpp \
-	qt-ui/starwidget.cpp \
-	qt-ui/modeldelegates.cpp \
-	qt-ui/profilegraphics.cpp \
-	qt-ui/globe.cpp \
-	qt-ui/kmessagewidget.cpp \
-	qt-ui/downloadfromdivecomputer.cpp \
-	qt-ui/preferences.cpp \
-	qt-ui/subsurfacewebservices.cpp \
-	qt-ui/divecomputermanagementdialog.cpp \
-	qt-ui/diveplanner.cpp \
-	qt-ui/divelistview.cpp \
-	qt-ui/about.cpp \
-	qt-ui/graphicsview-common.cpp \
-	qt-ui/printdialog.cpp \
-	qt-ui/printoptions.cpp \
-	qt-ui/printlayout.cpp \
-	qt-ui/completionmodels.cpp \
-	qt-ui/maintab.cpp \
-	qt-gui.cpp \
-	main.cpp \
-	$(RESFILE)
-
-FORMS = \
-	qt-ui/about.ui \
-	qt-ui/divecomputermanagementdialog.ui \
-	qt-ui/diveplanner.ui \
-	qt-ui/downloadfromdivecomputer.ui \
-	qt-ui/maintab.ui \
-	qt-ui/mainwindow.ui \
-	qt-ui/preferences.ui \
-	qt-ui/printoptions.ui \
-	qt-ui/renumber.ui \
-	qt-ui/subsurfacewebservices.ui \
-	qt-ui/tableview.ui
-
-RESOURCES = $(NAME).qrc
-
-ifneq ($(SQLITE3FLAGS),)
-	EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS)
-endif
-ifneq ($(ZIPFLAGS),)
-       EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS)
-endif
-ifneq ($(strip $(LIBXSLT)),)
-       EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS)
-endif
-
-ifneq (,$(filter $(UNAME),linux kfreebsd gnu))
-	SOURCES += linux.c
-else ifeq ($(UNAME), darwin)
-	SOURCES += macos.c
-	MACOSXINSTALL = /Applications/$(CAPITALIZED_NAME).app
-	MACOSXFILES = packaging/macosx
-	MACOSXSTAGING = $(MACOSXFILES)/$(CAPITALIZED_NAME).app
-	INFOPLIST = $(MACOSXFILES)/Info.plist
-	INFOPLISTINPUT = $(INFOPLIST).in
-	LDFLAGS += -headerpad_max_install_names
-else
-	SOURCES += windows.c
-	WINDOWSSTAGING = ./packaging/windows
-	WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/'))
-	NSIINPUTFILE = $(WINDOWSSTAGING)/$(NAME).nsi.in
-	NSIFILE = $(WINDOWSSTAGING)/$(NAME).nsi
-	MAKENSIS = makensis
-	XSLTDIR = .\\xslt
-	TARGET = $(NAME).exe
-endif
-
-LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBDIVECOMPUTER) \
-	$(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBSOUP) $(LIBWINSOCK) $(MARBLELIBS)
-
-MSGLANGS=$(notdir $(wildcard po/*.po))
-
-# Add files to the following variables if the auto-detection based on the
-# filename fails
-OBJS_NEEDING_MOC =
-HEADERS_NEEDING_MOC =
-
-include Rules.mk
diff --git a/Rules.mk b/Rules.mk
deleted file mode 100644
index d6ab2584c..000000000
--- a/Rules.mk
+++ /dev/null
@@ -1,289 +0,0 @@
-# -*- Makefile -*-
-# Rules for building and creating the version file
-
-VERSION_FILE = version.h
-# There's only one line in $(VERSION_FILE); use the shell builtin `read'
-STORED_VERSION_STRING = \
-	$(subst ",,$(shell [ ! -r $(VERSION_FILE) ] || \
-			   read ignore ignore v <$(VERSION_FILE) && echo $$v))
-#" workaround editor syntax highlighting quirk
-
-GET_VERSION = ./scripts/get-version
-VERSION_STRING := $(shell $(GET_VERSION) linux || echo "v$(VERSION)")
-# Mac Info.plist style with three numbers 1.2.3
-CFBUNDLEVERSION_STRING := $(shell $(GET_VERSION) darwin $(VERSION_STRING) || \
-	echo "$(VERSION).0")
-# Windows .nsi style with four numbers 1.2.3.4
-PRODVERSION_STRING := $(shell $(GET_VERSION) win $(VERSION_STRING) || \
-	echo "$(VERSION).0.0")
-
-MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/$(NAME).mo))
-
-ifeq ($(V),1)
-	PRETTYECHO=true
-	COMPILE_PREFIX=
-else
-	PRETTYECHO=echo
-	COMPILE_PREFIX=@
-endif
-
-C_SOURCES = $(filter %.c, $(SOURCES))
-CXX_SOURCES = $(filter %.cpp, $(SOURCES)) $(RESOURCES:.qrc=.qrc.cpp)
-OTHER_SOURCES = $(filter-out %.c %.cpp, $(SOURCES))
-OBJS = $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) $(OTHER_SOURCES)
-
-# Add the objects for the header files which define QObject subclasses
-HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(HEADERS))
-MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o)
-
-ALL_OBJS = $(OBJS) $(MOC_OBJS)
-
-# handling of uic
-UIC_HEADERS = $(patsubst qt-ui/%.ui, .uic/ui_%.h, $(FORMS))
-# Needs to exist before we add path
-$(shell mkdir -p .uic)
-vpath ui_%.h .uic
-
-# Files for using Qt Creator
-CREATOR_FILES = $(NAME).config $(NAME).creator $(NAME).files $(NAME).includes
-
-all: $(TARGET) doc
-
-$(TARGET): gen_version_file $(UIC_HEADERS) $(ALL_OBJS) $(INFOPLIST)
-	@$(PRETTYECHO) '    LINK' $(TARGET)
-	$(COMPILE_PREFIX)$(CXX) $(LDFLAGS) -o $(TARGET) $(ALL_OBJS) $(LIBS)
-
-gen_version_file $(VERSION_FILE):
-ifneq ($(STORED_VERSION_STRING),$(VERSION_STRING))
-	$(info updating $(VERSION_FILE) to $(VERSION_STRING))
-	@echo \#define VERSION_STRING \"$(VERSION_STRING)\" >$(VERSION_FILE)
-endif
-
-install: all
-	$(INSTALL) -d -m 755 $(BINDIR)
-	$(INSTALL) $(NAME) $(BINDIR)
-	$(INSTALL) -d -m 755 $(DESKTOPDIR)
-	$(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
-	$(INSTALL) -d -m 755 $(ICONDIR)
-	$(INSTALL) -m 644 $(ICONFILE) $(ICONDIR)
-	@-if test -z "$(DESTDIR)"; then \
-		$(gtk_update_icon_cache); \
-	fi
-	$(INSTALL) -d -m 755 $(MANDIR)
-	$(INSTALL) -m 644 $(MANFILES) $(MANDIR)
-	@-if test ! -z "$(XSLT)"; then \
-		$(INSTALL) -d -m 755 $(DATADIR)/$(NAME); \
-		$(INSTALL) -d -m 755 $(XSLTDIR); \
-		$(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \
-	fi
-	@-if test ! -z "$(MARBLEDIR)"; then \
-		$(INSTALL) -d -m 755 $(DATADIR)/$(NAME)/$(MARBLEDIR); \
-		$(TAR) cf - $(MARBLEDIR) | ( cd $(DATADIR)/$(NAME); $(TAR) xf - ); \
-	fi
-	for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \
-		$(INSTALL) -d $(prefix)/$$LOC; \
-		$(INSTALL) -m 644 $$LOC/$(NAME).mo $(prefix)/$$LOC/$(NAME).mo; \
-	done
-	$(INSTALL) -d -m 755 $(DOCDIR)
-	$(INSTALL) -m 644 Documentation/user-manual.html $(DOCDIR)
-	for IMG in $(wildcard Documentation/images/*); do \
-		$(INSTALL) -m 644 $$IMG $(DOCDIR)/images; \
-	done
-
-
-install-macosx: all
-	$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
-	$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
-	$(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/$(NAME)-bin
-	$(INSTALL) $(MACOSXFILES)/$(NAME).sh $(MACOSXINSTALL)/Contents/MacOS/$(NAME)
-	$(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXINSTALL)/Contents/
-	$(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
-	$(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
-	$(INSTALL) $(MACOSXFILES)/$(CAPITALIZED_NAME).icns $(MACOSXINSTALL)/Contents/Resources/
-	@-if test ! -z "$(MARBLEDIR)"; then \
-		$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/share/$(MARBLEDIR); \
-		$(TAR) cf - $(MARBLEDIR) | ( cd $(MACOSXINSTALL)/Contents/Resources/share; $(TAR) xf - ); \
-	fi
-	for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \
-		$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \
-		$(INSTALL) $$LOC/$(NAME).mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/$(NAME).mo; \
-	done
-	@-if test ! -z "$(XSLT)"; then \
-		$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/share/xslt; \
-		$(INSTALL) -m 644 $(XSLTFILES) $(MACOSXINSTALL)/Contents/Resources/share/xslt/; \
-	fi
-	$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/resources/share/doc/$(NAME)
-	$(INSTALL) -m 644 Documentation/user-manual.html $(MACOSXINSTALL)/Contents/Resources/share/doc/$(NAME)
-	for IMG in $(wildcard Documentation/images/*); do \
-		$(INSTALL) -m 644 $$IMG $(MACOSXINSTALL)/Contents/Resources/share/doc/$(NAME)/images; \
-	done
-
-
-create-macosx-bundle: all
-	$(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources
-	$(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/MacOS
-	$(INSTALL) $(NAME) $(MACOSXSTAGING)/Contents/MacOS/
-	$(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXSTAGING)/Contents/
-	$(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXSTAGING)/Contents/
-	$(INSTALL) $(ICONFILE) $(MACOSXSTAGING)/Contents/Resources/
-	$(INSTALL) $(MACOSXFILES)/$(CAPITALIZED_NAME).icns $(MACOSXSTAGING)/Contents/Resources/
-	for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \
-		$(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \
-		$(INSTALL) $$LOC/$(NAME).mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/$(NAME).mo; \
-	done
-	@-if test ! -z "$(XSLT)"; then \
-		$(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/xslt; \
-		$(INSTALL) -m 644 $(XSLTFILES) $(MACOSXSTAGING)/Contents/Resources/xslt/; \
-	fi
-	$(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/resources/share/doc/$(NAME)
-	$(INSTALL) -m 644 Documentation/user-manual.html $(MACOSXSTAGING)/Contents/Resources/share/doc/$(NAME)
-	for IMG in $(wildcard Documentation/images/*); do \
-		$(INSTALL) -m 644 $$IMG $(MACOSXSTAGING)/Contents/Resources/share/doc/$(NAME)/images; \
-	done
-	$(GTK_MAC_BUNDLER) packaging/macosx/$(NAME).bundle
-
-sign-macosx-bundle: all
-	codesign -s "3A8CE62A483083EDEA5581A61E770EC1FA8BECE8" /Applications/$(CAPITALIZED_NAME).app/Contents/MacOS/$(NAME)-bin
-
-$(RESFILE): packaging/windows/subsurface.rc
-	@$(PRETTYECHO) '    WINDRES' $<
-	@i686-w64-mingw32-windres -O coff -i $< -o $@
-
-install-cross-windows: all
-	$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/locale
-	for MSG in $(WINMSGDIRS); do\
-		$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/$$MSG;\
-		$(INSTALL) $(CROSS_PATH)/$$MSG/* $(WINDOWSSTAGING)/$$MSG;\
-	done
-	for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \
-		$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/$$LOC; \
-		$(INSTALL) $$LOC/$(NAME).mo $(WINDOWSSTAGING)/$$LOC/$(NAME).mo; \
-	done
-	$(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/doc/$(NAME)
-	$(INSTALL) -m 644 Documentation/user-manual.html $(WINDOWSSTAGING)/share/doc/$(NAME)
-	for IMG in $(wildcard Documentation/images/*); do \
-		$(INSTALL) -m 644 $$IMG $(WINDOWSSTAGING)/share/doc/$(NAME)/images; \
-	done
-
-
-create-windows-installer: all $(NSIFILE) install-cross-windows
-	$(MAKENSIS) $(NSIFILE)
-
-$(NSIFILE): $(NSIINPUTFILE)
-	$(shell cat $(NSIINPUTFILE) | sed -e 's/VERSIONTOKEN/$(VERSION_STRING)/;s/PRODVTOKEN/$(PRODVERSION_STRING)/' > $(NSIFILE))
-
-$(INFOPLIST): $(INFOPLISTINPUT)
-	$(shell cat $(INFOPLISTINPUT) | sed -e 's/CFBUNDLEVERSION_TOKEN/$(CFBUNDLEVERSION_STRING)/' > $(INFOPLIST))
-
-# Transifex merge the translations
-update-po-files:
-	xgettext -o po/$(NAME)-new.pot -s -k_ -kN_ -ktr --keyword=C_:1c,2  --add-comments="++GETTEXT" *.c qt-ui/*.cpp
-	tx push -s
-	tx pull -af
-
-MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $(EXTRA_FLAGS))
-
-%.o: %.c
-	@$(PRETTYECHO) '    CC' $<
-	@mkdir -p .dep/$(@D)
-	$(COMPILE_PREFIX)$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $<
-
-%.o: %.cpp
-	@$(PRETTYECHO) '    CXX' $<
-	@mkdir -p .dep/$(@D)
-	$(COMPILE_PREFIX)$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -I.uic -Iqt-ui -MD -MF .dep/$@.dep -c -o $@ $<
-
-# This rule is for running the moc on QObject subclasses defined in the .h
-# files.
-%.moc.cpp: %.h
-	@$(PRETTYECHO) '    MOC' $<
-	$(COMPILE_PREFIX)$(MOC) $(MOCFLAGS) $< -o $@
-
-# This rule is for running the moc on QObject subclasses defined in the .cpp
-# files; remember to #include "<file>.moc" at the end of the .cpp file, or
-# you'll get linker errors ("undefined vtable for...")
-%.moc: %.cpp
-	@$(PRETTYECHO) '    MOC' $<
-	$(COMPILE_PREFIX)$(MOC) -i $(MOCFLAGS) $< -o $@
-
-# This creates the Qt resource sources.
-%.qrc.cpp: %.qrc
-	@$(PRETTYECHO) '    RCC' $<
-	$(COMPILE_PREFIX)$(RCC) $< -o $@
-%.qrc:
-
-# Create the .ui headers in .uic searched by vpath
-# Added to include path in cpp rule
-.uic/ui_%.h: qt-ui/%.ui
-	@$(PRETTYECHO) '    UIC' $<
-	$(COMPILE_PREFIX)$(UIC) $< -o $@
-
-share/locale/%.UTF-8/LC_MESSAGES/$(NAME).mo: po/%.po po/%.aliases
-	@$(PRETTYECHO) '    MSGFMT' $*.po
-	@mkdir -p $(dir $@)
-	$(COMPILE_PREFIX)msgfmt -c -o $@ po/$*.po
-	@-if test -s po/$*.aliases; then \
-		for ALIAS in `cat po/$*.aliases`; do \
-			mkdir -p share/locale/$$ALIAS/LC_MESSAGES; \
-			cp $@ share/locale/$$ALIAS/LC_MESSAGES; \
-		done; \
-	fi
-
-satellite.png: satellite.svg
-	convert -transparent white -resize 11x16 -depth 8 $< $@
-
-# This should work, but it doesn't get the colors quite right - so I manually converted with Gimp
-#	convert -colorspace RGB -transparent white -resize 256x256 subsurface-icon.svg subsurface-icon.png
-#
-# The following creates the pixbuf data in .h files with the basename followed by '_pixmap'
-# as name of the data structure
-%.h: %.png
-	@echo '    gdk-pixbuf-csource' $<
-	@gdk-pixbuf-csource --struct --name `echo $* | sed 's/-/_/g'`_pixbuf $< > $@
-
-doc:
-	$(MAKE) -C Documentation doc
-
-clean:
-	rm -f $(ALL_OBJS) *~ $(NAME) $(VERSION_FILE) \
-		$(NAME).exe po/*~ po/$(NAME)-new.pot \
-		*.moc qt-ui/*.moc \
-		.uic/*.h \
-		$(RESOURCES:.qrc=.qrc.cpp)
-	rm -rf share
-
-confclean: clean
-	rm -f $(CONFIGFILE)
-	rm -rf .dep .uic
-
-distclean: confclean
-	$(MAKE) -C Documentation clean
-	rm -f $(CREATOR_FILES)
-
-release:
-	@scripts/check-version -cr $(VERSION_STRING)
-	git archive --prefix $(CAPITALIZED_NAME)-$(VERSION_STRING)/ \
-		    --output $(CAPITALIZED_NAME)-$(VERSION_STRING).tgz \
-		    v$(VERSION_STRING)
-
-.PHONY: creator-files
-creator-files: $(CREATOR_FILES)
-$(NAME).files: Makefile $(CONFIGFILE)
-	echo $(wildcard *.h qt-ui/*.h qt-ui/*.ui) $(HEADERS) $(SOURCES) | tr ' ' '\n' | sort | uniq > $(NAME).files
-	{ echo Makefile; echo Rules.mk; echo Configure.mk; } >> $(NAME).files
-$(NAME).config: Makefile $(CONFIGFILE)
-	echo $(patsubst -D%,%,$(filter -D%, $(CXXFLAGS) $(CFLAGS) $(EXTRA_FLAGS))) | tr ' ' '\n' | sort | uniq > $(NAME).config
-$(NAME).includes: Makefile $(CONFIGFILE)
-	echo $$PWD > $(NAME).includes
-	echo $(patsubst -I%,%,$(filter -I%, $(CXXFLAGS) $(CFLAGS) $(EXTRA_FLAGS))) | tr ' ' '\n' | sort | uniq >> $(NAME).includes
-$(NAME).creator:
-	echo '[General]' > $(NAME).creator
-
-ifneq ($(CONFIGURED)$(CONFIGURING),)
-.dep/%.o.dep: %.cpp
-	@mkdir -p $(@D)
-	@$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MM -MG -MF $@ -MT $(<:.cpp=.o) -c $<
-endif
-
-DEPS = $(addprefix .dep/,$(C_SOURCES:.c=.o.dep) $(CXX_SOURCES:.cpp=.o.dep))
--include $(DEPS)

From 9e069371c6ee3e2866296c43e15a2bfdd9064804 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Sun, 6 Oct 2013 18:41:37 -0700
Subject: [PATCH 03/13] Add qmake rules to install Subsurface

This is probably the most complex part of the new buildsystem. This
adds the following targets:

 - Linux:
   make install - installs to $(prefix) (default: /usr)
   The install path can be changed during make install time.

 - Windows:
   make install - installs Subsurface and its dependencies to
                  packaging/windows.

 - Mac:
   make mac-deploy     - populates Subsurface.app with the dependencies
   make install        - mac-deploy + install Subsurface.app to /Application
   make mac-create-dmg - mac-deploy + creates Subsurface-$VERSION.dmg

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 subsurface-install.pri | 102 +++++++++++++++++++++++++++++++++++++++++
 subsurface.pro         |  10 ++++
 2 files changed, 112 insertions(+)
 create mode 100644 subsurface-install.pri

diff --git a/subsurface-install.pri b/subsurface-install.pri
new file mode 100644
index 000000000..585481f62
--- /dev/null
+++ b/subsurface-install.pri
@@ -0,0 +1,102 @@
+marbledir.files = $$MARBLEDIR
+xslt.files = $$XSLT_FILES
+doc.files = $$DOC_FILES
+
+nltab = $$escape_expand(\\n\\t)
+
+mac {
+    # OS X bundling rules
+    #  "make mac-deploy" deploys the external libs (Qt, libdivecomputer, libusb, etc.) into the bundle
+    #  "make install" installs the bundle to /Application
+    #  "make mac-create-dmg" creates Subsurface.dmg
+
+    mac_bundle.path = /Application
+    mac_bundle.files = Subsurface.app
+    mac_bundle.CONFIG += no_check_exist directory
+    INSTALLS += mac_bundle
+    install.depends += mac-deploy
+
+    datadir = Contents/Resources/share/subsurface
+    marbledir.path = Contents/Resources/data
+    xslt.path = $$datadir
+    doc.path = Contents/Resources/share/doc/subsurface
+    doc.files = $$files($$doc.files)
+    QMAKE_BUNDLE_DATA += marbledir xslt doc
+
+    mac_deploy.target = mac-deploy
+    mac_deploy.commands += $$[QT_INSTALL_BINS]/macdeployqt $${TARGET}.app
+    !isEmpty(V):mac_deploy.commands += -verbose=1
+
+    mac_dmg.target = mac-create-dmg
+    mac_dmg.commands = $$mac_deploy.commands -dmg
+    mac_dmg.commands += $${nltab}$(MOVE) $${TARGET}.dmg $${TARGET}-$${VERSION}.dmg
+    QMAKE_EXTRA_TARGETS += mac_deploy mac_dmg
+} else: win32 {
+    # Windows bundling rules
+    # We don't have a helpful tool like macdeployqt for Windows, so we hardcode
+    # which libs we need.
+    # The only target is "make install", which copies everything into packaging/windows
+    WINDOWSSTAGING = packaging/windows
+
+    deploy.path = $$WINDOWSSTAGING
+    for(qtlib, $$list(QtCore QtGui QtNetwork QtWebKit QtSvg QtXml QtDeclarative)) {
+        CONFIG(debug, debug|release): deploy.files += $$[QT_INSTALL_BINS]/$${qtlib}d4.dll
+        else: deploy.files += $$[QT_INSTALL_BINS]/$${qtlib}4.dll
+    }
+
+    deploy.files += $$marbledir.files $$xslt.files $$doc.files
+    target.path = $$WINDOWSSTAGING
+    INSTALLS += deploy target
+
+    qt_conf.commands = echo \'[Paths]\' > $@
+    qt_conf.commands += $${nltab}echo \'Prefix=.\' >> $@
+    qt_conf.commands += $${nltab}echo \'Plugins=plugins\' >> $@
+    qt_conf.target = $$PWD/packaging/windows/qt.conf
+    install.depends += qt_conf
+} else {
+    # Linux install rules
+    # On Linux, we can count on packagers doing the right thing
+    # We just need to drop a few files here and there
+
+    # This is a fake rule just to create some rules in the target file
+    nl = $$escape_expand(\\n)
+    dummy.target = dummy-only-for-var-expansion
+    dummy.commands  = $${nl}prefix = /usr$${nl}\
+BINDIR = $(prefix)/bin$${nl}\
+DATADIR = $(prefix)/share$${nl}\
+DOCDIR = $(DATADIR)/doc/subsurface$${nl}\
+DESKTOPDIR = $(DATADIR)/applications$${nl}\
+ICONPATH = $(DATADIR)/icons/hicolor$${nl}\
+ICONDIR = $(ICONPATH)/scalable/apps$${nl}\
+MANDIR = $(DATADIR)/man/man1$${nl}\
+XSLTDIR = $(DATADIR)/subsurface
+    QMAKE_EXTRA_TARGETS += dummy
+
+    WINDOWSSTAGING = ./packaging/windows
+
+    target.path = /$(BINDIR)
+    target.files = $$TARGET
+
+    desktop.path = /$(DESKTOPDIR)
+    desktop.files = $$DESKTOP_FILE
+    manpage.path = /$(MANDIR)
+    manpage.files = $$MANPAGE
+
+    icon.path = /$(ICONDIR)
+    icon.files = $$ICON
+
+    xslt.path = /$(XSLTDIR)
+    marbledir.path = /$(DATADIR)/subsurface
+    doc.path = /$(DOCDIR)
+
+    # FIXME: Linguist translations
+    #l10n_install.commands = for LOC in $$files(share/locale/*/LC_MESSAGES); do \
+    #                $(INSTALL_PROGRAM) -d $(INSTALL_ROOT)/$(prefix)/$$LOC; \
+    #                $(INSTALL_FILE) $$LOC/subsurface.mo $(INSTALL_ROOT)/$(prefix)/$$LOC/subsurface.mo; \
+    #        done
+    #install.depends += l10n_install
+
+    INSTALLS += target desktop icon manpage xslt doc marbledir
+    install.target = install
+}
+QMAKE_EXTRA_TARGETS += install $$install.depends
diff --git a/subsurface.pro b/subsurface.pro
index 8a4996385..f3c0d12ca 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -126,4 +126,14 @@ doc.commands += $$escape_expand(\\n\\t)$(MAKE) -C $$PWD/Documentation OUT=$$OUT_
 all.depends += doc
 QMAKE_EXTRA_TARGETS += doc all
 
+DESKTOP_FILE = subsurface.desktop
+ICON = subsurface-icon.svg
+MANPAGE = subsurface.1
+XSLT_FILES = xslt/*.xslt xslt/*.xsl
+DOC_FILES = $$OUT_PWD/Documentation/user-manual.html Documentation/images
+MARBLEDIR = marbledata/maps
+
+OTHER_FILES += $$DESKTOPFILE $$ICON $$MANPAGE $$XSLT_FILES $$DOC_FILES $$MARBLEDIR
+
 include(subsurface-gen-version.pri)
+include(subsurface-install.pri)

From 88b34b56db73a297c36d900236a068b7cd116677 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Sun, 6 Oct 2013 22:01:34 -0700
Subject: [PATCH 04/13] Add information that goes into the Windows .exe file

And drop the unnecessary .rc file.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 packaging/windows/subsurface.rc | 25 -------------------------
 1 file changed, 25 deletions(-)
 delete mode 100644 packaging/windows/subsurface.rc

diff --git a/packaging/windows/subsurface.rc b/packaging/windows/subsurface.rc
deleted file mode 100644
index af79f6de9..000000000
--- a/packaging/windows/subsurface.rc
+++ /dev/null
@@ -1,25 +0,0 @@
-1 VERSIONINFO
-FILEVERSION     1,1,0,0
-PRODUCTVERSION  1,1,0,0
-BEGIN
-  BLOCK "StringFileInfo"
-  BEGIN
-    BLOCK "080904E4"
-    BEGIN
-      VALUE "CompanyName", "subsurface team"
-      VALUE "FileDescription", "subsurface dive log"
-      VALUE "FileVersion", "1.1"
-      VALUE "InternalName", "subsurface"
-      VALUE "LegalCopyright", "Linus Torvalds, Dirk Hohndel and others"
-      VALUE "OriginalFilename", "subsurface.exe"
-      VALUE "ProductName", "subsurface"
-      VALUE "ProductVersion", "1.1"
-    END
-  END
-
-  BLOCK "VarFileInfo"
-  BEGIN
-    VALUE "Translation", 0x809, 1252
-  END
-END
-ID ICON "subsurface.ico"
\ No newline at end of file

From 57994fa7a19ece18ffbecfabd69216190f62e425 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Sun, 6 Oct 2013 23:12:59 -0700
Subject: [PATCH 05/13] And let qmake create the Mac bundle on its own

It will even parse the Info.plist.in file for us and run sed on it.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 packaging/macosx/Info.plist.in |  2 +-
 subsurface.pro                 | 26 +++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/packaging/macosx/Info.plist.in b/packaging/macosx/Info.plist.in
index a623303a1..5e094401a 100644
--- a/packaging/macosx/Info.plist.in
+++ b/packaging/macosx/Info.plist.in
@@ -17,6 +17,6 @@
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>1.0</string>
 	<key>CFBundleVersion</key>
-	<string>CFBUNDLEVERSION_TOKEN</string>
+	<string>@SHORT_VERSION@</string>
 </dict>
 </plist>
diff --git a/subsurface.pro b/subsurface.pro
index f3c0d12ca..a04281941 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -3,6 +3,9 @@ include(subsurface-configure.pri)
 QT = core gui network webkit svg
 INCLUDEPATH += qt-ui $$PWD
 
+mac: TARGET = Subsurface
+else: TARGET = subsurface
+
 VERSION = 3.1
 
 HEADERS = \
@@ -127,13 +130,30 @@ all.depends += doc
 QMAKE_EXTRA_TARGETS += doc all
 
 DESKTOP_FILE = subsurface.desktop
-ICON = subsurface-icon.svg
+mac: ICON = packaging/macosx/Subsurface.icns
+else: ICON = subsurface-icon.svg
 MANPAGE = subsurface.1
-XSLT_FILES = xslt/*.xslt xslt/*.xsl
+XSLT_FILES = xslt
 DOC_FILES = $$OUT_PWD/Documentation/user-manual.html Documentation/images
 MARBLEDIR = marbledata/maps
 
-OTHER_FILES += $$DESKTOPFILE $$ICON $$MANPAGE $$XSLT_FILES $$DOC_FILES $$MARBLEDIR
+# This information will go into the Windows .rc file and linked into the .exe
+QMAKE_TARGET_COMPANY = subsurface team
+QMAKE_TARGET_DESCRIPTION = subsurface dive log
+QMAKE_TARGET_COPYRIGHT = Linus Torvalds, Dirk Hohndel and others
+
+# And this is the Mac Info.plist file
+# qmake automatically generates sed rules to replace:
+#  token                qmake expansion
+#  @ICON@               $$ICON
+#  @TYPEINFO@           first 4 chars of $$QMAKE_PKGINFO_TYPEINFO
+#  @EXECUTABLE@         $$QMAKE_ORIG_TARGET
+#  @LIBRARY@            $$QMAKE_ORIG_TARGET
+#  @SHORT_VERSION@      $$VER_MAJ.$$VER_MIN
+QMAKE_INFO_PLIST = packaging/macosx/Info.plist.in
+
+OTHER_FILES += $$DESKTOPFILE $$ICON $$MANPAGE $$XSLT_FILES $$DOC_FILES $$MARBLEDIR \
+        $$QMAKE_INFO_PLIST
 
 include(subsurface-gen-version.pri)
 include(subsurface-install.pri)

From 2fedb100ca84a94868e33f871e77b6379c3748c9 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 17:47:25 -0700
Subject: [PATCH 06/13] Add a tool to scan for dependencies on Windows

Similar to ldd on Linux.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 scripts/win-ldd.pl     | 69 ++++++++++++++++++++++++++++++++++++++++++
 subsurface-install.pri | 15 ++++++---
 2 files changed, 79 insertions(+), 5 deletions(-)
 create mode 100644 scripts/win-ldd.pl

diff --git a/scripts/win-ldd.pl b/scripts/win-ldd.pl
new file mode 100644
index 000000000..8af449a7b
--- /dev/null
+++ b/scripts/win-ldd.pl
@@ -0,0 +1,69 @@
+#!perl
+use strict;
+my %deploy;
+my $objdump = $ENV{objdump} ? $ENV{objdump} : "i686-w64-mingw32-objdump";
+my @searchdirs;
+
+sub addDependenciesFor($) {
+    open OBJDUMP, "-|", $objdump, "-p", $_[0] or die;
+    while (<OBJDUMP>) {
+        last if /^The Import Tables/;
+    }
+    while (<OBJDUMP>) {
+        next unless /DLL Name: (.*)/;
+        $deploy{$1} = 0 unless defined($deploy{$1});
+        last if /^\w/;
+    }
+    close OBJDUMP;
+}
+
+sub findMissingDependencies {
+    for my $name (keys %deploy) {
+        next if $deploy{$name};
+        my $path;
+        for my $dir (@searchdirs) {
+            my $fpath = "$dir/$name";
+            my $lcfpath = "$dir/" . lc($name);
+            if (-e $fpath) {
+                $path = $fpath;
+            } elsif (-e $lcfpath) {
+                $path = $lcfpath;
+            } else {
+                next;
+            }
+            addDependenciesFor($path);
+            last;
+        }
+
+        $path = "/missing/file" unless $path;
+        $deploy{$name} = $path;
+    }
+}
+
+for (@ARGV) {
+    s/^-L//;
+    next if /^-/;
+    if (-d $_) {
+        push @searchdirs, $_;
+    } elsif (-f $_) {
+        $deploy{$_} = $_;
+        addDependenciesFor($_);
+    }
+}
+
+while (1) {
+    findMissingDependencies();
+
+    my $i = 0;
+    while (my ($name, $path) = each(%deploy)) {
+        next if $path;
+        ++$i;
+        last;
+    }
+    last if $i == 0;
+}
+
+for (sort values %deploy) {
+    next if $_ eq "/missing/file";
+    print "$_\n";
+}
diff --git a/subsurface-install.pri b/subsurface-install.pri
index 585481f62..b8d73785a 100644
--- a/subsurface-install.pri
+++ b/subsurface-install.pri
@@ -39,11 +39,6 @@ mac {
     WINDOWSSTAGING = packaging/windows
 
     deploy.path = $$WINDOWSSTAGING
-    for(qtlib, $$list(QtCore QtGui QtNetwork QtWebKit QtSvg QtXml QtDeclarative)) {
-        CONFIG(debug, debug|release): deploy.files += $$[QT_INSTALL_BINS]/$${qtlib}d4.dll
-        else: deploy.files += $$[QT_INSTALL_BINS]/$${qtlib}4.dll
-    }
-
     deploy.files += $$marbledir.files $$xslt.files $$doc.files
     target.path = $$WINDOWSSTAGING
     INSTALLS += deploy target
@@ -53,6 +48,16 @@ mac {
     qt_conf.commands += $${nltab}echo \'Plugins=plugins\' >> $@
     qt_conf.target = $$PWD/packaging/windows/qt.conf
     install.depends += qt_conf
+
+    !win32-msvc* {
+        !equals($$QMAKE_HOST.os, "Windows"): dlls.commands += OBJDUMP=`$(CC) -dumpmachine`-objdump
+        dlls.commands += perl $$PWD/scripts/win-ldd.pl $(DESTDIR_TARGET)
+        dlls.commands += `$(CC) -print-search-dirs | $(SED) -n \'/^libraries: =/{s///;s/:/\\n/g;p;q;}\' | $(SED) -E \'s,/lib/?\\\$\$,/bin,\'`
+        dlls.commands += $$LIBS
+        dlls.commands += | while read name; do $(INSTALL_FILE) \$\$name $$PWD/$$WINDOWSSTAGING; done
+        dlls.depends = $(DESTDIR_TARGET)
+        install.depends += dlls
+    }
 } else {
     # Linux install rules
     # On Linux, we can count on packagers doing the right thing

From 9294d5984c2f0f052015573a3411de76f71b235f Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 21:05:57 -0700
Subject: [PATCH 07/13] Disable the code that tries to find an alternate
 objdump

On Linux distros, it seems, objdump is configured to read Windows
executables (BFD architecture "pei-i386"), so we don't need to find an
alternate / cross-compile version. But leave the code here in case we
run into a distro that does things differently.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 subsurface-install.pri | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subsurface-install.pri b/subsurface-install.pri
index b8d73785a..37c8e077f 100644
--- a/subsurface-install.pri
+++ b/subsurface-install.pri
@@ -50,7 +50,7 @@ mac {
     install.depends += qt_conf
 
     !win32-msvc* {
-        !equals($$QMAKE_HOST.os, "Windows"): dlls.commands += OBJDUMP=`$(CC) -dumpmachine`-objdump
+        #!equals($$QMAKE_HOST.os, "Windows"): dlls.commands += OBJDUMP=`$(CC) -dumpmachine`-objdump
         dlls.commands += perl $$PWD/scripts/win-ldd.pl $(DESTDIR_TARGET)
         dlls.commands += `$(CC) -print-search-dirs | $(SED) -n \'/^libraries: =/{s///;s/:/\\n/g;p;q;}\' | $(SED) -E \'s,/lib/?\\\$\$,/bin,\'`
         dlls.commands += $$LIBS

From 245e29a72e47177b3337f7046b6bb0702888e3d8 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 21:07:43 -0700
Subject: [PATCH 08/13] Use the $PATH environment variable to pass extra dirs
 for DLLs

Unix developers, look away... this is how it's done on Windows: the
binary loader searches $PATH for the DLLs, so let's reuse the same
variable. This simplifies the command-line a little.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 scripts/win-ldd.pl     | 2 +-
 subsurface-install.pri | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/win-ldd.pl b/scripts/win-ldd.pl
index 8af449a7b..6ca97b74a 100644
--- a/scripts/win-ldd.pl
+++ b/scripts/win-ldd.pl
@@ -2,7 +2,7 @@
 use strict;
 my %deploy;
 my $objdump = $ENV{objdump} ? $ENV{objdump} : "i686-w64-mingw32-objdump";
-my @searchdirs;
+my @searchdirs = split(/:/, $ENV{PATH});
 
 sub addDependenciesFor($) {
     open OBJDUMP, "-|", $objdump, "-p", $_[0] or die;
diff --git a/subsurface-install.pri b/subsurface-install.pri
index 37c8e077f..c71ae0ada 100644
--- a/subsurface-install.pri
+++ b/subsurface-install.pri
@@ -51,8 +51,8 @@ mac {
 
     !win32-msvc* {
         #!equals($$QMAKE_HOST.os, "Windows"): dlls.commands += OBJDUMP=`$(CC) -dumpmachine`-objdump
+        dlls.commands += PATH=\$\$PATH:`$(CC) -print-search-dirs | $(SED) -nE \'/^libraries: =/{s///;s,/lib/?(:|\\\$\$),/bin\\1,g;p;q;}\'`
         dlls.commands += perl $$PWD/scripts/win-ldd.pl $(DESTDIR_TARGET)
-        dlls.commands += `$(CC) -print-search-dirs | $(SED) -n \'/^libraries: =/{s///;s/:/\\n/g;p;q;}\' | $(SED) -E \'s,/lib/?\\\$\$,/bin,\'`
         dlls.commands += $$LIBS
         dlls.commands += | while read name; do $(INSTALL_FILE) \$\$name $$PWD/$$WINDOWSSTAGING; done
         dlls.depends = $(DESTDIR_TARGET)

From 603d65c9616ee85e0e0de1535874b981261589d2 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 21:27:10 -0700
Subject: [PATCH 09/13] Deploy some Qt plugins alongside the binary

Only implemented for Windows for now. On Mac, macdeployqt copies all
imageformat plugins on its own.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 subsurface-install.pri | 8 +++++++-
 subsurface.pro         | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/subsurface-install.pri b/subsurface-install.pri
index c71ae0ada..0615bc325 100644
--- a/subsurface-install.pri
+++ b/subsurface-install.pri
@@ -45,7 +45,7 @@ mac {
 
     qt_conf.commands = echo \'[Paths]\' > $@
     qt_conf.commands += $${nltab}echo \'Prefix=.\' >> $@
-    qt_conf.commands += $${nltab}echo \'Plugins=plugins\' >> $@
+    qt_conf.commands += $${nltab}echo \'Plugins=.\' >> $@
     qt_conf.target = $$PWD/packaging/windows/qt.conf
     install.depends += qt_conf
 
@@ -53,6 +53,12 @@ mac {
         #!equals($$QMAKE_HOST.os, "Windows"): dlls.commands += OBJDUMP=`$(CC) -dumpmachine`-objdump
         dlls.commands += PATH=\$\$PATH:`$(CC) -print-search-dirs | $(SED) -nE \'/^libraries: =/{s///;s,/lib/?(:|\\\$\$),/bin\\1,g;p;q;}\'`
         dlls.commands += perl $$PWD/scripts/win-ldd.pl $(DESTDIR_TARGET)
+
+        for(plugin, $$list($$DEPLOYMENT_PLUGIN)) {
+            CONFIG(debug, debug|release): dlls.commands += $$[QT_INSTALL_PLUGINS]/$${plugin}d4.dll
+            else: dlls.commands += $$[QT_INSTALL_PLUGINS]/$${plugin}4.dll
+        }
+
         dlls.commands += $$LIBS
         dlls.commands += | while read name; do $(INSTALL_FILE) \$\$name $$PWD/$$WINDOWSSTAGING; done
         dlls.depends = $(DESTDIR_TARGET)
diff --git a/subsurface.pro b/subsurface.pro
index a04281941..065897233 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -136,6 +136,7 @@ MANPAGE = subsurface.1
 XSLT_FILES = xslt
 DOC_FILES = $$OUT_PWD/Documentation/user-manual.html Documentation/images
 MARBLEDIR = marbledata/maps
+DEPLOYMENT_PLUGIN += imageformats/qjpeg
 
 # This information will go into the Windows .rc file and linked into the .exe
 QMAKE_TARGET_COMPANY = subsurface team

From 6c90fa7c64a151ac0c13f69966863608e77276af Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 21:40:24 -0700
Subject: [PATCH 10/13] Fix the Marble data installation for Windows

Qt-only Marble expects the data to be on applicationDirPath() + "/data".

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 subsurface-install.pri | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/subsurface-install.pri b/subsurface-install.pri
index 0615bc325..3a625973a 100644
--- a/subsurface-install.pri
+++ b/subsurface-install.pri
@@ -39,9 +39,10 @@ mac {
     WINDOWSSTAGING = packaging/windows
 
     deploy.path = $$WINDOWSSTAGING
-    deploy.files += $$marbledir.files $$xslt.files $$doc.files
+    deploy.files += $$xslt.files $$doc.files
     target.path = $$WINDOWSSTAGING
-    INSTALLS += deploy target
+    marbledir.path = $$WINDOWSSTAGING/data
+    INSTALLS += deploy marbledir target
 
     qt_conf.commands = echo \'[Paths]\' > $@
     qt_conf.commands += $${nltab}echo \'Prefix=.\' >> $@

From 3cbd961ce341424fc730b0711efcb1318e8169ac Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 18:29:04 -0700
Subject: [PATCH 11/13] Update the README and create an INSTALL file.

Let the README contain generic information and move the build
instructions to the INSTALL file.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 INSTALL | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++
 README  | 172 --------------------------------------------------------
 2 files changed, 155 insertions(+), 172 deletions(-)
 create mode 100644 INSTALL

diff --git a/INSTALL b/INSTALL
new file mode 100644
index 000000000..fe0f7967d
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,155 @@
+Building the Qt version under Linux
+-----------------------------------
+
+On Debian you need libqt4-dev, libmarble-dev, libzip-dev.
+Unfortunately the marble version in Debian stable (and possibly
+Ubuntu) appears broken and missing essential header files used in the
+current git version of Subsurface. We hack around this right now by
+including this header file but this needs to be revisited before an
+actual release.
+
+On Fedora you need qt-devel, marble-devel, libzip-devel,
+libxml2-devel, libxslt-devel, libsqlite3x-devel. If you are going to
+compile libdivecomputer, you need to libusb-devel too.
+
+On Debian the package names are different; try libxml2-dev,
+libsqlite3-dev, libxslt1-dev, libzip-dev (and libusb-1.0-0-dev if
+you're going to compile libdivecomputer).
+
+To compile libdivecomputer:
+$ git clone git://git.libdivecomputer.org/libdivecomputer
+$ cd libdivecomputer
+$ git checkout release-0.4
+$ autoreconf --install
+$ ./configure
+$ make
+$ sudo make install
+
+To compile Subsurface:
+$ git clone git://subsurface.hohndel.org/subsurface.git
+$ cd subsurface
+$ qmake
+$ make
+$ sudo make install     [optionally, add: prefix=/usr/local]
+
+Building the Qt version under MacOSX
+------------------------------------
+
+1)  Install Homebrew
+
+$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
+
+2) Install needed dependencies
+
+$ brew install asciidoc libzip qt sqlite cmake libusb pkg-config
+
+3) Make the brew version of sqlite the default
+
+$ brew link --force sqlite
+
+4) Install Marble
+
+$ mkdir -p ~/src/marble/build
+$ git clone -b KDE/4.11 git://anongit.kde.org/marble ~/src/marble/sources
+$ cd ~/src/marble/build
+$ cmake -DCMAKE_BUILD_TYPE=Debug -DQTONLY=TRUE -DCMAKE_INSTALL_PREFIX=/usr/local ~/src/marble/sources
+$ make
+$ sudo make install
+$ cd src/lib
+$ mkdir -p /usr/local/include/marble
+$ cp $(find . -name '*.h') /usr/local/include/marble/
+$ cp *dylib /usr/local/lib/
+
+5) Install Libdivecomputer
+
+$ brew install automake libtool
+$ cd ~/src
+$ git clone git://libdivecomputer.git.sourceforge.net/gitroot/libdivecomputer/libdivecomputer
+$ cd libdivecomputer
+$ git checkout release-0.4
+$ autoreconf --install
+$ ./configure
+$ make
+$ sudo make install
+
+6) Compile Subsurface
+
+$ cd ~/src
+$ git clone git://subsurface.hohndel.org/subsurface.git
+$ cd subsurface
+$ qmake
+$ make
+$ sudo make install
+
+After the above is done, Subsurface will be installed to
+/Applications.
+
+Another option is to create a .dmg for distribution:
+
+$ qmake
+$ make
+$ make mac-create-dmg
+
+Cross-building Subsurface on Linux for Windows
+----------------------------------------------
+
+Subsurface builds nicely with MinGW - the official builds are done as
+cross builds under Linux (currently on Fedora 17). A shell script to do
+that (plus the .nsi file to create the installer with makensis) are
+included in the packaging/Windows directory.
+
+The best way to get libdivecomputer to build appears to be
+
+$ git clone git://libdivecomputer.git.sourceforge.net/gitroot/libdivecomputer/libdivecomputer
+$ cd libdivecomputer
+$ git checkout release-0.4
+$ mingw32-configure
+$ mingw32-make
+$ sudo mingw32-make install
+
+To compile Subsurface, use:
+
+$ git clone git://subsurface.hohndel.org/subsurface.git
+$ cd subsurface
+$ i686-w64-mingw32-qmake-qt4
+$ make
+$ make install
+$ make create-windows-installer
+
+Building Subsurface on Windows
+------------------------------
+
+This is still work in progress.
+
+To build subsurface, use:
+
+$ git clone git://subsurface.hohndel.org/subsurface.git
+$ cd subsurface
+$ qmake
+$ make
+$ make install
+$ make create-windows-installer
+
+Build options
+-------------
+
+The following options are recognised when passed to qmake:
+
+ -config debug        Create a debug build
+ -config release      Create a release build
+                      The default depends on how Qt was built.
+ V=1                  Disable the "silent" build mode
+ LIBDCDEVEL=1         Search for libdivecomputer in ../libdivecomputer
+ INCLUDEPATH+=xxx     Add xxx to the include paths to the compiler
+                      (pass the actual path, without -I)
+ LIBS+=xxx            Add xxx to the linker flags. -l and -L options are
+                      recognised.
+
+The INCLUDEPATH and LIBS options are useful to tell the buildsystem
+about non-standard installation paths for the dependencies (such as
+Marble). They can be repeated as often as needed, or multiple
+arguments can be passed on the same switch, separated by a space. For
+example:
+
+  qmake LIBS+="-L$HOME/marble/lib -L$HOME/libdivecomputer/lib" \
+        INCLUDEPATH+="$HOME/marble/include $HOME/libdivecomputer/include"
diff --git a/README b/README
index 1b9f08d8b..11d7d3f6c 100644
--- a/README
+++ b/README
@@ -11,89 +11,6 @@ will get you the latest version of the fully functional Subsurface.
 
 git checkout Gtk
 
-If you are indeed planning to work on the Qt version, here are some
-pointers to get you started:
-
-Building the Qt version under Linux
------------------------------------
-
-On Debian you need libqt4-dev, libmarble-dev, libzip-dev.
-Unfortunately the marble version in Debian stable (and possibly
-Ubuntu) appears broken and missing essential header files used in the
-current git version of Subsurface. We hack around this right now by
-including this header file but this needs to be revisited before an
-actual release.
-
-On Fedora you need qt-devel, marble-devel, libzip-devel.
-
-Building the Qt version under MacOSX
-------------------------------------
-
-You might have built MacPorts packages with +quartz dependencies to
-build the previous Subsurface/Gtk version.  Switch to the +x11
-dependencies and prepare your system for Subsurface/Qt by doing:
-
-sudo port uninstall gtk-osx-application subsurface libdivecomputer
-sudo port install cairo +x11 pango +x11 py27-pygtk +x11 gtk2 +x11
-sudo port install qt4-mac marble libzip libtool libusb
-
-Then build libdivecomputer and Subsurface as described below.
-
-With the current version (and dependencies of marble), to run subsurface you have to once
-
-sudo port install dbus
-sudo launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist
-launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
-sudo chown -R ${USER} ~/Library/Preferences/KDE
-
-Buildling the Qt version under MacOSX, using dependencies from Homebrew
------------------------------------------------------------------------
-
-1)  Install Homebrew
-
-$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
-
-2) Install needed dependencies
-
-$ brew install asciidoc libzip qt sqlite cmake libusb pkg-config
-
-3) Make the brew version of sqlite the default
-
-$ brew link --force sqlite
-
-4) Install Marble
-
-$ mkdir -p ~/src/marble/build
-$ git clone -b KDE/4.11 git://anongit.kde.org/marble ~/src/marble/sources
-$ cd ~/src/marble/build
-$ cmake -DCMAKE_BUILD_TYPE=Debug -DQTONLY=TRUE -DCMAKE_INSTALL_PREFIX=/usr/local ~/src/marble/sources
-$ make
-$ sudo make install
-$ cd src/lib
-$ mkdir -p /usr/local/include/marble
-$ cp $(find . -name '*.h') /usr/local/include/marble/
-$ cp *dylib /usr/local/lib/
-
-5) Install Libdivecomputer
-
-$ brew install automake libtool
-$ cd ~/src
-$ git clone git://libdivecomputer.git.sourceforge.net/gitroot/libdivecomputer/libdivecomputer
-$ cd libdivecomputer
-$ git checkout release-0.4
-$ autoreconf --install
-$ ./configure
-$ make
-$ sudo make install
-
-6) Compile Subsurface
-
-$ cd ~/src
-$ git clone git://subsurface.hohndel.org/subsurface.git
-$ cd subsurface
-$ make
-
-
 Subsurface - an Open Source Divelog
 ===================================
 
@@ -154,95 +71,6 @@ can get a tar ball from
 
 http://subsurface.hohndel.org/downloads/Subsurface-3.1.tgz
 
-
-Building subsurface under Linux
--------------------------------
-You need libxml2-devel, libxslt-devel, gtk2-devel, glib2-devel,
-gconf2-devel, libsoup-devel, osm-gps-map-devel, libsqlite3x-devel, and
-libzip-devel to build this (and libusb-1.0 if you have libdivecomputer
-built with it, but then you obviously already have it installed).
-Check with your Linux distribution how to install these packages.
-
-On Debian the package names are different; try libxml2-dev,
-libgtk2.0-dev, libglib2.0-dev, libgconf2-dev, libsoup2.4-dev,
-libosmgpsmap-dev, libsqlite3-dev, libxslt1-dev, libzip-dev,
-zlib1g-dev (and libusb-1.0-0-dev if libdivecomputer is built with it).
-
-Note that contrary to earlier versions of Subsurface, starting in v3.1
-XSLT, LIBZIP and OSMGPSMAP are no longer optional but instead are
-required to build.
-
-You also need to have libdivecomputer installed. The current git
-versions of Subsurface assume that you use libdivecomputer version
-0.4, which goes something like this:
-
-git clone git://git.libdivecomputer.org/libdivecomputer
-cd libdivecomputer
-git checkout release-0.4
-autoreconf --install
-./configure
-make
-sudo make install
-
-NOTE! Sometimes you may need to tell the main Subsurface Makefile where
-you installed libdivecomputer; pkg-config for libdivecomputer doesn't
-always work unless the project has been installed by the distro.
-
-Just edit the makefile directly.
-
-
-Building Subsurface under Windows
----------------------------------
-Subsurface builds nicely with MinGW - the official builds are done as
-cross builds under Linux (currently on Fedora 17). A shell script to do
-that (plus the .nsi file to create the installer with makensis) are
-included in the packaging/Windows directory.
-
-Strangely the developers have failed to make 'https' support work in
-the cross-built Windows binaries. As a workaround at this point the
-cross built Windows binaries use http instead https connections (right
-now this only applies to divelogs.de uploads).
-
-The best way to get libdivecomputer to build appears to be
-
-mingw32-configure
-mingw32-make
-sudo mingw32-make install
-
-Once you have built and installed libdivecomputer you can use
-
-sh packaging/Windows/mingw-make.sh
-
-to then build subsurface. In order to create an installer simply use
-
-sh packaging/Windows/mingw-make.sh create-windows-installer
-
-
-Building subsurface on a Mac
-----------------------------
-Install MacPorts and install the dependencies from MacPorts:
-
-sudo port install libusb libtool libzip qt4-mac marble
-
-Install libdivecomputer:
-git clone git://git.libdivecomputer.org/libdivecomputer
-cd libdivecomputer
-git checkout release-0.4
-autoreconf --install
-LIBUSB_CFLAGS=-I/opt/local/include ./configure
-make
-sudo make install
-
-Install subsurface:
-git clone git://subsurface.hohndel.org/subsurface.git
-cd subsurface
-PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" make
-sudo make install-macosx
-
-More instructions on how to create a Subsurface DMG can be found in
-packaging/macosx/README
-
-
 Usage:
 ======
 

From f51f5d581ed14363e6ebc6684d5904e7d59616c4 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 23:44:45 -0700
Subject: [PATCH 12/13] Don't turn warnings on in Subsurface's build

We're getting a ton of them and they're mostly harmless. I've already
turned on the ones that are problematic (with -Werror even).

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 subsurface-configure.pri | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/subsurface-configure.pri b/subsurface-configure.pri
index 93f14003c..ef4bb8e65 100644
--- a/subsurface-configure.pri
+++ b/subsurface-configure.pri
@@ -8,6 +8,9 @@
 *-g++*: QMAKE_CFLAGS += -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=implicit-int
 !win32-msvc*: QMAKE_CFLAGS += -std=gnu99
 
+# Don't turn warnings on (but don't suppress them either)
+CONFIG -= warn_on warn_off
+
 # Check if we have pkg-config
 equals($$QMAKE_HOST.os, "Windows"):NUL=NUL
 else:NUL=/dev/null

From dddcd1016218a1b9b9662be078665e24d46efbac Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago@macieira.org>
Date: Tue, 8 Oct 2013 23:45:38 -0700
Subject: [PATCH 13/13] Turn off exceptions in C++

We don't use them in our code and Qt doesn't throw either, so save a
few bytes and maybe a few setjump() calls on Windows.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
---
 subsurface-configure.pri | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/subsurface-configure.pri b/subsurface-configure.pri
index ef4bb8e65..7836594dc 100644
--- a/subsurface-configure.pri
+++ b/subsurface-configure.pri
@@ -11,6 +11,10 @@
 # Don't turn warnings on (but don't suppress them either)
 CONFIG -= warn_on warn_off
 
+# Turn exceptions off
+!win32-msvc*: QMAKE_CXXFLAGS += -fno-exceptions
+CONFIG += exceptions_off
+
 # Check if we have pkg-config
 equals($$QMAKE_HOST.os, "Windows"):NUL=NUL
 else:NUL=/dev/null