From d326a91c865caff097af9b1736740291fb3e63ac Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 22:46:38 -0700 Subject: [PATCH 01/19] Move some of the checks a little bit up Signed-off-by: Thiago Macieira --- Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 076b5f123..56f2c7941 100644 --- a/Makefile +++ b/Makefile @@ -114,8 +114,20 @@ endif # we need GLIB2CFLAGS for gettext QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS) LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) +ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) + QTCXXFLAGS += -fPIE +endif LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) +ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) + LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) + GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) +else ifeq ($(UNAME), darwin) + LIBGTK += $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation -framework CoreServices + GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) + GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler +endif + LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB) @@ -145,13 +157,8 @@ ifneq ($(strip $(LIBSQLITE3)),) endif ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) - GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) OSSUPPORT = linux OSSUPPORT_CFLAGS = $(GTKCFLAGS) $(GCONF2CFLAGS) - ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) - CXXFLAGS += -fPIE - endif else ifeq ($(UNAME), darwin) OSSUPPORT = macos OSSUPPORT_CFLAGS = $(GTKCFLAGS) @@ -160,10 +167,7 @@ else ifeq ($(UNAME), darwin) MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app INFOPLIST = $(MACOSXFILES)/Info.plist INFOPLISTINPUT = $(INFOPLIST).in - EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation -framework CoreServices - CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) - GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler else OSSUPPORT = windows OSSUPPORT_CFLAGS = $(GTKCFLAGS) From e9ec2dcc455450262b56a901e9d397988d384480 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 23:09:23 -0700 Subject: [PATCH 02/19] Split the SQLite3, libzip, libxslt and osmgpsmap detection from use Signed-off-by: Thiago Macieira --- Makefile | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 56f2c7941..0eade3f36 100644 --- a/Makefile +++ b/Makefile @@ -136,25 +136,17 @@ LIBXSLT = $(shell $(XSLCONFIG) --libs) XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) GTKCFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0) -CFLAGS += $(shell $(XSLCONFIG) --cflags) +XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) -ifneq ($(strip $(LIBOSMGPSMAP)),) - GPSOBJ = gps.o - CFLAGS += -DHAVE_OSM_GPS_MAP -endif LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null) -ifneq ($(strip $(LIBZIP)),) - ZIP = -DLIBZIP $(shell $(PKGCONFIG) --cflags libzip) -endif +ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null) -ifneq ($(strip $(LIBSQLITE3)),) - SQLITE3 = -DSQLITE3 $(shell $(PKGCONFIG) --cflags sqlite3) -endif +SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3)) ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) OSSUPPORT = linux @@ -179,9 +171,6 @@ else XSLTDIR = .\\xslt endif -ifneq ($(strip $(LIBXSLT)),) - XSLT=-DXSLT='"$(XSLTDIR)"' -endif LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) \ $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) @@ -198,7 +187,7 @@ GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o deco.o planner.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ - webservice.o sha1.o $(GPSOBJ) $(OSSUPPORT).o $(RESFILE) $(QTOBJS) $(GTKOBJS) + webservice.o sha1.o $(OSSUPPORT).o $(RESFILE) $(QTOBJS) $(GTKOBJS) # Add files to the following variables if the auto-detection based on the # filename fails @@ -315,8 +304,22 @@ update-po-files: tx pull -af EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ - $(XSLT) $(ZIP) $(SQLITE3) $(LIBDIVECOMPUTERCFLAGS) \ - $(LIBSOUPCFLAGS) $(OSMGPSMAPFLAGS) $(GCONF2CFLAGS) + $(LIBDIVECOMPUTERCFLAGS) \ + $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) + +ifneq ($(SQLITE3FLAGS),) + EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) +endif +ifneq ($(ZIPFLAGS),) + EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) +endif +ifneq ($(strip $(LIBXSLT)),) + EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) +endif +ifneq ($(strip $(LIBOSMGPSMAP)),) + OBJS += gps.o + EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) +endif MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $(EXTRA_FLAGS)) From 83309d93692b7db7b6fce8c6c1f17eee228d626d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 23:13:10 -0700 Subject: [PATCH 03/19] Move the list of objects a little further up This also implies we don't need the OSSUPPORT variable anymore. We simply add to OBJS. Signed-off-by: Thiago Macieira --- Makefile | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 0eade3f36..b699b56f2 100644 --- a/Makefile +++ b/Makefile @@ -148,11 +148,22 @@ ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null) SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3)) +QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ + qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o + +GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o + +OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o \ + planner.o planner-gtk.o \ + parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ + qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ + webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) + ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - OSSUPPORT = linux + OBJS += linux.o OSSUPPORT_CFLAGS = $(GTKCFLAGS) $(GCONF2CFLAGS) else ifeq ($(UNAME), darwin) - OSSUPPORT = macos + OBJS += macos.o OSSUPPORT_CFLAGS = $(GTKCFLAGS) MACOSXINSTALL = /Applications/Subsurface.app MACOSXFILES = packaging/macosx @@ -161,7 +172,7 @@ else ifeq ($(UNAME), darwin) INFOPLISTINPUT = $(INFOPLIST).in LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) else - OSSUPPORT = windows + OBSJ += windows.o OSSUPPORT_CFLAGS = $(GTKCFLAGS) WINDOWSSTAGING = ./packaging/windows WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) @@ -179,16 +190,6 @@ MSGLANGS=$(notdir $(wildcard po/*.po)) MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) -QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ - qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o - -GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o - -OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o deco.o planner.o \ - parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ - qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ - webservice.o sha1.o $(OSSUPPORT).o $(RESFILE) $(QTOBJS) $(GTKOBJS) - # Add files to the following variables if the auto-detection based on the # filename fails OBJS_NEEDING_MOC = From 50420d48d93a79866d34b0462625531257cb6151 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 23:15:35 -0700 Subject: [PATCH 04/19] Remove the unused OSSUPPORT_CFLAGS variable Signed-off-by: Thiago Macieira --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index b699b56f2..37dc3437d 100644 --- a/Makefile +++ b/Makefile @@ -161,10 +161,8 @@ OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) OBJS += linux.o - OSSUPPORT_CFLAGS = $(GTKCFLAGS) $(GCONF2CFLAGS) else ifeq ($(UNAME), darwin) OBJS += macos.o - OSSUPPORT_CFLAGS = $(GTKCFLAGS) MACOSXINSTALL = /Applications/Subsurface.app MACOSXFILES = packaging/macosx MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app @@ -173,7 +171,6 @@ else ifeq ($(UNAME), darwin) LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) else OBSJ += windows.o - OSSUPPORT_CFLAGS = $(GTKCFLAGS) WINDOWSSTAGING = ./packaging/windows WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in From 77ebc2f4c854748edaff6bc518e105b56f656a47 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 23:18:36 -0700 Subject: [PATCH 05/19] Move the MSGOBJS variable definition a little further down Move it closer to the actual rules. This is not a variable that we'll usually modify. Signed-off-by: Thiago Macieira --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 37dc3437d..c5f72ccf8 100644 --- a/Makefile +++ b/Makefile @@ -184,8 +184,6 @@ LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIB $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) MSGLANGS=$(notdir $(wildcard po/*.po)) -MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) - # Add files to the following variables if the auto-detection based on the # filename fails @@ -193,6 +191,8 @@ OBJS_NEEDING_MOC = OBJS_NEEDING_UIC = HEADERS_NEEDING_MOC = +MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) + # Add the objects for the header files which define QObject subclasses HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(OBJS:.o=.h)) MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) From ddbb942d0fce58f5ef7335f23da703ddb721bcf9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 23:26:33 -0700 Subject: [PATCH 06/19] Reorder the Makefile Create three sections: 1) the detection rules 2) the main rules, what we usually edit 3) the build rules, which we usually don't change Signed-off-by: Thiago Macieira --- Makefile | 112 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index c5f72ccf8..e882a353d 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE CXX=g++ CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS INSTALL=install + +# This are the detection rules PKGCONFIG=pkg-config XML2CONFIG=xml2-config XSLCONFIG=xslt-config @@ -12,40 +14,7 @@ QMAKE=qmake MOC=moc UIC=uic -# these locations seem to work for SuSE and Fedora -# prefix = $(HOME) -prefix = $(DESTDIR)/usr -BINDIR = $(prefix)/bin -DATADIR = $(prefix)/share -DESKTOPDIR = $(DATADIR)/applications -ICONPATH = $(DATADIR)/icons/hicolor -ICONDIR = $(ICONPATH)/scalable/apps -MANDIR = $(DATADIR)/man/man1 -XSLTDIR = $(DATADIR)/subsurface/xslt -gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) - -NAME = subsurface -ICONFILE = $(NAME)-icon.svg -DESKTOPFILE = $(NAME).desktop -MANFILES = $(NAME).1 -XSLTFILES = xslt/*.xslt - -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 - UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win|gnu|kfreebsd") -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") # find libdivecomputer # First deal with the cross compile environment and with Mac. @@ -148,6 +117,30 @@ ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null) SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3)) +# These are the main rules + +# these locations seem to work for SuSE and Fedora +# prefix = $(HOME) +prefix = $(DESTDIR)/usr +BINDIR = $(prefix)/bin +DATADIR = $(prefix)/share +DESKTOPDIR = $(DATADIR)/applications +ICONPATH = $(DATADIR)/icons/hicolor +ICONDIR = $(ICONPATH)/scalable/apps +MANDIR = $(DATADIR)/man/man1 +XSLTDIR = $(DATADIR)/subsurface/xslt +gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) + +NAME = subsurface +ICONFILE = $(NAME)-icon.svg +DESKTOPFILE = $(NAME).desktop +MANFILES = $(NAME).1 +XSLTFILES = xslt/*.xslt + +EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ + $(LIBDIVECOMPUTERCFLAGS) \ + $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) + QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o @@ -159,6 +152,20 @@ OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) +ifneq ($(SQLITE3FLAGS),) + EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) +endif +ifneq ($(ZIPFLAGS),) + EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) +endif +ifneq ($(strip $(LIBXSLT)),) + EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) +endif +ifneq ($(strip $(LIBOSMGPSMAP)),) + OBJS += gps.o + EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) +endif + ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) OBJS += linux.o else ifeq ($(UNAME), darwin) @@ -179,7 +186,6 @@ else XSLTDIR = .\\xslt endif - LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) \ $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) @@ -191,6 +197,26 @@ OBJS_NEEDING_MOC = OBJS_NEEDING_UIC = HEADERS_NEEDING_MOC = +# These are the generic rules for building + +# 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/subsurface.mo)) # Add the objects for the header files which define QObject subclasses @@ -301,24 +327,6 @@ update-po-files: tx push -s tx pull -af -EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ - $(LIBDIVECOMPUTERCFLAGS) \ - $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) - -ifneq ($(SQLITE3FLAGS),) - EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) -endif -ifneq ($(ZIPFLAGS),) - EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) -endif -ifneq ($(strip $(LIBXSLT)),) - EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) -endif -ifneq ($(strip $(LIBOSMGPSMAP)),) - OBJS += gps.o - EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) -endif - MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $(EXTRA_FLAGS)) %.o: %.c From f6d133f3872d700a7c99be515bc1369f265f550a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 22 Apr 2013 23:28:29 -0700 Subject: [PATCH 07/19] Create Rules.mk and Configure.mk by copying the Makefile This is to help Git know that the two files are the same content as the Makefile. The next commit will trim the files to what they need to be. --- Configure.mk | 400 +++++++++++++++++++++++++++++++++++++++++++++++++++ Rules.mk | 400 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 800 insertions(+) create mode 100644 Configure.mk create mode 100644 Rules.mk diff --git a/Configure.mk b/Configure.mk new file mode 100644 index 000000000..e882a353d --- /dev/null +++ b/Configure.mk @@ -0,0 +1,400 @@ +VERSION=3.0.2 + +CC=gcc +CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE +CXX=g++ +CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS +INSTALL=install + +# This are the detection rules +PKGCONFIG=pkg-config +XML2CONFIG=xml2-config +XSLCONFIG=xslt-config +QMAKE=qmake +MOC=moc +UIC=uic + +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 +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 ($(LIBDCDEVEL),) + LIBDIVECOMPUTERDIR = ../libdivecomputer + LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include + LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/src/.libs/libdivecomputer.a +else 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) + +# 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 +else + QT_MODULES = QtGui QtSvg + QT_CORE = QtCore +endif + +# we need GLIB2CFLAGS for gettext +QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS) +LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) +ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) + QTCXXFLAGS += -fPIE +endif + +LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) +ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) + LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) + GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) +else ifeq ($(UNAME), darwin) + LIBGTK += $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation -framework CoreServices + GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) + GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler +endif + +LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) +LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB) + +LIBXML2 = $(shell $(XML2CONFIG) --libs) +LIBXSLT = $(shell $(XSLCONFIG) --libs) +XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) +GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) +GTKCFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0) +XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) +OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) +LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) +LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) +LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) + +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)) + +# These are the main rules + +# these locations seem to work for SuSE and Fedora +# prefix = $(HOME) +prefix = $(DESTDIR)/usr +BINDIR = $(prefix)/bin +DATADIR = $(prefix)/share +DESKTOPDIR = $(DATADIR)/applications +ICONPATH = $(DATADIR)/icons/hicolor +ICONDIR = $(ICONPATH)/scalable/apps +MANDIR = $(DATADIR)/man/man1 +XSLTDIR = $(DATADIR)/subsurface/xslt +gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) + +NAME = subsurface +ICONFILE = $(NAME)-icon.svg +DESKTOPFILE = $(NAME).desktop +MANFILES = $(NAME).1 +XSLTFILES = xslt/*.xslt + +EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ + $(LIBDIVECOMPUTERCFLAGS) \ + $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) + +QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ + qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o + +GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o + +OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o \ + planner.o planner-gtk.o \ + parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ + qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ + webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) + +ifneq ($(SQLITE3FLAGS),) + EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) +endif +ifneq ($(ZIPFLAGS),) + EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) +endif +ifneq ($(strip $(LIBXSLT)),) + EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) +endif +ifneq ($(strip $(LIBOSMGPSMAP)),) + OBJS += gps.o + EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) +endif + +ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) + OBJS += linux.o +else ifeq ($(UNAME), darwin) + OBJS += macos.o + MACOSXINSTALL = /Applications/Subsurface.app + MACOSXFILES = packaging/macosx + MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app + INFOPLIST = $(MACOSXFILES)/Info.plist + INFOPLISTINPUT = $(INFOPLIST).in + LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) +else + OBSJ += windows.o + WINDOWSSTAGING = ./packaging/windows + WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) + NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in + NSIFILE = $(WINDOWSSTAGING)/subsurface.nsi + MAKENSIS = makensis + XSLTDIR = .\\xslt +endif + +LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) \ + $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) + +MSGLANGS=$(notdir $(wildcard po/*.po)) + +# Add files to the following variables if the auto-detection based on the +# filename fails +OBJS_NEEDING_MOC = +OBJS_NEEDING_UIC = +HEADERS_NEEDING_MOC = + +# These are the generic rules for building + +# 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/subsurface.mo)) + +# Add the objects for the header files which define QObject subclasses +HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(OBJS:.o=.h)) +MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) + +ALL_OBJS = $(OBJS) $(MOC_OBJS) + +DEPS = $(wildcard .dep/*.dep) + +all: $(NAME) + +$(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) + $(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) + +gen_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)/subsurface; \ + $(INSTALL) -d -m 755 $(XSLTDIR); \ + $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \ + fi + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d $(prefix)/$$LOC; \ + $(INSTALL) -m 644 $$LOC/subsurface.mo $(prefix)/$$LOC/subsurface.mo; \ + 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)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \ + done + @-if test ! -z "$(XSLT)"; then \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/xslt; \ + $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXINSTALL)/Contents/Resources/xslt/; \ + fi + + +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)/Subsurface.icns $(MACOSXSTAGING)/Contents/Resources/ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/subsurface.mo; \ + done + @-if test ! -z "$(XSLT)"; then \ + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/xslt; \ + $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXSTAGING)/Contents/Resources/xslt/; \ + fi + $(GTK_MAC_BUNDLER) packaging/macosx/subsurface.bundle + +sign-macosx-bundle: all + codesign -s "3A8CE62A483083EDEA5581A61E770EC1FA8BECE8" /Applications/Subsurface.app/Contents/MacOS/subsurface-bin + +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/subsurface.mo $(WINDOWSSTAGING)/$$LOC/subsurface.mo; \ + 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/subsurface-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 + @echo ' CC' $< + @mkdir -p .dep .dep/qt-ui + @$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< + +%.o: %.cpp + @echo ' CXX' $< + @mkdir -p .dep .dep/qt-ui + @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< + +# Detect which files require the moc or uic tools to be run +CPP_NEEDING_MOC = $(shell grep -l -s '^\#include \".*\.moc\"' $(OBJS:.o=.cpp)) +OBJS_NEEDING_MOC += $(CPP_NEEDING_MOC:.cpp=.o) + +CPP_NEEDING_UIC = $(shell grep -l -s '^\#include \"ui_.*\.h\"' $(OBJS:.o=.cpp)) +OBJS_NEEDING_UIC += $(CPP_NEEDING_UIC:.cpp=.o) + +# This rule is for running the moc on QObject subclasses defined in the .h +# files. +%.moc.cpp: %.h + @echo ' MOC' $< + @$(MOC) $(MOCFLAGS) $< -o $@ + +# This rule is for running the moc on QObject subclasses defined in the .cpp +# files; remember to #include ".moc" at the end of the .cpp file, or +# you'll get linker errors ("undefined vtable for...") +%.moc: %.cpp + @echo ' MOC' $< + @$(MOC) -i $(MOCFLAGS) $< -o $@ + +# This creates the ui headers. +ui_%.h: %.ui + @echo ' UIC' $< + @$(UIC) $< -o $@ + +$(OBJS_NEEDING_MOC): %.o: %.moc +$(OBJS_NEEDING_UIC): qt-ui/%.o: qt-ui/ui_%.h + +share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases + mkdir -p $(dir $@) + 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) $(NAME).exe po/*~ po/subsurface-new.pot \ + $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h + rm -rf share .dep + +-include $(DEPS) diff --git a/Rules.mk b/Rules.mk new file mode 100644 index 000000000..e882a353d --- /dev/null +++ b/Rules.mk @@ -0,0 +1,400 @@ +VERSION=3.0.2 + +CC=gcc +CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE +CXX=g++ +CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS +INSTALL=install + +# This are the detection rules +PKGCONFIG=pkg-config +XML2CONFIG=xml2-config +XSLCONFIG=xslt-config +QMAKE=qmake +MOC=moc +UIC=uic + +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 +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 ($(LIBDCDEVEL),) + LIBDIVECOMPUTERDIR = ../libdivecomputer + LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include + LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/src/.libs/libdivecomputer.a +else 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) + +# 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 +else + QT_MODULES = QtGui QtSvg + QT_CORE = QtCore +endif + +# we need GLIB2CFLAGS for gettext +QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS) +LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) +ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) + QTCXXFLAGS += -fPIE +endif + +LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) +ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) + LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) + GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) +else ifeq ($(UNAME), darwin) + LIBGTK += $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation -framework CoreServices + GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) + GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler +endif + +LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) +LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB) + +LIBXML2 = $(shell $(XML2CONFIG) --libs) +LIBXSLT = $(shell $(XSLCONFIG) --libs) +XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) +GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) +GTKCFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0) +XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) +OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) +LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) +LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) +LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) + +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)) + +# These are the main rules + +# these locations seem to work for SuSE and Fedora +# prefix = $(HOME) +prefix = $(DESTDIR)/usr +BINDIR = $(prefix)/bin +DATADIR = $(prefix)/share +DESKTOPDIR = $(DATADIR)/applications +ICONPATH = $(DATADIR)/icons/hicolor +ICONDIR = $(ICONPATH)/scalable/apps +MANDIR = $(DATADIR)/man/man1 +XSLTDIR = $(DATADIR)/subsurface/xslt +gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) + +NAME = subsurface +ICONFILE = $(NAME)-icon.svg +DESKTOPFILE = $(NAME).desktop +MANFILES = $(NAME).1 +XSLTFILES = xslt/*.xslt + +EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ + $(LIBDIVECOMPUTERCFLAGS) \ + $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) + +QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ + qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o + +GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o + +OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o \ + planner.o planner-gtk.o \ + parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ + qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ + webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) + +ifneq ($(SQLITE3FLAGS),) + EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) +endif +ifneq ($(ZIPFLAGS),) + EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) +endif +ifneq ($(strip $(LIBXSLT)),) + EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) +endif +ifneq ($(strip $(LIBOSMGPSMAP)),) + OBJS += gps.o + EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) +endif + +ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) + OBJS += linux.o +else ifeq ($(UNAME), darwin) + OBJS += macos.o + MACOSXINSTALL = /Applications/Subsurface.app + MACOSXFILES = packaging/macosx + MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app + INFOPLIST = $(MACOSXFILES)/Info.plist + INFOPLISTINPUT = $(INFOPLIST).in + LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) +else + OBSJ += windows.o + WINDOWSSTAGING = ./packaging/windows + WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) + NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in + NSIFILE = $(WINDOWSSTAGING)/subsurface.nsi + MAKENSIS = makensis + XSLTDIR = .\\xslt +endif + +LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) \ + $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) + +MSGLANGS=$(notdir $(wildcard po/*.po)) + +# Add files to the following variables if the auto-detection based on the +# filename fails +OBJS_NEEDING_MOC = +OBJS_NEEDING_UIC = +HEADERS_NEEDING_MOC = + +# These are the generic rules for building + +# 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/subsurface.mo)) + +# Add the objects for the header files which define QObject subclasses +HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(OBJS:.o=.h)) +MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) + +ALL_OBJS = $(OBJS) $(MOC_OBJS) + +DEPS = $(wildcard .dep/*.dep) + +all: $(NAME) + +$(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) + $(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) + +gen_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)/subsurface; \ + $(INSTALL) -d -m 755 $(XSLTDIR); \ + $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \ + fi + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d $(prefix)/$$LOC; \ + $(INSTALL) -m 644 $$LOC/subsurface.mo $(prefix)/$$LOC/subsurface.mo; \ + 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)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \ + done + @-if test ! -z "$(XSLT)"; then \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/xslt; \ + $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXINSTALL)/Contents/Resources/xslt/; \ + fi + + +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)/Subsurface.icns $(MACOSXSTAGING)/Contents/Resources/ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/subsurface.mo; \ + done + @-if test ! -z "$(XSLT)"; then \ + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/xslt; \ + $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXSTAGING)/Contents/Resources/xslt/; \ + fi + $(GTK_MAC_BUNDLER) packaging/macosx/subsurface.bundle + +sign-macosx-bundle: all + codesign -s "3A8CE62A483083EDEA5581A61E770EC1FA8BECE8" /Applications/Subsurface.app/Contents/MacOS/subsurface-bin + +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/subsurface.mo $(WINDOWSSTAGING)/$$LOC/subsurface.mo; \ + 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/subsurface-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 + @echo ' CC' $< + @mkdir -p .dep .dep/qt-ui + @$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< + +%.o: %.cpp + @echo ' CXX' $< + @mkdir -p .dep .dep/qt-ui + @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< + +# Detect which files require the moc or uic tools to be run +CPP_NEEDING_MOC = $(shell grep -l -s '^\#include \".*\.moc\"' $(OBJS:.o=.cpp)) +OBJS_NEEDING_MOC += $(CPP_NEEDING_MOC:.cpp=.o) + +CPP_NEEDING_UIC = $(shell grep -l -s '^\#include \"ui_.*\.h\"' $(OBJS:.o=.cpp)) +OBJS_NEEDING_UIC += $(CPP_NEEDING_UIC:.cpp=.o) + +# This rule is for running the moc on QObject subclasses defined in the .h +# files. +%.moc.cpp: %.h + @echo ' MOC' $< + @$(MOC) $(MOCFLAGS) $< -o $@ + +# This rule is for running the moc on QObject subclasses defined in the .cpp +# files; remember to #include ".moc" at the end of the .cpp file, or +# you'll get linker errors ("undefined vtable for...") +%.moc: %.cpp + @echo ' MOC' $< + @$(MOC) -i $(MOCFLAGS) $< -o $@ + +# This creates the ui headers. +ui_%.h: %.ui + @echo ' UIC' $< + @$(UIC) $< -o $@ + +$(OBJS_NEEDING_MOC): %.o: %.moc +$(OBJS_NEEDING_UIC): qt-ui/%.o: qt-ui/ui_%.h + +share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases + mkdir -p $(dir $@) + 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) $(NAME).exe po/*~ po/subsurface-new.pot \ + $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h + rm -rf share .dep + +-include $(DEPS) From d47b9045802f5f05dfafad982cdf4ab4b86a2c2c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 12 Apr 2013 23:42:14 -0700 Subject: [PATCH 08/19] Trim Makefile, Configure.mk and Rules.mk Configure.mk contains the detection rules, whereas Rules.mk contains the rules to actually build Subsurface. This simplifies Makefile greatly, which is the file that should be actually modified during regular updates to the codebase. Signed-off-by: Thiago Macieira --- Configure.mk | 292 +---------------------------------------------- Makefile | 316 +-------------------------------------------------- Rules.mk | 202 +------------------------------- 3 files changed, 5 insertions(+), 805 deletions(-) diff --git a/Configure.mk b/Configure.mk index e882a353d..f9b9e0674 100644 --- a/Configure.mk +++ b/Configure.mk @@ -1,12 +1,6 @@ -VERSION=3.0.2 +# -*- Makefile -*- +# This file contains the detection rules -CC=gcc -CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE -CXX=g++ -CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS -INSTALL=install - -# This are the detection rules PKGCONFIG=pkg-config XML2CONFIG=xml2-config XSLCONFIG=xslt-config @@ -116,285 +110,3 @@ ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null) SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3)) - -# These are the main rules - -# these locations seem to work for SuSE and Fedora -# prefix = $(HOME) -prefix = $(DESTDIR)/usr -BINDIR = $(prefix)/bin -DATADIR = $(prefix)/share -DESKTOPDIR = $(DATADIR)/applications -ICONPATH = $(DATADIR)/icons/hicolor -ICONDIR = $(ICONPATH)/scalable/apps -MANDIR = $(DATADIR)/man/man1 -XSLTDIR = $(DATADIR)/subsurface/xslt -gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) - -NAME = subsurface -ICONFILE = $(NAME)-icon.svg -DESKTOPFILE = $(NAME).desktop -MANFILES = $(NAME).1 -XSLTFILES = xslt/*.xslt - -EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ - $(LIBDIVECOMPUTERCFLAGS) \ - $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) - -QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ - qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o - -GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o - -OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o \ - planner.o planner-gtk.o \ - parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ - qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ - webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) - -ifneq ($(SQLITE3FLAGS),) - EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) -endif -ifneq ($(ZIPFLAGS),) - EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) -endif -ifneq ($(strip $(LIBXSLT)),) - EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) -endif -ifneq ($(strip $(LIBOSMGPSMAP)),) - OBJS += gps.o - EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) -endif - -ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - OBJS += linux.o -else ifeq ($(UNAME), darwin) - OBJS += macos.o - MACOSXINSTALL = /Applications/Subsurface.app - MACOSXFILES = packaging/macosx - MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app - INFOPLIST = $(MACOSXFILES)/Info.plist - INFOPLISTINPUT = $(INFOPLIST).in - LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) -else - OBSJ += windows.o - WINDOWSSTAGING = ./packaging/windows - WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) - NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in - NSIFILE = $(WINDOWSSTAGING)/subsurface.nsi - MAKENSIS = makensis - XSLTDIR = .\\xslt -endif - -LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) \ - $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) - -MSGLANGS=$(notdir $(wildcard po/*.po)) - -# Add files to the following variables if the auto-detection based on the -# filename fails -OBJS_NEEDING_MOC = -OBJS_NEEDING_UIC = -HEADERS_NEEDING_MOC = - -# These are the generic rules for building - -# 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/subsurface.mo)) - -# Add the objects for the header files which define QObject subclasses -HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(OBJS:.o=.h)) -MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) - -ALL_OBJS = $(OBJS) $(MOC_OBJS) - -DEPS = $(wildcard .dep/*.dep) - -all: $(NAME) - -$(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) - $(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) - -gen_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)/subsurface; \ - $(INSTALL) -d -m 755 $(XSLTDIR); \ - $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \ - fi - for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ - $(INSTALL) -d $(prefix)/$$LOC; \ - $(INSTALL) -m 644 $$LOC/subsurface.mo $(prefix)/$$LOC/subsurface.mo; \ - 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)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ - for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ - $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ - $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \ - done - @-if test ! -z "$(XSLT)"; then \ - $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/xslt; \ - $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXINSTALL)/Contents/Resources/xslt/; \ - fi - - -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)/Subsurface.icns $(MACOSXSTAGING)/Contents/Resources/ - for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ - $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \ - $(INSTALL) $$LOC/subsurface.mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/subsurface.mo; \ - done - @-if test ! -z "$(XSLT)"; then \ - $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/xslt; \ - $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXSTAGING)/Contents/Resources/xslt/; \ - fi - $(GTK_MAC_BUNDLER) packaging/macosx/subsurface.bundle - -sign-macosx-bundle: all - codesign -s "3A8CE62A483083EDEA5581A61E770EC1FA8BECE8" /Applications/Subsurface.app/Contents/MacOS/subsurface-bin - -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/subsurface.mo $(WINDOWSSTAGING)/$$LOC/subsurface.mo; \ - 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/subsurface-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 - @echo ' CC' $< - @mkdir -p .dep .dep/qt-ui - @$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< - -%.o: %.cpp - @echo ' CXX' $< - @mkdir -p .dep .dep/qt-ui - @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< - -# Detect which files require the moc or uic tools to be run -CPP_NEEDING_MOC = $(shell grep -l -s '^\#include \".*\.moc\"' $(OBJS:.o=.cpp)) -OBJS_NEEDING_MOC += $(CPP_NEEDING_MOC:.cpp=.o) - -CPP_NEEDING_UIC = $(shell grep -l -s '^\#include \"ui_.*\.h\"' $(OBJS:.o=.cpp)) -OBJS_NEEDING_UIC += $(CPP_NEEDING_UIC:.cpp=.o) - -# This rule is for running the moc on QObject subclasses defined in the .h -# files. -%.moc.cpp: %.h - @echo ' MOC' $< - @$(MOC) $(MOCFLAGS) $< -o $@ - -# This rule is for running the moc on QObject subclasses defined in the .cpp -# files; remember to #include ".moc" at the end of the .cpp file, or -# you'll get linker errors ("undefined vtable for...") -%.moc: %.cpp - @echo ' MOC' $< - @$(MOC) -i $(MOCFLAGS) $< -o $@ - -# This creates the ui headers. -ui_%.h: %.ui - @echo ' UIC' $< - @$(UIC) $< -o $@ - -$(OBJS_NEEDING_MOC): %.o: %.moc -$(OBJS_NEEDING_UIC): qt-ui/%.o: qt-ui/ui_%.h - -share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases - mkdir -p $(dir $@) - 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) $(NAME).exe po/*~ po/subsurface-new.pot \ - $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h - rm -rf share .dep - --include $(DEPS) diff --git a/Makefile b/Makefile index e882a353d..3308c9f41 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +include Configure.mk VERSION=3.0.2 CC=gcc @@ -6,119 +7,6 @@ CXX=g++ CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS INSTALL=install -# This are the detection rules -PKGCONFIG=pkg-config -XML2CONFIG=xml2-config -XSLCONFIG=xslt-config -QMAKE=qmake -MOC=moc -UIC=uic - -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 -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 ($(LIBDCDEVEL),) - LIBDIVECOMPUTERDIR = ../libdivecomputer - LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include - LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/src/.libs/libdivecomputer.a -else 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) - -# 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 -else - QT_MODULES = QtGui QtSvg - QT_CORE = QtCore -endif - -# we need GLIB2CFLAGS for gettext -QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS) -LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) -ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) - QTCXXFLAGS += -fPIE -endif - -LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) -ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) - GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) -else ifeq ($(UNAME), darwin) - LIBGTK += $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation -framework CoreServices - GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) - GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler -endif - -LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) -LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB) - -LIBXML2 = $(shell $(XML2CONFIG) --libs) -LIBXSLT = $(shell $(XSLCONFIG) --libs) -XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) -GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) -GTKCFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0) -XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) -OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) -LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) -LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) -LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) - -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)) - -# These are the main rules - # these locations seem to work for SuSE and Fedora # prefix = $(HOME) prefix = $(DESTDIR)/usr @@ -197,204 +85,4 @@ OBJS_NEEDING_MOC = OBJS_NEEDING_UIC = HEADERS_NEEDING_MOC = -# These are the generic rules for building - -# 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/subsurface.mo)) - -# Add the objects for the header files which define QObject subclasses -HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(OBJS:.o=.h)) -MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) - -ALL_OBJS = $(OBJS) $(MOC_OBJS) - -DEPS = $(wildcard .dep/*.dep) - -all: $(NAME) - -$(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) - $(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) - -gen_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)/subsurface; \ - $(INSTALL) -d -m 755 $(XSLTDIR); \ - $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \ - fi - for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ - $(INSTALL) -d $(prefix)/$$LOC; \ - $(INSTALL) -m 644 $$LOC/subsurface.mo $(prefix)/$$LOC/subsurface.mo; \ - 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)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ - for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ - $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ - $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \ - done - @-if test ! -z "$(XSLT)"; then \ - $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/xslt; \ - $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXINSTALL)/Contents/Resources/xslt/; \ - fi - - -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)/Subsurface.icns $(MACOSXSTAGING)/Contents/Resources/ - for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ - $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \ - $(INSTALL) $$LOC/subsurface.mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/subsurface.mo; \ - done - @-if test ! -z "$(XSLT)"; then \ - $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/xslt; \ - $(INSTALL) -m 644 $(XSLTFILES) $(MACOSXSTAGING)/Contents/Resources/xslt/; \ - fi - $(GTK_MAC_BUNDLER) packaging/macosx/subsurface.bundle - -sign-macosx-bundle: all - codesign -s "3A8CE62A483083EDEA5581A61E770EC1FA8BECE8" /Applications/Subsurface.app/Contents/MacOS/subsurface-bin - -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/subsurface.mo $(WINDOWSSTAGING)/$$LOC/subsurface.mo; \ - 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/subsurface-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 - @echo ' CC' $< - @mkdir -p .dep .dep/qt-ui - @$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< - -%.o: %.cpp - @echo ' CXX' $< - @mkdir -p .dep .dep/qt-ui - @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< - -# Detect which files require the moc or uic tools to be run -CPP_NEEDING_MOC = $(shell grep -l -s '^\#include \".*\.moc\"' $(OBJS:.o=.cpp)) -OBJS_NEEDING_MOC += $(CPP_NEEDING_MOC:.cpp=.o) - -CPP_NEEDING_UIC = $(shell grep -l -s '^\#include \"ui_.*\.h\"' $(OBJS:.o=.cpp)) -OBJS_NEEDING_UIC += $(CPP_NEEDING_UIC:.cpp=.o) - -# This rule is for running the moc on QObject subclasses defined in the .h -# files. -%.moc.cpp: %.h - @echo ' MOC' $< - @$(MOC) $(MOCFLAGS) $< -o $@ - -# This rule is for running the moc on QObject subclasses defined in the .cpp -# files; remember to #include ".moc" at the end of the .cpp file, or -# you'll get linker errors ("undefined vtable for...") -%.moc: %.cpp - @echo ' MOC' $< - @$(MOC) -i $(MOCFLAGS) $< -o $@ - -# This creates the ui headers. -ui_%.h: %.ui - @echo ' UIC' $< - @$(UIC) $< -o $@ - -$(OBJS_NEEDING_MOC): %.o: %.moc -$(OBJS_NEEDING_UIC): qt-ui/%.o: qt-ui/ui_%.h - -share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases - mkdir -p $(dir $@) - 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) $(NAME).exe po/*~ po/subsurface-new.pot \ - $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h - rm -rf share .dep - --include $(DEPS) +include Rules.mk diff --git a/Rules.mk b/Rules.mk index e882a353d..59e73e13d 100644 --- a/Rules.mk +++ b/Rules.mk @@ -1,204 +1,4 @@ -VERSION=3.0.2 - -CC=gcc -CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE -CXX=g++ -CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS -INSTALL=install - -# This are the detection rules -PKGCONFIG=pkg-config -XML2CONFIG=xml2-config -XSLCONFIG=xslt-config -QMAKE=qmake -MOC=moc -UIC=uic - -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 -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 ($(LIBDCDEVEL),) - LIBDIVECOMPUTERDIR = ../libdivecomputer - LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include - LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/src/.libs/libdivecomputer.a -else 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) - -# 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 -else - QT_MODULES = QtGui QtSvg - QT_CORE = QtCore -endif - -# we need GLIB2CFLAGS for gettext -QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS) -LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) -ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) - QTCXXFLAGS += -fPIE -endif - -LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) -ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0) - GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0) -else ifeq ($(UNAME), darwin) - LIBGTK += $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation -framework CoreServices - GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) - GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler -endif - -LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) -LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB) - -LIBXML2 = $(shell $(XML2CONFIG) --libs) -LIBXSLT = $(shell $(XSLCONFIG) --libs) -XML2CFLAGS = $(shell $(XML2CONFIG) --cflags) -GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0) -GTKCFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0) -XSLCFLAGS = $(shell $(XSLCONFIG) --cflags) -OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null) -LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null) -LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4) -LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4) - -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)) - -# These are the main rules - -# these locations seem to work for SuSE and Fedora -# prefix = $(HOME) -prefix = $(DESTDIR)/usr -BINDIR = $(prefix)/bin -DATADIR = $(prefix)/share -DESKTOPDIR = $(DATADIR)/applications -ICONPATH = $(DATADIR)/icons/hicolor -ICONDIR = $(ICONPATH)/scalable/apps -MANDIR = $(DATADIR)/man/man1 -XSLTDIR = $(DATADIR)/subsurface/xslt -gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) - -NAME = subsurface -ICONFILE = $(NAME)-icon.svg -DESKTOPFILE = $(NAME).desktop -MANFILES = $(NAME).1 -XSLTFILES = xslt/*.xslt - -EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ - $(LIBDIVECOMPUTERCFLAGS) \ - $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) - -QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ - qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o - -GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o - -OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o \ - planner.o planner-gtk.o \ - parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ - qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ - webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) - -ifneq ($(SQLITE3FLAGS),) - EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) -endif -ifneq ($(ZIPFLAGS),) - EXTRA_FLAGS += -DLIBZIP $(ZIPFLAGS) -endif -ifneq ($(strip $(LIBXSLT)),) - EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) -endif -ifneq ($(strip $(LIBOSMGPSMAP)),) - OBJS += gps.o - EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) -endif - -ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - OBJS += linux.o -else ifeq ($(UNAME), darwin) - OBJS += macos.o - MACOSXINSTALL = /Applications/Subsurface.app - MACOSXFILES = packaging/macosx - MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app - INFOPLIST = $(MACOSXFILES)/Info.plist - INFOPLISTINPUT = $(INFOPLIST).in - LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) -else - OBSJ += windows.o - WINDOWSSTAGING = ./packaging/windows - WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) - NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in - NSIFILE = $(WINDOWSSTAGING)/subsurface.nsi - MAKENSIS = makensis - XSLTDIR = .\\xslt -endif - -LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) \ - $(EXTRALIBS) $(LIBZIP) -lpthread -lm $(LIBOSMGPSMAP) $(LIBSOUP) $(LIBWINSOCK) - -MSGLANGS=$(notdir $(wildcard po/*.po)) - -# Add files to the following variables if the auto-detection based on the -# filename fails -OBJS_NEEDING_MOC = -OBJS_NEEDING_UIC = -HEADERS_NEEDING_MOC = - -# These are the generic rules for building - +# -*- Makefile -*- # Rules for building and creating the version file VERSION_FILE = version.h From c11ce7e1574889734fa010ad3d8379aa41720fdc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 09:00:15 -0700 Subject: [PATCH 09/19] Introduce a cache of the configuration You may have noticed that running make is a little slow. Every time that it is loaded, it will try to detect everything again. So, instead, save the output and reload it the next time. This is implemented by adding a rule that (re-)creates the config.cache file, which is included by make. If the file doesn't exist yet, make will first run the rule which creates it, then reload itself. You can also cause it to reconfigure by running "make configure". Signed-off-by: Thiago Macieira --- .gitignore | 1 + Configure.mk | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ Rules.mk | 3 +++ 3 files changed, 52 insertions(+) diff --git a/.gitignore b/.gitignore index 54650bcf2..b62d8982b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ Documentation/user-manual.pdf Documentation/user-manual.text packaging/windows/subsurface.nsi packaging/macos/Info.plist +config.cache diff --git a/Configure.mk b/Configure.mk index f9b9e0674..fa04a44ec 100644 --- a/Configure.mk +++ b/Configure.mk @@ -1,5 +1,6 @@ # -*- Makefile -*- # This file contains the detection rules +all: PKGCONFIG=pkg-config XML2CONFIG=xml2-config @@ -8,6 +9,11 @@ QMAKE=qmake MOC=moc UIC=uic +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 @@ -110,3 +116,45 @@ ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null)) LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null) SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3)) + +# Write the configure file +all: configure +configure $(CONFIGURE): Configure.mk + @echo "\ + CONFIGURED = 1 \\\ + UNAME = $(UNAME) \\\ + LIBDIVECOMPUTERDIR = $(LIBDIVECOMPUTERDIR) \\\ + LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERCFLAGS) \\\ + LIBDIVECOMPUTER = $(LIBDIVECOMPUTER) \\\ + LIBQT = $(LIBQT) \\\ + QTCXXFLAGS = $(QTCXXFLAGS) \\\ + LIBGTK = $(LIBGTK) \\\ + GTKCFLAGS = $(GTKCFLAGS) \\\ + LIBGCONF2 = $(LIBGCONF2) \\\ + GCONF2CFLAGS = $(GCONF2CFLAGS) \\\ + GTK_MAC_BUNDLER = $(GTK_MAC_BUNDLER) \\\ + LIBXML2 = $(LIBXML2) \\\ + LIBXSLT = $(LIBXSLT) \\\ + XML2CFLAGS = $(XML2CFLAGS) \\\ + GLIB2CFLAGS = $(GLIB2CFLAGS) \\\ + XSLCFLAGS = $(XSLCFLAGS) \\\ + OSMGPSMAPFLAGS = $(OSMGPSMAPFLAGS) \\\ + LIBOSMGPSMAP = $(LIBOSMGPSMAP) \\\ + LIBSOUPCFLAGS = $(LIBSOUPCFLAGS) \\\ + LIBSOUP = $(LIBSOUP) \\\ + LIBZIP = $(LIBZIP) \\\ + ZIPFLAGS = $(ZIPFLAGS) \\\ + LIBSQLITE3 = $(LIBSQLITE3) \\\ + SQLITE3FLAGS = $(SQLITE3FLAGS) \\\ + " | sed 's,\\,\n,g' > $(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/Rules.mk b/Rules.mk index 59e73e13d..5374e060b 100644 --- a/Rules.mk +++ b/Rules.mk @@ -197,4 +197,7 @@ clean: $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h rm -rf share .dep +confclean: clean + rm -f $(CONFIGFILE) + -include $(DEPS) From b1c9ed76dcae007e500da286dbfaa421d33b6d45 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 09:09:52 -0700 Subject: [PATCH 10/19] Cache the Qt tools detected (and detect RCC) Since we're caching the include flags and linker flags, we should also cache the exact helper binaries we're running. This avoids getting errors because the environment changed. Signed-off-by: Thiago Macieira --- Configure.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Configure.mk b/Configure.mk index fa04a44ec..99292795a 100644 --- a/Configure.mk +++ b/Configure.mk @@ -75,9 +75,11 @@ 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) else QT_MODULES = QtGui QtSvg QT_CORE = QtCore + QTBINDIR = $(shell $(QMAKE) -query QT_INSTALL_BINS) endif # we need GLIB2CFLAGS for gettext @@ -86,6 +88,9 @@ LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), ) QTCXXFLAGS += -fPIE endif +MOC = $(QTBINDIR)/moc +UIC = $(QTBINDIR)/uic +RCC = $(QTBINDIR)/rcc LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) @@ -128,6 +133,9 @@ configure $(CONFIGURE): Configure.mk LIBDIVECOMPUTER = $(LIBDIVECOMPUTER) \\\ LIBQT = $(LIBQT) \\\ QTCXXFLAGS = $(QTCXXFLAGS) \\\ + MOC = $(MOC) \\\ + UIC = $(UIC) \\\ + RCC = $(RCC) \\\ LIBGTK = $(LIBGTK) \\\ GTKCFLAGS = $(GTKCFLAGS) \\\ LIBGCONF2 = $(LIBGCONF2) \\\ From c8b360c3b5fdeb9f878cb5db648a121a10e33772 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 09:19:03 -0700 Subject: [PATCH 11/19] Add a HEADERS variable to the Makefile Similar to the qmake variable of the same name, this lists (at least) the headers that may need moc to be run on. Adding more headers is not a problem. Signed-off-by: Thiago Macieira --- Makefile | 10 ++++++++++ Rules.mk | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3308c9f41..41e5f093b 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,16 @@ EXTRA_FLAGS = $(QTCXXFLAGS) $(GTKCFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \ $(LIBDIVECOMPUTERCFLAGS) \ $(LIBSOUPCFLAGS) $(GCONF2CFLAGS) +HEADERS = \ + qt-ui/addcylinderdialog.h \ + qt-ui/divelistview.h \ + qt-ui/maintab.h \ + qt-ui/mainwindow.h \ + qt-ui/models.h \ + qt-ui/plotareascene.h \ + qt-ui/starwidget.h \ + + QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o diff --git a/Rules.mk b/Rules.mk index 5374e060b..8ffb88b86 100644 --- a/Rules.mk +++ b/Rules.mk @@ -20,7 +20,7 @@ PRODVERSION_STRING := $(shell $(GET_VERSION) win $(VERSION_STRING) || \ MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) # Add the objects for the header files which define QObject subclasses -HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(OBJS:.o=.h)) +HEADERS_NEEDING_MOC += $(shell grep -l -s 'Q_OBJECT' $(HEADERS)) MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) ALL_OBJS = $(OBJS) $(MOC_OBJS) From d773c02bf36f3b09584123bfd0e84a56304b33fb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 09:27:55 -0700 Subject: [PATCH 12/19] Add a SOURCES variable to the Makefile, replacing OBJS Instead of listing objects, let's list sources. This matches also what qmake and most other buildsystems do. The notable exception is the kernel. The reason that listing the sources will be interesting is because I'm about to add rules to create the dependency files. Signed-off-by: Thiago Macieira --- Makefile | 55 +++++++++++++++++++++++++++++++++++++++++-------------- Rules.mk | 5 +++++ 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 41e5f093b..055d7b138 100644 --- a/Makefile +++ b/Makefile @@ -39,16 +39,43 @@ HEADERS = \ qt-ui/starwidget.h \ -QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o qt-ui/divelistview.o \ - qt-ui/addcylinderdialog.o qt-ui/models.o qt-ui/starwidget.o - -GTKOBJS = info-gtk.o divelist-gtk.o planner-gtk.o statistics-gtk.o - -OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o \ - planner.o planner-gtk.o \ - parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ - qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ - webservice.o sha1.o $(RESFILE) $(QTOBJS) $(GTKOBJS) +SOURCES = \ + cochran.c \ + deco.c \ + device.c \ + dive.c \ + divelist.c \ + divelist-gtk.c \ + download-dialog.c \ + equipment.c \ + file.c \ + info.c \ + info-gtk.c \ + libdivecomputer.c \ + main.c \ + parse-xml.c \ + planner.c \ + planner-gtk.c \ + prefs.c \ + print.c \ + profile.c \ + save-xml.c \ + sha1.c \ + statistics.c \ + statistics-gtk.c \ + time.c \ + uemis.c \ + uemis-downloader.c \ + webservice.c \ + qt-gui.cpp \ + qt-ui/addcylinderdialog.cpp \ + qt-ui/divelistview.cpp \ + qt-ui/maintab.cpp \ + qt-ui/mainwindow.cpp \ + qt-ui/models.cpp \ + qt-ui/plotareascene.cpp \ + qt-ui/starwidget.cpp \ + $(RESFILE) ifneq ($(SQLITE3FLAGS),) EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) @@ -60,14 +87,14 @@ ifneq ($(strip $(LIBXSLT)),) EXTRA_FLAGS += -DXSLT='"$(XSLTDIR)"' $(XSLCFLAGS) endif ifneq ($(strip $(LIBOSMGPSMAP)),) - OBJS += gps.o + SOURCES += gps.c EXTRA_FLAGS += -DHAVE_OSM_GPS_MAP $(OSMGPSMAPFLAGS) endif ifneq (,$(filter $(UNAME),linux kfreebsd gnu)) - OBJS += linux.o + SOURCES += linux.c else ifeq ($(UNAME), darwin) - OBJS += macos.o + SOURCES += macos.c MACOSXINSTALL = /Applications/Subsurface.app MACOSXFILES = packaging/macosx MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app @@ -75,7 +102,7 @@ else ifeq ($(UNAME), darwin) INFOPLISTINPUT = $(INFOPLIST).in LDFLAGS += -headerpad_max_install_names -sectcreate __TEXT __info_plist $(INFOPLIST) else - OBSJ += windows.o + SOURCES += windows.c WINDOWSSTAGING = ./packaging/windows WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) NSIINPUTFILE = $(WINDOWSSTAGING)/subsurface.nsi.in diff --git a/Rules.mk b/Rules.mk index 8ffb88b86..e7108fd4b 100644 --- a/Rules.mk +++ b/Rules.mk @@ -19,6 +19,11 @@ PRODVERSION_STRING := $(shell $(GET_VERSION) win $(VERSION_STRING) || \ MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) +C_SOURCES = $(filter %.c, $(SOURCES)) +CXX_SOURCES = $(filter %.cpp, $(SOURCES)) +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) From a0b523a5afc91c3816f6c44e61f8a05d5fe5e80a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 09:49:48 -0700 Subject: [PATCH 13/19] Get the list of dependency includes from the SOURCES list Signed-off-by: Thiago Macieira --- Rules.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Rules.mk b/Rules.mk index e7108fd4b..bc135aab7 100644 --- a/Rules.mk +++ b/Rules.mk @@ -30,8 +30,6 @@ MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) ALL_OBJS = $(OBJS) $(MOC_OBJS) -DEPS = $(wildcard .dep/*.dep) - all: $(NAME) $(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) @@ -205,4 +203,5 @@ clean: confclean: clean rm -f $(CONFIGFILE) +DEPS = $(addprefix .dep/,$(C_SOURCES:.c=.o.dep) $(CXX_SOURCES:.cpp=.o.dep)) -include $(DEPS) From ce3f073d422d03d473ff18e6793a9228fb02fa12 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 11:30:05 -0700 Subject: [PATCH 14/19] Generate the C++ dependencies at configure-time We use the -MG preprocessor option to the compiler to ask it to check all #includes and tell us what's missing. Then our own rules will generate the moc and uic files that the .cpp #include. Unfortunately, our rules make uic generate output in qt-ui/ for qt-ui/*.ui, while the compiler generates rules for no directory. We need to fake it by forcing the generation. Signed-off-by: Thiago Macieira --- Rules.mk | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Rules.mk b/Rules.mk index bc135aab7..56ef8813a 100644 --- a/Rules.mk +++ b/Rules.mk @@ -35,7 +35,7 @@ all: $(NAME) $(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) $(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) -gen_version_file: +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) @@ -142,13 +142,6 @@ MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $ @mkdir -p .dep .dep/qt-ui @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< -# Detect which files require the moc or uic tools to be run -CPP_NEEDING_MOC = $(shell grep -l -s '^\#include \".*\.moc\"' $(OBJS:.o=.cpp)) -OBJS_NEEDING_MOC += $(CPP_NEEDING_MOC:.cpp=.o) - -CPP_NEEDING_UIC = $(shell grep -l -s '^\#include \"ui_.*\.h\"' $(OBJS:.o=.cpp)) -OBJS_NEEDING_UIC += $(CPP_NEEDING_UIC:.cpp=.o) - # This rule is for running the moc on QObject subclasses defined in the .h # files. %.moc.cpp: %.h @@ -167,8 +160,12 @@ ui_%.h: %.ui @echo ' UIC' $< @$(UIC) $< -o $@ -$(OBJS_NEEDING_MOC): %.o: %.moc -$(OBJS_NEEDING_UIC): qt-ui/%.o: qt-ui/ui_%.h +# This forces the creation of ui headers with the wrong path +# This is required because the -MG option to the compiler outputs +# unknown files with no path prefix +ui_%.h: qt-ui/%.ui + @echo ' UIC' $< + @$(UIC) $< -o qt-ui/$@ share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases mkdir -p $(dir $@) @@ -198,10 +195,17 @@ doc: clean: rm -f $(ALL_OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot \ $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h - rm -rf share .dep + rm -rf share confclean: clean rm -f $(CONFIGFILE) + rm -rf .dep + +ifneq ($(CONFIGURED)$(CONFIGURING),) +.dep/%.o.dep: %.cpp + @mkdir -p .dep .dep/qt-ui + @$(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 f94b6bbefd1cef992fbc71808603612a6ee2f793 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 22:20:05 -0700 Subject: [PATCH 15/19] Make the "silent mode" compilation be optional only. If you run make V=1 Then we'll output the full command-line. It's useful for debugging problems with the build. Signed-off-by: Thiago Macieira --- Rules.mk | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Rules.mk b/Rules.mk index 56ef8813a..844e843ba 100644 --- a/Rules.mk +++ b/Rules.mk @@ -19,6 +19,14 @@ PRODVERSION_STRING := $(shell $(GET_VERSION) win $(VERSION_STRING) || \ MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) +ifeq ($(V),1) + PRETTYECHO=true + COMPILE_PREFIX= +else + PRETTYECHO=echo + COMPILE_PREFIX=@ +endif + C_SOURCES = $(filter %.c, $(SOURCES)) CXX_SOURCES = $(filter %.cpp, $(SOURCES)) OTHER_SOURCES = $(filter-out %.c %.cpp, $(SOURCES)) @@ -133,39 +141,39 @@ update-po-files: MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $(EXTRA_FLAGS)) %.o: %.c - @echo ' CC' $< + @$(PRETTYECHO) ' CC' $< @mkdir -p .dep .dep/qt-ui - @$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< + $(COMPILE_PREFIX)$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< %.o: %.cpp - @echo ' CXX' $< + @$(PRETTYECHO) ' CXX' $< @mkdir -p .dep .dep/qt-ui - @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< + $(COMPILE_PREFIX)$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< # This rule is for running the moc on QObject subclasses defined in the .h # files. %.moc.cpp: %.h - @echo ' MOC' $< - @$(MOC) $(MOCFLAGS) $< -o $@ + @$(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 ".moc" at the end of the .cpp file, or # you'll get linker errors ("undefined vtable for...") %.moc: %.cpp - @echo ' MOC' $< - @$(MOC) -i $(MOCFLAGS) $< -o $@ + @$(PRETTYECHO) ' MOC' $< + $(COMPILE_PREFIX)$(MOC) -i $(MOCFLAGS) $< -o $@ # This creates the ui headers. ui_%.h: %.ui - @echo ' UIC' $< - @$(UIC) $< -o $@ + @$(PRETTYECHO) ' UIC' $< + $(COMPILE_PREFIX)$(UIC) $< -o $@ # This forces the creation of ui headers with the wrong path # This is required because the -MG option to the compiler outputs # unknown files with no path prefix ui_%.h: qt-ui/%.ui - @echo ' UIC' $< - @$(UIC) $< -o qt-ui/$@ + @$(PRETTYECHO) ' UIC' $< + $(COMPILE_PREFIX)$(UIC) $< -o qt-ui/$@ share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases mkdir -p $(dir $@) From 17ea074dc0dc438a918d4e4fa1e5197ecec8217b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 22:23:45 -0700 Subject: [PATCH 16/19] Prettify the msgfmt and linking arguments Signed-off-by: Thiago Macieira --- Rules.mk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Rules.mk b/Rules.mk index 844e843ba..fd26d74d0 100644 --- a/Rules.mk +++ b/Rules.mk @@ -41,7 +41,8 @@ ALL_OBJS = $(OBJS) $(MOC_OBJS) all: $(NAME) $(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) - $(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) + @$(PRETTYECHO) ' LINK' $(NAME) + $(COMPILE_PREFIX)$(CXX) $(LDFLAGS) -o $(NAME) $(ALL_OBJS) $(LIBS) gen_version_file $(VERSION_FILE): ifneq ($(STORED_VERSION_STRING),$(VERSION_STRING)) @@ -176,8 +177,9 @@ ui_%.h: qt-ui/%.ui $(COMPILE_PREFIX)$(UIC) $< -o qt-ui/$@ share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases - mkdir -p $(dir $@) - msgfmt -c -o $@ po/$*.po + @$(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; \ From c5d244eeea0583eaef3a30e01e7efb2e8a060af8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 23:24:47 -0700 Subject: [PATCH 17/19] Add support for Qt resources in Subsurface Signed-off-by: Thiago Macieira --- .gitignore | 1 + Makefile | 3 +++ Rules.mk | 9 ++++++++- subsurface.qrc | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 subsurface.qrc diff --git a/.gitignore b/.gitignore index b62d8982b..5a90c6d4e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ Documentation/user-manual.text packaging/windows/subsurface.nsi packaging/macos/Info.plist config.cache +*.qrc.cpp diff --git a/Makefile b/Makefile index 055d7b138..3e0af9993 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,9 @@ SOURCES = \ qt-ui/starwidget.cpp \ $(RESFILE) + +RESOURCES = subsurface.qrc + ifneq ($(SQLITE3FLAGS),) EXTRA_FLAGS += -DSQLITE3 $(SQLITE3FLAGS) endif diff --git a/Rules.mk b/Rules.mk index fd26d74d0..ee99773ba 100644 --- a/Rules.mk +++ b/Rules.mk @@ -28,7 +28,7 @@ else endif C_SOURCES = $(filter %.c, $(SOURCES)) -CXX_SOURCES = $(filter %.cpp, $(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) @@ -164,6 +164,12 @@ MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $ @$(PRETTYECHO) ' MOC' $< $(COMPILE_PREFIX)$(MOC) -i $(MOCFLAGS) $< -o $@ +# This creates the Qt resource sources. +%.qrc.cpp: %.qrc + @$(PRETTYECHO) ' RCC' $< + $(COMPILE_PREFIX)$(RCC) $< -o $@ +%.qrc: + # This creates the ui headers. ui_%.h: %.ui @$(PRETTYECHO) ' UIC' $< @@ -205,6 +211,7 @@ doc: clean: rm -f $(ALL_OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot \ $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h + rm -f $(RESOURCES:.qrc=.qrc.cpp) rm -rf share confclean: clean diff --git a/subsurface.qrc b/subsurface.qrc new file mode 100644 index 000000000..2496c8778 --- /dev/null +++ b/subsurface.qrc @@ -0,0 +1 @@ + \ No newline at end of file From d312b7d6fd40c961c1922f670388cdd8a4b92e77 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 23:36:46 -0700 Subject: [PATCH 18/19] Don't hardcode the paths for mkdir: just get them from the target The $(@D) (equivalent to $(dir $@)) tells us what the directory the target is in. We could also have used the one for the source. They're equivalent there. Signed-off-by: Thiago Macieira --- Rules.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Rules.mk b/Rules.mk index ee99773ba..d3c8c79a8 100644 --- a/Rules.mk +++ b/Rules.mk @@ -143,12 +143,12 @@ MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $ %.o: %.c @$(PRETTYECHO) ' CC' $< - @mkdir -p .dep .dep/qt-ui + @mkdir -p .dep/$(@D) $(COMPILE_PREFIX)$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< %.o: %.cpp @$(PRETTYECHO) ' CXX' $< - @mkdir -p .dep .dep/qt-ui + @mkdir -p .dep/$(@D) $(COMPILE_PREFIX)$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< # This rule is for running the moc on QObject subclasses defined in the .h @@ -220,7 +220,7 @@ confclean: clean ifneq ($(CONFIGURED)$(CONFIGURING),) .dep/%.o.dep: %.cpp - @mkdir -p .dep .dep/qt-ui + @mkdir -p $(@D) @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MM -MG -MF $@ -MT $(<:.cpp=.o) -c $< endif From b073823e3acbeb4b15c95101e9708d60cc7b2703 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 14 Apr 2013 00:30:25 -0700 Subject: [PATCH 19/19] Clean up the moc intermediates too in make clean Signed-off-by: Thiago Macieira --- Makefile | 2 +- Rules.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3e0af9993..6ebba4dd5 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ VERSION=3.0.2 CC=gcc CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE CXX=g++ -CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS +CXXFLAGS=-Wall -g $(CLCXXFLAGS) -DQT_NO_KEYWORDS INSTALL=install # these locations seem to work for SuSE and Fedora diff --git a/Rules.mk b/Rules.mk index d3c8c79a8..d5bc31246 100644 --- a/Rules.mk +++ b/Rules.mk @@ -210,7 +210,7 @@ doc: clean: rm -f $(ALL_OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot \ - $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h + $(VERSION_FILE) $(HEADERS_NEEDING_MOC:.h=.moc) *.moc qt-ui/*.moc qt-ui/ui_*.h rm -f $(RESOURCES:.qrc=.qrc.cpp) rm -rf share