]> git.tdb.fi Git - ext/subsurface.git/blob - Makefile
Merge branch 'mingw-port-cleanup' of git://github.com/dirkhh/subsurface
[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         $(gtk_update_icon_cache)
94         $(INSTALL) -d -m 755 $(MANDIR)
95         $(INSTALL) -m 644 $(MANFILES) $(MANDIR)
96
97 LIBXML2 = $(shell $(XML2CONFIG) --libs)
98 XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
99 GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
100 GCONF2CFLAGS =  $(shell $(PKGCONFIG) --cflags gconf-2.0)
101 GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
102
103 parse-xml.o: parse-xml.c dive.h
104         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c $(XML2CFLAGS)  parse-xml.c
105
106 save-xml.o: save-xml.c dive.h
107         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c save-xml.c
108
109 dive.o: dive.c dive.h
110         $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c dive.c
111
112 main.o: main.c dive.h display.h divelist.h
113         $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) -c main.c
114
115 profile.o: profile.c dive.h display.h divelist.h
116         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c profile.c
117
118 info.o: info.c dive.h display.h display-gtk.h divelist.h
119         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c info.c
120
121 equipment.o: equipment.c dive.h display.h divelist.h
122         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c equipment.c
123
124 divelist.o: divelist.c dive.h display.h divelist.h
125         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
126
127 print.o: print.c dive.h display.h display-gtk.h
128         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c print.c
129
130 libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
131         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) \
132                         $(LIBDIVECOMPUTERCFLAGS) \
133                         -c libdivecomputer.c
134
135 gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
136         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) \
137                         $(LIBDIVECOMPUTERCFLAGS) \
138                         -DVERSION_STRING='"v$(VERSION)"' \
139                         -c gtk-gui.c
140
141 uemis.o: uemis.c uemis.h
142         $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c uemis.c
143
144 clean:
145         rm -f $(OBJS) *~ $(NAME)