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 UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win")
30 # find libdivecomputer
31 # First deal with the cross compile environment and with Mac.
32 # For the native case, Linus doesn't want to trust pkg-config given
33 # how young libdivecomputer still is - so we check the typical
34 # subdirectories of /usr/local and /usr and then we give up. You can
35 # override by simply setting it here
37 ifeq ($(CC), i686-w64-mingw32-gcc)
38 # ok, we are cross building for Windows
39 LIBDIVECOMPUTERINCLUDES = $(shell $(PKGCONFIG) --cflags libdivecomputer)
40 LIBDIVECOMPUTERARCHIVE = $(shell $(PKGCONFIG) --libs libdivecomputer)
41 RESFILE = packaging/windows/subsurface.res
42 LDFLAGS += -Wl,-subsystem,windows
43 else ifeq ($(UNAME), darwin)
44 LIBDIVECOMPUTERINCLUDES = $(shell $(PKGCONFIG) --cflags libdivecomputer)
45 LIBDIVECOMPUTERARCHIVE = $(shell $(PKGCONFIG) --libs libdivecomputer)
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 LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null)
91 ifneq ($(strip $(LIBZIP)),)
92 ZIP = -DLIBZIP $(shell $(PKGCONFIG) --cflags libzip)
95 ifeq ($(UNAME), linux)
96 LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0)
97 GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
99 OSSUPPORT_CFLAGS = $(GTK2CFLAGS) $(GCONF2CFLAGS)
100 else ifeq ($(UNAME), darwin)
102 OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
103 MACOSXINSTALL = /Applications/Subsurface.app
104 MACOSXFILES = packaging/macosx
105 EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation
106 CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration)
109 OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
112 ifneq ($(strip $(LIBXSLT)),)
113 # We still need proper paths and install options for OSX and Windows
114 ifeq ($(shell sh -c 'uname -s 2>/dev/null || echo not'),Linux)
115 XSLT=-DXSLT='"$(XSLTDIR)"'
119 LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm
121 OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \
122 parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
123 gtk-gui.o statistics.o file.o cochran.o $(OSSUPPORT).o $(RESFILE)
126 $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
129 $(INSTALL) -d -m 755 $(BINDIR)
130 $(INSTALL) $(NAME) $(BINDIR)
131 $(INSTALL) -d -m 755 $(DESKTOPDIR)
132 $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
133 $(INSTALL) -d -m 755 $(ICONDIR)
134 $(INSTALL) $(ICONFILE) $(ICONDIR)
135 @-if test -z "$(DESTDIR)"; then \
136 $(gtk_update_icon_cache); \
138 $(INSTALL) -d -m 755 $(MANDIR)
139 $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
140 @-if test ! -z "$(XSLT)"; then \
141 $(INSTALL) -d -m 755 $(DATADIR)/subsurface; \
142 $(INSTALL) -d -m 755 $(XSLTDIR); \
143 $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \
146 install-macosx: $(NAME)
147 $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
148 $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
149 $(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/
150 $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXINSTALL)/Contents/
151 $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
152 $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
153 $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
155 file.o: file.c dive.h file.h
156 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) $(ZIP) -c file.c
158 cochran.o: cochran.c dive.h file.h
159 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) $(ZIP) -c cochran.c
161 parse-xml.o: parse-xml.c dive.h
162 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) -c parse-xml.c
164 save-xml.o: save-xml.c dive.h
165 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c save-xml.c
167 dive.o: dive.c dive.h
168 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c dive.c
170 main.o: main.c dive.h display.h divelist.h
171 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) $(XML2CFLAGS) -c main.c
173 profile.o: profile.c dive.h display.h divelist.h
174 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c profile.c
176 info.o: info.c dive.h display.h display-gtk.h divelist.h
177 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c info.c
179 equipment.o: equipment.c dive.h display.h divelist.h
180 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c equipment.c
182 statistics.o: statistics.c dive.h display.h divelist.h
183 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c statistics.c
185 divelist.o: divelist.c dive.h display.h divelist.h
186 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c divelist.c
188 print.o: print.c dive.h display.h display-gtk.h
189 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c print.c
191 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
192 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \
193 $(LIBDIVECOMPUTERCFLAGS) \
196 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
197 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) $(XML2CFLAGS) \
198 $(LIBDIVECOMPUTERCFLAGS) \
199 -DVERSION_STRING='"v$(VERSION)"' \
202 uemis.o: uemis.c dive.h uemis.h
203 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c uemis.c
205 $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h
206 $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c
209 $(MAKE) -C Documentation doc
212 rm -f $(OBJS) *~ $(NAME)