-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·113 lines (86 loc) · 4.02 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
##----------------------------------------------------------------------------##
##
## CARLsim4 Project Makefile
## -------------------------
##
## Authors: Michael Beyeler <[email protected]>
## Kristofor Carlson <[email protected]>
##
## Institute: Cognitive Anteater Robotics Lab (CARL)
## Department of Cognitive Sciences
## University of California, Irvine
## Irvine, CA, 92697-5100, USA
##
## Version: 03/31/2016
##
##----------------------------------------------------------------------------##
################################################################################
# Start of user-modifiable section
################################################################################
# In this section, specify all files that are part of the project.
# Name of the binary file to be created.
# NOTE: There must be a corresponding .cpp file named main_$(proj_target).cpp!
proj_target := hello_world
# Directory where all include files reside. The Makefile will automatically
# detect and include all .h files within that directory.
proj_inc_dir := inc
# Directory where all source files reside. The Makefile will automatically
# detect and include all .cpp and .cu files within that directory.
proj_src_dir := src
################################################################################
# End of user-modifiable section
################################################################################
#------------------------------------------------------------------------------
# Include configuration file
#------------------------------------------------------------------------------
# NOTE: If your CARLsim4 installation does not reside in the default path, make
# sure the environment variable CARLSIM4_INSTALL_DIR is set.
ifdef CARLSIM4_INSTALL_DIR
CARLSIM4_INC_DIR := $(CARLSIM4_INSTALL_DIR)/include
else
CARLSIM4_INC_DIR := $(HOME)/CARL/include
endif
# include compile flags etc.
include $(CARLSIM4_INC_DIR)/configure.mk
#------------------------------------------------------------------------------
# Build local variables
#------------------------------------------------------------------------------
main_src_file := $(proj_src_dir)/main_$(proj_target).cpp
# build list of all .cpp, .cu, and .h files (but don't include main_src_file)
cpp_files := $(wildcard $(proj_src_dir)/*.cpp)
cpp_files := $(filter-out $(main_src_file),$(cpp_files))
cu_files := $(wildcard $(proj_src_dir)/src/*.cu)
inc_files := $(wildcard $(proj_inc_dir)/*.h)
# compile .cpp files to -cpp.o, and .cu files to -cu.o
obj_cpp := $(patsubst %.cpp, %-cpp.o, $(cpp_files))
obj_cu += $(patsubst %.cu, %-cu.o, $(cu_files))
# handled by clean and distclean
clean_files := $(obj_files) $(proj_target)
distclean_files := $(clean_files) results/* *.dot *.dat *.csv *.log
#------------------------------------------------------------------------------
# Project targets and rules
#------------------------------------------------------------------------------
.PHONY: $(proj_target) nocuda clean distclean help
default: $(proj_target)
$(proj_target): $(main_src_file) $(inc_files) $(obj_cpp) $(obj_cu)
$(eval CARLSIM4_FLG += -Wno-deprecated-gpu-targets)
$(eval CARLSIM4_LIB += -lcurand)
$(NVCC) $(CARLSIM4_FLG) $(obj_cpp) $(obj_cu) $< -o $(proj_target) $(CARLSIM4_LIB)
nocuda: $(main_src_file) $(inc_files) $(obj_cpp)
$(eval CARLSIM4_FLG += -D__NO_CUDA__)
$(CXX) $(CARLSIM4_FLG) $(obj_cpp) $(obj_cu) $< -o $(proj_target) $(CARLSIM4_LIB) -lpthread
$(proj_src_dir)/%-cpp.o: $(proj_src_dir)/%.cpp $(inc_files)
$(CXX) -c $(CXXINCFL) $(CXXFL) $< -o $@
$(proj_src_dir)/%-cu.o: $(proj_src_dir)/%.cu $(inc_files)
$(NVCC) -c $(NVCCINCFL) $(SIMINCFL) $(NVCCFL) $< -o $@
clean:
$(RM) $(clean_files)
distclean:
$(RM) $(distclean_files)
help:
$(info CARLsim4 Project options:)
$(info )
$(info make Compiles this project)
$(info make clean Cleans out all object files)
$(info make distclean Cleans out all object and output files)
$(info make help Brings up this message)