-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
executable file
·71 lines (56 loc) · 1.73 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
# Make file for GCS-Flow model
# Copyright 2014 Phong Le <[email protected]>
# All Rights Reserved.
# Executable name
TARGET = gcsflow
# Project Name
BINDIR = bin
# Source, Include, Object, and Library Directories
SRCDIR = src
INCDIR = include
OBJDIR = src/obj
LIBDIR = lib
# Compiler, Flags, and Library
NVCC = nvcc
NVCCFLAGS = -O3 -arch=sm_20 -I/$(INCDIR)
GXX = g++
GXXFLAGS = -O3 -Wall
LIBS = -lnetcdf
CUSOURCES = $(shell cd $(SRCDIR) && ls *.cu)
CCSOURCES = $(shell cd $(SRCDIR) && ls *.cc)
# CUDA source code and dependency
CUDEPS = $(patsubst %,$(INCDIR)/%,$(CUSOURCES:.cu=.h))
CUOBJ = $(patsubst %,$(OBJDIR)/%,$(CUSOURCES:.cu=.cu.o))
# CPP source code and dependency
CCDEPS = $(patsubst %,$(INCDIR)/%,$(CCSOURCES:.cc=.h))
CCOBJ = $(patsubst %,$(OBJDIR)/%,$(CCSOURCES:.cc=.cc.o))
all: build print $(TARGET)
$(OBJDIR)/%.cu.o: $(SRCDIR)/%.cu $(CUDEPS)
$(NVCC) $(NVCCFLAGS) -dc -o $@ $<
$(OBJDIR)/%.cc.o: $(SRCDIR)/%.cc $(CCDEPS)
$(GXX) $(GXXFLAGS) -c -o $@ $<
lib_cuda.a: $(CUOBJ)
$(NVCC) $(NVCCFLAGS) -lib $^ -o $(BINDIR)/$@
$(TARGET): lib_cuda.a $(CCOBJ)
@echo ""
@echo "Linking..."
$(NVCC) $(NVCCFLAGS) $(OBJDIR)/*cc.o $(BINDIR)/$< -o $(BINDIR)/$@ $(LIBS)
@echo ""
@echo "Compilation file "$@" successfully. DONE!!!!"
@echo ""
# Clean-up executables and object files
.PHONY: clean
print:
@echo ""
@echo "Compling objects..."
# Check for the existence of sub directories.
# If not exist, then create these directories to dump data to.
# If exist do nothing
build:
@echo ""
@echo "Creating Directories..."
if [ ! -d "$(LIBDIR)" ]; then mkdir $(LIBDIR); fi
if [ ! -d "$(OBJDIR)" ]; then mkdir $(OBJDIR); fi
if [ ! -d "$(BINDIR)" ]; then mkdir $(BINDIR); fi
clean:
rm -f $(BINDIR)/lib_cuda.a $(OBJDIR)/*.o *~ core $(INCDIR)/*~