From 42365ede79ec34dba58447458bbc3f1c66cba7d1 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Mon, 1 Apr 2013 12:25:15 +0300 Subject: Setup Makefile for Qt/C++ builds Setup the build variables for building with QtWidgets, and add rules for processing the Q_OBJECT macros with moc and generate widget code from .ui files with uic. Signed-off-by: Alberto Mardegan --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 50d668f39..36c82543b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,9 @@ *.rej *.exe *.dmg +*.moc.cpp *.patch +*.ui.h *.xml version.h !dives/*.xml -- cgit v1.2.3-70-g09d2 From 9dbda9f62aca314aa7cb7ef588b1ce5ec43a01b9 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 10 Apr 2013 19:02:06 +0400 Subject: Update .gitignore Ignore some moc/uic-generated files. Signed-off-by: Alberto Mardegan --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 36c82543b..54650bcf2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.rej *.exe *.dmg +*.moc *.moc.cpp *.patch *.ui.h @@ -11,6 +12,7 @@ version.h !dives/*.xml *~ po/*.mo +qt-ui/ui_*.h /subsurface .dep/ share/ -- cgit v1.2.3-70-g09d2 From c11ce7e1574889734fa010ad3d8379aa41720fdc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 09:00:15 -0700 Subject: 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(+) (limited to '.gitignore') 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) -- cgit v1.2.3-70-g09d2 From c5d244eeea0583eaef3a30e01e7efb2e8a060af8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 13 Apr 2013 23:24:47 -0700 Subject: 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 (limited to '.gitignore') 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 -- cgit v1.2.3-70-g09d2 From aea8493165a98d1653c7adf475ca2267d505bfe8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 May 2013 12:18:02 -0700 Subject: Add a make rule (creator-files) that creates files for using Qt Creator Qt Creator cannot import Subsurface directly because our buildsystem is not any of the three that it understands (qmake, cmake, autotools). So, instead, we can create the files Creator uses for "Other Project" projects. The files are: - subsurface.config: the #defines from the command line (-D args) - subsurface.creator: an XDG Desktop-style file with Creator settings - subsurface.files: the list of source and header files - subsurface.includes: the include paths (-I args) They are also added to .gitignore, alongside the *.user file that Creator uses to store per-user settings (editor configuration). Signed-off-by: Thiago Macieira Signed-off-by: Dirk Hohndel --- .gitignore | 5 +++++ Rules.mk | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 5a90c6d4e..0d488491e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,8 @@ packaging/windows/subsurface.nsi packaging/macos/Info.plist config.cache *.qrc.cpp +/subsurface.config +/subsurface.creator +/subsurface.creator.user +/subsurface.files +/subsurface.includes diff --git a/Rules.mk b/Rules.mk index 8dc95c08d..c0ef1ee9e 100644 --- a/Rules.mk +++ b/Rules.mk @@ -38,6 +38,9 @@ MOC_OBJS = $(HEADERS_NEEDING_MOC:.h=.moc.o) ALL_OBJS = $(OBJS) $(MOC_OBJS) +# Files for using Qt Creator +CREATOR_FILES = subsurface.config subsurface.creator subsurface.files subsurface.includes + all: $(NAME) $(NAME): gen_version_file $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST) @@ -219,6 +222,19 @@ confclean: clean rm -rf .dep distclean: confclean + rm -f $(CREATOR_FILES) + +.PHONY: creator-files +creator-files: $(CREATOR_FILES) +subsurface.files: Makefile $(CONFIGFILE) + echo $(wildcard *.h) $(HEADERS) $(SOURCES) | tr ' ' '\n' | sort | uniq > subsurface.files +subsurface.config: Makefile $(CONFIGFILE) + echo $(patsubst -D%,%,$(filter -D%, $(CXXFLAGS) $(CFLAGS) $(EXTRA_FLAGS))) | tr ' ' '\n' | sort | uniq > subsurface.config +subsurface.includes: Makefile $(CONFIGFILE) + echo $$PWD > subsurface.includes + echo $(patsubst -I%,%,$(filter -I%, $(CXXFLAGS) $(CFLAGS) $(EXTRA_FLAGS))) | tr ' ' '\n' | sort | uniq >> subsurface.includes +subsurface.creator: + echo '[General]' > subsurface.creator ifneq ($(CONFIGURED)$(CONFIGURING),) .dep/%.o.dep: %.cpp -- cgit v1.2.3-70-g09d2