-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmakefile
65 lines (50 loc) · 1.38 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
# --- Source names ---
PROGS = platform_query sum nbody
# --- Output Directories ---
FOCAL_DIR ?= ..
OPENCL_DIR ?= /usr/lib/
BINDIR = $(FOCAL_DIR)/bin/
OBJDIR = $(FOCAL_DIR)/obj/
MODDIR = $(FOCAL_DIR)/mod/
# --- Targets ---
PROGOBJS =$(addprefix $(OBJDIR), $(addsuffix .o, $(PROGS)))
KERNELOBJS = $(addprefix $(OBJDIR), $(addsuffix .cl.o, $(PROGS)) )
EXEC = $(addprefix $(BINDIR), $(PROGS))
.NOTPARALLEL:
# --- Main build target ---
all: $(EXEC)
include $(FOCAL_DIR)/make.include
# --- Compiler Flags ---
FFLAGS=$(FOCAL_FFLAGS)
# --- Link Flags ---
ifeq ($(BUILD), release)
FOCAL_LFLAGS ?= -L$(FOCAL_DIR)/lib -lFocal
else ifeq ($(BUILD), debug)
FOCAL_LFLAGS ?= -L$(FOCAL_DIR)/lib -lFocaldbg
else
$(error unrecognized build.)
endif
OPENCL_LFLAGS ?= -g -L$(OPENCL_DIR) -lOpenCL
LFLAGS = $(FOCAL_LFLAGS) $(OPENCL_LFLAGS)
# --- Cleanup (reset) ---
clean:
rm -f $(PROGOBJS)
rm -f $(KERNELOBJS)
rm -f $(EXEC)
# Programs depend on modules
$(PROGOBJS): $(FOCAL_LIB_OBJS)
# Recipe to link executables
$(BINDIR)%: $(addprefix $(OBJDIR), %.o %.cl.o) | $(BINDIR)
$(FC) $^ $(LFLAGS) -o $@
# Recipe to compile fortran objects
$(OBJDIR)%.o: %.f90
$(FC) $(FFLAGS) -c $< -o $@
# Recipe to 'compile' kernel source into a binary object
$(OBJDIR)%.cl.o: %.cl
cp $< fclKernels.cl
ld -r -b binary fclKernels.cl -o $@
rm fclKernels.cl
nm $@
# Recipe to create output directory
$(BINDIR):
mkdir $@