-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
91 lines (80 loc) · 3.25 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
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
##############################################
# #
# Makefile for Fortran-Library #
# #
##############################################
# Flags for user to tune
# Default to install to Fortran-Library
prefix = .
# intel and gnu compilers are supported
compiler = intel
flag = -O3
# User does not have to take care of following variables
gnumkl = -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_gnu_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl
gnumkl_sequential = -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl
src = $(addprefix source/, StringUtility.f90 General.f90 Mathematics.f90 LinearAlgebra.f90 \
NonlinearOptimization.f90 IntegralTransform.f90 \
Clustering.f90 Statistics.f90 Chemistry.f90 \
GeometryTransformation.f90 \
FortranLibrary.f90 )
RealPrefix = $(realpath $(prefix))
incdir = $(RealPrefix)/include
libdir = $(RealPrefix)/lib
libFL.a libFL.so: $(src)
ifeq ($(compiler),intel)
ifort -fpp -qopenmp -parallel -mkl -static-intel -ipo $(flag) -c $^
xiar rcs libFL.a *.o
rm *.o
ifort -fpp -qopenmp -parallel -mkl -static-intel -ipo $(flag) -shared -fpic $^ -o libFL.so
else
gfortran -fpp -fopenmp -ffree-line-length-0 -fno-range-check -I${MKLROOT}/include $(flag) -c $^
ar rcs libFL.a *.o
rm *.o
gfortran -fpp -fopenmp -ffree-line-length-0 -fno-range-check -I${MKLROOT}/include $(flag) -shared -fpic $^ -o libFL.so
endif
.PHONY: install
install: | $(incdir) $(libdir)
mv *.mod $(incdir)
mv *.a $(libdir)
mv *.so $(libdir)
cp cpp/*.hpp $(incdir)
ifneq ($(realpath .),$(RealPrefix))
cp -r FortranLibrary $(RealPrefix)
endif
$(incdir):
mkdir $(incdir)
$(libdir):
mkdir $(libdir)
.PHONY: test
test:
ifeq ($(compiler),intel)
ifort -qopenmp -parallel -mkl -static-intel -ipo $(flag) -I$(incdir) test/test.f90 $(libdir)/libFL.a -o test/test_static.exe
else
gfortran -fopenmp -ffree-line-length-0 -fno-range-check -I${MKLROOT}/include $(flag) -I$(incdir) test/test.f90 -l:libFL.a $(gnumkl) -o test/test_static.exe
endif
test/test_static.exe > test/log_static
ifeq (,$(findstring $(libdir),$(LIBRARY_PATH)))
$(error Please add prefix/lib to LIBRARY_PATH)
endif
ifeq (,$(findstring $(libdir),$(LD_LIBRARY_PATH)))
$(error Please add prefix/lib to LD_LIBRARY_PATH)
endif
ifeq ($(compiler),intel)
ifort -qopenmp -parallel -mkl -static-intel -ipo $(flag) test/test.f90 -lFL -o test/test_dynamic.exe
else
gfortran -fopenmp -ffree-line-length-0 -fno-range-check -I${MKLROOT}/include $(flag) -I$(incdir) test/test.f90 -lFL $(gnumkl) -o test/test_dynamic.exe
endif
test/test_dynamic.exe > test/log_dynamic
ifeq (,$(findstring $(incdir),$(CPATH)))
$(error Please add prefix/include to CPATH)
endif
ifeq ($(compiler),intel)
icpc -qopenmp -parallel -mkl -static-intel $(flag) test/test.cpp -lFL -o test/test_cpp.exe
else
g++ -fopenmp -I${MKLROOT}/include $(flag) test/test.cpp -lFL $(gnumkl) -o test/test_cpp.exe
endif
test/test_cpp.exe > test/log_cpp
ifeq (,$(findstring $(RealPrefix),$(PYTHONPATH)))
$(error Please add prefix to PYTHONPATH)
endif
python test/test.py > test/log_py