Project

General

Profile

Preparing a Mac machine for Bilder » History » Version 69

John Cary, 12/09/2019 05:53 PM

1 2 Redmine Admin
# Preparing a Mac machine for Bilder #
2 1 Redmine Admin
3 24 John Cary
__If all you need is python and sphinx__ (e.g., for builds of documentation), then you need only
4
5
* XCode with command line tools
6
* Latex installed as noted below
7
8
and then you can add the arguments,  -W python, and your installed Python and CMake will be used if your path is correct.
9
10
11 2 Redmine Admin
## Bilder on Darwin ##
12 1 Redmine Admin
13 16 John Cary
Darwin comes with bash, so it is Bilder ready for the most part.
14 1 Redmine Admin
15 16 John Cary
### OS X Versions ###
16 1 Redmine Admin
17 16 John Cary
Yosemite's XCode that supports C++ 11 by default.
18 1 Redmine Admin
19 16 John Cary
El Capitan's clang compiler supports OpenMP.
20
21 1 Redmine Admin
## Case insensitive file system ##
22
23
We have noted and filed bugs for CMake errors on OS X when using the case-sensitive file system. To fix we use the case-insensitive file system. There may be problems with various packages and the case-insensitive file system.
24
25 2 Redmine Admin
## C and C++ compilers and Xcode command line tools ##
26 1 Redmine Admin
27 64 Nathan Neri
Install Xcode. To obtain version 10.3 (10.x is required for c++17), visit https://developer.apple.com/xcode/download, then at the bottom third of the page, click on the "Additional Tools" link . Sign in with your Apple ID.  
28 1 Redmine Admin
29
~~~~~~
30 31 John Cary
sudo xcode-select --install
31 1 Redmine Admin
~~~~~~
32
33 63 David Alexander
With mojave, one must additionally open the XCode app and install the command line tools or execute this command:
34 35 John Cary
35
~~~~~~
36
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
37
~~~~~~
38
39 65 David Alexander
or use the graphical interface with
40
41
~~~~~~
42 66 John Cary
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
43 65 David Alexander
~~~~~~
44
45 69 John Cary
Not doing this may give you an error like
46
47
~~~~~~
48
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/system_error:146:
49
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__errc:191:43: error: use of undeclared identifier 'EOWNERDEAD'
50
    owner_dead                          = EOWNERDEAD,
