]> git.tdb.fi Git - ext/subsurface.git/blob - Makefile
Use the new packaging directory for MacOSX specific files, and provide shell script...
[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 MACOSXINSTALL = /Applications/Subsurface.app
26 MACOSXFILES = packaging/macosx
27
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
34 #
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
42 else
43
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)
48
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
65 else
66 $(error Cannot find libdivecomputer - please edit Makefile)
67 endif
68 endif
69
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)
75
76 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
77 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
78 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
79
80 LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
81
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 \
84         gtk-gui.o $(RESFILE)
85
86 $(NAME): $(OBJS)
87         $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
88
89 install: $(NAME)
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         $(gtk_update_icon_cache)
97         $(INSTALL) -d -m 755 $(MANDIR)
98         $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
99
100 LIBXML2 = $(shell $(XML2CONFIG) --libs)
101 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
102 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
103 GCONF2CFLAGS =  $(shell $(PKGCONFIG) --cflags gconf-2.0)
104 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
105
106 install-macosx: $(NAME)
107         $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
108         $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
109         $(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/
110         $(INSTALL) $(MACOSXFILES)/subsurface.sh $(MACOSXINSTALL)/Contents/MacOS/
111         $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXINSTALL)/Contents/
112         $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/
113         $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/
114         $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/
115
116 parse-xml.o: parse-xml.c dive.h
117         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c $(XML2CFLAGS)  parse-xml.c
118
119 save-xml.o: save-xml.c dive.h
120         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c save-xml.c
121
122 dive.o: dive.c dive.h
123         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c dive.c
124
125 main.o: main.c dive.h display.h divelist.h
126         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) -c main.c
127
128 profile.o: profile.c dive.h display.h divelist.h
129         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c profile.c
130
131 info.o: info.c dive.h display.h display-gtk.h divelist.h
132         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c info.c
133
134 equipment.o: equipment.c dive.h display.h divelist.h
135         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c equipment.c
136
137 divelist.o: divelist.c dive.h display.h divelist.h
138         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
139
140 print.o: print.c dive.h display.h display-gtk.h
141         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c print.c
142
143 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
144         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) \
145                         $(LIBDIVECOMPUTERCFLAGS) \
146                         -c libdivecomputer.c
147
148 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
149         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) \
150                         $(LIBDIVECOMPUTERCFLAGS) \
151                         -DVERSION_STRING='"v$(VERSION)"' \
152                         -c gtk-gui.c
153
154 uemis.o: uemis.c uemis.h
155         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c uemis.c
156
157 clean:
158         rm -f $(OBJS) *~ $(NAME)