-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·77 lines (68 loc) · 3.32 KB
/
configure
File metadata and controls
executable file
·77 lines (68 loc) · 3.32 KB
1
2
3
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#CONFIGURATION FILE - update to project name (make it $(TARGET).cfg, where TARGET is in the Makefile)
CFIL="semigroup.cfg"
#COLOURS
NC='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
#Finding pari.cfg location.
printf "We need to find the location of the ${RED}configuration file${NC} (${GREEN}pari.cfg${NC}), which contains the location of the ${RED}compiled library${NC} (${GREEN}libpari.so${NC} and the ${RED}header files${NC}. The standard location is:\n\t${GREEN}/usr/local/lib/pari/pari.cfg${NC},\nbut this can depend on the system.\n"
while true; do
printf "Where should we look for ${GREEN}pari.cfg${NC}? (default is ${GREEN}/usr${NC})\n"
#Retrieve the user input
read -r -p " " SEARCHLOC
if [ "$SEARCHLOC" = "" ]; then
SEARCHLOC="/usr"
fi
printf "Searching for ${GREEN}pari.cfg${NC}:\n"
FOUNDLOCS=$(find $SEARCHLOC -name pari.cfg 2>/dev/null)
#Test if anything was found
if [ "${FOUNDLOCS}" = "" ]; then
printf "${RED}No file found${NC}. Perhaps PARI/GP is installed in a different directory than what you supplied? Try supplying another directory or searching in '/', which may be very slow.\nThe command ${RED}type -a gp${NC} may also help you get an idea of approximately where to look. If this is a link, call ${RED}readlink -f (insert location)${NC} to see where it is linked to.\nSimilarly, ${RED}open gp${NC}, and type in ${RED}default()${NC}. Look at the values of ${RED}datadir${NC} and ${RED}help${NC}. The file is often located in ${RED}(path to help)/../../lib/pari/pari.cfg${NC}, or at least, in a nearby folder.\n\n\n"
continue
fi
#Print out the found files and version numbers
FOUNDARRAY=()
IND=1
printf "Here are the places we found ${GREEN}pari.cfg${NC}:\n"
for POSS in $FOUNDLOCS; do
FOUNDARRAY+=($POSS)
VER=$(grep pari_release= ${POSS} -s | cut -d"'" -f2 | cut -d"-" -f1,2,3)
printf "\t${PURPLE}${IND}${NC}: Version ${YELLOW}${VER}${NC}\tLocation ${GREEN}${POSS}${NC}\n"
((IND++))
done;
((IND--))
#Determine which are correct, if any.
printf "Which one is correct? If none, type 0.\n"
while true; do
read CFGNUM
if [ $CFGNUM -ge 0 ] && [ $CFGNUM -le $IND ]; then
break;
fi
printf "Please give an answer from ${PURPLE}1${NC} to ${PURPLE}${IND}${NC}\n"
done
#User selected none
if test $CFGNUM -eq 0; then
printf "${RED}No file selected${NC}. Perhaps PARI/GP is installed in a different directory than what you supplied? Try supplying another directory or searching in '/', which may be very slow.\nThe command ${RED}type -a gp${NC} may also help you get an idea of approximately where to look. If this is a link, call ${RED}readlink -f (insert location)${NC} to see where it is linked to.\nSimilarly, ${RED}open gp${NC}, and type in ${RED}default()${NC}. Look at the values of ${RED}datadir${NC} and ${RED}help${NC}. The file is often located in ${RED}(path to help)/../../lib/pari/pari.cfg${NC}, or at least, in a nearby folder.\n\n\n"
else
((CFGNUM--))
CFGLOC=${FOUNDARRAY[${CFGNUM}]}
break
fi
done
#Save the CFG location.
printf "CFG='${CFGLOC}'\n" > $CFIL
#Determine the OS
UNAME=`uname -a`
if grep -q Microsoft <<< $UNAME; then
OS="WSL"
elif grep -q Linux <<< $UNAME; then
OS="Linux"
else
OS="Mac"
fi
printf "OS='${OS}'\n" >> $CFIL
#Done!
printf "${RED}Setup complete${NC}!\n"