51
~~~~~~
52
53 65 David Alexander
The exact name of the pkg might be different in the future. This page https://apple.stackexchange.com/questions/337940/why-is-usr-include-missing-i-have-xcode-and-command-line-tools-installed-moja says it is better to use `xcrun --show-sdk-path` to find the default SDK path and then one can find the exact package name.
54 35 John Cary
55 1 Redmine Admin
## HomeBrew ##
56
57
One must select a non-OSX package manager for some additional packages. The candidates are HomeBrew, MacPorts, and Fink, with the HomeBrew being our recommendation at this time, as it is active, and it has the philosophy of not building extraneous stuff that is already present on OSX, which MacPorts tends to do, thus using up more disk space.  HomeBrew also installs packages in their own subdirs with links to other places in /opt, thus making removal a matter removing a directory and then removing broken links in /opt/homebrew.
58
59 14 John Cary
HomeBrew requires that one not have root privileges.  So we make the directory into which we can write:
60 1 Redmine Admin
61
~~~~~~
62 29 John Cary
sudo -s
63
mkdir -p /opt/homebrew
64
chgrp -R admin /opt
65
chmod -R 775 /opt
66
chmod -R 2775 /opt/homebrew
67
exit
68 14 John Cary
~~~~~~
69
70
and then we work as nonroot:
71
72
~~~~~~
73 29 John Cary
cd /opt
74 57 John Cary
# curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
75
git clone https://github.com/Homebrew/brew.git homebrew
76 39 David Alexander
~~~~~~
77
78
~~~~~~
79 29 John Cary
chmod -R a+rX /opt/homebrew
80 14 John Cary
find /opt/homebrew -type l -exec chmod -h a+r '{}' \;
81 1 Redmine Admin
~~~~~~
82
83 39 David Alexander
These last too lines can be reused at anytime there is a permissions problem.
84 1 Redmine Admin
85 39 David Alexander
As root again execute these lines to pick up some paths in the defaults paths:
86
87 1 Redmine Admin
~~~~~~
88 29 John Cary
sudo -s
89
echo "/opt/homebrew/bin" > /etc/paths.d/homebrew
90
echo "/opt/homebrew/share/man" > /etc/manpaths.d/homebrew
91
chmod a+r /etc/paths.d/homebrew /etc/manpaths.d/homebrew
92
exit
93 1 Redmine Admin
~~~~~~
94
95
Get the required packages...
96
97
~~~~~~
98 29 John Cary
brew install gnupg libpng freetype gd ghostscript
99 1 Redmine Admin
~~~~~~
100
101 16 John Cary
Nice to have:
102 1 Redmine Admin
103 16 John Cary
~~~~~~
104 29 John Cary
brew install imagemagick
105 16 John Cary
~~~~~~
106
107 45 Nathan Neri
git large file support (for VisIt)
108
109
~~~~~~
110
brew install git-lfs
111 56 Nathan Neri
git lfs install --force --skip-smudge
112 45 Nathan Neri
~~~~~~
113
114 25 David Howdle
For Qt5:
115
116
~~~~~~
117
brew install bison flex gperf libcapn
118 1 Redmine Admin
~~~~~~
119 25 David Howdle
120 39 David Alexander
To get fortran, which comes with the gcc compiler:
121 1 Redmine Admin
122
~~~~~~
123 62 John Cary
brew install gcc@8
124 1 Redmine Admin
~~~~~~
125
126 39 David Alexander
With versions older than gcc 6.5 (released Nov 2018) possibly needed for OSs older than Mojave, gfortran is not installed with gcc and you need to add the following argument "--with-fortran" to the above brew install command.
127 1 Redmine Admin
128 39 David Alexander
OPTIONAL:
129
130
If you receive an error regarding ruby version:
131
132
~~~~~~
133
brew install ruby@2.3
134
~~~~~~
135
136
may help.
137
138 1 Redmine Admin
139
## LaTeX ##
140
141
Those with sufficient hard drive space (3.4GB after install) may wish to download the full MacTeX package from <http://www.tug.org/mactex/downloading.html>. After installing, one can see the 'README ME FIRST.pdf' in /Applications/Tex. You will likely need to add /usr/texbin to your path:
142 29 John Cary
143
~~~~~~
144 1 Redmine Admin
setenv PATH /usr/texbin:${PATH}  # For tcsh
145 13 Redmine Admin
export PATH=/usr/texbin:${PATH}  # For bash
146 1 Redmine Admin
~~~~~~
147
148 13 Redmine Admin
For those who like GUIs, the !TeXworks in /Applications/TeX/TeXworks should work fine.
149
150
For those with limited space, install BasicTeX from <https://tug.org/mactex/morepackages.html>. Add to your PATH:
151 32 John Cary
152 13 Redmine Admin
~~~~~~
153
    /usr/local/texlive/2017/bin/universal-darwin/
