--- examples/Makefile.orig	2015-04-15 07:50:13 UTC
+++ examples/Makefile
@@ -85,8 +85,8 @@ CIMG_EXTRA_FILES = use_tiff_stream use_j
 # Set correct variables and paths
 #---------------------------------
 CIMG_VERSION = 1.6.2
-X11PATH      = /usr/X11R6
-CC           = g++
+#X11PATH      = $(X11PATH)
+CC           = $(CXX)
 EXEPFX       =
 CCVER       = $(CC)
 ifeq ($(notdir $(CC)),g++)
@@ -100,7 +100,7 @@ CCVER        = "icpc \( `$(CC) -v 2>&1`\
 CFLAGS       = -I..
 LIBS         =
 else
-CFLAGS       = -I.. -Wall -W
+CFLAGS       = -I.. -Wall -W $(CPPFLAGS)
 LIBS         = -lm
 endif
 
@@ -124,12 +124,12 @@ CIMG_VT100_CFLAGS = -Dcimg_use_vt100
 
 # Flags to enable code optimization by the compiler.
 ifeq ($(notdir $(CC)),g++)
-CIMG_OPT_CFLAGS = -O2 -mtune=generic
+CIMG_OPT_CFLAGS = -mtune=generic
 else
 ifeq ($(notdir $(CC)),icpc)
 CIMG_OPT_CFLAGS = -fast
 else
-CIMG_OPT_CFLAGS = -O2
+CIMG_OPT_CFLAGS =
 endif
 endif
 
@@ -141,7 +141,7 @@ CIMG_OPENMP_CFLAGS = -Dcimg_use_openmp -
 endif
 
 # Flags to enable OpenCV support.
-CIMG_OPENCV_CFLAGS = -Dcimg_use_opencv -I/usr/include/opencv
+CIMG_OPENCV_CFLAGS = -Dcimg_use_opencv -I$(LOCALBASE)/include/opencv
 CIMG_OPENCV_LIBS = -lopencv_core -lopencv_highgui
 #CIMG_OPENCV_LIBS = -lcv -lhighgui    #-> Use this for OpenCV < 2.2.0
 
@@ -152,7 +152,7 @@ CIMG_NODISPLAY_CFLAGS = -Dcimg_display=0
 # (X11 is used by CImg to handle display windows)
 # !!! For 64bits systems : replace -L$(X11PATH)/lib by -L$(X11PATH)/lib64 !!!
 CIMG_X11_CFLAGS = -I$(X11PATH)/include
-CIMG_X11_LIBS = -L$(X11PATH)/lib -lpthread -lX11
+CIMG_X11_LIBS = -L$(X11PATH)/lib -lX11 $(PTHREAD_LIBS)
 
 # Flags to enable fast image display, using the XSHM library (when using X11).
 # !!! Seems to randomly crash when used on MacOSX and 64bits systems, so use it only when necessary !!!
@@ -182,7 +182,7 @@ CIMG_JPEG_LIBS = -ljpeg
 # Flags to enable native support for TIFF image files, using the TIFF library.
 # ( http://www.libtiff.org/ )
 CIMG_TIFF_CFLAGS = -Dcimg_use_tiff
-CIMG_TIFF_LIBS = -ltiff
+CIMG_TIFF_LIBS = -ltiff -ltiffxx
 
 # Flags to enable native support for MINC2 image files, using the MINC2 library.
 # ( http://en.wikibooks.org/wiki/MINC/Reference/MINC2.0_Users_Guide )
@@ -191,12 +191,12 @@ CIMG_MINC2_LIBS = -lminc_io -lvolume_io2
 
 # Flags to enable native support for EXR image files, using the OpenEXR library.
 # ( http://www.openexr.com/ )
-CIMG_EXR_CFLAGS = -Dcimg_use_openexr -I/usr/include/OpenEXR
+CIMG_EXR_CFLAGS = -Dcimg_use_openexr -I$(LOCALBASE)/include/OpenEXR
 CIMG_EXR_LIBS = -lIlmImf -lHalf
 
 # Flags to enable native support for various video files, using the FFMPEG library.
 # ( http://www.ffmpeg.org/ )
