diff -uN freefem++-3.44/build/download.ORG freefem++-3.44/build/download
--- freefem++-3.44/build/download.ORG	2015-09-24 23:14:53.000000000 +0900
+++ freefem++-3.44/build/download	2016-03-02 11:58:29.499035000 +0900
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!//usr/local/bin/bash -e
 # ======================================================================
 # Written by Antoine Le Hyaric
 # Laboratoire Jacques-Louis Lions
@@ -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/local/bin/wget || test -x /opt/local/bin/wget
 then
 
     opts=
diff -uN freefem++-3.44/build/cleancrlf.ORG freefem++-3.44/build/cleancrlf
--- freefem++-3.44/build/cleancrlf.ORG	2015-09-18 01:21:39.000000000 +0900
+++ freefem++-3.44/build/cleancrlf	2016-03-02 11:58:29.499419000 +0900
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # ======================================================================
 # Written by Antoine Le Hyaric
 # http://www.ljll.math.upmc.fr/lehyaric
diff -uN freefem++-3.44/build/ff-md5.ORG freefem++-3.44/build/ff-md5
--- freefem++-3.44/build/ff-md5.ORG	2015-11-25 23:23:16.000000000 +0900
+++ freefem++-3.44/build/ff-md5	2016-03-02 11:58:29.499770000 +0900
@@ -1,10 +1,10 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # Download third-party packages independently of FF configuration (request from FH)
 # ======================================================================
 # Written by Antoine Le Hyaric
 # http://www.ljll.math.upmc.fr/lehyaric
 # Laboratoire Jacques-Louis Lions
-# Université Pierre et Marie Curie-Paris6, UMR 7598, Paris, F-75005 France
+# Université Pierre et Marie Curie-Paris6, UMR 7598, Paris, F-75005 France
 # ======================================================================
 # This file is part of Freefem++
 #
diff -uN freefem++-3.44/build/links2files.ORG freefem++-3.44/build/links2files
--- freefem++-3.44/build/links2files.ORG	2015-09-18 01:21:39.000000000 +0900
+++ freefem++-3.44/build/links2files	2016-03-02 11:58:29.500136000 +0900
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # ======================================================================
 # Written by Antoine Le Hyaric
 # Laboratoire Jacques-Louis Lions
diff -uN freefem++-3.44/build/orgindex.ORG freefem++-3.44/build/orgindex
--- freefem++-3.44/build/orgindex.ORG	2015-09-18 01:21:39.000000000 +0900
+++ freefem++-3.44/build/orgindex	2016-03-02 11:58:29.500540000 +0900
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # Build an index of all Emacs org-mode hyperlinks
 # ======================================================================
 # Written by Antoine Le Hyaric
diff -uN freefem++-3.44/download/getall.ORG freefem++-3.44/download/getall
--- freefem++-3.44/download/getall.ORG	2016-02-18 15:47:50.000000000 +0900
+++ freefem++-3.44/download/getall	2016-03-02 11:58:29.501068000 +0900
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 # Download third-party packages independently of FF configuration (request from FH)
 # ======================================================================
 # Written by Antoine Le Hyaric
diff -uN freefem++-3.44/configure.ORG freefem++-3.44/configure
--- freefem++-3.44/configure.ORG	2016-02-18 16:46:49.000000000 +0900
+++ freefem++-3.44/configure	2016-03-03 15:44:45.231912000 +0900
@@ -6527,7 +6527,7 @@
 		case $i in
 # save last directory of the list
 		    -L*)
-			d=`expr $i : '-L\(.*\)'`;
+			d=`expr X$i : 'X-L\(.*\)'`;
 			echo " try $d "
 			if test -e "$d/libg2c.so" ; then
 			    ff_flibs="$d/libg2c.so"
@@ -6554,7 +6554,7 @@
             for i in $FLIBS; do
 		case $i in
 		    -L*)
-			d=`expr $i : '-L\(.*\)'`;
+			d=`expr X$i : 'X-L\(.*\)'`;
 			if test -e "$d/libgfortran.$ff_suffix_dylib_a" -a  -e "$d/libquadmath.$ff_suffix_dylib_a"  ; then
 			   ff_flibs="$d/libgfortran.$ff_suffix_dylib_a $d/libquadmath.$ff_suffix_dylib_a"
 			    ff_okkk=1
diff -uN freefem++-3.44/src/fflib/AFunction.cpp.ORG freefem++-3.44/src/fflib/AFunction.cpp
--- freefem++-3.44/src/fflib/AFunction.cpp.ORG	2016-02-12 18:27:58.000000000 +0900
+++ freefem++-3.44/src/fflib/AFunction.cpp	2016-03-02 11:58:29.516106000 +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
-#if defined (_WIN32  ) || (__GNUC__ >=5)
+#if defined (_WIN32  ) || (__GNUC__ >=5) || defined(__FreeBSD__)
 #define NM_STD std::
 #else
 #define NM_STD 
diff -uN freefem++-3.44/src/femlib/CheckPtr.cpp.ORG freefem++-3.44/src/femlib/CheckPtr.cpp
--- freefem++-3.44/src/femlib/CheckPtr.cpp.ORG	2015-09-18 01:21:39.000000000 +0900
+++ freefem++-3.44/src/femlib/CheckPtr.cpp	2016-03-02 11:58:29.516728000 +0900
@@ -3,7 +3,11 @@
 #if __APPLE__
 #include <malloc/malloc.h>
 #else
+# ifdef __FreeBSD__
+#include <stdlib.h>
+# else
 #include <malloc.h>
+# endif
 #endif
 
 static long verbosity;
diff -uN freefem++-3.44/examples++-load/ff-pkg-download.in.ORG freefem++-3.44/examples++-load/ff-pkg-download.in
--- freefem++-3.44/examples++-load/ff-pkg-download.in.ORG	2015-09-18 01:21:39.000000000 +0900
+++ freefem++-3.44/examples++-load/ff-pkg-download.in	2016-03-02 11:58:29.517167000 +0900
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/local/bin/bash
 # Building WHERE_LIBRARY-download
 # ======================================================================
 # Laboratoire Jacques-Louis Lions
diff -uN freefem++-3.44/Makefile.in.ORG freefem++-3.44/Makefile.in
--- freefem++-3.44/Makefile.in.ORG	2016-02-18 16:46:50.000000000 +0900
+++ freefem++-3.44/Makefile.in	2016-03-02 11:58:29.518281000 +0900
@@ -1152,7 +1152,7 @@
 	test `uname` != Darwin || ( $(MAKE) FreeFem++.app.tgz  ; test -d $(DESTDIR)/Applications ||  mkdir $(DESTDIR)/Applications ; tar zxf FreeFem++.app.tgz  -C $(DESTDIR)/Applications )
 
 script/PostInstall.sh:./Makefile script/PostInstall.m4
-	m4 script/PostInstall.m4 "-DFF__FVER=$(PACKAGE_VERSION)" "-DFF_BINDIR=$(bindir)" "-DFF__DATADIR=$(pkgdatadir)" >script/PostInstall.sh
+	m4 "-DFF__FVER=$(PACKAGE_VERSION)" "-DFF_BINDIR=$(bindir)" "-DFF__DATADIR=$(pkgdatadir)" script/PostInstall.m4 >script/PostInstall.sh
 	chmod a+x script/PostInstall.sh
 
 ListFiles-natives: .FORCE  FreeFem++-CoCoa