154 32 John Cary
~~~~~~
155 1 Redmine Admin
156 32 John Cary
and then install the packages noted at
157 29 John Cary
158 32 John Cary
[[LaTeX packages needed by Bilder]]
159 1 Redmine Admin
160
You may need to use sudo.
161 32 John Cary
162
~~~~~~
163 1 Redmine Admin
sudo tlmgr update --self
164 29 John Cary
sudo tlmgr install <needed packages>
165 32 John Cary
~~~~~~
166
167 1 Redmine Admin
and then used the autoupdate feature to get any additionally needed packages.  This minimal installation is 230 M instead of the usual 2GB.
168
169
170
## Disable spindump ##
171
172
for faster compilations via
173
174 29 John Cary
~~~~~~
175 11 Redmine Admin
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist
176 34 John Cary
~~~~~~
177
178
## LLVM-Clang ##
179
180 58 John Cary
LLVM-Clang (aka LlvmClang) is different from AppleClang.  It has support for target attributes and openmp, and provides a build chain for high-performance computing.  Check out the llvm-project of your chosen version.
181
182
We use homebrew to install this with
183
184
~~~~~~
185 67 David Alexander
brew install llvm@8
186 58 John Cary
~~~~~~
187
188
Then link it into place using
189
190
~~~~~~
191
cd /opt
192 61 John Cary
rm -f llvmclang
193 68 David Alexander
ln -s /opt/homebrew/Cellar/llvm@8/8.0.1_1 llvmclang
194 58 John Cary
~~~~~~
195
196
NOT RECOMMENDED
197
198
You can also build from the llvm repo, but we have not worked out the configuration args.
199 1 Redmine Admin
200 48 Nathan Neri
~~~~~~
201
cd /opt
202 54 David Alexander
git clone -b <Branch> https://github.com/llvm/llvm-project.git llvm-<Version>
203 53 David Alexander
# You can see the branches you can clone at https://github.com/llvm/llvm-project
204 54 David Alexander
# e.g.  git clone -b llvmorg-8.0.0 https://github.com/llvm/llvm-project.git llvm-8.0.0
205 48 Nathan Neri
~~~~~~
206 1 Redmine Admin
207 48 Nathan Neri
To configure and build:
208 49 Nathan Neri
209 48 Nathan Neri
~~~~~~
210
cd /opt/llvm-<Version>
211 1 Redmine Admin
mkdir build
212
cd build
213 55 David Alexander
cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang;openmp;libcxx;libcxxabi" -DLLVM_ENABLE_RTTI:BOOL=ON -DLLVM_ENABLE_EH:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH="/opt/llvm-<Version>/install" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
214 54 David Alexander
make # Add appropriate -j argument for the machine to build faster
215
          # with -j 8 on qamojavellvm the build and installation took a little under an hour
216 48 Nathan Neri
make install
217
~~~~~~
218 1 Redmine Admin
219 48 Nathan Neri
Bilder will look in /opt/llvmclang/bin for llvm binaries (as well as $LLVM_DIR/bin, and your installation dir/bin, in case you need to keep multiple versions for different builds), so we set a link to the installation directory in the chosen version of llvm:
220 43 Tech-X Corporation
221 44 Tech-X Corporation
~~~~~~
222 43 Tech-X Corporation
cd /opt
223 48 Nathan Neri
sudo ln -s llvm-<Version>/install llvmclang
224 44 Tech-X Corporation
~~~~~~
225 43 Tech-X Corporation
226 11 Redmine Admin
## Java ##
227
228
You will need to install java by invoking the executable in any way such as...
229
230
~~~~~~
231
java -version
232 1 Redmine Admin
~~~~~~
233
234
Follow the instructions in the dialog that takes you to the Oracle website and choose the latest version to download.  (as of Nov 2015 this is 1.8)
235
236
## HostName ##
237 2 Redmine Admin
238 1 Redmine Admin
For bilder to properly send emails the fully qualified hostname must set on the machine. To check this try...
239 31 John Cary
240 29 John Cary
~~~~~~
241 1 Redmine Admin
hostname -f
242
~~~~~~
243
244
this should return machinename.domainname.com rather than just machinename.  If it does not, then set the hostname of the machine by typing the following commands.
245
246
~~~~~~
247
sudo scutil --set ComputerName "machinename"
248
sudo scutil --set LocalHostName "machinename"
249
sudo scutil --set HostName "machinename.domainname.com"
250
dscacheutil -flushcache
251
~~~~~~
252
253
Restart your Mac after this.
254
255
## Power Saving Modes ##
256
257
For build machines that are not personal machines, disabling certain options will help in connectivity and responsiveness:
258
259
~~~~~~
260
Under Spotlight
261
 - disabled the main HD. (multiple mdworkers taking up a lot of cpu.)
262
~~~~~~
263
264
~~~~~~
265
Under Energy Saver
266
 - Computer sleep: Set to never
267
 - Unchecked Put hard disks to sleep when possible
