]> git.tdb.fi Git - ext/subsurface.git/blob - Makefile
Add basic MacOSX app bundle install target
[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 MACOSXICONFILE = macosx/Subsurface.icns
27 MACOSXINFOFILE = macosx/Info.plist
28 MACOSXPKGFILE = macosx/PkgInfo
29
30 # find libdivecomputer
31 # First deal with the cross compile environment.
32 # For the native case, Linus doesn't want to trust pkg-config given
33 # how young libdivecomputer still is - so we check the typical
34 # subdirectories of /usr/local and /usr and then we give up. You can
35 # override by simply setting it here
36 #
37 ifeq ($(CC), i686-w64-mingw32-gcc)
38 # ok, we are cross building for Windows
39         LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer
40         LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer`
41         LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer`
42         RESFILE = packaging/windows/subsurface.res
43         LDFLAGS += -Wl,-subsystem,windows
44 else
45
46 libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
47 libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
48 libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
49 libdc-usr64 := $(wildcard /usr/lib64/libdivecomputer.a)
50
51 ifneq ($(strip $(libdc-local)),)
52         LIBDIVECOMPUTERDIR = /usr/local
53         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
54         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
55 else ifneq ($(strip $(libdc-local64)),)
56         LIBDIVECOMPUTERDIR = /usr/local
57         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
58         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
59 else ifneq ($(strip $(libdc-usr)),)
60         LIBDIVECOMPUTERDIR = /usr
61         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
62         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
63 else ifneq ($(strip $(libdc-usr64)),)
64         LIBDIVECOMPUTERDIR = /usr
65         LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
66         LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
67 else
68 $(error Cannot find libdivecomputer - please edit Makefile)
69 endif
70 endif
71
72 # Libusb-1.0 is only required if libdivecomputer was built with it.
73 # And libdivecomputer is only built with it if libusb-1.0 is
74 # installed. So get libusb if it exists, but don't complain
75 # about it if it doesn't.
76 LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
77
78 LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
79 LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
80 LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
81
82 LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
83
84 OBJS =  main.o dive.o profile.o info.o equipment.o divelist.o \
85         parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
86         gtk-gui.o $(RESFILE)
87
88 $(NAME): $(OBJS)
89         $(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
90
91 install: $(NAME)
92         $(INSTALL) -d -m 755 $(BINDIR)
93         $(INSTALL) $(NAME) $(BINDIR)
94         $(INSTALL) -d -m 755 $(DESKTOPDIR)
95         $(INSTALL) $(DESKTOPFILE) $(DESKTOPDIR)
96         $(INSTALL) -d -m 755 $(ICONDIR)
97         $(INSTALL) $(ICONFILE) $(ICONDIR)
98         $(gtk_update_icon_cache)
99         $(INSTALL) -d -m 755 $(MANDIR)
100         $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
101
102 LIBXML2 = $(shell $(XML2CONFIG) --libs)
103 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
104 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
105 GCONF2CFLAGS =  $(shell $(PKGCONFIG) --cflags gconf-2.0)
106 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
107
108 install-macosx: $(NAME)
109         $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
110         $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
111         $(INSTALL) $(NAME) $(MACOSXINSTALL)/Contents/MacOS/
112         $(INSTALL) $(MACOSXINFOFILE) $(MACOSXINSTALL)/Contents/
113         $(INSTALL) $(MACOSXPKGFILE) $(MACOSXINSTALL)/Contents/
114         $(INSTALL) $(MACOSXICONFILE) $(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)