-
Notifications
You must be signed in to change notification settings - Fork 8
/
make.include
73 lines (58 loc) · 2.23 KB
/
make.include
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
# ######### Non-recursive sub-makefile for Focal #########
#
# To use:
# 1. Include this sub makefile into your main makefile
# 2. Define 'FOCAL_DIR' as path to focal root directory
# 3. Create a dependency for the executable on '$(FOCAL_LIB_OBJS)'
# 4. Add FFLAGS+=-I$(FOCAL_MODDIR) to be able to 'use' Focal library
#
# (!) Do NOT define any variables in your parent makefile that
# begin with the prefix 'FOCAL_' except 'FOCAL_DIR'
# Directories
FOCAL_DIR ?= ./focal
FOCAL_OBJDIR = $(FOCAL_DIR)/obj/
FOCAL_LIBDIR = $(FOCAL_DIR)/lib/
FOCAL_MODDIR = $(FOCAL_DIR)/mod/
# Source directories
vpath %.f90 $(FOCAL_DIR)/src
vpath %.f90 $(FOCAL_DIR)/external
vpath %.f90 $(FOCAL_DIR)/external/clfortran
vpath %.f90 $(FOCAL_DIR)/external/fortran-utils
# Source files
FOCAL_BASE = Focal clfortran futils_sorting
FOCAL_SRCS = Focal_Error Focal_Memory Focal_HostMemory \
Focal_Query Focal_Setup Focal_Utils Focal_Profile \
Focal_Debug Focal_NoDebug
FOCAL_LIBS = Focal Focaldbg
# Objects
FOCAL_BASE_OBJS = $(addprefix $(FOCAL_OBJDIR), $(addsuffix .o, $(FOCAL_BASE)) )
FOCAL_OBJS = $(addprefix $(FOCAL_OBJDIR), $(addsuffix .o, $(FOCAL_SRCS) ) )
FOCAL_LIB_OBJS = $(addprefix $(FOCAL_LIBDIR)lib, $(addsuffix .a, $(FOCAL_LIBS)) )
FOCAL_BUILDDIRS = $(FOCAL_MODDIR) $(FOCAL_OBJDIR) $(FOCAL_LIBDIR)
# --- Compiler flags ---
include $(FOCAL_DIR)/make.compiler
# --- Recipes ---
focal: $(FOCAL_LIB_OBJS)
focal_clean:
rm -f $(FOCAL_OBJDIR)*
rm -f $(FOCAL_LIBDIR)*.a
rm -f $(FOCAL_MODDIR)*.mod
rm -f $(FOCAL_MODDIR)*.smod
# Generate release library
$(FOCAL_LIBDIR)libFocal.a: $(FOCAL_BASE_OBJS) $(filter-out $(FOCAL_OBJDIR)Focal_Debug.o, $(FOCAL_OBJS))
rm -f $@
$(AR) -cq $@ $^
# Generate debug library
$(FOCAL_LIBDIR)libFocaldbg.a: $(FOCAL_BASE_OBJS) $(filter-out $(FOCAL_OBJDIR)Focal_NoDebug.o, $(FOCAL_OBJS))
rm -f $@
$(AR) -cq $@ $^
# Compile fortran objects
$(FOCAL_OBJDIR)%.o: %.f90
$(FC) $(FOCAL_FFLAGS) -c $< -o $@
# Code modules depend on base modules
$(FOCAL_OBJS): $(FOCAL_BASE_OBJS)
# All objects need build directories to exist (order-only dependency here)
$(FOCAL_BASE_OBJS): | $(FOCAL_BUILDDIRS)
$(FOCAL_BUILDDIRS):
mkdir $@
.PHONY: focal focal_clean