]> git.tdb.fi Git - ext/subsurface.git/blob - Makefile
Have "make install" act more as expected for a desktop application
[ext/subsurface.git] / Makefile
1 VERSION=1.0
2
3 CC=gcc
4 CFLAGS=-Wall -Wno-pointer-sign -g
5 INSTALL=install
6
7 # these locations seem to work for SuSE and Fedora
8 # prefix = $(HOME)
9 prefix = /usr
10 DESTDIR = $(prefix)/bin
11 DESKTOPDIR = $(prefix)/share/applications
12 ICONPATH = $(prefix)/share/icons/hicolor
13 ICONDIR = $(ICONPATH)/scalable/apps
14 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH)
15
16 NAME = subsurface
17 ICONFILE = $(NAME).svg
18 DESKTOPFILE = $(NAME).desktop
19
20 # find libdivecomputer; we don't trust pkg-config here given how young
21 # libdivecomputer still is - so we check /usr/local and /usr and then we
22 # give up. You can override by simply setting it here
23 #
24 libdc-local := $(wildcard /usr/local/include/libdivecomputer/*)
25 libdc-usr := $(wildcard /usr/include/libdivecomputer/*)
26
27 ifneq ($(strip $(libdc-local)),)
28         LIBDIVECOMPUTERDIR = /usr/local
29         LIBDIVECOMPUTERINCLUDES = $(LIBDIVECOMPUTERDIR)/include/libdivecomputer
30         LIBDIVECOMPUTERARCHIVE = -L$(LIBDIVECOMPUTERDIR)/lib -ldivecomputer
31 else ifneq ($(strip $(libdc-usr)),)
32         LIBDIVECOMPUTERDIR = /usr
33         LIBDIVECOMPUTERINCLUDES = $(LIBDIVECOMPUTERDIR)/include/libdivecomputer
34         LIBDIVECOMPUTERARCHIVE = -ldivecomputer
35 else
36         $(error Cannot find libdivecomputer - please edit Makefile)
37 endif
38
39 # Libusb-1.0 is only required if libdivecomputer was built with it.
40 # And libdivecomputer is only built with it if libusb-1.0 is
41 # installed. So get libusb if it exists, but don't complain
42 # about it if it doesn't.
43 LIBUSB = $(shell pkg-config --libs libusb-1.0 2> /dev/null)
44
45 LIBXML2 = $(shell xml2-config --libs)
46 LIBGTK = $(shell pkg-config --libs gtk+-2.0 glib-2.0 gconf-2.0)
47 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
48
49 LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
50
51 OBJS =  main.o dive.o profile.o info.o equipment.o divelist.o \
52         parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
53         gtk-gui.o
54
55 $(NAME): $(OBJS)
56         $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
57
58 install: $(NAME)
59         $(INSTALL) -d -m 755 $(DESTDIR)
60         $(INSTALL) $(NAME) $(DESTDIR)
61         $(INSTALL) -d -m 755 $(DESKTOPDIR)
62         $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
63         $(INSTALL) -d -m 755 $(ICONDIR)
64         $(INSTALL) $(ICONFILE) $(ICONDIR)
65         $(gtk_update_icon_cache)
66
67 parse-xml.o: parse-xml.c dive.h
68         $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c `xml2-config --cflags`  parse-xml.c
69
70 save-xml.o: save-xml.c dive.h
71         $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c save-xml.c
72
73 dive.o: dive.c dive.h
74         $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c dive.c
75
76 main.o: main.c dive.h display.h divelist.h
77         $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0 gconf-2.0` \
78                 -c main.c
79
80 profile.o: profile.c dive.h display.h divelist.h
81         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c profile.c
82
83 info.o: info.c dive.h display.h display-gtk.h divelist.h
84         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c info.c
85
86 equipment.o: equipment.c dive.h display.h divelist.h
87         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c equipment.c
88
89 divelist.o: divelist.c dive.h display.h divelist.h
90         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c divelist.c
91
92 print.o: print.c dive.h display.h display-gtk.h
93         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c print.c
94
95 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
96         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` \
97                         -I$(LIBDIVECOMPUTERINCLUDES) \
98                         -c libdivecomputer.c
99
100 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h
101         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0 gconf-2.0` \
102                         -I$(LIBDIVECOMPUTERINCLUDES) \
103                         -DVERSION_STRING='"v$(VERSION)"' \
104                         -c gtk-gui.c
105
106 uemis.o: uemis.c uemis.h
107         $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c uemis.c
108
109 clean:
110         rm -f $(OBJS) *~ $(NAME)