Split reading/writing preferences into OS specific files

This adds tested code for Linux and Mac OS, implementing the api that
Linus suggested.

The Windows code was moved into its own file, but hasn't even been compile
tested, yet.

In order to have just one interface to set or get a preference value we
encode TRUE as (void *) 1 and FALSE as NULL. This works consistently on
all platforms and regardless of whether we have 32 or 64 bit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2011-11-23 22:56:57 -08:00
parent cf6e0e7ca1
commit 671f6544ac
6 changed files with 283 additions and 185 deletions

View file

@ -80,11 +80,39 @@ LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0 gconf-2.0)
LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
LIBXML2 = $(shell $(XML2CONFIG) --libs)
LIBXSLT = $(shell $(XSLCONFIG) --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)
CFLAGS += $(shell $(XSLCONFIG) --cflags)
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
OSSUPPORT = linux
OSSUPPORT_CFLAGS = $(GTK2CFLAGS) $(GCONF2CFLAGS)
else ifeq ($(UNAME), Darwin)
OSSUPPORT = macos
OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
else
OSSUPPORT = windows
OSSUPPORT_CFLAGS = $(GTK2CFLAGS)
endif
ifneq ($(strip $(LIBXSLT)),)
# We still need proper paths and install options for OSX and Windows
ifeq ($(shell sh -c 'uname -s 2>/dev/null || echo not'),Linux)
XSLT=-DXSLT='"$(XSLTDIR)"'
endif
endif
LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \
parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
gtk-gui.o statistics.o $(RESFILE)
gtk-gui.o statistics.o $(OSSUPPORT).o $(RESFILE)
$(NAME): $(OBJS)
$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
@ -107,21 +135,6 @@ install: $(NAME)
$(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \
fi
LIBXML2 = $(shell $(XML2CONFIG) --libs)
LIBXSLT = $(shell $(XSLCONFIG) --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)
CFLAGS += $(shell $(XSLCONFIG) --cflags)
ifneq ($(strip $(LIBXSLT)),)
# We still need proper paths and install options for OSX and Windows
ifeq ($(shell sh -c 'uname -s 2>/dev/null || echo not'),Linux)
XSLT=-DXSLT='"$(XSLTDIR)"'
endif
endif
install-macosx: $(NAME)
$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources
$(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/MacOS
@ -176,5 +189,8 @@ gtk-gui.o: gtk-gui.c dive.h display.h divelist.h display-gtk.h libdivecomputer.h
uemis.o: uemis.c dive.h uemis.h
$(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) $(XML2CFLAGS) -c uemis.c
$(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h
$(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c
clean:
rm -f $(OBJS) *~ $(NAME)