4 CFLAGS=-Wall -Wno-pointer-sign -g
9 # these locations seem to work for SuSE and Fedora
11 prefix = $(DESTDIR)/usr
12 BINDIR = $(prefix)/bin
13 DATADIR = $(prefix)/share
14 DESKTOPDIR = $(DATADIR)/applications
15 ICONPATH = $(DATADIR)/icons/hicolor
16 ICONDIR = $(ICONPATH)/scalable/apps
17 MANDIR = $(DATADIR)/man/man1
18 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH)
21 ICONFILE = $(NAME).svg
22 DESKTOPFILE = $(NAME).desktop
25 MACOSXINSTALL = /Applications/Subsurface.app
26 MACOSXFILES = packaging/macosx
28 # find libdivecomputer
29 # First deal with the cross compile environment.
30 # For the native case, Linus doesn't want to trust pkg-config given
31 # how young libdivecomputer still is - so we check the typical
32 # subdirectories of /usr/local and /usr and then we give up. You can
33 # override by simply setting it here
35 ifeq ($(CC), i686-w64-mingw32-gcc)
36 # ok, we are cross building for Windows
37 LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer
38 LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer`
39 LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer`
40 RESFILE = packaging/windows/subsurface.res
41 LDFLAGS += -Wl,-subsystem,windows
44 libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
45 libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
46 libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
47 libdc-usr64 := $(wildcard /usr/lib64/libdivecomputer.a)
49 ifneq ($(strip $(libdc-local)),)
50 LIBDIVECOMPUTERDIR = /usr/local
51 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
52 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
53 else ifneq ($(strip $(libdc-local64)),)
54 LIBDIVECOMPUTERDIR = /usr/local
55 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
56 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
57 else ifneq ($(strip $(libdc-usr)),)
58 LIBDIVECOMPUTERDIR = /usr
59 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
60 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
61 else ifneq ($(strip $(libdc-usr64)),)
62 LIBDIVECOMPUTERDIR = /usr
63 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
64 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
66 $(error Cannot find libdivecomputer - please edit Makefile)
70 # Libusb-1.0 is only required if libdivecomputer was built with it.
71 # And libdivecomputer is only built with it if libusb-1.0 is
72 # installed. So get libusb if it exists, but don't complain
73 # about it if it doesn't.
74 LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
76 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
77 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
78 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
80 LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
82 OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \
83 parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
87 $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
90 $(INSTALL) -d -m 755 $(BINDIR)
91 $(INSTALL) $(NAME) $(BINDIR)
92 $(INSTALL) -d -m 755 $(DESKTOPDIR)
93 $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
94 $(INSTALL) -d -m 755 $(ICONDIR)
95 $(INSTALL) $(ICONFILE) $(ICONDIR)
96 @-if test -z "$(DESTDIR)"; then \
97 $(gtk_update_icon_cache); \
99 $(INSTALL) -d -m 755 $(MANDIR)
100 $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
102 LIBXML2 = $(shell $(XML2CONFIG) --libs)
103 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
104 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
105 GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
106 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
108 install-macosx: $(NAME)
109 $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
110 $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
111 $(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/
112 $(INSTALL) $(MACOSXFILES)/subsurface.sh $(MACOSXINSTALL)/Contents/MacOS/
113 $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXINSTALL)/Contents/
114 $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
115 $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
116 $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
118 parse-xml.o: parse-xml.c dive.h
119 $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c $(XML2CFLAGS) parse-xml.c
121 save-xml.o: save-xml.c dive.h
122 $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c save-xml.c
124 dive.o: dive.c dive.h
125 $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c dive.c
127 main.o: main.c dive.h display.h divelist.h
128 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) -c main.c
130 profile.o: profile.c dive.h display.h divelist.h
131 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c profile.c
133 info.o: info.c dive.h display.h display-gtk.h divelist.h
134 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c info.c
136 equipment.o: equipment.c dive.h display.h divelist.h
137 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c equipment.c
139 divelist.o: divelist.c dive.h display.h divelist.h
140 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
142 print.o: print.c dive.h display.h display-gtk.h
143 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c print.c
145 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
146 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) \
147 $(LIBDIVECOMPUTERCFLAGS) \
150 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
151 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) \
152 $(LIBDIVECOMPUTERCFLAGS) \
153 -DVERSION_STRING='"v$(VERSION)"' \
156 uemis.o: uemis.c uemis.h
157 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c uemis.c
160 rm -f $(OBJS) *~ $(NAME)