]> git.tdb.fi Git - ext/subsurface.git/blob - Makefile
Subsurface 1.2
[ext/subsurface.git] / Makefile
1 VERSION=1.2
2
3 CC=gcc
4 CFLAGS=-Wall -Wno-pointer-sign -g
5 INSTALL=install
6 PKGCONFIG=pkg-config
7 XML2CONFIG=xml2-config
8 XSLCONFIG=xslt-config
9
10 # these locations seem to work for SuSE and Fedora
11 # prefix = $(HOME)
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)
21
22 NAME = subsurface
23 ICONFILE = $(NAME).svg
24 DESKTOPFILE = $(NAME).desktop
25 MANFILES = $(NAME).1
26 XSLTFILES = xslt/*.xslt
27
28 MACOSXINSTALL = /Applications/Subsurface.app
29 MACOSXFILES = packaging/macosx
30
31 # find libdivecomputer
32 # First deal with the cross compile environment.
33 # For the native case, Linus doesn't want to trust pkg-config given
34 # how young libdivecomputer still is - so we check the typical
35 # subdirectories of /usr/local and /usr and then we give up. You can
36 # override by simply setting it here
37 #
38 ifeq ($(CC), i686-w64-mingw32-gcc)
39 # ok, we are cross building for Windows
40         LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer
41         LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer`
42         LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer`
43         RESFILE = packaging/windows/subsurface.res
44         LDFLAGS += -Wl,-subsystem,windows
45 else
46
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)
51
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
68 else
69 $(error Cannot find libdivecomputer - please edit Makefile)
70 endif
71 endif
72
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)
78
79 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0)
80 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
81 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
82
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)
89
90 UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win")
91
92
93 ifeq ($(UNAME), linux)
94         LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0)
95         GCONF2CFLAGS =  $(shell $(PKGCONFIG) --cflags gconf-2.0)
96         OSSUPPORT = linux
97         OSSUPPORT_CFLAGS = $(GTK2CFLAGS) $(GCONF2CFLAGS)
98 else ifeq ($(UNAME), darwin)
99         OSSUPPORT = macos
100         OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
101 else
102         OSSUPPORT = windows
103         OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
104 endif
105
106 ifneq ($(strip $(LIBXSLT)),)
107         # We still need proper paths and install options for OSX and Windows
108         ifeq ($(shell sh -c 'uname -s 2>/dev/null || echo not'),Linux)
109                 XSLT=-DXSLT='"$(XSLTDIR)"'
110         endif
111 endif
112
113 LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) -lpthread
114
115 OBJS =  main.o dive.o profile.o info.o equipment.o divelist.o \
116         parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
117         gtk-gui.o statistics.o $(OSSUPPORT).o $(RESFILE)
118
119 $(NAME): $(OBJS)
120         $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
121
122 install: $(NAME)
123         $(INSTALL) -d -m 755 $(BINDIR)
124         $(INSTALL) $(NAME) $(BINDIR)
125         $(INSTALL) -d -m 755 $(DESKTOPDIR)
126         $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
127         $(INSTALL) -d -m 755 $(ICONDIR)
128         $(INSTALL) $(ICONFILE) $(ICONDIR)
129         @-if test -z "$(DESTDIR)"; then \
130                 $(gtk_update_icon_cache); \
131         fi
132         $(INSTALL) -d -m 755 $(MANDIR)
133         $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
134         @-if test ! -z "$(XSLT)"; then \
135                 $(INSTALL) -d -m 755 $(DATADIR)/subsurface; \
136                 $(INSTALL) -d -m 755 $(XSLTDIR); \
137                 $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \
138         fi
139
140 install-macosx: $(NAME)
141         $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
142         $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
143         $(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/
144         $(INSTALL) $(MACOSXFILES)/subsurface.sh $(MACOSXINSTALL)/Contents/MacOS/
145         $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXINSTALL)/Contents/
146         $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
147         $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
148         $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
149
150 parse-xml.o: parse-xml.c dive.h
151         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) $(XSLT) -c parse-xml.c
152
153 save-xml.o: save-xml.c dive.h
154         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c save-xml.c
155
156 dive.o: dive.c dive.h
157         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c dive.c
158
159 main.o: main.c dive.h display.h divelist.h
160         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) $(XML2CFLAGS) -c main.c
161
162 profile.o: profile.c dive.h display.h divelist.h
163         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c profile.c
164
165 info.o: info.c dive.h display.h display-gtk.h divelist.h
166         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c info.c
167
168 equipment.o: equipment.c dive.h display.h divelist.h
169         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c equipment.c
170
171 statistics.o: statistics.c dive.h display.h divelist.h
172         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c statistics.c
173
174 divelist.o: divelist.c dive.h display.h divelist.h
175         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c divelist.c
176
177 print.o: print.c dive.h display.h display-gtk.h
178         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c print.c
179
180 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
181         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) \
182                         $(LIBDIVECOMPUTERCFLAGS) \
183                         -c libdivecomputer.c
184
185 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
186         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) $(XML2CFLAGS) \
187                         $(LIBDIVECOMPUTERCFLAGS) \
188                         -DVERSION_STRING='"v$(VERSION)"' \
189                         -c gtk-gui.c
190
191 uemis.o: uemis.c dive.h uemis.h
192         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c uemis.c
193
194 $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h
195         $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c
196
197 clean:
198         rm -f $(OBJS) *~ $(NAME)