diff -uN freefem++-3.38-1/download/scotch/Makefile.ORG freefem++-3.38-1/download/scotch/Makefile
--- freefem++-3.38-1/download/scotch/Makefile.ORG	2015-03-27 06:38:16.000000000 +0900
+++ freefem++-3.38-1/download/scotch/Makefile	2016-02-25 10:07:22.801885000 +0900
@@ -87,6 +87,7 @@
 	patch -p1 <scotch_6.0.3.patch
 	#cd $(SRCDIR)/src/libscotch/; patch -p1 < ../../../scotch_5.1_esmumps.patch
 	#cd $(SRCDIR)/src/esmumps/; patch -p1 < ../../../Makefile.patch
+	cd $(SRCDIR) && patch -p4 -b -z .ORG < ../../../scotch-1.diff
 	touch $(SRCDIR)
 
 $(PACKAGE):
diff -uN freefem++-3.38-1/download/scotch/Makefile-scotch.inc.ORG freefem++-3.38-1/download/scotch/Makefile-scotch.inc
--- freefem++-3.38-1/download/scotch/Makefile-scotch.inc.ORG	2015-03-27 06:19:46.000000000 +0900
+++ freefem++-3.38-1/download/scotch/Makefile-scotch.inc	2016-02-25 10:07:22.805224000 +0900
@@ -23,7 +23,7 @@
 CFLAGSSTD = -DCOMMON_STUB_FORK  -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_TIMING_OLD -DSCOTCH_RENAME -DSCOTCH_DETERMINISTIC
 
 ifeq (@WIN32DLLTARGET@,) 
-CFLAGS	= @CFLAGS@ -I'@MPI_INC_DIR@' $(FFINTSCOTCH) -Drestrict=__restrict $(CFLAGSSTD)
+CFLAGS	= -std=c99 @CFLAGS@ -I'@MPI_INC_DIR@' $(FFINTSCOTCH) -Drestrict=__restrict $(CFLAGSSTD)
 else
 CFLAGS	= @CFLAGS@ -I'@MPI_INC_DIR@' $(FFINTSCOTCH) -Drestrict=__restrict $(CFLAGSWIN)
 endif
diff -uN freefem++-3.38-1/download/nlopt/Makefile.ORG freefem++-3.38-1/download/nlopt/Makefile
--- freefem++-3.38-1/download/nlopt/Makefile.ORG	2015-02-19 17:38:01.000000000 +0900
+++ freefem++-3.38-1/download/nlopt/Makefile	2016-02-25 10:07:22.807921000 +0900
@@ -7,8 +7,9 @@
 
 FAIRE: ../pkg $(SRCDIR)/FAIT 
 
-$(SRCDIR)/FAIT: $(TARGZ)
+$(SRCDIR)/FAIT0: $(TARGZ)
 	tar zxvf $(TARGZ)
+	cd $(SRCDIR) && patch -p4 -b -z .ORG < ../../../nlopt-1.diff
 #
 #	FFCS - 30/11/11 - "--disable-dependency-tracking": dependencies pose problem on mixed Cygwin/MinGW setups
 #	because of slashes and backslashes
@@ -24,6 +25,9 @@
 #
 #	FFCS - 30/11/11 - we need to know when the building process breaks
 #
+	touch $(SRCDIR)/FAIT0
+
+$(SRCDIR)/FAIT: $(SRCDIR)/FAIT0
 	cd $(SRCDIR) && $(MAKE) install
 	touch $(SRCDIR)/FAIT
 	$(MAKE) WHERE
diff -uN freefem++-3.38-1/src/femlib/gmres.hpp.ORG freefem++-3.38-1/src/femlib/gmres.hpp
--- freefem++-3.38-1/src/femlib/gmres.hpp.ORG	2014-07-10 23:34:21.000000000 +0900
+++ freefem++-3.38-1/src/femlib/gmres.hpp	2016-02-25 10:07:22.811018000 +0900
@@ -71,12 +71,14 @@
 }
 
 
+#ifndef __sun__
 template < class Real >
 Real 
 abs(Real x)
 {
   return (x > 0 ? x : -x);
 }
+#endif
 
 
 template < class Operator, class Vector, class Preconditioner,
diff -uN freefem++-3.38-1/src/fflib/AFunction.cpp.ORG freefem++-3.38-1/src/fflib/AFunction.cpp
--- freefem++-3.38-1/src/fflib/AFunction.cpp.ORG	2015-03-31 18:46:56.000000000 +0900
+++ freefem++-3.38-1/src/fflib/AFunction.cpp	2016-02-25 10:07:22.818519000 +0900
@@ -35,7 +35,7 @@
 //  put here some def dur to c++11 
 // problem with mixed with using namespace std; 
 // to correct bug in g++ v 4.8.1 add std
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__sun__)
 #define NM_STD std::
 #else
 #define NM_STD 
