--- Makefile.orig	2015-05-26 13:57:59.000000000 -0500
+++ Makefile	2015-05-26 17:42:09.000000000 -0500
@@ -41,6 +41,7 @@
 ifeq ($(UNAME), Darwin)
 SONAME_FLAG = -install_name
 SHARED_FLAG = -dynamiclib
+OSX_FLAGS = -current_version ${SOVERSION} -compatibility_version ${SOMAJOR}
 endif
 
 all: ${PROJECTNV} ${BUILDDIR}/${PROJECT}.pc po
@@ -111,16 +112,16 @@
 	@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
 	$(QUIET)ar rcs $@ ${OBJECTS}
 
-${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}: ${OBJECTS}
+${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.${SOVERSION}.dylib: ${OBJECTS}
 	$(call colorecho,LD,$@)
 	@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
-	$(QUIET)${CC} -Wl,${SONAME_FLAG},lib${PROJECT}.so.${SOMAJOR} \
-		${SHARED_FLAG} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
+	$(QUIET)${CC} -Wl,${SONAME_FLAG},${LIBDIR}/lib${PROJECT}.${SOMAJOR}.dylib \
+		${SHARED_FLAG} ${OSX_FLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
 
 ${PROJECT}: static shared
 ${PROJECTNV}: ${PROJECT}
 static: ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.a
-shared: ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}
+shared: ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.${SOVERSION}.dylib
 release: ${PROJECT}
 
 # debug build
@@ -142,14 +143,14 @@
 	@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
 	$(QUIET)${AR} rcs $@ ${OBJECTS_DEBUG}
 
-${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}: ${OBJECTS_DEBUG}
+${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.${SOVERSION}.dylib: ${OBJECTS_DEBUG}
 	$(call colorecho,LD,$@)
 	@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
-	$(QUIET)${CC} -Wl,${SONAME_FLAG},lib${PROJECT}.so.${SOMAJOR} ${SHARED_FLAG} ${LDFLAGS} -o $@ ${OBJECTS_DEBUG} ${LIBS}
+	$(QUIET)${CC} -Wl,${SONAME_FLAG},${LIBDIR}/lib${PROJECT}.${SOMAJOR}.dylib ${SHARED_FLAG} ${OSX_FLAGS} ${LDFLAGS} -o $@ ${OBJECTS_DEBUG} ${LIBS}
 
 ${PROJECT}-debug: \
 	${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.a \
-	${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}
+	${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.${SOVERSION}.dylib
 debug: ${PROJECT}-debug
 
 # gcov build
@@ -171,11 +172,11 @@
 	@mkdir -p ${BUILDDIR_GCOV}/${BINDIR}
 	$(QUIET)${AR} rcs $@ ${OBJECTS_GCOV}
 
-${BUILDDIR_GCOV}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}: ${OBJECTS_GCOV}
+${BUILDDIR_GCOV}/${BINDIR}/lib${PROJECT}.${SOVERSION}.dylib: ${OBJECTS_GCOV}
 	$(call colorecho,LD,$@)
 	@mkdir -p ${BUILDDIR_GCOV}/${BINDIR}
-	$(QUIET)${CC} -Wl,${SONAME_FLAG},lib${PROJECT}.so.${SOMAJOR} ${SHARED_FLAG} \
-		${GCOV_LDFLAGS} -o $@ ${OBJECTS_GCOV} ${LIBS}
+	$(QUIET)${CC} -Wl,${SONAME_FLAG},${LIBDIR}/lib${PROJECT}.${SOMAJOR}.dylib ${SHARED_FLAG} \
+		${OSX_FLAGS} ${GCOV_LDFLAGS} -o $@ ${OBJECTS_GCOV} ${LIBS}
 
 ${PROJECT}-gcov: ${BUILDDIR_GCOV}/${BINDIR}/lib${PROJECT}.a
 gcov: ${PROJECT}-gcov
@@ -245,11 +246,11 @@
 install-shared: shared
 	$(call colorecho,INSTALL,"Install shared library")
 	$(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}
-	$(QUIET)install -m 644 ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}
-	$(QUIET)ln -sf lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}/lib${PROJECT}.so.${SOMAJOR} || \
-		echo "Failed to create lib${PROJECT}.so.${SOMAJOR}. Please check if it exists and points to the correct version of lib${PROJECT}.so."
-	$(QUIET)ln -sf lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}/lib${PROJECT}.so || \
-		echo "Failed to create lib${PROJECT}.so. Please check if it exists and points to the correct version of lib${PROJECT}.so."
+	$(QUIET)install -m 644 ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.${SOVERSION}.dylib ${DESTDIR}${LIBDIR}
+	$(QUIET)ln -sf lib${PROJECT}.${SOVERSION}.dylib ${DESTDIR}${LIBDIR}/lib${PROJECT}.${SOMAJOR}.dylib || \
+		echo "Failed to create lib${PROJECT}.${SOMAJOR}.dylib. Please check if it exists and points to the correct version of lib${PROJECT}.dylib"
+	$(QUIET)ln -sf lib${PROJECT}.${SOVERSION}.dylib ${DESTDIR}${LIBDIR}/lib${PROJECT}.dylib || \
+		echo "Failed to create lib${PROJECT}.dylib. Please check if it exists and points to the correct version of lib${PROJECT}.dylib."
 
 install-headers: ${PROJECTNV}/version.h ${BUILDDIR}/${PROJECT}.pc
 	$(call colorecho,INSTALL,"Install pkg-config file")
@@ -268,8 +269,8 @@
 
 uninstall: uninstall-headers
 	$(call colorecho,UNINSTALL,"Remove library files")
-	$(QUIET)rm -f ${LIBDIR}/lib${PROJECT}.a ${LIBDIR}/lib${PROJECT}.so.${SOVERSION} \
-		${LIBDIR}/lib${PROJECT}.so.${SOMAJOR} ${LIBDIR}/lib${PROJECT}.so
+	$(QUIET)rm -f ${LIBDIR}/lib${PROJECT}.a ${LIBDIR}/lib${PROJECT}.${SOVERSION}.dylib \
+		${LIBDIR}/lib${PROJECT}.${SOMAJOR}.dylib ${LIBDIR}/lib${PROJECT}.dylib
 	$(QUIET)${MAKE} -C po uninstall
 
 uninstall-headers:
