diff --git a/debian/rules b/debian/rules
index 0c77d2b4ba44429a987e7f0ba51509c8dbfdfcda..071599b78e4440d52657c08f7f2cf6cb70ad4391 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,14 +23,14 @@ build-stamp:
 	# Building Matlab 7.4 MEX files
 ifeq ($(shell test -d $(MATLAB74_ROOT) && echo yes), yes)
 	$(MATLAB74_ROOT)/etc/lmboot
-	cd mex/sources && $(MATLAB74_ROOT)/bin/matlab -nodisplay -r build_matlab
+	cd mex/sources && $(MATLAB74_ROOT)/bin/matlab -nodisplay -r build_matlab_debian
 	$(MATLAB74_ROOT)/etc/lmdown
 endif
 
 	# Building Matlab 7.5 MEX files
 ifeq ($(shell test -d $(MATLAB75_ROOT) && echo yes), yes)
 	$(MATLAB75_ROOT)/etc/lmboot
-	cd mex/sources && $(MATLAB75_ROOT)/bin/matlab -nodisplay -r build_matlab
+	cd mex/sources && $(MATLAB75_ROOT)/bin/matlab -nodisplay -r build_matlab_debian
 	$(MATLAB75_ROOT)/etc/lmdown
 endif
 
diff --git a/mex/sources/build_matlab.m b/mex/sources/build_matlab.m
index d127e8e96081d4ae46cf2a4f533318ded3cb7837..d1f063c19355c5179c39458d3dcb5d65bfdaa104 100644
--- a/mex/sources/build_matlab.m
+++ b/mex/sources/build_matlab.m
@@ -1,6 +1,21 @@
 % Build file for Dynare MEX Librairies under Matlab
-% Copyright Dynare Team (2007-2008)
-% GNU Public License
+
+% Copyright (C) 2007-2008 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 addpath '../../matlab'; % For matlab_ver_less_than
 
