aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Thiago Macieira <thiago@macieira.org>2013-04-22 23:26:33 -0700
committerGravatar Thiago Macieira <thiago@macieira.org>2013-04-23 00:06:32 -0700
commitddbb942d0fce58f5ef7335f23da703ddb721bcf9 (patch)
treee1b505b5a416036cc013219c9659fe3c18fcf1da
parent77ebc2f4c854748edaff6bc518e105b56f656a47 (diff)
downloadsubsurface-ddbb942d0fce58f5ef7335f23da703ddb721bcf9.tar.gz
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 <thiago@macieira.org>
-rw-r--r--Makefile112
1 files 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