CC=gcc
CFLAGS=-Wall -Wno-pointer-sign -g
INSTALL=install
+PKGCONFIG=pkg-config
+XML2CONFIG=xml2-config
# these locations seem to work for SuSE and Fedora
# prefix = $(HOME)
DESKTOPFILE = $(NAME).desktop
MANFILES = $(NAME).1
-# find libdivecomputer; we don't trust pkg-config here given how young
-# libdivecomputer still is - so we check /usr/local and /usr and then we
-# give up. You can override by simply setting it here
+# find libdivecomputer
+# First deal with the cross compile environment.
+# For the native case, Linus doesn't want to trust pkg-config given
+# how young libdivecomputer still is - so we check the typical
+# subdirectories of /usr/local and /usr and then we give up. You can
+# override by simply setting it here
#
+ifeq ($(CC), i686-w64-mingw32-gcc)
+# ok, we are cross building for Windows
+ LIBDIVECOMPUTERDIR = /usr/i686-w64-mingw32/sys-root/mingw/include/libdivecomputer
+ LIBDIVECOMPUTERINCLUDES = `$(PKGCONFIG) --cflags libdivecomputer`
+ LIBDIVECOMPUTERARCHIVE = `$(PKGCONFIG) --libs libdivecomputer`
+else
+
libdc-local := $(wildcard /usr/local/lib/libdivecomputer.a)
libdc-local64 := $(wildcard /usr/local/lib64/libdivecomputer.a)
libdc-usr := $(wildcard /usr/lib/libdivecomputer.a)
ifneq ($(strip $(libdc-local)),)
LIBDIVECOMPUTERDIR = /usr/local
- LIBDIVECOMPUTERINCLUDES = $(LIBDIVECOMPUTERDIR)/include/libdivecomputer
+ LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
else ifneq ($(strip $(libdc-local64)),)
LIBDIVECOMPUTERDIR = /usr/local
- LIBDIVECOMPUTERINCLUDES = $(LIBDIVECOMPUTERDIR)/include/libdivecomputer
+ LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
else ifneq ($(strip $(libdc-usr)),)
LIBDIVECOMPUTERDIR = /usr
- LIBDIVECOMPUTERINCLUDES = $(LIBDIVECOMPUTERDIR)/include/libdivecomputer
+ LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib/libdivecomputer.a
else ifneq ($(strip $(libdc-usr64)),)
LIBDIVECOMPUTERDIR = /usr
- LIBDIVECOMPUTERINCLUDES = $(LIBDIVECOMPUTERDIR)/include/libdivecomputer
+ LIBDIVECOMPUTERINCLUDES = -I$(LIBDIVECOMPUTERDIR)/include/libdivecomputer
LIBDIVECOMPUTERARCHIVE = $(LIBDIVECOMPUTERDIR)/lib64/libdivecomputer.a
else
$(error Cannot find libdivecomputer - please edit Makefile)
endif
+endif
# Libusb-1.0 is only required if libdivecomputer was built with it.
# And libdivecomputer is only built with it if libusb-1.0 is
# installed. So get libusb if it exists, but don't complain
# about it if it doesn't.
-LIBUSB = $(shell pkg-config --libs libusb-1.0 2> /dev/null)
-
-# it appears that xml2-config isn't included in the libxml2 package for
-# MinGW - so under Windows you may want to replace this with a hardcoded
-# path to the installdir - something like
-# LIBXML2 = -L/c/opt/gtk/lib -lxml2
-LIBXML2 = $(shell xml2-config --libs)
-LIBGTK = $(shell pkg-config --libs gtk+-2.0 glib-2.0 gconf-2.0)
-LIBDIVECOMPUTERCFLAGS = -I$(LIBDIVECOMPUTERINCLUDES)
+LIBUSB = $(shell $(PKGCONFIG) --libs libusb-1.0 2> /dev/null)
+
+LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
+LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
LIBS = $(LIBXML2) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
$(INSTALL) -d -m 755 $(MANDIR)
$(INSTALL) -m 644 $(MANFILES) $(MANDIR)
-# it appears that xml2-config isn't included in the libxml2 package for
-# MinGW - so under Windows you may want to replace this with a hardcoded
-# path to the inclde dir - something like
-#
-# XML2INCLUDE = -I/c/opt/gtk/include/libxml2
-#
-# parse-xml.o: parse-xml.c dive.h
-# $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c $(XML2INCLUDE) parse-xml.c
+LIBXML2 = $(shell $(XML2CONFIG) --libs)
+XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
+GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
+GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
+GTK2CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-2.0)
-
parse-xml.o: parse-xml.c dive.h
- $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c `xml2-config --cflags` parse-xml.c
+ $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c $(XML2CFLAGS) parse-xml.c
save-xml.o: save-xml.c dive.h
- $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c save-xml.c
+ $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c save-xml.c
dive.o: dive.c dive.h
- $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0` -c dive.c
+ $(CC) $(CFLAGS) $(GLIB2CFLAGS) -c dive.c
main.o: main.c dive.h display.h divelist.h
- $(CC) $(CFLAGS) `pkg-config --cflags glib-2.0 gconf-2.0` \
- -c main.c
+ $(CC) $(CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) -c main.c
profile.o: profile.c dive.h display.h divelist.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c profile.c
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c profile.c
info.o: info.c dive.h display.h display-gtk.h divelist.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c info.c
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c info.c
equipment.o: equipment.c dive.h display.h divelist.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c equipment.c
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c equipment.c
divelist.o: divelist.c dive.h display.h divelist.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c divelist.c
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
print.o: print.c dive.h display.h display-gtk.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c print.c
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c print.c
libdivecomputer.o: libdivecomputer.c dive.h display.h display-gtk.h libdivecomputer.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` \
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) \
$(LIBDIVECOMPUTERCFLAGS) \
-c libdivecomputer.c
gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h Makefile
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0 gconf-2.0` \
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(GCONF2CFLAGS) \
$(LIBDIVECOMPUTERCFLAGS) \
-DVERSION_STRING='"v$(VERSION)"' \
-c gtk-gui.c
uemis.o: uemis.c uemis.h
- $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c uemis.c
+ $(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c uemis.c
clean:
rm -f $(OBJS) *~ $(NAME)