1#!/bin/sh
2
3#
4#  This file is part of the Yices SMT Solver.
5#  Copyright (C) 2017 SRI International.
6#
7#  Yices is free software: you can redistribute it and/or modify
8#  it under the terms of the GNU General Public License as published by
9#  the Free Software Foundation, either version 3 of the License, or
10#  (at your option) any later version.
11#
12#  Yices is distributed in the hope that it will be useful,
13#  but WITHOUT ANY WARRANTY; without even the implied warranty of
14#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#  GNU General Public License for more details.
16#
17#  You should have received a copy of the GNU General Public License
18#  along with Yices.  If not, see <http://www.gnu.org/licenses/>.
19#
20
21#
22# Construct a README file from a template
23#
24# This scripts replaces
25#  __YICES__      by the 2.2.1
26#  __GMP__        by the 6.0.0
27#  __DYLIB__      by the name of the dynamic library
28#  __OS_VERSION__ by the Linux/Android
29# in the template
30#
31#
32# Usage:
33#   ./mkreadme <dist> <template>
34#
35# <dist> must be a distribution directory like
36#   build/arm-linux-androideabi-release/static-dist
37#
38# The template must be an appropriate text file for the distribution
39# (e.g. etc/README.static.linux)
40#
41# NOTE: this script replaces the default mkreadme when cross-compiling
42#
43
44usage="Usage: $0 <distribution directory> <template>\n
45\n
46   For example\n
47\n
48    $0 ./build/x86_64-unknown-linux-gnu-release/dist ./etc/README.linux\n
49"
50
51if test $# != 2 ; then
52   echo "$usage"
53   exit 1
54fi
55
56dist=$1
57template=$2
58libdir=$dist/lib
59
60if test ! -d $dist ; then
61   echo "Error: $dist not found or not a directory"
62   exit 1
63fi
64
65if test ! -f $template ; then
66   echo "Error: $template not found"
67   exit 1
68fi
69
70if test ! -d $libdir ; then
71   echo "Error: $libdir not found or not a directory"
72   exit 1
73fi
74
75
76if test -x $dist/bin/yices ; then
77  yices=$dist/bin/yices
78else
79  if test -x $dist/bin/yices.exe ; then
80     yices=$dist/bin/yices.exe
81  else
82    echo "Error: can't find yices or yices.exe in $dist/bin"
83    exit 1
84  fi
85fi
86
87#
88# Version stuff
89#
90clean_os_version="Android 14"
91gmp_version="6.0.0"
92yices_verion="2.2.1"
93
94
95#
96# Get the dynamic library name
97#
98libname="none"
99alllibs=`ls $libdir`
100for lib in $alllibs; do
101  case $lib in
102    libyices.so.* | libyices.*.dylib )
103      if test $libname = "none" ; then
104        libname=$lib
105      else
106        echo "Error: found two dymanic libraries: $libname and $lib in $dist/lib"
107        exit 1
108      fi
109    ;;
110  esac
111done
112
113
114
115#
116# Apply the substitution
117#
118sed -e "s/__YICES__/${yices_version}/g" -e "s/__GMP__/${gmp_version}/g" \
119    -e "s/__DYLIB__/${libname}/g" -e "s,__OS_VERSION__,${clean_os_version},g" $template
120
121