forked from aopp-pred/rpe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (62 loc) · 2.26 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
# Makefile for the reduced-precision emulator.
#
# Copyright 2015-2016 Andrew Dawson, Peter Dueben
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Source file and headers used to generate the library code:
src = src/rp_emulator.F90
genincdir = src/include
geninc = $(wildcard $(genincdir)/*.i $(genincdir)/*.f90)
# The processed source file:
unified_source = src/processed/rp_emulator.f90
# The module and library resulting from compiling the processed source:
object = src/rp_emulator.o
moduledir = modules
module = $(moduledir)/rp_emulator.mod
libstatic = lib/librpe.a
libshared = lib/librpe.so
# Set the variable F90 if it is not set in the environment.
ifneq ($(origin F90), environment)
F90 = gfortran
endif
# Set the required compiler flags for each supported compiler.
ifneq (,$(findstring gfortran,$(F90)))
FFLAGS += -J$(moduledir)
endif
ifneq (,$(findstring ifort,$(F90)))
FFLAGS += -module $(moduledir)
endif
# Convenience targets for the source code and compiled library:
.PHONY: all source library shared test
all: library
source: $(unified_source)
library: $(libstatic)
shared: $(libshared)
# Compile the emulator source to generate a module and an object file:
$(object) $(module): $(src) $(geninc)
$(F90) -c -I$(genincdir) $(FFLAGS) -fPIC $(src) -o $(object)
# Create a library archive from the compiled code:
$(libstatic): $(object)
ar curv $(libstatic) $(object)
$(libshared): $(object)
$(F90) -shared -o $(libshared) $(object)
# Generate the full source listing using the C preprocessor:
$(unified_source): $(src) $(geninc)
mkdir -p $(dir $(unified_source))
cpp -I$(genincdir) $(src) | sed '/^#/d' > $(unified_source)
# Test the built library.
test: library
$(MAKE) -C test test
# Cleanup tasks:
clean:
$(RM) $(libstatic) $(libshared) $(module) $(object) $(unified_source)