From: Hauke Wintjen <hwintjen@rimpl-consulting.de>
Date: Fri, 29 Mar 2013 22:21:36 +0100
Subject: Use system wide libjpeg

---
 Source/Core/Makefile |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/Source/Core/Makefile
+++ b/Source/Core/Makefile
@@ -5,14 +5,12 @@
 INC_DIRS = \
 	../../Include \
 	../../ThirdParty/PSCommon/XnLib/Include \
-	../Drivers/OniFile/Formats \
-	../../ThirdParty/LibJPEG
+	../Drivers/OniFile/Formats
 
 SRC_FILES = \
 	*.cpp \
 	../Drivers/OniFile/Formats/XnCodec.cpp \
-	../Drivers/OniFile/Formats/XnStreamCompression.cpp \
-	../../ThirdParty/LibJPEG/*.c \
+	../Drivers/OniFile/Formats/XnStreamCompression.cpp
 
 ifeq ("$(OSTYPE)","Darwin")
 	INC_DIRS += /opt/local/include
@@ -23,7 +21,7 @@
 LIB_NAME = OpenNI2
 
 LIB_DIRS = ../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib dl pthread
+USED_LIBS = XnLib dl pthread jpeg
 ifneq ("$(OSTYPE)","Darwin")
         USED_LIBS += rt  
 endif
@@ -32,4 +30,11 @@
 
 CFLAGS += -Wall
 
+ifeq ($(shell ld -ljpeg -o /dev/null 1>&2 2> /dev/null; echo $$?), 0)
+  USED_LIBS += jpeg
+else
+  INC_DIRS  += ../../ThirdParty/LibJPEG
+  SRC_FILES += ../../ThirdParty/LibJPEG/*.c
+endif
+
 include ../../ThirdParty/PSCommon/BuildSystem/CommonCppMakefile
--- a/Source/Drivers/OniFile/Makefile
+++ b/Source/Drivers/OniFile/Makefile
@@ -6,15 +6,12 @@
 	. \
 	../../../Include \
 	../../../ThirdParty/PSCommon/XnLib/Include \
-	../../../ThirdParty/LibJPEG \
 	Formats
 
 SRC_FILES = \
 	*.cpp \
 	Formats/*.cpp \
-	XnLibExtensions/*.cpp \
-	../../../ThirdParty/LibJPEG/*.c
-
+	XnLibExtensions/*.cpp
 
 ifeq ("$(OSTYPE)","Darwin")
 	INC_DIRS += /opt/local/include
@@ -25,7 +22,7 @@
 LIB_NAME = OniFile
 
 LIB_DIRS = ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib pthread 
+USED_LIBS = XnLib pthread jpeg
 ifneq ("$(OSTYPE)","Darwin")
         USED_LIBS += rt  
 endif
--- a/Source/Drivers/PS1080/Makefile
+++ b/Source/Drivers/PS1080/Makefile
@@ -14,8 +14,7 @@
 	DriverImpl/*.cpp\
 	Formats/*.cpp	\
 	Include/*.cpp	\
-	Sensor/*.cpp	\
-	../../../ThirdParty/LibJPEG/*.c
+	Sensor/*.cpp
 
 
 ifeq ("$(OSTYPE)","Darwin")
@@ -27,7 +26,7 @@
 LIB_NAME = PS1080
 
 LIB_DIRS += ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib dl pthread
+USED_LIBS = XnLib dl pthread jpeg
 ifneq ("$(OSTYPE)","Darwin")
         USED_LIBS += rt usb-1.0
 else