-CIMG_FFMPEG_CFLAGS = -Dcimg_use_ffmpeg -D__STDC_CONSTANT_MACROS -I/usr/include/libavcodec -I/usr/include/libavformat -I/usr/include/libswscale -I/usr/include/ffmpeg
+CIMG_FFMPEG_CFLAGS = -Dcimg_use_ffmpeg -D__STDC_CONSTANT_MACROS -I$(LOCALBASE)/include/libavcodec -I$(LOCALBASE)/include/libavformat -I$(LOCALBASE)/include/libswscale -I$(LOCALBASE)/include/ffmpeg
 CIMG_FFMPEG_LIBS = -lavcodec -lavformat -lswscale
 
 # Flags to enable native support for compressed .cimgz files, using the Zlib library.
@@ -209,10 +209,10 @@ CIMG_ZLIB_LIBS = -lz
 CIMG_CURL_CFLAGS = -Dcimg_use_curl
 CIMG_CURL_LIBS = -lcurl
 
-# Flags to enable native support of most classical image file formats, using the Magick++ library.
+# Flags to enable native support of most classical image file formats, using the GraphicsMagick++ library.
 # ( http://www.imagemagick.org/Magick++/ )
-CIMG_MAGICK_CFLAGS = -Dcimg_use_magick `Magick++-config --cppflags` `Magick++-config --cxxflags`
-CIMG_MAGICK_LIBS = `Magick++-config --ldflags` `Magick++-config --libs`
+CIMG_MAGICK_CFLAGS = -Dcimg_use_magick `GraphicsMagick++-config --cppflags` `GraphicsMagick++-config --cxxflags`
+CIMG_MAGICK_LIBS = `GraphicsMagick++-config --ldflags` `GraphicsMagick++-config --libs`
 
 # Flags to enable faster Discrete Fourier Transform computation, using the FFTW3 library
 # ( http://www.fftw.org/ )
@@ -225,14 +225,17 @@ endif
 
 # Flags to enable the use of LAPACK routines for matrix computation
 # ( http://www.netlib.org/lapack/ )
-CIMG_LAPACK_CFLAGS = -Dcimg_use_lapack
-CIMG_LAPACK_LIBS = -lblas -lg2c -llapack
+#CIMG_LAPACK_CFLAGS = -Dcimg_use_lapack
+#CIMG_LAPACK_LIBS = -lblas -llapack
 
 # Flags to enable the use of the Board library
 # ( http://libboard.sourceforge.net/ )
-CIMG_BOARD_CFLAGS = -Dcimg_use_board -I/usr/include/board
+CIMG_BOARD_CFLAGS = -Dcimg_use_board -I$(LOCALBASE)/include/board
 CIMG_BOARD_LIBS = -lboard
 
+# Flags to compile on FreeBSD
+CIMG_FREEBSD_LDFLAGS = $(LDFLAGS) -ansi -ffast-math  -I$(X11PATH)/include $(EXTRA_FLAGS) -lX11 -L$(X11PATH)/lib
+
 # Flags to compile on Sun Solaris
 CIMG_SOLARIS_LIBS = -R$(X11PATH)/lib -lrt -lnsl -lsocket
 
@@ -335,7 +338,8 @@ $(CIMG_X11_CFLAGS) \
 $(CIMG_XSHM_CFLAGS)" \
 "CONF_LIBS = \
 $(CIMG_X11_LIBS) \
-$(CIMG_XSHM_LIBS)" \
+$(CIMG_XSHM_LIBS) \
+$(PTHREAD_LIBS)" \
 all
 
 olinux:
@@ -378,8 +382,10 @@ $(CIMG_ZLIB_CFLAGS) \
 $(CIMG_CURL_CFLAGS) \
 $(CIMG_OPENCV_CFLAGS) \
 $(CIMG_MAGICK_CFLAGS) \
+$(CIMG_LAPACK_CFLAGS) \
 $(CIMG_FFTW3_CFLAGS)" \
 "CONF_LIBS = \
+$(CIMG_FREEBSD_LDFLAGS) \
 $(CIMG_X11_LIBS) \
 $(CIMG_XSHM_LIBS) \
 $(CIMG_XRANDR_LIBS) \
@@ -389,6 +395,7 @@ $(CIMG_PNG_LIBS) \
 $(CIMG_JPEG_LIBS) \
 $(CIMG_ZLIB_LIBS) \
 $(CIMG_CURL_LIBS) \
+$(CIMG_LAPACK_LIBS) \
 $(CIMG_OPENCV_LIBS) \
 $(CIMG_MAGICK_LIBS) \
 $(CIMG_FFTW3_LIBS)" \
