-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_scipdl.sh
executable file
·273 lines (191 loc) · 7.39 KB
/
build_scipdl.sh
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/bin/bash
### This is for MacOS Monterey both arm64 and intel ###
# This is a bash script. Builds SciPDL v2.084.
# Build SciPDL from the sources. Note right now this is only likely to work on Karl's Mac.
# Note run this from the git directory
# Note this depends on my 'gfortran' script being in the PATH which does static linking (and this is a symlink
# to gfortran-static)
set -e # Stop on error
HERE=$PWD
# Add GIT directory to PATH to allow pick up of misc scripts.
PATH=$HERE:$PATH
export PATH
cp gfortran-static gfortran
# Where to build everything
mkdir ~/Downloads/build
cd ~/Downloads/build
echo +++++++++++++++++++++++++++++ Fetch Sources +++++++++++++++++++++++++++++
if true
then
curl -OL https://www.cpan.org/src/5.0/perl-5.38.2.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/E/ET/ETJ/PGPLOT-2.29.tar.gz
curl -OL https://mirror.freedif.org/GNU/gsl/gsl-2.7.1.tar.gz
curl -OL https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.4.0.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/P/PR/PRATZLAFF/Astro-FITS-CFITSIO-1.18.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/E/ET/ETJ/PDL-2.088.tar.gz
curl -OL https://www.fftw.org/fftw-3.3.10.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/E/ET/ETJ/PDL-FFTW3-0.19.tar.gz
curl -OL https://www.dropbox.com/s/ib3q8pcgepyiwg9/pgplot531.tar.gz
cp $HERE/patches/pgplot2.patch .
cp $HERE/patches/pdl-fftw3-0.18.patch .
cp $HERE/patches/AstroFitsIO.patch .
fi
echo -+++++++++++++++++++++++++++++ Initial Setup +++++++++++++++++++++++++++++
# Do specific things for x86_64 vs ARM64 for my particular computer setup
myarch=`uname -m`
if [[ "$myarch" == "x86_64" ]]
then
echo --- Detected x86_64 ---
fi
if [[ "$myarch" == "arm64" ]]
then
echo --- Detected arm64 ---
fi
# Just in case
# Set up directories
mkdir /Applications/PDL
cp $HERE/setup_* /Applications/PDL
source /Applications/PDL/setup_bash
if false
then # Skip a bunch of code
echo Hello
fi ### End of the code skip
echo +++++++++++++++++++++++++++++ build perl +++++++++++++++++++++++++++++
tar xvfz perl-5.38.2.tar.gz
cd perl-5.38.2
./Configure -de -Dcc=gcc -Dprefix=/Applications/PDL
make
# All tests OK!
make test
make install
cd ..
# Update the PATH
echo +++++++++++++++++++++++++++++ Install pgplot +++++++++++++++++++++++++++++
tar xvfz pgplot531.tar.gz
cd pgplotsrc
patch -p 1 -i ../pgplot2.patch
SRC=$PWD
mkdir /Applications/PDL/pgplot
cd /Applications/PDL/pgplot
cp $SRC/drivers.list .
$SRC/makemake $SRC/ darwin gfortran_gcc_BigSur_static
make
make clean
cd $SRC/..
rm -fr pgplotsrc
echo +++++++++++++++++++++++++++++ Install ExtUtils::F77 +++++++++++++++++++++++++++++
cpan -i ETJ/ExtUtils-F77-1.26.tar.gz
echo +++++++++++++++++++++++++++++ Install perl-PGPLOT +++++++++++++++++++++++++++++
cpan -i Devel::CheckLib
export PGPLOT_DEV=/NULL # Suppress interactive tests
tar xvf PGPLOT-2.29.tar.gz
cd PGPLOT-2.29
perl Makefile.PL
make
# Now super ugly hack to make the bundle static!
gfortran -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong \
-Wl,-no_compact_unwind PGPLOT.o -o blib/arch/auto/PGPLOT/PGPLOT.bundle \
-L/Applications/PDL/pgplot -lcpgplot -lpgplot -static-libgfortran -static-libgcc \
/opt/local/lib/libX11.a /opt/local/lib/libxcb.a /opt/local/lib/libXdmcp.a /opt/local/lib/libXau.a /opt/local/lib/libpng.a -lz
make
make test
make install
cd ..
echo +++++++++++++++++++++++++++++ Install misc perl modules +++++++++++++++++++++++++++++
cpan -i Parse::RecDescent Inline Devel::CheckLib Convert::UU File::Map Test2::V0 \
Module::Compile Test::Deep Test::Exception List::MoreUtils Pod::Parser
cpan -iT Term::ReadLine::Perl Term::ReadKey # -T suppresses the interactive test
echo +++++++++++++++++++++++++++++ Install GSL +++++++++++++++++++++++++++++
# Note I can't get Alien to work as it needs Net:SSLeay that won't install correctly
# cpan -i Alien::GSL
tar xvf gsl-2.7.1.tar.gz
cd gsl-2.7.1
# This works around what appears to be an optimisation bug in ARM64 gcc 12.1
CFLAGS='-g -O' ./configure --disable-shared prefix=/Applications/PDL
make
make check
make install
cd ..
echo +++++++++++++++++++++++++++++ Install cfitsio +++++++++++++++++++++++++++++
# Noting cpan -i Alien::CFITSIO does not seem to work on my M1 Monterey machine, missing SSL stuff?
tar xvf cfitsio-4.4.0.tar.gz
cd cfitsio-4.4.0
./configure prefix=/Applications/PDL CC=gcc
make
# Run test progs
make install
make testprog
echo ---------- Testing ----------
./testprog > foo.out # CC test
# Should be same:
diff foo.out testprog.out
echo ----------------------------
rm /Applications/PDL/lib/libcfitsio*dylib
cd ..
echo +++++++++++++++++++++++++++++ Install Astro::FITS modules +++++++++++++++++++++++++++++
# Can't use CPAN as it wants to do Alien::CFITSIO
tar xvf Astro-FITS-CFITSIO-1.18.tar.gz
cd Astro-FITS-CFITSIO-1.18
patch -i ../AstroFitsIO.patch
# Note adding of -lcurl and lib/incl dirs
perl Makefile.PL LIBS="-Wl,-no_compact_unwind -L/Applications/PDL/lib -lcfitsio -lcurl -lm" INC="-I/Applications/PDL/include"
make
make test
make install
cd ..
cpan -i GSB/Astro-FITS-Header-3.09.tar.gz
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo ++++++++++++++++++++++++++++ Install PDL!!! ++++++++++++++++++++++++++++
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Note cpan -i ETJ/PDL-2.084.tar.gz also works but do it this way so I can look at the leftovers
# from the build easily
tar xvfz PDL-2.088.tar.gz
cd PDL-2.088
perl Makefile.PL
make
# Fix up static gfortran linking for modules that use fortran libs
# Note 'gfortran' is my static script
cd Libtmp/Slatec
gfortran $EXTRAFLAGS -mmacosx-version-min=12.7 -bundle -undefined dynamic_lookup -fstack-protector-strong Slatec.o barf.o pp-*.o slatec/*.o -o ../../blib/arch/auto/PDL/Slatec/Slatec.bundle -lm
cd ../../Libtmp/Minuit
gfortran $EXTRAFLAGS -mmacosx-version-min=12.7 -bundle -undefined dynamic_lookup -fstack-protector-strong Minuit.o FCN.o pp-*.o minuitlib/*.o -o ../../blib/arch/auto/PDL/Minuit/Minuit.bundle -lm
cd ../..
make test
make install
cd ..
echo +++++++++++++++++++++++++++++ Install libfftw +++++++++++++++++++++++++++++
#cpan -i Alien::FFTW3 # does not work as can't seem to install IO:: modules
tar xvf fftw-3.3.10.tar.gz
cd fftw-3.3.10
# Install double precision library
# Note need to set F77 explicitly for some weird reason
./configure prefix=/Applications/PDL
make
make check
make install
# Install single precision library
./configure --enable-float prefix=/Applications/PDL
make
make check
make install
cd ..
echo +++++++++++++++++++++++++++++ Install PDL::FFTW3 +++++++++++++++++++++++++++++
#cpan -i PDL::FFTW3 # Does not seem to work
tar xvf PDL-FFTW3-0.19.tar.gz
cd PDL-FFTW3-0.19
# Patch the Makefile.PL to find the libs in the right place
patch -i ../pdl-fftw3-0.18.patch
perl Makefile.PL
make
make test
make install
cd ..
echo -+++++++++++++++++++++++++++++ Installing utilites +++++++++++++++++++++++++++++
# I am told ditto is better for copying app folders
ditto "$HERE/Apps/pdl [here].app" "/Applications/PDL/pdl [here].app"
ditto "$HERE/Apps/pdl [home].app" "/Applications/PDL/pdl [home].app"
cp $HERE/go_pdl /Applications/PDL
echo +++++++++++++++++++++++++++++ Installing final perl modules +++++++++++++++++++++++++++++
# For some reason this sometimes randomly fails unless put at the end!
cpan -i Inline::C
echo +++++++++++++++++++++++++++++ Done! +++++++++++++++++++++++++++++