diff -uN freefem++-3.38-1/src/fflib/InitFunct.hpp.ORG freefem++-3.38-1/src/fflib/InitFunct.hpp
--- freefem++-3.38-1/src/fflib/InitFunct.hpp.ORG	2015-03-03 22:42:11.000000000 +0900
+++ freefem++-3.38-1/src/fflib/InitFunct.hpp	2016-02-25 10:07:22.825129000 +0900
@@ -37,7 +37,7 @@
 } ;
 
 //
-#if _WIN32
+#if _WIN32 || defined(__sun__)
 #define LOADINITIO {					\
     streambuf * so =ffapi::cout()->rdbuf() ;		\
     streambuf * si =ffapi::cin()->rdbuf() ;		\
diff -uN freefem++-3.38-1/src/medit/Makefile.in.ORG freefem++-3.38-1/src/medit/Makefile.in
--- freefem++-3.38-1/src/medit/Makefile.in.ORG	2015-06-26 23:25:36.000000000 +0900
+++ freefem++-3.38-1/src/medit/Makefile.in	2016-02-25 17:09:47.268349000 +0900
@@ -841,7 +841,7 @@
 compil.date: $(ffmedit_SOURCES)
 	echo "#define COMPIL " '"' `date` '(with ff++ $(VERSION))''"' > compil.date
 picking.$(OBJEXT):picking.c
-	${CC} -c $< $(CNOFLAGS) -o $@ 
+	${CC} -c $< $(CNOFLAGS) $(CPPFLAGS) -o $@ 
 
 ###pinking.no-optffmedit$(EXEEXT):picking.c
 ###	rm picking.$(OBJEXT)
diff -uN freefem++-3.38-1/examples++-load/Makefile.in.ORG freefem++-3.38-1/examples++-load/Makefile.in
--- freefem++-3.38-1/examples++-load/Makefile.in.ORG	2015-06-29 22:36:01.000000000 +0900
+++ freefem++-3.38-1/examples++-load/Makefile.in	2016-02-25 10:07:22.831814000 +0900
@@ -1801,6 +1801,7 @@
 	chmod a+x $@
 	-if [ -d ../download/bin ] ;then cp $@ ../download/bin; fi
 WHERE_LIBRARY-download:ff-pkg-download FORCE  WHERE_LIBRARY-config WHERE_LIBRARY
+	-if [ ! -f $@ ]; then touch $@; fi
 	@./ff-pkg-download >$@-new
 	@diff $@-new $@  || (cp $@-new $@ ;touch WHERE_LIBRARY)
 WHERE_LIBRARY:
diff -uN freefem++-3.38-1/examples++-load/ff-get-dep.in.ORG freefem++-3.38-1/examples++-load/ff-get-dep.in
--- freefem++-3.38-1/examples++-load/ff-get-dep.in.ORG	2015-02-10 22:40:09.000000000 +0900
+++ freefem++-3.38-1/examples++-load/ff-get-dep.in	2016-02-25 10:07:22.837753000 +0900
@@ -21,7 +21,7 @@
 esac 
 dircommand=`dirname $0`
 if [   -f "WHERE_LIBRARY-download" ] ; then
-dircommand="./"
+    dirwhere="./"
 elif [   -f "$dircommand/WHERE_LIBRARY-download" ] ; then
     dirwhere=$dircommand
 elif [ -f '@ff_prefix_dir@/lib/WHERE_LIBRARY-download' ] ; then
diff -uN freefem++-3.38-1/build/download.ORG freefem++-3.38-1/build/download
--- freefem++-3.38-1/build/download.ORG	2015-06-09 17:52:49.000000000 +0900
+++ freefem++-3.38-1/build/download	2016-02-25 10:07:22.840508000 +0900
@@ -31,7 +31,7 @@
 # $2=local name
 # $3=BAD_CERT if the SSL certificate of the web server is wrong
 
-if test -x /usr/bin/wget || test -x /opt/local/bin/wget
+if test -x /usr/sfw/bin/wget || test -x /usr/local/bin/wget
 then
 
     opts=
@@ -45,7 +45,7 @@
 
     wget "$1" --timeout=30 --tries=2 --output-document="$2" --no-verbose $opts
     ret=$?
-elif test -x /usr/bin/curl
+elif test -x /usr/local/bin/curl
 then
     curl -L "$1" --output "$2"
     ret=$?
