diff --git a/LINUX.md b/LINUX.md new file mode 100644 index 000000000..10d3d2f14 --- /dev/null +++ b/LINUX.md @@ -0,0 +1,226 @@ +# TerraMA² - Build and Generate Package in Linux + +## Dependencies that require manual installation on Linux + +First of all make sure that your machine has the following installed requirements, before proceeding: +* Git (call in shell command line): +``` +$ sudo apt-get install git +``` +* Build-Essentials (call in shell command line): +``` +$ sudo apt-get install build-essential +``` +* [CMake (preferably version 3.0.2)](https://cmake.org/download/) or call in shell command line: +``` +$ sudo apt-get install cmake-gui +``` + +## Build and Install TerraLib + +You should build and install TerraLib package required by TerraMA², according to the link below: + - [Build and install TerraLib Package](http://www.dpi.inpe.br/terralib5/wiki/doku.php?id=wiki:documentation:devguide#downloading_the_source_code_and_building_instructions). + +## Cloning TerraMA² Repository + +1.1. Open the shell command line. + +1.2. Make a new folder to host TerraMA² source code: +``` +$ mkdir -p /home/USER/mydevel/terrama2/codebase +``` + +1.3. Change the current directory to that new folder: +``` +$ cd /home/USER/mydevel/terrama2/codebase +``` + +1.4. Make a local copy of TerraMA² repository: +``` +$ git clone https://github.com/terrama2/terrama2.git . +``` + +1.5. Then change to the branch you want to build, if necessary: +``` +$ git checkout -b master origin/master +``` + +We will assume that the codebase (all the source tree) is located at: `/home/USER/mydevel/terrama2/codebase` + +## Building dependencies on Linux + +To compile TerraMA² from a fresh git clone you'll need: + +- libcurl3-dev +- libpython2.7-dev +- libquazip0-dev +- libproj-dev +- libgeos++-dev +- libxerces-c-dev +- screen +- postgresql-9.3-postgis-2.1 + +All can be installed with the command: + +Ubuntu 14.04 +``` +$ sudo apt-get install curl libcurl3-dev libpython2.7-dev libquazip0-dev libproj-dev libgeos++-dev libxerces-c-dev screen postgresql-9.3-postgis-2.1 +``` + +Ubuntu 16.04 +``` +$ sudo apt-get install curl libcurl3-dev libpython2.7-dev libquazip-dev libproj-dev libgeos++-dev libxerces-c-dev screen postgresql-9.5-postgis-2.2 +```` + +We also need the VMime library, as the ubuntu version is outdated we should use the [VMime](https://github.com/kisli/vmime/archive/v0.9.2.tar.gz) source version. + +Or generate the VMime debian package (especially if you want to generate the TerraMA² package) as shown below: + +### VMime + +1.1. Install the vmime and debian package dependencies with the command: +``` +$ sudo apt install doxygen graphviz gnutls-bin gsasl libghc-gsasl-dev libgnutls-dev libssl-dev debhelper devscripts cmake +``` + +1.2. Download the VMime source used by the development team, from the link below: + - [vv0.9.2.tar.gz](https://github.com/kisli/vmime/archive/v0.9.2.tar.gz). + +1.3. Open the shell command line and change the current directory to that folder: +``` +$ cd /home/USER/mydevel/terrama2/codebase/packages/deb-package +``` + +1.4. Copy the downloaded source to current directory. + +1.5. In the shell command line, call the script *deb-vmime.sh* that will generate the debian package for VMime: +``` +$ ./deb-vmime.sh +``` + +1.6. When the script finishes, just run the following command to install VMime package: +``` +$ sudo dpkg -i terrama2-vmime_0.9.2-ubuntu16.04_amd64.deb +``` + +1.7. Then check and install any missing library, finishing the dependencies installation with the command: +``` +$ sudo apt install -f +``` + +### NodeJs + +The NodeJs can be installed with the commands: +``` +$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - +$ sudo apt-get install -y nodejs +``` + +## Build Instructions + +After choosing the right branch or tag to work on, make sure you have all the third-party library dependencies needed before trying to build TerraMA². + +The `build/cmake` folder contains a CMake project for building TerraMA². + +You should use at least CMake version 2.8.12. Older versions than this may not work properly. + +### Development Environment + +1.1. Open a Command Prompt (Shell). + +1.2. Create a folder out of the TerraMA² source tree to generate the build system, for example: +``` +$ cd /home/USER/mydevel/terrama2 +$ mkdir build-release +$ cd build-release +``` +**Note:** for the sake of simplicity create this directory in the same level as the source tree (as showned above). + +1.3. For Linux systems you must choose the build configuration: +``` +$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING="Release" -DCMAKE_INSTALL_PREFIX:PATH="/home/USER/myinstall/terrama2" -DCMAKE_PREFIX_PATH:PATH="/home/USER/mylibs;/home/USER/mylibs/terralib5/lib/cmake" ../codebase/build/cmake +``` + +1.4. Building (with 4 process in parallel): +``` +$ make -j 4 +``` + +1.5. Installing: +``` +$ make install +``` + +1.6. Uninstalling: +``` +$ make uninstall +``` + +**Notes:** + +- Some Linux flavours with different versions of GNU gcc and Boost will need more parameters such as: +``` + -DCMAKE_INCLUDE_PATH:PATH="/usr/local;/opt/include" + -DCMAKE_LIBRARY_PATH:PATH="/usr/local;/opt/lib" + -DCMAKE_PROGRAM_PATH:PATH="/usr/local/bin;/opt/bin" + -DBOOST_ROOT:PATH="/opt/boost" +``` + +- Boost can also be indicated by *BOOST_INCLUDEDIR*: +``` + -DBOOST_INCLUDEDIR:PATH="/usr/local/include" +``` + +- The parameter -lpthread must be informed only if your Boost was not built as a shared library: +``` + -DCMAKE_CXX_FLAGS:STRING="-lpthread" +``` + +- For building with Qt5 you can provide the *Qt5_DIR* variable as: +``` + -DQt5_DIR:PATH="/usr/local/lib/cmake/Qt5" +``` + +- For generating a debug version set *CMAKE_BUILD_TYPE* as: +``` + -DCMAKE_BUILD_TYPE:STRING="Debug" +``` + +### Package + +1.1 Change the current directory to that folder: +``` +$ cd /home/USER/mydevel/terrama2/codebase/packages/deb-package +``` + +1.2. In the shell command line, call the script *deb-terrama2.sh* to build and generate automatically the TerraMA² package: +``` +$ ./deb-terrama2.sh +``` + +**Note:** the script will assume that you installed terralib (and dependencies) at `/opt/terralib/5.2.2`. + +1.3. When finished the generated package will be located in the `build-package` folder in the same directory as your codebase. + +1.4. To install TerraMA² debian package in the shell command line change the current directory to the `build-package` folder and run the following command: +``` +$ sudo dpkg -i TerraMA2-4.0.0-rc1-linux-x64-Ubuntu-16.04.deb +``` + +### Quick Notes for Developers + +- For Linux, you can set the following variable: +``` +$ export LD_LIBRARY_PATH=/home/USER/mylibs/lib +``` + +- If you want to use QtCreator on Linux you can install it through the following command: +``` +$ sudo apt-get install qtcreator +``` + +## Reporting Bugs + +Any problem should be reported to terrama2-team@dpi.inpe.br. + +For more information on TerraMA², please, visit its main web page at: http://www.dpi.inpe.br/terrama2. \ No newline at end of file diff --git a/MAC.md b/MAC.md index edfbac663..72ce0cdb2 100644 --- a/MAC.md +++ b/MAC.md @@ -1,56 +1,71 @@ # TerraMA² - Build and Generate Package in Mac OS +## Dependencies that require manual installation on Mac OS + +First of all make sure that your machine has the following installed requirements, before proceeding: +* [Git](https://git-scm.com/downloads) +* [CMake (preferably version 3.0.2)](https://cmake.org/download/) +* [Qt (preferably version 5.4.1)](https://download.qt.io/archive/qt/) +* [Postgresql](https://postgresapp.com) +* Xcode Command Line Tools (call in shell command line): +``` +$ xcode-select --install +``` + + ## Build and Install TerraLib -First of all you should build and install TerraLib required by TerraMA², according to the link below: +You should build and install TerraLib required by TerraMA², according to the link below: - [Build and install TerraLib](http://www.dpi.inpe.br/terralib5/wiki/doku.php?id=wiki:documentation:devguide#downloading_the_source_code_and_building_instructions). ## Cloning TerraMA² Repository -- Open the shell command line. +1.1. Open the shell command line. -- Make a new folder to host TerraMA² source code: +1.2. Make a new folder to host TerraMA² source code: ``` $ mkdir -p /Users/USER/mydevel/terrama2/codebase ``` -- Change the current directory to that new folder: +1.3. Change the current directory to that new folder: ``` $ cd /Users/USER/mydevel/terrama2/codebase ``` -- Make a local copy of TerraMA² repository: +1.4. Make a local copy of TerraMA² repository: ``` $ git clone https://github.com/terrama2/terrama2.git . ``` -- Then change to the branch you want to build, if necessary: +1.5. Then change to the branch you want to build, if necessary: ``` $ git checkout -b master origin/master ``` -### Bash script for building all dependencies on Mac OS +We will assume that the codebase (all the source tree) is located at: `/Users/USER/mydevel/terrama2/codebase` + +## Bash script for building all dependencies on Mac OS We have prepared a special bash script for building and installing the dependencies on Mac OS. This script can be found in TerraMA² source tree under *install* folder. Follow the steps below: -- Download the third-party libraries package used by the development team: - - [terrama2-3rdparty-macos.tar.gz](http://www.dpi.inpe.br/terrama2-devel/terrama2-3rdparty-macos-sierra.tar.gz). +1.1. Download the third-party libraries source used by the development team: + - [quazip-0.7.3.tar.gz](https://sourceforge.net/projects/quazip/files/latest/download). + - [vv0.9.2.tar.gz](https://github.com/kisli/vmime/archive/v0.9.2.tar.gz). -- Open the shell command line in the same folder you have downloaded the 3rd-party package. +1.2. Open the shell command line in the same folder you have downloaded the third-party sources. -- Make sure your Qt and CMake environment can be found in your PATH: +1.3. Make sure your Qt and CMake environment can be found in your PATH: ``` $ export PATH=$PATH:/Users/USER/Qt5.4.1/5.4/clang_64/bin:/Applications/CMake.app/Contents/bin ``` -- In the shell command line, call the script *install-3rdparty-macos-sierra.sh* (for Sierra and El-Capitan OS versions) setting the target to install all the stuffs from these third-party libraries and tools: +1.4. In the shell command line, call the script *install-3rdparty-macos-sierra.sh* (for Sierra and El-Capitan OS versions) setting the target to install all the stuffs from these third-party libraries and tools: ``` $ TERRAMA2_DEPENDENCIES_DIR=/Users/USER/mylibs /Users/USER/mydevel/terrama2/codebase/install/install-3rdparty-macos-sierra.sh ``` **Note:** Don't choose as target location a system folder such as */usr* or */usr/local*. Try some user specific folder. Replace the folder named *USER* by your user name. - ## Build Instructions After choosing the right branch or tag to work on, make sure you have all the third-party library dependencies needed before trying to build TerraMA². @@ -59,36 +74,86 @@ The `build/cmake` folder contains a CMake project for building TerraMA². You should use at least CMake version 2.8.12 for building TerraMA². Older versions than this may not work properly. -We will assume that the codebase (all the source tree) is located at: `/Users/USER/mydevel/terrama2/codebase` +### Development Environment + +1.1. Open a Command Prompt (Shell). + +1.2. Create a folder out of the TerraMA² source tree to generate the build system, for example: +``` +$ cd /Users/USER/mydevel/terrama2 +$ mkdir build-release +$ cd build-release +``` +**Note:** for the sake of simplicity create this directory in the same level as the source tree (as showned above). + +1.3. For Mac OS systems you must choose the build configuration: +``` +$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING="Release" -DCMAKE_INSTALL_PREFIX:PATH="/Users/USER/mylibs/terrama2" -DCMAKE_PREFIX_PATH:PATH="/Users/USER/mylibs;/Users/USER/mylibs/terralib5/lib/cmake;/Users/USER/Qt5.4.1/5.4/clang_64/lib/cmake" ../codebase/build/cmake +``` + +**Note:** Please, in the cmake call above, take special attention to the key *CMAKE_PREFIX_PATH* and Qt location. + +1.4. Building (with 4 process in parallel): +``` +$ make -j 4 +``` -- Change the current directory to that folder: +1.5. Installing: +``` +$ make install +``` +1.6. Uninstalling: +``` +$ make uninstall +``` + +**Notes:** + +- You have to specify valid paths for *CMAKE_PREFIX_PATH*. If you have a Qt version installed as a framework in your home directory, you have to tell CMake where to locate its CMake support. For instance, if you have Qt version 5.4.1 installed, you have to add to *CMAKE_PREFIX_PATH* the following directory: +``` +/Users/USER/Qt5.4.1/5.4/clang_64/lib/cmake +``` +- You have also to tell where TerraLib? CMake support is located. Add to *CMAKE_PREFIX_PATH* where TerraLib? is installed, for example: +``` +/Users/USER/mylibs/terralib/lib/cmake +``` +- You can also generate an Xcode project by using the "Xcode generator" option: +``` +-G "Xcode" +``` +- There are some useful variables that can be set inside Xcode in order to run an application. The following environment variable can be set: +``` +DYLD_FALLBACK_LIBRARY_PATH +DYLD_FALLBACK_FRAMEWORK_PATH +``` + +### Package + +1.1. Change the current directory to that folder: ``` $ cd /Users/USER/mydevel/terrama2/codebase/packages/dmg-package ``` -- Open the *dmg-terrama2.sh* script, with the code editor of your choice. +1.2. Open the *dmg-terrama2.sh* script, with the code editor of your choice. -- Change the variables according to your environment: +1.3. Change the variables according to your environment: * `TL_PATH`: path to installed terralib (path/to/terralib/lib/cmake/terralib-version/). * `TL_THIRD_DIR`: path to TerraLib third-party. * `TM_THIRD_DIR`: path to TerraMA² third-party (if not installed with TerraLib's third-party). * `PATH`: should add Qt and CMake path to system's path. -- After check the script variables, in the shell command line, call the script *dmg-terrama2.sh* to build and generate automatically the TerraMA² package: +1.4. After check the script variables, in the shell command line, call the script *dmg-terrama2.sh* to build and generate automatically the TerraMA² package: ``` -$ ./dmg-terralib +$ ./dmg-terralib.sh ``` -- When finished the generated package will be located in the `build-package` folder in the same directory as your codebase. +1.5. When finished the generated package will be located in the `build-package` folder in the same directory as your codebase. -- To install the Drag-N-Drop package just double click it, accept the terms and drag the *terrama2-service* app to `Applications`. +1.6. To install the Drag-N-Drop package just double click it, accept the terms and drag the *terrama2-service* app to `Applications`. ### Quick Notes for Developers -If you have experienced any problem building any of the third-party tool on Mac OS, try to install Xcode command line tools: -``` -$ xcode-select --install -``` + ## Reporting Bugs diff --git a/README.md b/README.md index 5c91fc047..7f5bab5ad 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Besides that, it provides support for building models to several application dom The computational platform is based on a service-oriented architecture, which is open and provides the technological infrastructure required to develop and implement operating systems to monitor early warnings of environmental risks. + ## Source Code Instructions In the root directory of TerraMA² codebase (the source code tree) there are some text files explaining the details of the codebase: @@ -41,7 +42,6 @@ In the root directory of TerraMA² codebase (the source code tree) there are som - **[README:](https://github.com/TerraMA2/terrama2/blob/master/README)** Contains instructions about how to build and how is organized TerraMA² plataform source code. -If you want to build TerraMA² from source, first take a look at the section **Dependencies** (below in this document) and read the right tip for automatically building the dependencies in your platform. ## Source Code Organization @@ -61,11 +61,15 @@ If you want to build TerraMA² from source, first take a look at the section **D - **[tool:](https://github.com/TerraMA2/terrama2/tree/master/tools)** Contains some helper tools for managig TerraMA² code. + ## C++ Dependencies The file named **[DEPENDENCIES](https://github.com/TerraMA2/terrama2/blob/master/DEPENDENCIES)** in the root of TerraMA² source tree contains the official list of third-party libraries and tools that you must install before building TerraMA² from source. If you want to build yourself TerraMA² then you need to install some third-party libraries. Below we show the list of third-party libraries dependencies and its versions: + +- **CMake (Mandatory):** You should use at least CMake version 2.8.12 for building TerraMA². Older versions than this may not work properly. You can download it from: https://cmake.org/download/ + - **Boost (Mandatory):** TerraMA² is built on top of Boost libraries. You will need to have them installed in order to build TerraMA². Make sure to have at least version 1.54.0 installed. If you prefer to install from source, download it from: http://www.boost.org. - **Qt (Mandatory):** Make sure you have an installed Qt version 5.2.1 or later. Linux users may use any package manager to perform an easy installation. Mac OS X can use package managers such as Homebrew (http://brew.sh) or MacPorts (http://www.macports.org) in order to have an easy installation. If you prefer to install from source, download it from: http://qt-project.org/downloads. @@ -76,70 +80,7 @@ If you want to build yourself TerraMA² then you need to install some third-part - **Google Test (Optional):** Google Test is the Google's C++ test framework. You can download it from: https://github.com/google/googletest. -## Build Instructions - -### Packages - -If you want to build and generate TerraMA² packages, first take a look at the sections below and read the right tips for automatically building in your platform: - -- **[MAC:](https://github.com/TerraMA2/terrama2/blob/master/MAC.md)** Contains instructions about how to build and generate TerraMA² package on Mac OS. - -## Web Application and Components Dependencies - -All the web application dependencies and install steps you can find in: https://github.com/TerraMA2/terrama2/tree/master/webapp#terrama-webapp. - -The file named **[DEPENDENCIES](https://github.com/TerraMA2/terrama2/blob/master/DEPENDENCIES)** in the root of TerraMA² source tree contains the official list of third-party libraries and tools that you must install before building TerraMA² from source. - -### Bash script for building all dependencies on Linux Ubuntu 14.04 - -We have prepared a special bash script for building and installing the dependencies on Linux Ubuntu 14.04. This script can be found in TerraMA² source tree under *install* folder. Follow the steps below: - -- Download the third-party libraries package used by the development team: [terrama2-3rdparty-linux-ubuntu-14.04.tar.gz](http://www.dpi.inpe.br/terrama2-devel/terrama2-3rdparty-linux-ubuntu-14.04.tar.gz). - -- Copy the script [install-3rdparty-linux-ubuntu-14.04.sh](https://raw.githubusercontent.com/TerraMA2/terrama2/master/install/install-3rdparty-linux-ubuntu-14.04.sh) to the same folder you have downloaded the *terrama2-3rdparty-linux-ubuntu-14.04.tar.gz* package. - -- Open the shell command line and call the script *install-3rdparty-linux-ubuntu-14.04.sh* setting the target to install all the stuffs from these third-party libraries and tools: -``` -$ ./install-3rdparty-linux-ubuntu-14.04.sh /home/USER/MyLibs /home/USER/MyDevel/terrama2/codebase -``` - -**Note:** Don't choose as target location a system folder such as */usr* or */usr/local*. Try some user specifiic folder. The best suggestion is to replace the folder named *user* by your user name. - -### Bash script for building all dependencies on Mac OS X - -We have prepared a special bash script for building and installing the dependencies on Mac OS X. This script can be found in TerraMA² source tree under *install* folder. Follow the steps below: - -- Download the third-party libraries package used by the development team: - - [terrama2-3rdparty-macosx-yosemite.tar.gz](http://www.dpi.inpe.br/terrama2-devel/terrama2-3rdparty-macosx-yosemite.tar.gz). - - [terrama2-3rdparty-macosx-el-capitan.tar.gz](http://www.dpi.inpe.br/terrama2-devel/terrama2-3rdparty-macosx-el-capitan.tar.gz). - -- Copy one of the scripts to the same folder you have downloaded the 3rd-party package: - - [install-3rdparty-macosx-yosemite.sh](https://raw.githubusercontent.com/TerraMA2/terrama2/master/install/install-3rdparty-macosx-yosemite.sh) - - [install-3rdparty-macosx-el-capitan.sh](https://raw.githubusercontent.com/TerraMA2/terrama2/master/install/install-3rdparty-macosx-el-capitan.sh) - -- Open the shell command line. - -- Make sure your Qt and CMake environment can be found in your PATH: -``` -$ export PATH=$PATH:/Users/user/Qt5.4.1/5.4/clang_64/bin:/Applications/CMake.app/Contents/bin -``` - -- In the shell command line, call the script *install-3rdparty-macosx-yosemite.sh* (or the El-Capitan one) setting the target to install all the stuffs from these third-party libraries and tools: -``` -$ ./install-3rdparty-macosx-yosemite.sh /home/USER/MyLibs /home/USER/MyDevel/terrama2/codebase -``` - -**Note:** Don't choose as target location a system folder such as */usr* or */usr/local*. Try some user specifiic folder. The best suggestion is to replace the folder named *USER* by your user name. - -### Prepared dependencies for Microsot Windows - -**THIS SECTION IS UNDER DEVELOPMENT** - -For Microsoft Visual C++ users we have prepared a zip file containing all the third-party libraries in a binary format. You can download this package from http://www.dpi.inpe.br/terrama2-devel. In that folder you will find: -- **terrama2-3rdparty-msvc-2013-win64.zip:** all the third-party libraries for building a 64-bit version of TerraMA2 with Qt 5.4.1 support. -- **terrama2-3rdparty-msvc-2013-win32.zip:** all the third-party libraries for building a 32-bit version of TerraMA2 with Qt 5.4.1 support. - -Microsoft Windows users that had downloaded the auxiliary package (in the TerraMA² site) must install Qt 5.4.1. +All the *web application* dependencies and install steps you can find in: https://github.com/TerraMA2/terrama2/tree/master/webapp#terrama-webapp. ## Cloning TerraMA² Repository @@ -161,10 +102,12 @@ $ cd /home/user/mydevel/terrama2/codebase $ git clone https://github.com/terrama2/terrama2.git . ``` + ## Branches You can check all branches available (remotes and local) and see the current one (marked with "*"): - -`$ git branch -a` +``` +$ git branch -a +``` The output of above command will be something like: ``` @@ -194,20 +137,24 @@ We have the following branches: For a more complete releases info, check: https://github.com/TerraMA2/terrama2/releases To switch to one of the branches listed above, use the checkout command and create a local branch to track the remote branch. The syntax of "git checkout" is: - -`$ git checkout -b ` +``` +$ git checkout -b +``` In order to switch to branch *b-4.0.0-alpha* you can use the following command: +``` +$ git checkout -b b-4.0.0-alpha* origin/b-4.0.0-alpha* +``` -`$ git checkout -b b-4.0.0-alpha* origin/b-4.0.0-alpha*` ## Tags Also there are tags which usually are originated from a release branch. For instance, tag *t-4.0.0-alpha1* will be originated from branch *b-4.0.0-alpha*. To check all tags available, use: - -`$ git tag -l (list all tag names)` +``` +$ git tag -l (list all tag names) +``` ``` t-4.0.0-alpha1 t-4.0.0-alpha2 @@ -218,187 +165,33 @@ To check all tags available, use: ``` If you want to checkout a specific version given by a tag and create a local branch to work on you can use the following git command: - -`$ git checkout -b ` - -For instance, to checkout *t-4.0.0-alpha1* you can enter the following command: - -`$ git checkout -b t-4.0.0-alpha1 t-4.0.0-alpha1` - -## Build Instructions - -After choosing the right branch or tag to work on, follow the insructions on **DEPENDENCIES** section. Make sure you have all the third-party library dependencies listed in this section before trying to build TerraMA². - -The `build/cmake` folder contains a CMake project for building TerraMA². - -Until now its build has been tested on: -- Linux Ubuntu 14.04 -- Mac OS X Yosemite -- Microsoft Windows 7. - -You should use at least CMake version 2.8.12 for building TerraMA². Older versions than this may not work properly. - -Follow the build steps below according to your platform. - -### Building on Linux with GNU G++ - -1.1. Open a Command Prompt (Shell). - -1.2. We will assume that the codebase (all the source tree) is located at: - -`/home/user/mydevel/terrama2/codebase` - -1.3. Create a folder out of the TerraMA² source tree to generate the build system, for example: -``` -$ cd /home/user/mydevel/terrama2 -$ mkdir build-release -$ cd build-release ``` -**Note:** for the sake of simplicity create this directory in the same level as the source tree (as showned above). - -1.4. For Linux systems you must choose the build configuration: -``` -$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING="Release" -DCMAKE_INSTALL_PREFIX:PATH="/home/user/myinstall/terrama2" -DCMAKE_PREFIX_PATH:PATH="/home/user/mylibs;/home/user/mylibs/terralib5/lib/cmake" ../codebase/build/cmake -``` - -1.5 Building (with 4 process in parallel): -``` -$ make -j 4 -``` - -1.6 Installing: -``` -$ make install -``` - -1.7 Uninstalling: -``` -$ make uninstall +$ git checkout -b ``` -Notes: -* Some Linux flavours with different versions of GNU gcc and Boost will need more parameters such as: -``` - -DCMAKE_INCLUDE_PATH:PATH="/usr/local;/opt/include" - -DCMAKE_LIBRARY_PATH:PATH="/usr/local;/opt/lib" - -DCMAKE_PROGRAM_PATH:PATH="/usr/local/bin;/opt/bin" - -DBOOST_ROOT:PATH="/opt/boost" -``` -* Boost can also be indicated by BOOST_INCLUDEDIR (note: without an '_' separating INCLUDE and DIR): -``` - -DBOOST_INCLUDEDIR:PATH="/usr/local/include" -``` -* The parameter -lpthread must be informed only if your Boost was not built as a shared library: -``` - -DCMAKE_CXX_FLAGS:STRING="-lpthread" -``` -* For building with Qt5 you can provide the Qt5_DIR variable as: -``` - -DQt5_DIR:PATH="/usr/local/lib/cmake/Qt5" -``` -* For generating a debug version set CMAKE_BUILD_TYPE as: -``` - -DCMAKE_BUILD_TYPE:STRING="Debug" -``` - -### Building on Mac OS X Yosemite - -1.1 Open a Command Prompt (Shell). - -1.2. We will assume that the codebase (all the source tree) is located at: -``` -/Users/user/mydevel/terrama2/codebase -``` - -1.3. Create a folder out of the TerraMA² source tree to generate the build system, for example: -``` -$ cd /Users/user/mydevel/terrama2 -$ mkdir build-release -$ cd build-release -``` -**Note:** for the sake of simplicity create this directory in the same level as the source tree (as showned above). - -1.4. For Mac OS X systems you must choose the build configuration: -``` -$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING="Release" -DCMAKE_INSTALL_PREFIX:PATH="/Users/user/myinstall/terrama2" -DCMAKE_PREFIX_PATH:PATH="/Users/user/mylibs;/Users/user/mylibs/terralib5/lib/cmake;/Users/user/Qt5.4.1/5.4/clang_64/lib/cmake" ../codebase/build/cmake -``` - -**Note:** Please, in the cmake call above, take special attention to the key *CMAKE_PREFIX_PATH* and Qt location. - -1.5. Building (with 4 process in parallel): -``` -$ make -j 4 -``` - -1.6. Installing: -``` -$ make install -``` -1.7. Uninstalling: -``` -$ make uninstall -``` - -Notes: - -* You have to specify valid paths for *CMAKE_PREFIX_PATH*. If you have a Qt version installed as a framework in your home directory, you have to tell CMake where to locate its CMake support. For instance, if you have Qt version 5.4.1 installed, you have to add to *CMAKE_PREFIX_PATH* the following directory: -``` -/Users/user/Qt5.4.1/5.4/clang_64/lib/cmake -``` - -* You have also to tell where TerraLib? CMake support is located. Add to CMAKE_PREFIX_PATH where TerraLib? is installed, for example: -``` -/Users/user/MyLibs/terralib/lib/cmake -``` - -* You can also generate an Xcode project by using the "Xcode generator" option: -``` --G "Xcode" -``` - -* There are some useful variables that can be set inside Xcode in order to run an application. The following environment variable can be set: +For instance, to checkout *t-4.0.0-alpha1* you can enter the following command: ``` -DYLD_FALLBACK_LIBRARY_PATH -DYLD_FALLBACK_FRAMEWORK_PATH +$ git checkout -b t-4.0.0-alpha1 t-4.0.0-alpha1 ``` -### Building on Microsoft Windows with Visual C++ -**TO BE DONE** +## Build Instructions +The `build/cmake` folder contains a CMake project for building TerraMA². -### Quick Notes for Developers +Until now its build has been tested on: +- Linux Ubuntu 14.04 and Ubuntu 16.04 +- Mac OS X El Capitan and Mac OS Sierra -If you have built TerraMA² in Debug mode and you want to run it inside the build tree, you may need to set some environment variables: -* For Mac OS X, you can set the following variables: -``` -$ export DYLD_FALLBACK_LIBRARY_PATH=/Users/user/mylibs/lib -$ export DYLD_FALLBACK_FRAMEWORK_PATH=/Users/user/mylibs/lib/ -``` +After choosing the right branch or tag to work on, if you want to build TerraMA² and generate packages, first take a look at the sections below and read the right tips for automatically building in your platform: -* For Linux, you can set the following variable: -``` -$ export LD_LIBRARY_PATH=/home/user/mylibs/lib -``` +- **[LINUX:](https://github.com/TerraMA2/terrama2/blob/master/LINUX.md)** Contains instructions about how to build and generate TerraMA² package on Linux. -If you want to use QtCreator on Linux Ubuntu 14.04 you can install it through the following command: -``` -$ sudo apt-get install qtcreator -``` - -On Linux Ubuntu 14.04 you can install git through the following command: -``` -$ sudo apt-get install git -``` +- **[MAC:](https://github.com/TerraMA2/terrama2/blob/master/MAC.md)** Contains instructions about how to build and generate TerraMA² package on Mac OS. -If you have experienced any problem building any of the third-party tool on Mac OS X, try to install Xcode command line tools: -``` -$ xcode-select --install -``` ## Reporting Bugs Any problem should be reported to terrama2-team@dpi.inpe.br. - For more information on TerraMA², please, visit its main web page at: http://www.dpi.inpe.br/terrama2. diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 31aa7aefb..d73ba63b6 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -517,24 +517,6 @@ install(DIRECTORY ${TERRAMA2_ABSOLUTE_ROOT_DIR}/third-party # # Generate a post installation script with the installation folder # -<<<<<<< HEAD -configure_file(${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/postinst.in - ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/postinst @ONLY) -configure_file(${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/prerm.in - ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/prerm @ONLY) -configure_file(${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/postrm.in - ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/postrm @ONLY) - -install(FILES ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/remove-config.py - DESTINATION ${TERRAMA2_DESTINATION_SHARE}/scripts COMPONENT scripts) -# Copy instalation and removal scripts -install(FILES ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/postinst - DESTINATION ${TERRAMA2_DESTINATION_SHARE}/scripts COMPONENT scripts) -install(FILES ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/prerm - DESTINATION ${TERRAMA2_DESTINATION_SHARE}/scripts COMPONENT scripts) -install(FILES ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/postrm - DESTINATION ${TERRAMA2_DESTINATION_SHARE}/scripts COMPONENT scripts) -======= if(APPLE) install(DIRECTORY ${TERRAMA2_ABSOLUTE_ROOT_DIR}/scripts/mac/ @@ -565,7 +547,6 @@ elseif(UNIX) DESTINATION ${TERRAMA2_DESTINATION_SHARE}/scripts COMPONENT scripts) endif() ->>>>>>> Adding support for Mac package generation # # If generating a deb package the script is executed by the debian post install configuration # sa: build/cmake/terrama2-cpack-options.cmake.in diff --git a/install/install-3rdparty-macos-sierra.sh b/install/install-3rdparty-macos-sierra.sh index a800eb1a3..7e35fb46a 100755 --- a/install/install-3rdparty-macos-sierra.sh +++ b/install/install-3rdparty-macos-sierra.sh @@ -77,40 +77,13 @@ function valid() fi } - -# -# Check for terrama2-3rdparty-macos-sierra.tar.gz -# -if [ ! -f ./terrama2-3rdparty-macos-sierra.tar.gz ]; then - echo "Please, make sure to have terrama2-3rdparty-macos-sierra.tar.gz in the current directory!" - exit -fi - -# -# Extract packages -# -echo "extracting packages..." -sleep 1s - -tar xzvf terrama2-3rdparty-macos-sierra.tar.gz -valid $? "Error: could not extract 3rd party libraries (terrama2-3rdparty-macos-sierra.tar.gz)" - -echo "packages extracted!" -sleep 1s - -# -# Go to 3rd party libraries dir -# -cd terrama2-3rdparty-macos-sierra -valid $? "Error: could not enter 3rd-party libraries dir (terrama2-3rdparty-macos-sierra)" - # # Check installation dir # -if [ "$1" == "" ]; then - TERRAMA2_DEPENDENCIES_DIR="$HOME/mylibs-teste" -else - TERRAMA2_DEPENDENCIES_DIR="$1" + +if [ -z "$TERRAMA2_DEPENDENCIES_DIR" ]; then + echo "Please, select the installation folder of the third-party libraries through the variable TERRAMA2_DEPENDENCIES_DIR." + exit fi export PATH=$PATH:$HOME/Qt5.4.1/5.4/clang_64/bin:/Applications/CMake.app/Contents/bin @@ -229,6 +202,7 @@ fi # Finished! # clear +echo "" echo "****************************************" echo "* TerraMA2 Installer for Mac OS Sierra *" echo "****************************************" diff --git a/scripts/mac/postinst.sh b/scripts/mac/postinst.sh index 588eab659..5a955b4e4 100755 --- a/scripts/mac/postinst.sh +++ b/scripts/mac/postinst.sh @@ -13,12 +13,9 @@ if [ -z "$TERRAMA2_APP_DIR" ]; then export TERRAMA2_APP_DIR=.. fi - echo "Post-installation script..." -# -# Install Optional Thirdparties -# +# Check manually installed thirdparties ( echo "Checking for Postgresql version..." which psql &>/dev/null @@ -33,25 +30,21 @@ echo "Post-installation script..." fi ) - -# # Install web dependencies -# -( - echo "Installing Bower and Grunt..." - npm install bower -g &>/dev/null - npm install grunt -g &>/dev/null - valid $? "Error installing web dependencies." -) - ( echo "Installing Webapp dependencies..." cd ${TERRAMA2_APP_DIR}/webapp - npm install + + npm install bower &>/dev/null + valid $? "Unable to install Bower." + npm install grunt &>/dev/null + valid $? "Unable to install Grunt." + + npm install >/dev/null valid $? "Unable to install NodeJs dependencies." - bower install --allow-root >/dev/null + npm run bower -- install --allow-root >/dev/null valid $? "Unable to install Bower dependencies." - grunt >/dev/null + npm run grunt >/dev/null valid $? "Error executing grunt." chmod +x bin/webapp-stop.js @@ -60,53 +53,103 @@ echo "Post-installation script..." ( echo "Installing Webcomponents dependencies..." cd ${TERRAMA2_APP_DIR}/webcomponents + + npm install grunt &>/dev/null + valid $? "Unable to install Grunt." + npm install >/dev/null valid $? "Unable to install NodeJs dependencies." - grunt >/dev/null + npm run grunt >/dev/null valid $? "Error executing grunt." ) ( echo "Installing Webmonitor dependencies..." cd ${TERRAMA2_APP_DIR}/webmonitor + + npm install bower &>/dev/null + valid $? "Unable to install Bower." + npm install grunt &>/dev/null + valid $? "Unable to install Grunt." + npm install >/dev/null valid $? "Unable to install NodeJs dependencies." - bower install --allow-root >/dev/null + npm run bower -- install --allow-root >/dev/null valid $? "Unable to install Bower dependencies." + npm run grunt >/dev/null + valid $? "Error executing grunt." ) -# +# Create default config files +( + cd ${TERRAMA2_APP_DIR}/webapp/config + if ! [ -d "instances" ]; then + cp -r sample_instances instances + fi +) +( + cd ${TERRAMA2_APP_DIR}/webmonitor/config + if ! [ -d "instances" ]; then + cp -r sample_instances instances + fi +) + +# If not root, end script +if [ "$EUID" -ne 0 ]; then + echo "End post-installation script..." + exit 0 +fi + # Install and configure pm2 -# ( # Check if pm2 is already installed npm list pm2 -g >/dev/null if [ $? != 0 ]; then echo "Configuring pm2..." + # Install pm2 npm install pm2 -g >/dev/null - pm2 install pm2-logrotate >/dev/null valid $? "Error installing pm2." + pm2 install pm2-logrotate >/dev/null + valid $? "Error installing pm2-logrotate." + # Allows the service to start with the system /usr/bin/osascript -e 'do shell script "env PATH=$PATH:/usr/local/bin pm2 startup" with administrator privileges' valid $? "Error adding pm2 to startup." fi ) +# Create a terrama2 user +# and default data folder +( + adduser --system --no-create-home terrama2 + if [ $? -eq 0 ]; then + # new user created + # setting new password + echo terrama2:terrama4 | chpasswd + sudo usermod -a -G sudo terrama2 + fi + + mkdir -p /var/lib/terrama2/data + chown terrama2 /var/lib/terrama2 -R +) + +# Add webapp to pm2 startup ( - # Add webapp to pm2 startup echo "Adding Webapp in pm2 startup..." cd ${TERRAMA2_APP_DIR}/webapp + pm2 start npm --name webapp -- start >/dev/null valid $? "Error executing webapp." pm2 save >/dev/null valid $? "Error saving pm2 state." ) +# Add webmonitor to pm2 startup ( - # Add webmonitor to pm2 startup echo "Adding Webcomponents in pm2 startup..." cd ${TERRAMA2_APP_DIR}/webmonitor + pm2 start npm --name webmonitor -- start >/dev/null valid $? "Error executing webmonitor." pm2 save >/dev/null @@ -114,5 +157,4 @@ echo "Post-installation script..." ) echo "End post-installation script..." - exit 0 \ No newline at end of file