diff -rupN FreeImage_3_17_0_orig/Makefile.gnu FreeImage_3_17_0_new/Makefile.gnu
--- FreeImage_3_17_0_orig/Makefile.gnu	2015-03-08 18:04:00.000000000 +0200
+++ FreeImage_3_17_0_new/Makefile.gnu	2015-08-22 14:16:36.068525956 +0300
@@ -5,17 +5,19 @@ include Makefile.srcs
 
 # General configuration variables:
 DESTDIR ?= /
-INCDIR ?= $(DESTDIR)/usr/include
-INSTALLDIR ?= $(DESTDIR)/usr/lib
+INCDIR ?= $(DESTDIR)/include
+INSTALLDIR ?= $(DESTDIR)/lib
 
 # Converts cr/lf to just lf
 DOS2UNIX = dos2unix
 
-LIBRARIES = -lstdc++
+LIBRARIES = -lgnustl_shared -lndk-missing_1
+LDFLAGS = -L$(ndkMissing_dir)/lib
 
 MODULES = $(SRCS:.c=.o)
 MODULES := $(MODULES:.cpp=.o)
-CFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
+CFLAGS = $(user_CFLAGS)
+CFLAGS += -fPIC -fexceptions -fvisibility=hidden
 # OpenJPEG
 CFLAGS += -DOPJ_STATIC
 # LibRaw
@@ -23,28 +25,27 @@ CFLAGS += -DNO_LCMS
 # LibJXR
 CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
 CFLAGS += $(INCLUDE)
-CXXFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
+CXXFLAGS = $(user_CXXFLAGS)
+CXXFLAGS += -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
 # LibJXR
 CXXFLAGS += -D__ANSI__
 CXXFLAGS += $(INCLUDE)
 
-ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
-	CFLAGS += -fPIC
-	CXXFLAGS += -fPIC
-endif
-
 TARGET  = freeimage
 STATICLIB = lib$(TARGET).a
 SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
 LIBNAME	= lib$(TARGET).so
-VERLIBNAME = $(LIBNAME).$(VER_MAJOR)
+VERLIBNAME = lib$(TARGET)_$(VER_MAJOR).so
 HEADER = Source/FreeImage.h
 
 
 
 default: all
 
-all: dist
+all: foo dist
+
+foo:
+	echo "my CFLAGS = " $(CFLAGS)
 
 dist: FreeImage
 	mkdir -p Dist
@@ -71,12 +72,11 @@ $(SHAREDLIB): $(MODULES)
 
 install:
 	install -d $(INCDIR) $(INSTALLDIR)
-	install -m 644 -o root -g root $(HEADER) $(INCDIR)
-	install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
-	install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
+	install -m 644 $(HEADER) $(INCDIR)
+	install -m 644 $(STATICLIB) $(INSTALLDIR)
+	install -m 755 $(SHAREDLIB) $(INSTALLDIR)
 	ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
-	ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)	
-#	ldconfig
+	ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
 
 clean:
 	rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
diff -rupN FreeImage_3_17_0_orig/Makefile.gnu~ FreeImage_3_17_0_new/Makefile.gnu~
--- FreeImage_3_17_0_orig/Makefile.gnu~	1970-01-01 02:00:00.000000000 +0200
+++ FreeImage_3_17_0_new/Makefile.gnu~	2015-08-22 14:16:36.068525956 +0300
@@ -0,0 +1,82 @@
+# Linux makefile for FreeImage
+
+# This file can be generated by ./gensrclist.sh
+include Makefile.srcs
+
+# General configuration variables:
+DESTDIR ?= /
+INCDIR ?= $(DESTDIR)/include
+INSTALLDIR ?= $(DESTDIR)/lib
+
+# Converts cr/lf to just lf
+DOS2UNIX = dos2unix
+
+LIBRARIES = -lgnustl_shared -lndk-missing
+LDFLAGS = -L$(ndkMissing_dir)/lib
+
+MODULES = $(SRCS:.c=.o)
+MODULES := $(MODULES:.cpp=.o)
+CFLAGS = $(user_CFLAGS)
+CFLAGS += -fPIC -fexceptions -fvisibility=hidden
+# OpenJPEG
+CFLAGS += -DOPJ_STATIC
+# LibRaw
+CFLAGS += -DNO_LCMS
+# LibJXR
+CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
+CFLAGS += $(INCLUDE)
+CXXFLAGS = $(user_CXXFLAGS)
+CXXFLAGS += -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
+# LibJXR
+CXXFLAGS += -D__ANSI__
+CXXFLAGS += $(INCLUDE)
+
+TARGET  = freeimage
+STATICLIB = lib$(TARGET).a
+SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
+LIBNAME	= lib$(TARGET).so
+VERLIBNAME = $(LIBNAME)
+HEADER = Source/FreeImage.h
+
+
+
+default: all
+
+all: foo dist
+
+foo:
+	echo "my CFLAGS = " $(CFLAGS)
+
+dist: FreeImage
+	mkdir -p Dist
+	cp *.a Dist/
+	cp *.so Dist/
+	cp Source/FreeImage.h Dist/
+
+dos2unix:
+	@$(DOS2UNIX) $(SRCS) $(INCLS)
+
+FreeImage: $(STATICLIB) $(SHAREDLIB)
+
+.c.o:
+	$(CC) $(CFLAGS) -c $< -o $@
+
+.cpp.o:
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+$(STATICLIB): $(MODULES)
+	$(AR) r $@ $(MODULES)
+
+$(SHAREDLIB): $(MODULES)
+	$(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
+
+install:
+	install -d $(INCDIR) $(INSTALLDIR)
+	install -m 644 $(HEADER) $(INCDIR)
+	install -m 644 $(STATICLIB) $(INSTALLDIR)
+	install -m 755 $(SHAREDLIB) $(INSTALLDIR)
+	ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
+
+clean:
+	rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
+
diff -rupN FreeImage_3_17_0_orig/Source/LibJXR/common/include/wmspecstring.h FreeImage_3_17_0_new/Source/LibJXR/common/include/wmspecstring.h
--- FreeImage_3_17_0_orig/Source/LibJXR/common/include/wmspecstring.h	2015-03-02 01:50:58.000000000 +0200
+++ FreeImage_3_17_0_new/Source/LibJXR/common/include/wmspecstring.h	2015-08-22 14:16:36.084525640 +0300
@@ -286,7 +286,9 @@ extern "C" {
 
 #if defined(_WINDOWS_)
 /* Windows Internal */
+#if defined _WIN32
 #define __volatile                          __$volatile
+#endif
 #define __nonvolatile                       __$nonvolatile
 #define __deref_volatile                    __deref __volatile
 #define __deref_nonvolatile                 __deref __nonvolatile
diff -rupN FreeImage_3_17_0_orig/Source/LibRawLite/internal/libraw_x3f.cpp FreeImage_3_17_0_new/Source/LibRawLite/internal/libraw_x3f.cpp
--- FreeImage_3_17_0_orig/Source/LibRawLite/internal/libraw_x3f.cpp	2014-08-31 23:45:02.000000000 +0300
+++ FreeImage_3_17_0_new/Source/LibRawLite/internal/libraw_x3f.cpp	2015-08-22 14:16:36.092525482 +0300
@@ -625,7 +625,7 @@ static x3f_huffman_t *new_huffman(x3f_hu
   I->output.file = NULL;
 
   if (infile == NULL) {
-    I->error = "No infile";
+    I->error = const_cast<char*>("No infile");
     return x3f;
   }
 
