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 # find libdivecomputer
26 # First deal with the cross compile environment.
27 # For the native case, Linus doesn't want to trust pkg-config given
28 # how young libdivecomputer still is - so we check the typical
29 # subdirectories of /usr/local and /usr and then we give up. You can
30 # override by simply setting it here
32 ifeq ($(CC), i686-w64-mingw32-gcc)
33 # ok, we are cross building for Windows
34 LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer
35 LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer`
36 LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer`
37 RESFILE = packaging/windows/subsurface.res
40 libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
41 libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
42 libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
43 libdc-usr64 := $(wildcard /usr/lib64/libdivecomputer.a)
45 ifneq ($(strip $(libdc-local)),)
46 LIBDIVECOMPUTERDIR = /usr/local
47 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
48 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
49 else ifneq ($(strip $(libdc-local64)),)
50 LIBDIVECOMPUTERDIR = /usr/local
51 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
52 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
53 else ifneq ($(strip $(libdc-usr)),)
54 LIBDIVECOMPUTERDIR = /usr
55 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
56 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
57 else ifneq ($(strip $(libdc-usr64)),)
58 LIBDIVECOMPUTERDIR = /usr
59 LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
60 LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
62 $(error Cannot find libdivecomputer - please edit Makefile)
66 # Libusb-1.0 is only required if libdivecomputer was built with it.
67 # And libdivecomputer is only built with it if libusb-1.0 is
68 # installed. So get libusb if it exists, but don't complain
69 # about it if it doesn't.
70 LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
72 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
73 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
74 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
76 LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
78 OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \
79 parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
83 $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
86 $(INSTALL) -d -m 755 $(BINDIR)
87 $(INSTALL) $(NAME) $(BINDIR)
88 $(INSTALL) -d -m 755 $(DESKTOPDIR)
89 $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
90 $(INSTALL) -d -m 755 $(ICONDIR)
91 $(INSTALL) $(ICONFILE) $(ICONDIR)
92 $(gtk_update_icon_cache)
93 $(INSTALL) -d -m 755 $(MANDIR)
94 $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
96 LIBXML2 = $(shell $(XML2CONFIG) --libs)
97 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
98 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
99 GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
100 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
102 parse-xml.o: parse-xml.c dive.h
103 $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c $(XML2CFLAGS) parse-xml.c
105 save-xml.o: save-xml.c dive.h
106 $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c save-xml.c
108 dive.o: dive.c dive.h
109 $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c dive.c
111 main.o: main.c dive.h display.h divelist.h
112 $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) -c main.c
114 profile.o: profile.c dive.h display.h divelist.h
115 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c profile.c
117 info.o: info.c dive.h display.h display-gtk.h divelist.h
118 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c info.c
120 equipment.o: equipment.c dive.h display.h divelist.h
121 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c equipment.c
123 divelist.o: divelist.c dive.h display.h divelist.h
124 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
126 print.o: print.c dive.h display.h display-gtk.h
127 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c print.c
129 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
130 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) \
131 $(LIBDIVECOMPUTERCFLAGS) \
134 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
135 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) \
136 $(LIBDIVECOMPUTERCFLAGS) \
137 -DVERSION_STRING='"v$(VERSION)"' \
140 uemis.o: uemis.c uemis.h
141 $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c uemis.c
144 rm -f $(OBJS) *~ $(NAME)