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