eosio_build.sh 6.2 KB
Newer Older
1 2
#!/bin/bash
##########################################################################
3
# This is the EOSIO automated install script for Linux and Mac OS.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
# This file was downloaded from https://github.com/EOSIO/eos
#
# Copyright (c) 2017, Respective Authors all rights reserved.
#
# After June 1, 2018 this software is available under the following terms:
# 
# The MIT License
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# https://github.com/EOSIO/eos/blob/master/LICENSE.txt
##########################################################################

	VERSION=1.1
	ULIMIT=$( ulimit -u )
	WORK_DIR=$PWD
	BUILD_DIR=${WORK_DIR}/build
	TEMP_DIR=/tmp
38
	ARCH=$( uname )
39 40
	DISK_MIN=20
	
41
	txtbld=$(tput bold)
42 43 44
	bldred=${txtbld}$(tput setaf 1)
	txtrst=$(tput sgr0)

45
	printf "\n\tARCHITECTURE: ${ARCH}\n"
46 47 48 49

	if [ $ARCH == "Linux" ]; then
		
		if [ ! -e /etc/os-release ]; then
50 51 52 53 54 55 56 57
			printf "\n\tEOSIO currently supports Amazon, Centos, Fedora, Mint & Ubuntu Linux only.\n"
			printf "\tPlease install on the latest version of one of these Linux distributions.\n"
			printf "\thttps://aws.amazon.com/amazon-linux-ami/\n"
			printf "\thttps://www.centos.org/\n"
			printf "\thttps://start.fedoraproject.org/\n"
			printf "\thttps://linuxmint.com/\n"
			printf "\thttps://www.ubuntu.com/\n"
			printf "\tExiting now.\n"
58 59 60 61 62 63
			exit 1
		fi
	
		OS_NAME=$( cat /etc/os-release | grep ^NAME | cut -d'=' -f2 | sed 's/\"//gI' )
	
		case $OS_NAME in
64 65
			"Amazon Linux AMI")
				FILE=${WORK_DIR}/scripts/eosio_build_amazon.sh
66
				export CMAKE=${HOME}/opt/cmake/bin/cmake
67 68
				CXX_COMPILER=g++
				C_COMPILER=gcc
69
				export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
70
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
71
			;;
72 73 74
			"CentOS Linux")
				FILE=${WORK_DIR}/scripts/eosio_build_centos.sh
				export CMAKE=${HOME}/opt/cmake/bin/cmake
75 76
				CXX_COMPILER=g++
				C_COMPILER=gcc
77
				export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
78 79
				MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
				export PATH=${HOME}/opt/mongodb/bin:$PATH
80
			;;
81 82
			"Fedora")
				FILE=${WORK_DIR}/scripts/eosio_build_fedora.sh
83 84
				CXX_COMPILER=g++
				C_COMPILER=gcc
85
				export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
86
				MONGOD_CONF=/etc/mongod.conf
87 88 89 90 91
			;;
			"Linux Mint")
				FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
				CXX_COMPILER=clang++-4.0
				C_COMPILER=clang-4.0
92
				MONGOD_CONF=/etc/mongod.conf
93
			;;
94 95 96 97
			"Ubuntu")
				FILE=${WORK_DIR}/scripts/eosio_build_ubuntu.sh
				CXX_COMPILER=clang++-4.0
				C_COMPILER=clang-4.0
98
				MONGOD_CONF=/etc/mongod.conf
99
			;;
100 101 102 103
			*)
				printf "\n\tUnsupported Linux Distribution. Exiting now.\n\n"
				exit 1
		esac
104
		
105 106 107
		export BOOST_ROOT=${HOME}/opt/boost_1_66_0
		export OPENSSL_ROOT_DIR=/usr/include/openssl
		export OPENSSL_LIBRARIES=/usr/include/openssl
108
		export WASM_ROOT=${HOME}/opt/wasm
109

110 111 112 113
	 . $FILE
	fi

	if [ $ARCH == "Darwin" ]; then
114 115
		OPENSSL_ROOT_DIR=/usr/local/opt/openssl
		OPENSSL_LIBRARIES=/usr/local/opt/openssl/lib
116
		export WASM_ROOT=/usr/local/wasm
117 118
		CXX_COMPILER=clang++
		C_COMPILER=clang
119
		MONGOD_CONF=/usr/local/etc/mongod.conf
120

121
	  . scripts/eosio_build_darwin.sh
122 123 124 125 126 127
	fi

	printf "\n\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOS.IO\n\n"

	COMPILE_EOS=1
	COMPILE_CONTRACTS=1
128
	CMAKE_BUILD_TYPE=RelWithDebInfo
129 130 131 132 133

	cd ${WORK_DIR}
	mkdir -p ${BUILD_DIR}
	cd ${BUILD_DIR}

134 135 136 137 138
	if [ -z $CMAKE ]; then
		CMAKE=$( which cmake )
	fi
	
	$CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
139
	-DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_ROOT=${WASM_ROOT} \
140
	-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DBUILD_MONGO_DB_PLUGIN=true \
141
	-DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} ..
142
	
143 144
	if [ $? -ne 0 ]; then
		printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\n\n"
145 146 147
		exit -1
	fi

148
	make -j${CPU_CORE} VERBOSE=0
149 150 151 152 153 154

	if [ $? -ne 0 ]; then
		printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building EOSIO has exited with the above error.\n\n"
		exit -1
	fi

155 156
	printf "\n\t>>>>>>>>>>>>>>>>>>>> EOSIO has been successfully built.\n\n"

157 158 159 160 161 162 163 164 165
	printf "\n\tVerifying MongoDB is running.\n"
	MONGODB_PID=$( pgrep -x mongod )
	if [ -z $MONGODB_PID ]; then
		printf "\tMongoDB is not currently running.\n"
		printf "\tStarting MongoDB.\n"
		mongod -f ${MONGOD_CONF} &
		if [ $? -ne 0 ]; then
			printf "\n\tUnable to start MongoDB.\nExiting now.\n\n"
			exit -1
166
		fi
167 168 169 170
		MONGODB_PID=$( pgrep -x mongod )
		printf "\n\tSuccessfully started MongoDB PID = ${MONGODB_PID}.\n"
	else
		printf "\n\tMongoDB is running PID=${MONGODB_PID}.\n"
171
	fi
172 173
	
	make test
J
Jonathan Giszczak 已提交
174

J
Jonathan Giszczak 已提交
175
   if [ "x${EOSIO_BUILD_PACKAGE}" != "x" ]; then
J
Jonathan Giszczak 已提交
176 177 178 179 180 181 182 183 184 185 186
      # Build eos.io package
      $CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
      -DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_ROOT=${WASM_ROOT} \
      -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} \
      -DCMAKE_INSTALL_PREFIX=/usr ..

      if [ $? -ne 0 ]; then
         printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building eos.io package has exited with the above error.\n\n"
         exit -1
      fi

187
      make -j${CPU_CORE} VERBOSE=0 package
J
Jonathan Giszczak 已提交
188 189 190 191 192 193 194

      if [ $? -ne 0 ]; then
         printf "\n\t>>>>>>>>>>>>>>>>>>>> MAKE building eos.io package has exited with the above error.\n\n"
         exit -1
      fi

      printf "\n\t>>>>>>>>>>>>>>>>>>>> eos.io package has been successfully built.\n\n"
195
   fi