1#!/bin/bash 2# 3# This script downloads and builds the dependencies of SWI-Prolog. It 4# was designed to build the dependencies in a controlled way for the 5# MacOS binary bundle, but should be easily adapted to install the 6# dependencies on other Unix-like platforms. 7# 8# To use this, run `. macos-deps.sh` to get the various functions in 9# your shell. Note that the BDB download is no longer easily available 10# and requires registering an account with Oracle. 11 12# Set PREFIX to point at the prefix for installing the dependencies. 13# Configure using cmake -DMACOSX_DEPENDENCIES_FROM=$PREFIX 14 15PREFIX="$HOME/deps" 16export MACOSX_DEPLOYMENT_TARGET=10.12 17 18GMP_VERSION=6.1.2 19SSL_VERSION=1.1.1f 20JPEG_VERSION=9b 21ZLIB_VERSION=1.2.11 22ARCHIVE_VERSION=3.4.0 23UUID_VERSION=1.6.2 24BDB_VERSION=6.1.26 25ODBC_VERSION=2.3.7 26PCRE_VERSION=8.43 27FFI_VERSION=3.3 28YAML_VERSION=0.1.7 29READLINE_VERSION=8.0 30 31# installation prefix. This path should not have spaces in one of the 32# directory names. 33 34src="$(pwd)" 35################ 36# Handy for running autoconf from a directory 37 38export LDFLAGS=-L$PREFIX/lib 39export CFLAGS="-mmacosx-version-min=10.12 -O2" 40 41config() 42{ if [ -r ./configure ]; then 43 ./configure --prefix=$PREFIX 44 elif [ -r ../src/configure ]; then 45 ./configure --prefix=$PREFIX 46 fi 47} 48 49 50########################### 51# Download and install the GMP library. 52 53download_gmp() 54{ GMP_FILE=gmp-$GMP_VERSION.tar.bz2 55 56 [ -f $GMP_FILE ] || \ 57 wget https://ftp.gnu.org/gnu/gmp/$GMP_FILE 58 tar jxf $GMP_FILE 59} 60 61build_gmp() 62{ ( cd gmp-$GMP_VERSION 63 ./configure --prefix=$PREFIX \ 64 --enable-shared --disable-static --enable-fat 65 make 66 make install 67 ) 68} 69 70########################### 71# Download and install ssl 72 73download_ssl() 74{ SSL_FILE=openssl-$SSL_VERSION.tar.gz 75 [ -f $SSL_FILE ] || wget http://www.openssl.org/source/$SSL_FILE 76 tar xzf $SSL_FILE 77} 78 79build_ssl() 80{ ( cd openssl-$SSL_VERSION 81 ./Configure --prefix=$PREFIX shared threads darwin64-x86_64-cc 82 make depend 83 make 84 make install_sw 85 ) 86} 87 88########################### 89# Download and install BerkeleyDB 90# http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/overview/index.html 91 92download_libdb() 93{ BDB_FILE=db-$BDB_VERSION.tar.gz 94 95 [ -f $BDB_FILE ] || \ 96 curl http://download.oracle.com/otn/berkeley-db/$BDB_FILE > $BDB_FILE 97 tar zxvf $BDB_FILE 98} 99 100build_libdb() 101{ ( cd db-$BDB_VERSION/build_unix 102 ../dist/configure --prefix=$PREFIX \ 103 --enable-shared --disable-static 104 make library_build 105 make install_lib install_include 106 ) 107} 108 109 110########################### 111# Download and install BerkeleyDB 112# http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/overview/index.html 113 114download_odbc() 115{ ODBC_FILE=unixODBC-$ODBC_VERSION.tar.gz 116 117 [ -f $ODBC_FILE ] || \ 118 curl http://www.unixodbc.org/$ODBC_FILE > $ODBC_FILE 119 tar zxvf $ODBC_FILE 120} 121 122build_odbc() 123{ ( cd unixODBC-$ODBC_VERSION 124 ./configure --prefix=$PREFIX --enable-gui=no --enable-iconv=no --with-included-ltdl 125 make 126 make install 127 ) 128} 129 130 131########################### 132# Download and install jpeg 133 134download_jpeg() 135{ JPEG_FILE=jpegsrc.v$JPEG_VERSION.tar.gz 136 137 [ -f $JPEG_FILE ] || wget http://www.ijg.org/files/$JPEG_FILE 138 tar xzf $JPEG_FILE 139} 140 141build_jpeg() 142{ ( cd jpeg-$JPEG_VERSION 143 ./configure --prefix=$PREFIX --enable-shared 144 make 145 make install 146 ) 147} 148 149########################### 150# Download and install zlib 151 152download_zlib() 153{ ZLIB_FILE=zlib-$ZLIB_VERSION.tar.gz 154 155 [ -f $ZLIB_FILE ] || wget http://zlib.net/$ZLIB_FILE 156 tar xzf $ZLIB_FILE 157} 158 159build_zlib() 160{ ( cd zlib-$ZLIB_VERSION 161 ./configure --prefix=$PREFIX 162 make 163 make install 164 ) 165} 166 167########################### 168# Download and install libreadline 169 170download_readline() 171{ READLINE_FILE=readline-$READLINE_VERSION.tar.gz 172 173 [ -f $READLINE_FILE ] || wget https://ftp.gnu.org/gnu/readline/$READLINE_FILE 174 tar xzf $READLINE_FILE 175} 176 177build_readline() 178{ ( cd readline-$READLINE_VERSION 179 ./configure --prefix=$PREFIX 180 make 181 make install 182 ) 183} 184 185################################# 186# Download and install libarchive 187 188download_libarchive() 189{ ARCHIVE_FILE=libarchive-$ARCHIVE_VERSION.tar.gz 190 191 [ -f $ARCHIVE_FILE ] || \ 192 wget http://www.libarchive.org/downloads/$ARCHIVE_FILE 193 tar xzf $ARCHIVE_FILE 194} 195 196# lt_cv_deplibs_check_method=pass_all works around a bug in libtool 197# causing: "linker path does not have real file for library" error on MinGW 198# See http://lists.cairographics.org/archives/cairo/2009-July/017686.html 199 200build_libarchive() 201{ ( cd libarchive-$ARCHIVE_VERSION 202 ./configure --prefix=$PREFIX --with-pic \ 203 --without-iconv --without-openssl --without-nettle --without-xml2 \ 204 --without-expat --without-libregex --without-bz2lib \ 205 --without-lzmadec --without-lzma --without-lzo2 206 make 207 make install 208 ) 209} 210 211 212################################# 213# Download and install libpcre 214 215 216download_libpcre() 217{ PCRE_FILE=pcre-$PCRE_VERSION.tar.gz 218 219 [ -f $PCRE_FILE ] || \ 220 wget https://ftp.pcre.org/pub/pcre/$PCRE_FILE 221 tar xzf $PCRE_FILE 222} 223 224 225build_libpcre() 226{ ( cd pcre-$PCRE_VERSION 227 ./configure --prefix=$PREFIX \ 228 --disable-static --disable-cpp --enable-utf8 --enable-unicode-properties 229 make pcre.dll 230 make install 231 ) 232} 233 234 235################################# 236# Download and install libuuid 237 238download_libuuid() 239{ UUID_FILE=uuid-$UUID_VERSION.tar.gz 240 241 [ -f $UUID_FILE ] || \ 242 curl ftp://ftp.ossp.org/pkg/lib/uuid/$UUID_FILE > $UUID_FILE 243 tar zxvf $UUID_FILE 244} 245 246build_libuuid() 247{ ( cd uuid-$UUID_VERSION 248 ./configure --prefix=$PREFIX 249 make 250 make install 251 ) 252} 253 254################################ 255# Download and install libffi 256 257download_libffi() 258{ FFI_FILE=libffi-$FFI_VERSION.tar.gz 259 [ -f $FFI_FILE ] || \ 260 curl ftp://sourceware.org/pub/libffi/$FFI_FILE > $FFI_FILE 261 tar zxvf $FFI_FILE 262} 263 264build_libffi() 265{ ( cd libffi-$FFI_VERSION 266 ./configure --prefix=$PREFIX 267 make 268 make install 269 # Bit strange location for the headers 270 cp $PREFIX/lib/libffi-$FFI_VERSION/include/*.h $PREFIX/include 271 ) 272} 273 274 275################################ 276# Download and install libyaml 277 278download_libyaml() 279{ #tested 01f3a8786127748b5bbd4614880c4484570bbd44 280 if [ -d libyaml ]; then 281 git -C libyaml pull 282 else 283 git clone https://github.com/yaml/libyaml 284 fi 285} 286 287build_libyaml() 288{ ( cd libyaml 289 ./bootstrap 290 ./configure --prefix=$PREFIX 291 make 292 make install 293 ) 294} 295 296 297########################### 298# Do the whole lot for all prerequisites 299 300clean_prerequisites() 301{ ( cd gmp-$GMP_VERSION && make distclean ) 302 ( cd openssl-$SSL_VERSION && make distclean ) 303 ( cd jpeg-$JPEG_VERSION && make distclean ) 304 ( cd zlib-$ZLIB_VERSION && make distclean ) 305 ( cd libarchive-$ARCHIVE_VERSION && make distclean ) 306 ( cd uuid-$UUID_VERSION && make distclean ) 307 ( cd ffi-$FFI_VERSION && make distclean ) 308 ( cd libyaml && make distclean ) 309} 310 311 312download_prerequisites() 313{ download_gmp 314 download_ssl 315 download_jpeg 316 download_zlib 317 download_readline 318 download_libarchive 319 download_libuuid 320 download_libdb 321 download_odbc 322 download_libpcre 323 download_libffi 324 download_libyaml 325} 326 327build_prerequisites() 328{ build_gmp 329 build_ssl 330 build_jpeg 331 build_zlib 332 build_readline 333 build_libarchive 334 build_libuuid 335 build_libdb 336 build_odbc 337 build_libpcre 338 build_libffi 339 build_libyaml 340} 341