]> git.tdb.fi Git - ext/subsurface.git/blob - Makefile
Don't run gtk-update-icon-cache if DESTDIR is set
[ext/subsurface.git] / Makefile
1 VERSION=1.1
2
3 CC=gcc
4 CFLAGS=-Wall -Wno-pointer-sign -g
5 INSTALL=install
6 PKGCONFIG=pkg-config
7 XML2CONFIG=xml2-config
8
9 # these locations seem to work for SuSE and Fedora
10 # prefix = $(HOME)
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)
19
20 NAME = subsurface
21 ICONFILE = $(NAME).svg
22 DESKTOPFILE = $(NAME).desktop
23 MANFILES = $(NAME).1
24
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
31 #
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
38         LDFLAGS += -Wl,-subsystem,windows
39 else
40
41 libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
42 libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
43 libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
44 libdc-usr64 := $(wildcard /usr/lib64/libdivecomputer.a)
45
46 ifneq ($(strip $(libdc-local)),)
47         LIBDIVECOMPUTERDIR = /usr/local
48         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
49         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
50 else ifneq ($(strip $(libdc-local64)),)
51         LIBDIVECOMPUTERDIR = /usr/local
52         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
53         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
54 else ifneq ($(strip $(libdc-usr)),)
55         LIBDIVECOMPUTERDIR = /usr
56         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
57         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
58 else ifneq ($(strip $(libdc-usr64)),)
59         LIBDIVECOMPUTERDIR = /usr
60         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
61         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
62 else
63 $(error Cannot find libdivecomputer - please edit Makefile)
64 endif
65 endif
66
67 # Libusb-1.0 is only required if libdivecomputer was built with it.
68 # And libdivecomputer is only built with it if libusb-1.0 is
69 # installed. So get libusb if it exists, but don't complain
70 # about it if it doesn't.
71 LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
72
73 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
74 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
75 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
76
77 LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
78
79 OBJS =  main.o dive.o profile.o info.o equipment.o divelist.o \
80         parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
81         gtk-gui.o $(RESFILE)
82
83 $(NAME): $(OBJS)
84         $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
85
86 install: $(NAME)
87         $(INSTALL) -d -m 755 $(BINDIR)
88         $(INSTALL) $(NAME) $(BINDIR)
89         $(INSTALL) -d -m 755 $(DESKTOPDIR)
90         $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
91         $(INSTALL) -d -m 755 $(ICONDIR)
92         $(INSTALL) $(ICONFILE) $(ICONDIR)
93         @-if test -z "$(DESTDIR)"; then \
94                 $(gtk_update_icon_cache); \
95         fi
96         $(INSTALL) -d -m 755 $(MANDIR)
97         $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
98
99 LIBXML2 = $(shell $(XML2CONFIG) --libs)
100 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
101 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
102 GCONF2CFLAGS =  $(shell $(PKGCONFIG) --cflags gconf-2.0)
103 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
104
105 parse-xml.o: parse-xml.c dive.h
106         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c $(XML2CFLAGS)  parse-xml.c
107
108 save-xml.o: save-xml.c dive.h
109         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c save-xml.c
110
111 dive.o: dive.c dive.h
112         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c dive.c
113
114 main.o: main.c dive.h display.h divelist.h
115         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) -c main.c
116
117 profile.o: profile.c dive.h display.h divelist.h
118         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c profile.c
119
120 info.o: info.c dive.h display.h display-gtk.h divelist.h
121         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c info.c
122
123 equipment.o: equipment.c dive.h display.h divelist.h
124         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c equipment.c
125
126 divelist.o: divelist.c dive.h display.h divelist.h
127         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
128
129 print.o: print.c dive.h display.h display-gtk.h
130         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c print.c
131
132 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
133         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) \
134                         $(LIBDIVECOMPUTERCFLAGS) \
135                         -c libdivecomputer.c
136
137 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
138         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) \
139                         $(LIBDIVECOMPUTERCFLAGS) \
140                         -DVERSION_STRING='"v$(VERSION)"' \
141                         -c gtk-gui.c
142
143 uemis.o: uemis.c uemis.h
144         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c uemis.c
145
146 clean:
147         rm -f $(OBJS) *~ $(NAME)