4 CFLAGS=-Wall -Wno-pointer-sign -g
10 # these locations seem to work for SuSE and Fedora
12 prefix = $(DESTDIR)/usr
13 BINDIR = $(prefix)/bin
14 DATADIR = $(prefix)/share
15 DESKTOPDIR = $(DATADIR)/applications
16 ICONPATH = $(DATADIR)/icons/hicolor
17 ICONDIR = $(ICONPATH)/scalable/apps
18 MANDIR = $(DATADIR)/man/man1
19 XSLTDIR = $(DATADIR)/subsurface/xslt
20 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH)
23 ICONFILE = $(NAME).svg
24 DESKTOPFILE = $(NAME).desktop
26 XSLTFILES = xslt/*.xslt
28 MACOSXINSTALL = /Applications/Subsurface.app
29 MACOSXFILES = packaging/macosx
31 # find libdivecomputer
32 # First deal with the cross compile environment.
33 # For the native case, Linus doesn't want to trust pkg-config given
34 # how young libdivecomputer still is - so we check the typical
35 # subdirectories of /usr/local and /usr and then we give up. You can
36 # override by simply setting it here
38 ifeq ($(CC), i686-w64-mingw32-gcc)
39 # ok, we are cross building for Windows
40 LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer
41 LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer`
42 LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer`
43 RESFILE = packaging/windows/subsurface.res
44 LDFLAGS += -Wl,-subsystem,windows
47 libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
48 libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
49 libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
50 libdc-usr64 := $(wildcard /usr/lib64/libdivecomputer.a)
52 ifneq ($(strip $(libdc-local)),)
53 LIBDIVECOMPUTERDIR = /usr/local
54 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
55 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
56 else ifneq ($(strip $(libdc-local64)),)
57 LIBDIVECOMPUTERDIR = /usr/local
58 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
59 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
60 else ifneq ($(strip $(libdc-usr)),)
61 LIBDIVECOMPUTERDIR = /usr
62 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
63 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
64 else ifneq ($(strip $(libdc-usr64)),)
65 LIBDIVECOMPUTERDIR = /usr
66 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
67 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
69 $(error Cannot find libdivecomputer - please edit Makefile)
73 # Libusb-1.0 is only required if libdivecomputer was built with it.
74 # And libdivecomputer is only built with it if libusb-1.0 is
75 # installed. So get libusb if it exists, but don't complain
76 # about it if it doesn't.
77 LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
79 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0)
80 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
81 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
83 LIBXML2 = $(shell $(XML2CONFIG) --libs)
84 LIBXSLT = $(shell $(XSLCONFIG) --libs)
85 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
86 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
87 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
88 CFLAGS += $(shell $(XSLCONFIG) --cflags)
90 UNAME := $(shell $(CC) -v 2>&1 | grep Target | grep -E -o "linux|darwin|win")
93 ifeq ($(UNAME), linux)
94 LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0)
95 GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
97 OSSUPPORT_CFLAGS = $(GTK2CFLAGS) $(GCONF2CFLAGS)
98 else ifeq ($(UNAME), darwin)
100 OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
103 OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
106 ifneq ($(strip $(LIBXSLT)),)
107 # We still need proper paths and install options for OSX and Windows
108 ifeq ($(shell sh -c 'uname -s 2>/dev/null || echo not'),Linux)
109 XSLT=-DXSLT='"$(XSLTDIR)"'
113 LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) -lpthread
115 OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \
116 parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
117 gtk-gui.o statistics.o $(OSSUPPORT).o $(RESFILE)
120 $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
123 $(INSTALL) -d -m 755 $(BINDIR)
124 $(INSTALL) $(NAME) $(BINDIR)
125 $(INSTALL) -d -m 755 $(DESKTOPDIR)
126 $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
127 $(INSTALL) -d -m 755 $(ICONDIR)
128 $(INSTALL) $(ICONFILE) $(ICONDIR)
129 @-if test -z "$(DESTDIR)"; then \
130 $(gtk_update_icon_cache); \
132 $(INSTALL) -d -m 755 $(MANDIR)
133 $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
134 @-if test ! -z "$(XSLT)"; then \
135 $(INSTALL) -d -m 755 $(DATADIR)/subsurface; \
136 $(INSTALL) -d -m 755 $(XSLTDIR); \
137 $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \
140 install-macosx: $(NAME)
141 $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
142 $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
143 $(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/
144 $(INSTALL) $(MACOSXFILES)/subsurface.sh $(MACOSXINSTALL)/Contents/MacOS/
145 $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXINSTALL)/Contents/
146 $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
147 $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
148 $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
150 parse-xml.o: parse-xml.c dive.h
151 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) -c parse-xml.c
153 save-xml.o: save-xml.c dive.h
154 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c save-xml.c
156 dive.o: dive.c dive.h
157 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c dive.c
159 main.o: main.c dive.h display.h divelist.h
160 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) $(XML2CFLAGS) -c main.c
162 profile.o: profile.c dive.h display.h divelist.h
163 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c profile.c
165 info.o: info.c dive.h display.h display-gtk.h divelist.h
166 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c info.c
168 equipment.o: equipment.c dive.h display.h divelist.h
169 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c equipment.c
171 statistics.o: statistics.c dive.h display.h divelist.h
172 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c statistics.c
174 divelist.o: divelist.c dive.h display.h divelist.h
175 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c divelist.c
177 print.o: print.c dive.h display.h display-gtk.h
178 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c print.c
180 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
181 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \
182 $(LIBDIVECOMPUTERCFLAGS) \
185 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
186 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) $(XML2CFLAGS) \
187 $(LIBDIVECOMPUTERCFLAGS) \
188 -DVERSION_STRING='"v$(VERSION)"' \
191 uemis.o: uemis.c dive.h uemis.h
192 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c uemis.c
194 $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h
195 $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c
198 rm -f $(OBJS) *~ $(NAME)