-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile
executable file
·148 lines (114 loc) · 3.75 KB
/
compile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#! /bin/bash
# compile script for the C programs used by FormCalc
# last modified 16 Feb 22 th
# If this compile script doesn't work on your system, check these things:
#
# a) You need gcc. If that's not installed on your system, change all
# "gcc"s to "cc"s, but have your fingers crossed: not all ccs will
# compile MathLink programs without errors. You may need to change
# CFLAGS to e.g. relax strict ANSI compliance.
#
# b) You need mcc. mcc is a script which compiles MathLink programs.
# Such programs have the extension .tm. If you have Mathematica,
# you should also have mcc. If mcc is not on the path, specify it
# in the environment variable MCC, e.g.
# export MCC=/usr/local/Wolfram/Mathematica/m.n/Executables/mcc
CC="${CC:-gcc}"
CXX="${CXX:-g++}"
MCC="${MCC:-mcc}"
MATH="${MATH:-math}"
CFLAGS="${CFLAGS:--O3 -fomit-frame-pointer -ffast-math -Wall -Wextra} $@"
SRC="${SRC:-`dirname "$0"`}"
os="`uname`"
exe=
test "${os::3}" = CYG && exe=.exe
test -z "$DEST" && {
mathcmd="$MATH"
shopt -s nullglob
set --
case "$os" in
Darwin)
mathcmd=MathKernel
set -- /Applications/Mathematica*/Contents/MacOS \
$HOME/Desktop/Mathematica*/Contents/MacOS ;;
CYG*)
exe=.exe
w64="`cygpath -u "${ProgramW6432:-/cygdrive/c/Program Files}"`"
w32="`cygpath -u "${PROGRAMFILES:-/cygdrive/c/Program Files (x86)}"`"
eval set -- `ls -tdQ {"$w64","$w32"}/"Wolfram Research"/Mathematica/*` ;;
esac
mathcmd="`IFS=:
PATH="$PATH:$*" which "$mathcmd"`"
test -z "$mathcmd" && {
echo "No 'math' command found" 1>&2
exit 1
}
[[ `"$mathcmd" -run 'Print[7 673, $SystemID]; Exit[]' < /dev/null` =~ 4711([^$'\r\n']*) ]] || {
echo "Cannot determine Mathematica's system ID using $mathcmd" 1>&2
exit 1
}
DEST="${BASH_REMATCH[1]}"
}
BIN="$DEST"
case "$DEST" in
Please)
cat << _EOF_
I can't seem to run the Mathematica Kernel.
Maybe you have a buggy Mathematica installation or you're
out of licenses.
Please make sure you can start the Mathematica Kernel without
additional flags (such as -pwfile) and re-run $0.
_EOF_
exit 1 ;;
Linux-x86-64)
CFLAGS+=" -m64" MCFLAGS+=" -b64";;
MacOSX-x86-64)
CFLAGS+=" -m64" MCFLAGS+=" -n";;
MacOSX-ARM64)
MCFLAGS+=" -n";;
Windows-x86-64)
MCFLAGS+=" -D__int64='long long int'"
${DLLTOOL:-dlltool} --help | grep x86-64 > /dev/null || BIN=Windows ;;
esac
test -d "$DEST" || mkdir "$DEST" || {
echo "Cannot create directory $DEST"
exit 1
}
echo "Compiling for system type $DEST"
t="$SRC/drivers/tools"
mcc="REALCC=\"$CC\" CC=\"$t/fcc\" \
REALCXX=\"$CXX\" CXX=\"$t/f++\" \
PATH=\""'$$PATH'":$t\" $MCC -st $MCFLAGS $CFLAGS"
# Mma 5.1's mcc needs -lpthread for static linking
mclibs="-lpthread"
cc="$CC $CFLAGS"
make -f - << _EOF_ || exit 1
all: $DEST/tform$exe \
$DEST/ReadForm$exe $DEST/ToForm$exe \
$DEST/ToFortran$exe $DEST/ToC$exe \
$DEST/ReadData$exe $DEST/reorder$exe
$DEST/tform$exe: $SRC/bin/$BIN/tform$exe
cp -p $SRC/bin/$BIN/* $DEST/
$DEST/ReadForm$exe: $SRC/FormCalc/ReadForm.tm
$mcc -o $DEST/ReadForm$exe $SRC/FormCalc/ReadForm.tm $mclibs
-strip $DEST/ReadForm$exe
$DEST/ToForm$exe: $SRC/FormCalc/ToForm.c
$cc -o $DEST/ToForm$exe $SRC/FormCalc/ToForm.c
-strip $DEST/ToForm$exe
$DEST/ToFortran$exe: $SRC/FormCalc/ToFortran.c
$cc -o $DEST/ToFortran$exe $SRC/FormCalc/ToFortran.c
-strip $DEST/ToFortran$exe
$DEST/ToC$exe: $SRC/FormCalc/ToC.c
$cc -o $DEST/ToC$exe $SRC/FormCalc/ToC.c
-strip $DEST/ToC$exe
$DEST/ReadData$exe: $SRC/tools/ReadData.tm
$mcc -o $DEST/ReadData$exe $SRC/tools/ReadData.tm $mclibs
-strip $DEST/ReadData$exe
$DEST/reorder$exe: $SRC/tools/reorder.c
$cc -o $DEST/reorder$exe $SRC/tools/reorder.c
-strip $DEST/reorder$exe
_EOF_
# Second, make the util library.
cd "$DEST"
trap "rm -f makefile" 0 1 2 3 15
"../$SRC/drivers/configure" --make="util.a build clean"