-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (45 loc) · 1.48 KB
/
Makefile
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
##################################################
#
# Haskell, HMatrix and Fortran demo
#
##################################################
repl: libs
hpack
LD_LIBRARY_PATH=c/1_hello:c/2_fpow:c/4_scalarmul cabal repl
run: libs
hpack
LD_LIBRARY_PATH=c/1_hello:c/2_fpow:c/4_scalarmul cabal run
libs: libhello.so libfpow.so libscalarmul.so
libhello.so:
# compile c code
gcc -g -Wall -lgfortran -c -o c/1_hello/lib.o c/1_hello/lib.c
# compile fortran code
gfortran -c -o c/1_hello/hello.o c/1_hello/hello.f95
# dynamic linking
gcc -shared -o c/1_hello/libhello.so c/1_hello/lib.o c/1_hello/hello.o
# ar -csr c/1_hello/libhello.a c/1_hello/lib.o c/1_hello/hello.o
libfpow.so:
# compile c code
gcc -g -Wall -lgfortran -lm -c -o c/2_fpow/lib.o c/2_fpow/lib.c
# compile fortran code
gfortran -c -o c/2_fpow/fpow.o c/2_fpow/fpow.f95
# dynamic linking
gcc -shared -o c/2_fpow/libfpow.so c/2_fpow/lib.o c/2_fpow/fpow.o
# ar -csr c/2_fpow/libfpow.a c/2_fpow/lib.o c/2_fpow/fpow.o
libscalarmul.so:
# compile c code
gcc -g -Wall -lgfortran -c -o c/4_scalarmul/lib.o c/4_scalarmul/lib.c
# compile fortran code
gfortran -c -o c/4_scalarmul/scalarmul.o c/4_scalarmul/scalarmul.f95
# dynamic linking
gcc -shared -o c/4_scalarmul/libscalarmul.so c/4_scalarmul/lib.o c/4_scalarmul/scalarmul.o
clean:
rm -f c/1_hello/*.o
rm -f c/1_hello/*.so
rm -f c/1_hello/*.a
rm -f c/2_fpow/*.o
rm -f c/2_fpow/*.so
rm -f c/2_fpow/*.a
rm -f c/4_scalarmul/*.o
rm -f c/4_scalarmul/*.so
rm -f c/4_scalarmul/*.a