268
 - Unchecked Wake for network access
269
~~~~~~
270
271
&nbsp;
272
&nbsp;
273
&nbsp;
274
&nbsp;
275
&nbsp;
276
&nbsp;
277
&nbsp;
278
&nbsp;
279
&nbsp;
280 29 John Cary
&nbsp;
281
282
---
283
284 31 John Cary
---
285 1 Redmine Admin
286 31 John Cary
## X11 ##
287
288
X11 should not be needed, but if it is needed:
289
290
Install [XQuartz X11](http://xquartz.macosforge.org/landing/).
291
292
Create a symbolic link so that the X11 headers can be found by the compiler:
293
294
~~~~~~
295
sudo ln -s /opt/X11/include/X11 /usr/local/include/X11
296 1 Redmine Admin
~~~~~~
297 31 John Cary
298
# DEPRECATED INSTRUCTIONS #
299
300
301
## Other gfortran options (besides HomeBrew) ##
302
303
### Option 2: HPC ###
304
305
Install gfortran from [SourceForge HPC](http://hpc.sourceforge.net).  (Do not also install the other gcc compilers.)
306
307
As of March 29, 2015, the version is 4.9.0.
308
309
Install via
310
311
~~~~~~
312
$ tar xzf gfortran-4.9-bin.tar.gz -C /
313
~~~~~~
314
315
### Option 3: GNU ###
316
317
Install gfortran using the installer from <http://gcc.gnu.org/wiki/GFortranBinaries>.
318
319
As of March 29, 2015, the version is 4.9.0.
320
321 30 John Cary
The binaries will end up being installed in /usr/local/bin
322
323
324
## Git ##
325 11 Redmine Admin
326 1 Redmine Admin
If any repository package requires Git protocol, then for Lion and earlier you may need Git from <http://git-scm.com/download/mac> and add /usr/local/git/bin to your path.
327 10 Redmine Admin
328
329
### Macports ### 
330 11 Redmine Admin
331
This provides wget, freetype, and other utilities. Get macports from <http://www.macports.org/install.php> and install.
332
333 10 Redmine Admin
Note: Before proceeding with the installation of various macports packages noted below on Lion machines with Xcode 4.3, one needs to run
334 29 John Cary
335 10 Redmine Admin
~~~~~~
336
sudo xcode-select -switch /Applications/Xcode.app
337
~~~~~~
338 11 Redmine Admin
339
Otherwise, there will be an error installing zlib during the wget installation below.
340 1 Redmine Admin
341
After the macports installation, do
342 29 John Cary
343
~~~~~~
344
sudo port install wget
345 1 Redmine Admin
sudo port install ImageMagick +no_x11
346
sudo port install f2c
347
~~~~~~
348
349
350 11 Redmine Admin
### XCode ###
351 1 Redmine Admin
### Lion ###
352
353
On Lion, the command line compilers are not installed automatically. After installing Xcode, navigate to the 
354 2 Redmine Admin
Preferences->Download dialog 
355 1 Redmine Admin
and install the Command Line Tools. The dialog is.. 
356
357
!screenShotCommandLineTools.png!
358
359 11 Redmine Admin
or from the command line do
360 29 John Cary
361
~~~~~~
362 1 Redmine Admin
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
363
xcodebuild
364
      (hit agree)
365
~~~~~~
366
367
You may subsequently need to build your first package with sudo in order to accept the Xcode licenses.
368
369
### Mountain Lion ### 
370
371
Same as Mavericks?
372
373 2 Redmine Admin
### Mavericks ###
374 29 John Cary
375 1 Redmine Admin
~~~~~~
376
sudo xcode-select --install
377
~~~~~~
378
379
380
## Java ##
381
382
(The below does not apply to yosemite.)
383
384
The cmake build may fail due to missing java headers linked to in /System/Library/Frameworks/JavaVM.framework/Headers. To fix:
385 29 John Cary
386
~~~~~~
387 1 Redmine Admin
cd /System/Library/Frameworks/JavaVM.framework/Headers
388
sudo mv jni.h jni.h.missing
389
~~~~~~