-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_scipdl.sh
executable file
·294 lines (210 loc) · 8.28 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/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
# Refuse to run if anaconda is present and activated
if [[ -n "$CONDA_PREFIX" && -d "$CONDA_PREFIX" ]]; then
echo "Anaconda is activated. CONDA_PREFIX: $CONDA_PREFIX"
echo "Please use 'conda deactivate' and try again. Believe me having Anaconda in your"
echo "path is a big bag of hurt for this build."
exit 1
fi
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 +++++++++++++++++++++++++++++
VERSION_PDL=2.093
VERSION_PERL=5.40.0
VERSION_PGPLOT=2.35
VERSION_EXTUTILS_F77=1.26
VERSION_GSL=2.8
VERSION_CFITSIO=4.5.0
VERSION_ASTRO_FITSIO=1.18
VERSION_ASTRO_FITS_HEADER=3.09
VERSION_FFTW=3.3.10
VERSION_PDL_FFTW3=0.20
if true
then
curl -OL https://www.cpan.org/src/5.0/perl-$VERSION_PERL.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/E/ET/ETJ/PGPLOT-$VERSION_PGPLOT.tar.gz
curl -OL https://ftp.gnu.org/gnu/gsl/gsl-$VERSION_GSL.tar.gz
curl -OL https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-$VERSION_CFITSIO.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/P/PR/PRATZLAFF/Astro-FITS-CFITSIO-$VERSION_ASTRO_FITSIO.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/E/ET/ETJ/PDL-$VERSION_PDL.tar.gz
curl -OL https://www.fftw.org/fftw-$VERSION_FFTW.tar.gz
curl -OL https://cpan.metacpan.org/authors/id/E/ET/ETJ/PDL-FFTW3-$VERSION_PDL_FFTW3.tar.gz
curl -OL https://www.dropbox.com/s/ib3q8pcgepyiwg9/pgplot531.tar.gz
cp $HERE/patches/pgplot2.patch .
cp $HERE/patches/pdl-fftw3-0.20.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
# Ensure cpan does not prompt if not configured.
export PERL_MM_USE_DEFAULT=1
echo +++++++++++++++++++++++++++++ build perl +++++++++++++++++++++++++++++
tar xvfz perl-$VERSION_PERL.tar.gz
cd perl-$VERSION_PERL
./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-$VERSION_EXTUTILS_F77.tar.gz
echo +++++++++++++++++++++++++++++ Install perl-PGPLOT +++++++++++++++++++++++++++++
cpan -i Devel::CheckLib
export PGPLOT_DEV=/NULL # Suppress interactive tests
tar xvf PGPLOT-$VERSION_PGPLOT.tar.gz
cd PGPLOT-$VERSION_PGPLOT
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-$VERSION_GSL.tar.gz
cd gsl-$VERSION_GSL
# 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-$VERSION_CFITSIO.tar.gz
cd cfitsio-$VERSION_CFITSIO/
./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-$VERSION_ASTRO_FITSIO.tar.gz
cd Astro-FITS-CFITSIO-$VERSION_ASTRO_FITSIO
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-$VERSION_ASTRO_FITS_HEADER.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-$VERSION_PDL.tar.gz
cd PDL-$VERSION_PDL
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-$VERSION_FFTW.tar.gz
cd fftw-$VERSION_FFTW
# 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-$VERSION_PDL_FFTW3.tar.gz
cd PDL-FFTW3-$VERSION_PDL_FFTW3
# Patch the Makefile.PL to find the libs in the right place
patch -i ../pdl-fftw3-0.20.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! +++++++++++++++++++++++++++++