building, installing and running software€¦ · building, installing and running software ... 2...
TRANSCRIPT
![Page 1: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/1.jpg)
1
Building, installingand running software
Bob DowlingUniversity Computing Service
Day three
http://www-uxsup.csx.cam.ac.uk/courses/http://training.csx.cam.ac.uk/
![Page 2: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/2.jpg)
2
Progress so far
LocationUnpackingConfigured buildsSimple makeUsing libraries
${HOME}/sw
Builds:configuremakemake install
Makefile
Librariesbuild timerun time
![Page 3: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/3.jpg)
3
Today
1. Real world exampleA bad Makefile
2. Recursive make
3. Rewrite Makefile from scratch
![Page 4: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/4.jpg)
4
Meet the enemy
LAPACK
BLAS
Linear Algebra Package
Basic Linear Algebra Subprograms(Fortran)
Well respected pair of libraries
Extensively used
Absolute $@%#! to build
![Page 5: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/5.jpg)
5
Worked example: unpacking
$ cd /tmp/building
$ tar -xf /ux/Lessons/Building/
$ cd
LAPACK.tgz
LAPACK
![Page 6: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/6.jpg)
6
Worked example: first look
$ ls
BLAS
latapeINSTALL
TIMINGREADMETESTINGmake.incSRCMakefile
No buildinstructions!
Can we get thisto work unaided?
![Page 7: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/7.jpg)
7
INSTALL directory
ls INSTALL/
dlamch.fdlamchtst.fdsecnd.fdsecnd.f.RS6Kdsecndtst.flawn81.pdflawn81.pslawn81.texlsame.flsametst.f
Makefilemake.inc.ALPHAmake.inc.HPPAmake.inc.IRIX64make.inc.LINUXmake.inc.O2Kmake.inc.pghpfmake.inc.RS6Kmake.inc.SGI5make.inc.SUN4
Per-architectureinclude files$
![Page 8: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/8.jpg)
8
LAPACK Makefile
# Top Level Makefile for LAPACK# Version 3.0# June 30, 1999
include make.inc
all: install lib testing …
Comments
Include the contents ofanother file
Standardtarget
![Page 9: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/9.jpg)
9
LAPACK Makefile
blaslib)( $(MAKE);cd BLAS/SRC
:
target sub-shell
changedirectory
startanothermake
![Page 10: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/10.jpg)
10
Recursive make
LAPACK
BLAS INSTALL SRC TESTING
SRC EIG LIN
make
make[1]
make[1] make[1] make[1]
make[2]make[2]
![Page 11: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/11.jpg)
11
Iterative development
Freshlyunpackedsource
Build Install
Start fromscratch?
Makefile
Changes
Success?
Analysis
![Page 12: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/12.jpg)
12
Default make.inc
# The machine (platform) identifier to# append to the library names
PLAT = _SUN4SOL2
Sun4 hardwareSolaris 2 operating system
![Page 13: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/13.jpg)
13
Build #1
$ cp INSTALL/make.inc.LINUX make.inc
$ make make01.log&>
Log for this attempt
Output, errors,everything
Record changeto file in lab book
![Page 14: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/14.jpg)
14
Success? #1
Fails almostinstantly
$ make make01.log&>
We need toread the log
![Page 15: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/15.jpg)
15
Reading a make log
Start at the end & work backwards
“Rewind”
![Page 16: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/16.jpg)
16
Analysis #1: last line
make Error 2]lapacklib: *** [
target
Error message
Error 2: Error in a sub-make or sub-shell
![Page 17: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/17.jpg)
17
Analysis #1: penultimate line
make[1]: Leaving directory/tmp
building
LAPACK
SRCmake[1]
make
Sub-make
`/tmp/building/LAPACK/SRC'
![Page 18: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/18.jpg)
18
Analysis #1: antepenultimate line
make[1] Error 127]sgbbrd.o: *** [
Samesub-make
target
error message
Error 127: “Command not found”
![Page 19: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/19.jpg)
19
Analysis #1: previous line
make[1] Command not found: :g77
Told you so! ☺
This command
![Page 20: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/20.jpg)
20
Changes #1: previous line
g77 gfortran
…g77… …gfortran…
make.inc
Record changeto file in lab book
![Page 21: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/21.jpg)
21
Start from scratch?
Nothing wrong with what's done do far.
![Page 22: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/22.jpg)
22
Build #2
$ make make02.log&>
Distinctlog file
5 (ish)minutes
![Page 23: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/23.jpg)
23
Analysis #2: Last line
make: *** [testing] Error 2
Sub-make error(again)
![Page 24: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/24.jpg)
24
Analysis #2:
make[1]: Leaving directory
/tmp
building
LAPACK
TESTINGmake[1]
` '/tmp/building/LAPACK/TESTING
make
![Page 25: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/25.jpg)
25
Analysis #2:
make[1] Error 2xlintsts:*** [ ]
sub-make
Error in sub-sub-make
Trying tobuild xlintsts
/tmp
building
LAPACK
TESTINGxlintsts
![Page 26: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/26.jpg)
26
/tmp
building
Analysis #2:
make[2]
LAPACK
TESTING
LIN
make[1]
`/tmp/building/LAPACK/TESTING/LIN
make
make[2]
': Leaving directory
Sub-sub-make
![Page 27: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/27.jpg)
27
/tmp
building
Analysis #2:
make[2]
LAPACK
TESTING
LIN../xlintsts
xlintsts
Equivalent
Error 1]../xlintsts: *** [
target
“Something went wrong”
![Page 28: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/28.jpg)
28
Analysis #2:/tmp
building
LAPACK
TESTING
LIN
gfortran: ../../blas_LINUX.a:
blas_LINUX.a
../
../
No such file or directory
![Page 29: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/29.jpg)
29
Analysis #2:/tmp
building
LAPACK
TESTING
LIN
$ ls -l blas_LINUX.als: cannot access blas_LINUX.a:No such file or directory
blas_LINUX.a✗
![Page 30: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/30.jpg)
30
Analysis #2:/tmp
building
LAPACK
TESTING
LIN
blas_LINUX.a
Why does blas_LINUX.a not exist?
Because the Makefile doesn't build it!
?
![Page 31: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/31.jpg)
31
Analysis #2:
Why doesn't theMakefile build it?
Because it'scommented out!
lib: lapacklib tmglib# lapacklib tmglibblasliblib:
Makefile
![Page 32: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/32.jpg)
32
Changes #2
lib: lapacklib tmglib# lapacklib tmglibblasliblib:
Makefile
lib: lapacklib tmglib#lapacklib tmglibblasliblib:
Makefile
![Page 33: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/33.jpg)
33
Start from scratch?
Nothing wrong with what's done so far.
![Page 34: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/34.jpg)
34
Build #3
$ make make03.log&>
5‒10minutes
Third log file
![Page 35: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/35.jpg)
35
“Sleep whenyou're dead.”
Ten minutes
![Page 36: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/36.jpg)
36
Analysis #3: Last line
make Error 2]timing: *** [
target
sub-make error
![Page 37: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/37.jpg)
37
Analysis #3
make[1]: Leaving directory` '/tmp/building/LAPACK/TIMING
/tmp
building
LAPACK
TIMINGmake[1]
make
![Page 38: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/38.jpg)
38
Analysis #3
make[1]: *** [
/tmp
building
LAPACK
TIMINGstime.out
Error 127]stime.out
Trying to buildstime.out
Command not found
![Page 39: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/39.jpg)
39
Analysis #3
xlintims stime.out< stime.in >
the target
thecommandnot found
/tmp
building
LAPACK
TIMINGmake[1]
![Page 40: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/40.jpg)
40
Analysis #3/tmp
building
LAPACK
TIMINGmake[1]
We are here
xlintims ?
$ find -name xlintims.
![Page 41: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/41.jpg)
41
xlintims
Analysis #3/tmp
building
LAPACK
TIMINGmake[1]
xlintims ?
$ find -name xlintims.
./TIMING/
xlintims ……
It's there!
![Page 42: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/42.jpg)
42
Analysis #3/tmp
building
LAPACK
TIMINGmake[1]
xlintims ……
“ PATHis not on the”.
![Page 43: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/43.jpg)
43
Changes #3
$ export PATH="${PATH}: ".
Add “.” to PATH
!Do not make thischange permanent!
![Page 44: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/44.jpg)
44
Start from scratch?
Nothing wrong with what's done so far?
There shouldn't be anything wrong…
![Page 45: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/45.jpg)
45
Build #4
$ make make04.log&>
Fails almostimmediately
Fourth log file
![Page 46: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/46.jpg)
46
Analysis #4: Last line
make Error 2]blas_testing: *** [
Top-levelmake
![Page 47: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/47.jpg)
47
Analysis #4: The error message
At line 130 of file zblat2.fFortran runtime error: File exists
Need to look at the larger error message.
Need to look at the action being taken.
Need to look at the zblat2.f file.
![Page 48: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/48.jpg)
48
Analysis #4: The Makefileblas_testing:
…( ; ./xblat2s < sblat2.in ; \
./xblat2d < dblat2.in ; \
./xblat2c < cblat2.in ; \
…./xblat2z < zblat2.in )
cd BLAS
/tmp/building/LAPACK/BLAS
Source of the lasterror message
“How not to write a Makefile”
Makefile
![Page 49: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/49.jpg)
49
Analysis #4: The program…* Read name and unit number for * summary output file and open file. READ( NIN, FMT = * )SUMMRY READ( NIN, FMT = * )NOUT
NOUTC = NOUT*…
OPEN( NOUT, FILE = SUMMRY, )STATUS = 'NEW'
zblat2.f
Line 130File must notalready exist!
![Page 50: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/50.jpg)
50
Changes #4
None!
Just start from scratch!
![Page 51: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/51.jpg)
51
Start from scratch!
$ cp make*.log .. Copy the log filesout of LAPACK
$ cd .. Get out of LAPACKourselves
$ rm -rf LAPACK/ Remove LAPACK
$ tar -xf /ux/Lessions/Building/LAPACK.tgz
Create a fresh copyof LAPACK
![Page 52: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/52.jpg)
52
Build #5
Repeat the previous changes!
1.
2.
3.
4.
INSTALL/make.inc.LINUX → make.inc
g77 → gfortran
“lib” target in Makefile
Check “.” on PATH
5. make &> make05.loginstall lib
Cheat to save time
>1hr → ~10mins
![Page 53: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/53.jpg)
53
Installation
$ make install✘$ ls *.a
blas_LINUX.a
tmglib_LINUX.alapack_LINUX.a
basic linear algebrasubprograms
linear algebrapackage
timing library
![Page 54: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/54.jpg)
54
Installation
$ install blas_LINUX.a ${HOME}/sw/lib/libblas.a
$ install lapack_LINUX.a ${HOME}/sw/lib/liblapack.a
![Page 55: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/55.jpg)
55
Progress
LocationUnpackingConfigured buildsSimple makeUsing librariesReal world example
Real worldexample(almost)
![Page 56: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/56.jpg)
56
A “multiple purposegenerally recognizedas safe food substance”
Five minutes
![Page 57: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/57.jpg)
57
Makefiles from scratch
LAPACKMakefilesare awful
We knowbetterprinciples
vs.It's a lotof work
Should be alast resort
![Page 58: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/58.jpg)
58
What are we building?
LAPACK
BLAS SRC
SRC
141sourcefiles
libblas.a
1,291sourcefiles
liblapack.a
![Page 59: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/59.jpg)
59
libblas.a/tmp
building
LAPACK
BLAS
SRC
SBLAS1 = isamax.o sasum.o saxpy.o scopy.o \ sdot.o snrm2.o srot.o srotg.o \ sscal.o sswap.o…ZBLAS3 = zgemm.o zsymm.o zsyrk.o zsyr2k.o \ ztrmm.o ztrsm.o zhemm.o zherk.o \ zher2k.o
Makefile
1. Keep the lists of file names
2. Ditch the rest
![Page 60: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/60.jpg)
60
libblas.a/tmp
building
LAPACK
BLAS
SRC
OBJECTS = $(SBLAS1) $(CBLAS1) $(DBLAS1) \ $(ZBLAS1) $(CB1AUX) $(ZB1AUX) \ $(ALLBLAS) $(SBLAS2) $(CBLAS2) \ $(DBLAS2) $(ZBLAS2) $(SBLAS3) \ $(CBLAS3) $(DBLAS3) $(ZBLAS3)
Makefile
3. Glue all the object files togetherfor convenience
![Page 61: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/61.jpg)
61
Tool for building static libraries
/usr/bin/ar Builds an object file “archive”
isamax.o
sasum.o
zher2k.o
…libblas.a
libblas.a isamax.o … zher2k.o:
$(AR) $(ARFLAGS) $@ $^TAB
![Page 62: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/62.jpg)
62
libblas.a/tmp
building
LAPACK
BLAS
SRC
libblas.a: $(OBJECTS)TAB $(AR) $(ARFLAGS) $@ $^
Makefile
4. Add the rule to the Makefile
![Page 63: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/63.jpg)
63
libblas.a/tmp
building
LAPACK
BLAS
SRC
PREFIX=${HOME}/swTARGET=libblas.a
all: $(TARGET)
install: allinstall -d $(PREFIX)/libinstall $(TARGET) $(PREFIX)/lib
clean:$(RM) $(TARGET) $(OBJECTS)
Makefile
5. Add the standard targets
![Page 64: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/64.jpg)
64
And that's it!
$ make
gfortran -c -o isamax.o isamax.fgfortran -c -o sasum.o sasum.f...ar: creating libblas.aa - isamax.o...a - zher2k.o
FC=gfortran Identify Fortrancompiler
![Page 65: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/65.jpg)
65
Same for liblapack.a/tmp
building
LAPACK
SRC
Makefile
1. Keep the lists of file names
2. Ditch the rest
3. Glue all the object files togetherfor convenience
4. Add the library build rule to the Makefile
5. Add the standard targets
![Page 66: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/66.jpg)
66
Gluing it together
LAPACK
BLAS SRC
SRC
make
make[1]
make[1]
![Page 67: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/67.jpg)
67
Top-level Makefile
all:allall
cd BLAS/SRC && $(MAKE)cd SRC && $(MAKE)
clean :cleanclean
cd BLAS/SRC && $(MAKE)cd SRC && $(MAKE)
installinstallinstall
cd BLAS/SRC && $(MAKE)cd SRC && $(MAKE)
: all
Pure recursion
![Page 68: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/68.jpg)
68
Top-level Makefile
all :allall
cd BLAS/SRC && $(MAKE)cd SRC && $(MAKE)
Common macros
export FC = gfortran
clean :cleanclean
cd BLAS/SRC && $(MAKE)cd SRC && $(MAKE)
![Page 69: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/69.jpg)
69
And that's it!
$ cd /tmp/building/LAPACK$ make
![Page 70: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/70.jpg)
70
Progress
LocationUnpackingConfigured buildsSimple makeUsing librariesReal world exampleRecursive makeBuild from scratch
![Page 71: Building, installing and running software€¦ · Building, installing and running software ... 2 Progress so far Location Unpacking Configured builds ... the Makefile 5](https://reader031.vdocuments.mx/reader031/viewer/2022021821/5b057c0f7f8b9ad5548b7e7c/html5/thumbnails/71.jpg)
71
LocationUnpackingConfigured buildsSimple makeUsing librariesReal world exampleRecursive makeBuild from scratch
Conclusion
A tough course
You can buildsoftware:
configure-styleMakefile-style
Personal copies:no systemprivileges
Congratulations!