Skip to content

Commit 5697e87

Browse files
committed
Add native Linux support.
1 parent a298ed1 commit 5697e87

5 files changed

Lines changed: 90 additions & 37 deletions

File tree

Makefile

Lines changed: 0 additions & 23 deletions
This file was deleted.

Makefile.lapack

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VPATH := ../lapack/SRC:../lapack/BLAS/SRC:../lapack/INSTALL
22

3-
FFLAGS := -O2
3+
FFLAGS := -fPIC -O2
44

55
SRCS := \
66
daxpy.f \
@@ -194,13 +194,11 @@ SRCS := \
194194

195195
OBJS := $(patsubst %.f,%.o,$(SRCS))
196196

197-
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539#c3
198-
LDFLAGS := -shared -static-libgcc
199-
LDLIBS := -Wl,-Bstatic -lgfortran -lquadmath -Wl,-Bdynamic -lm
197+
LDFLAGS += -shared
200198

201-
lapack.dll: $(OBJS)
199+
$(LAPACKLIB): $(OBJS)
202200
$(LINK.c) $^ $(LDLIBS) -o $@
203201

204202
%.o: ../lapack/%.f
205203
@mkdir -p $(dir $@)
206-
$(COMPILE.f) $(OUTPUT_OPTION) $<
204+
$(COMPILE.f) -fPIC $(OUTPUT_OPTION) $<

Makefile.linux

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ZIPFILE := Math-linux.zip
2+
DLLS := build-linux-fftw32/fftw32.so build-linux-fftw64/fftw64.so build-linux-lapack32/lapack32.so build-linux-lapack64/lapack64.so
3+
4+
export LDLIBS := -lgfortran
5+
6+
$(ZIPFILE): Math.dyalog $(DLLS)
7+
zip -j $@ $^
8+
9+
build-linux-fftw32/Makefile: | build-linux-fftw32
10+
cd build-linux-fftw32 && ../fftw/configure --enable-shared --disable-static --enable-sse2 --enable-avx CC="gcc -m32" && $(MAKE)
11+
12+
build-linux-fftw32/fftw32.so: build-linux-fftw32/Makefile
13+
$(MAKE) -C build-linux-fftw32
14+
cp build-linux-fftw32/.libs/libfftw3.so $@
15+
16+
build-linux-fftw64/Makefile: | build-linux-fftw64
17+
cd build-linux-fftw64 && ../fftw/configure --enable-shared --disable-static --enable-sse2 --enable-avx CC="gcc -m64"
18+
19+
build-linux-fftw64/fftw64.so: build-linux-fftw64/Makefile
20+
$(MAKE) -C build-linux-fftw64
21+
cp build-linux-fftw64/.libs/libfftw3.so $@
22+
23+
build-linux-lapack32/lapack32.so: | build-linux-lapack32
24+
$(MAKE) -C build-linux-lapack32 -f ../Makefile.lapack CC="gcc -m32" FC="gfortran -m32" LAPACKLIB=$(notdir $@)
25+
26+
build-linux-lapack64/lapack64.so: | build-linux-lapack64
27+
$(MAKE) -C build-linux-lapack64 -f ../Makefile.lapack CC="gcc -m64" FC="gfortran -m64" LAPACKLIB=$(notdir $@)
28+
29+
build-linux-%:
30+
mkdir $@
31+
32+
clean:
33+
rm -rf $(ZIPFILE) build-linux-*