@@ -63,12 +78,25 @@ eval([ COMPILE_COMMAND ' kronecker/sparse_hessian_times_B_kronecker_C.cc ' BLAS_
 disp('Compiling A_times_B_kronecker_C...')
 eval([ COMPILE_COMMAND ' kronecker/A_times_B_kronecker_C.cc ' BLAS_PATH ]);
 disp('Compiling gensylv...')
-eval([ COMPILE_COMMAND ' -DMATLAB -Igensylv/cc gensylv/matlab/gensylv.cpp' ...
-       ' gensylv/cc/*.cpp ' BLAS_PATH ' ' LAPACK_PATH ]);
+eval([ COMPILE_COMMAND ' -DMATLAB -Igensylv/cc ' ...
+       'gensylv/matlab/gensylv.cpp ' ...
+       'gensylv/cc/BlockDiagonal.cpp ' ... 
+       'gensylv/cc/GeneralMatrix.cpp ' ...
+       'gensylv/cc/GeneralSylvester.cpp ' ...
+       'gensylv/cc/IterativeSylvester.cpp ' ...
+       'gensylv/cc/KronUtils.cpp ' ...
+       'gensylv/cc/KronVector.cpp ' ...
+       'gensylv/cc/QuasiTriangular.cpp ' ...
+       'gensylv/cc/QuasiTriangularZero.cpp ' ...
+       'gensylv/cc/SchurDecomp.cpp ' ...
+       'gensylv/cc/SchurDecompEig.cpp ' ...
+       'gensylv/cc/SimilarityDecomp.cpp ' ...
+       'gensylv/cc/SylvException.cpp ' ...
+       'gensylv/cc/SylvMatrix.cpp ' ...
+       'gensylv/cc/SylvMemory.cpp ' ...
+       'gensylv/cc/SylvParams.cpp ' ...
+       'gensylv/cc/TriangularSylvester.cpp ' ...
+       'gensylv/cc/Vector.cpp ' ...
+       BLAS_PATH ' ' LAPACK_PATH ]);
 disp('Compiling simulate...')
 eval([ COMPILE_COMMAND ' -Isimulate -I../../preprocessor/include simulate/simulate.cc simulate/Interpreter.cc simulate/Mem_Mngr.cc simulate/SparseMatrix.cc simulate/linbcg.cc' ]);
-
-% Forcing exit is necessary when autobuilding MEX files for Debian packages.
-% In interactive mode, if anything fails during the compilation process,
-% this line will not be reached and the user will see the error message.
-exit
diff --git a/mex/sources/build_matlab_debian.m b/mex/sources/build_matlab_debian.m
new file mode 100644
index 0000000000000000000000000000000000000000..0b0967ca6708dbd4f6fa199d68bb82e31ba445a8
--- /dev/null
+++ b/mex/sources/build_matlab_debian.m
@@ -0,0 +1,23 @@
+% Debian build file for Dynare MEX Librairies under Matlab.
+% Exit is forced, because otherwise Matlab gives a prompt
+% at the end of the compilation.
+
+% Copyright (C) 2008 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
+
+build_matlab
+exit
diff --git a/mex/sources/build_octave.m b/mex/sources/build_octave.m
index 76bfb72f126d4864988a8b51e354420cae1d38de..673edb2f73e834542b6f96e7715e0c9d7bd51d74 100644
--- a/mex/sources/build_octave.m
+++ b/mex/sources/build_octave.m
@@ -1,6 +1,21 @@
 % Build file for Dynare MEX Librairies for Octave
-% Copyright Dynare Team (2008)
-% GNU Public License
+
+% Copyright (C) 2008 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 COMPILE_OPTIONS = '-DNO_BLAS_H -DNO_LAPACK_H -DOCTAVE';
 
@@ -16,7 +31,25 @@ eval([ COMPILE_COMMAND ' kronecker/sparse_hessian_times_B_kronecker_C.cc -o ../o
 disp('Compiling A_times_B_kronecker_C...')
 eval([ COMPILE_COMMAND ' kronecker/A_times_B_kronecker_C.cc -o ../octave/A_times_B_kronecker_C.mex']);
 disp('Compiling gensylv...')
-% With MS Visual C++ it is necessary to list all the source file names (a wildcard will not make it)
-eval([ COMPILE_COMMAND ' -DMATLAB -Igensylv/cc gensylv/matlab/gensylv.cpp gensylv/cc/BlockDiagonal.cpp gensylv/cc/GeneralMatrix.cpp gensylv/cc/GeneralSylvester.cpp gensylv/cc/IterativeSylvester.cpp gensylv/cc/KronUtils.cpp gensylv/cc/KronVector.cpp gensylv/cc/QuasiTriangular.cpp gensylv/cc/QuasiTriangularZero.cpp gensylv/cc/SchurDecomp.cpp gensylv/cc/SchurDecompEig.cpp gensylv/cc/SimilarityDecomp.cpp gensylv/cc/SylvException.cpp gensylv/cc/SylvMatrix.cpp gensylv/cc/SylvMemory.cpp gensylv/cc/SylvParams.cpp gensylv/cc/TriangularSylvester.cpp gensylv/cc/Vector.cpp -o ../octave/gensylv.mex']);
+eval([ COMPILE_COMMAND ' -DMATLAB -Igensylv/cc ' ...
+       'gensylv/matlab/gensylv.cpp ' ...
+       'gensylv/cc/BlockDiagonal.cpp ' ... 
+       'gensylv/cc/GeneralMatrix.cpp ' ...
+       'gensylv/cc/GeneralSylvester.cpp ' ...
+       'gensylv/cc/IterativeSylvester.cpp ' ...
+       'gensylv/cc/KronUtils.cpp ' ...
+       'gensylv/cc/KronVector.cpp ' ...
+       'gensylv/cc/QuasiTriangular.cpp ' ...
+       'gensylv/cc/QuasiTriangularZero.cpp ' ...
+       'gensylv/cc/SchurDecomp.cpp ' ...
+       'gensylv/cc/SchurDecompEig.cpp ' ...
+       'gensylv/cc/SimilarityDecomp.cpp ' ...
+       'gensylv/cc/SylvException.cpp ' ...
+       'gensylv/cc/SylvMatrix.cpp ' ...
+       'gensylv/cc/SylvMemory.cpp ' ...
+       'gensylv/cc/SylvParams.cpp ' ...
+       'gensylv/cc/TriangularSylvester.cpp ' ...
+       'gensylv/cc/Vector.cpp ' ...
+       '-o ../octave/gensylv.mex']);
 disp('Compiling simulate...')
 eval([ COMPILE_COMMAND ' -Isimulate -I../../preprocessor/include simulate/simulate.cc simulate/Interpreter.cc simulate/Mem_Mngr.cc simulate/SparseMatrix.cc simulate/linbcg.cc -o ../octave/simulate.mex']);