From 848f540fb1771d1e2938cea906c8515d452f9b86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Thu, 23 Feb 2017 16:05:06 +0100
Subject: [PATCH] Added functions for installing x13 binaries.

---
 .gitignore                       |  6 ++++--
 externals/x13/.gitignore         |  4 ++++
 externals/x13/installx13.m       | 27 +++++++++++++++++++++++++++
 externals/x13/uninstallx13.m     | 31 +++++++++++++++++++++++++++++++
 src/initialize_dseries_toolbox.m |  8 +++++++-
 5 files changed, 73 insertions(+), 3 deletions(-)
 create mode 100644 externals/x13/.gitignore
 create mode 100644 externals/x13/installx13.m
 create mode 100644 externals/x13/uninstallx13.m

diff --git a/.gitignore b/.gitignore
index 6501527..4f6a2bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
 *~
-externals
+externals/*
 src/git.info
-src/git.last-commit-hash
\ No newline at end of file
+src/git.last-commit-hash
+
+!externals/x13/
diff --git a/externals/x13/.gitignore b/externals/x13/.gitignore
new file mode 100644
index 0000000..f81d555
--- /dev/null
+++ b/externals/x13/.gitignore
@@ -0,0 +1,4 @@
+x13.zip
+linux/*
+windows/*
+*~
diff --git a/externals/x13/installx13.m b/externals/x13/installx13.m
new file mode 100644
index 0000000..d70d72b
--- /dev/null
+++ b/externals/x13/installx13.m
@@ -0,0 +1,27 @@
+function installx13()
+
+% Installs CENSUS X13 binaries (Windows and Linux).
+
+% Copyright (C) 2017 Dynare Team
+%
+% This code 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 dseries submodule 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/>.
+
+    
+if ~exist('x13.zip','file')
+    websave('x13.zip', 'http://www.dynare.org/x13/x13.zip');
+    unzip('x13.zip');
+    movefile('binaries/linux','./linux');
+    movefile('binaries/windows','./windows');
+    rmdir('binaries');
+end
diff --git a/externals/x13/uninstallx13.m b/externals/x13/uninstallx13.m
new file mode 100644
index 0000000..4057bdb
--- /dev/null
+++ b/externals/x13/uninstallx13.m
@@ -0,0 +1,31 @@
+function uninstallx13()
+
+% Uninstalls CENSUS X13 binaries (Windows and Linux).
+
+% Copyright (C) 2017 Dynare Team
+%
+% This code 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 dseries submodule 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/>.
+
+    
+if exist('x13.zip','file')
+    delete('x13.zip')
+end
+
+if exist('linux','dir')
+    rmdir('linux')
+end
+
+if exist('windows','dir')
+    rmdir('windows')
+end
diff --git a/src/initialize_dseries_toolbox.m b/src/initialize_dseries_toolbox.m
index 9e8dad1..9f97de3 100644
--- a/src/initialize_dseries_toolbox.m
+++ b/src/initialize_dseries_toolbox.m
@@ -48,4 +48,10 @@ end
 
 if ~exist('get_cells_id','file')
     addpath([dseries_src_root '/utilities/missing/get_cells_id'])
-end
\ No newline at end of file
+end
+
+% Install X13 binaries
+opath = pwd();
+cd([dseries_src_root '/../externals/x13'])
+installx13();
+cd(opath);
\ No newline at end of file
-- 
GitLab