Makefile.windows

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ZIPFILE := Math-windows.zip
2+
3+
DLLS := build-windows-fftw32/fftw32.dll build-windows-fftw64/fftw64.dll build-windows-lapack32/lapack32.dll build-windows-lapack64/lapack64.dll
4+
5+
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539#c3
6+
export LDFLAGS := -static-libgcc
7+
export LDLIBS := -Wl,-Bstatic -lgfortran -lquadmath -Wl,-Bdynamic -lm
8+
9+
$(ZIPFILE): Math.dyalog $(DLLS)
10+
zip -j $@ $^
11+
12+
build-windows-fftw32/Makefile: | build-windows-fftw32
13+
cd build-windows-fftw32 && ../fftw/configure --host=mingw32 --disable-alloca --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --with-incoming-stack-boundary=2 --enable-sse2 --enable-avx CC=i686-w64-mingw32-gcc
14+
15+
build-windows-fftw32/fftw32.dll: build-windows-fftw32/Makefile
16+
$(MAKE) -C build-windows-fftw32 CCLD="i686-w64-mingw32-gcc -Wc,-static-libgcc"
17+
cp build-windows-fftw32/.libs/libfftw3-3.dll $@
18+
19+
build-windows-fftw64/Makefile: | build-windows-fftw64
20+
cd build-windows-fftw64 && ../fftw/configure --host=mingw32 --disable-alloca --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --with-incoming-stack-boundary=2 --enable-sse2 --enable-avx CC=x86_64-w64-mingw32-gcc
21+
22+
build-windows-fftw64/fftw64.dll: build-windows-fftw64/Makefile
23+
$(MAKE) -C build-windows-fftw64 CCLD="x86_64-w64-mingw32-gcc -Wc,-static-libgcc"
24+
cp build-windows-fftw64/.libs/libfftw3-3.dll $@
25+
26+
build-windows-lapack32/lapack32.dll: | build-windows-lapack32
27+
$(MAKE) -C build-windows-lapack32 -f ../Makefile.lapack CC=i686-w64-mingw32-gcc FC=i686-w64-mingw32-gfortran LAPACKLIB=$(notdir $@)
28+
29+
build-windows-lapack64/lapack64.dll: | build-windows-lapack64
30+
$(MAKE) -C build-windows-lapack64 -f ../Makefile.lapack CC=x86_64-w64-mingw32-gcc FC=x86_64-w64-mingw32-gfortran LAPACKLIB=$(notdir $@)
31+
32+
build-windows-%:
33+
mkdir $@
34+
35+
clean:
36+
rm -rf $(ZIPFILE) build-windows-*

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ build scripts for the libraries are included.
1010

1111
## Using the namespace
1212

13-
Download `math.zip` and extract the files somewhere on your computer. In order
14-
for Windows to find the DLLs you'll have to put them:
13+
Download an appropriate `Math-*.zip` from the releases page and extract the
14+
files somewhere on your computer.
15+
16+
In order for Windows to find the DLLs you'll have to put them:
1517

1618
* in the current directory (this might be determined by the properties of the
1719
shortcut you use to start Dyalog), or
@@ -20,13 +22,20 @@ shortcut you use to start Dyalog), or
2022

2123
## Building the libraries
2224

23-
The only supported build configuration is cross-compiling from Linux to Windows.
25+
The supported build configurations are:
26+
* Linux (x86 and x86-64)
27+
* Cross-compiling from Linux to Windows (x86 and x86-64)
2428

25-
To build (tested on Ubuntu 15.10):
29+
To build natively:
2630

27-
* install some cross-compilers with
28-
`sudo apt-get install gcc-mingw-w64 gfortran-mingw-w64`
31+
* install some 32- and 64-bit Fortran compilers with
32+
`sudo apt-get install gfortran-multilib`
2933
* `cd` into the root of the repository
30-
* type `make` (or e.g. `make -j8` if you have 8 CPU cores)
34+
* type `make -f Makefile.linux` to make `Math-linux.zip`
35+
36+
To cross-compile (tested on Ubuntu 17.04):
3137

32-
This will generate the release package `math.zip` in the current directory.
38+
* install some cross-compilers with
39+
`sudo apt-get install gfortran-mingw-w64`
40+
* `cd` into the root of the repository
41+
* type `make -f Makefile.windows` to make `Math-windows.zip`

0 commit comments

Comments
 (0)