forked from AlloSphere-Research-Group/AlloSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.buildandrun
More file actions
39 lines (32 loc) · 1.44 KB
/
Makefile.buildandrun
File metadata and controls
39 lines (32 loc) · 1.44 KB
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
#RUN_INC_DIRS ?=
#RUN_SRC_DIRS ?=
RUN_DIRS += examples/
VPATH += $(RUN_SRC_DIRS)
RUN_SRCS = $(wildcard $(addsuffix /*.cpp, $(RUN_SRC_DIRS)))
RUN_SRCS += $(wildcard $(addsuffix /*.c, $(RUN_SRC_DIRS)))
RUN_OBJS = $(addsuffix .o, $(basename $(notdir $(RUN_SRCS)) ))
#RUN_OBJS := $(addsuffix .o, $(basename $(subst /,_,$(RUN_OBJS)) ))
RUN_OBJS := $(addprefix $(OBJ_DIR), $(RUN_OBJS))
# These variables are used to link to all libraries found in build/lib/
LINK_LIBS_PATH = $(wildcard $(BUILD_DIR)lib/*.$(SLIB_EXT))
LINK_LIBS_PATH += $(wildcard $(BUILD_DIR)lib/*.$(DLIB_EXT))
LINK_LIBS_FLAGS =
# Compile and run source files in examples/ folder
# For whatever reason, we need this rule so the objects don't get rm'ed by make
runobjs: $(RUN_OBJS)
# Hack to prevent circular dependencies with compile-and-run rule
.PHONY: %.hpp
%.hpp:
# FIXME: this rule should only work for .cpp and .c
EXEC_TARGETS = $(addsuffix %.cpp, $(RUN_DIRS)) $(addsuffix %.c, $(RUN_DIRS))
ifeq ($(PLATFORM), linux)
LINK_LIBS_FLAGS += $(addprefix -l :, $(notdir $(LINK_LIBS_PATH)))
endif
.PRECIOUS: $(EXEC_TARGETS)
$(EXEC_TARGETS): MY_FLAGS = $(shell test -e $(@D)/flags.txt && cat $(@D)/flags.txt)
#$(EXEC_TARGETS): MY_FLAGS += -l$(LIB_NAME)
$(EXEC_TARGETS): FORCE $(ALL_BUILD_DIRS) $(LIB_PATH) runobjs
$(CXX) $(CXXFLAGS) -o $(BIN_DIR)$(*F) $@ -I$(BUILD_DIR)/include/ $(RUN_OBJS) $(LINK_LIBS_FLAGS) $(LINK_LIBS_PATH) $(LDFLAGS) $(MY_FLAGS)
ifneq ($(AUTORUN), 0)
@cd $(BIN_DIR) && ./$(*F)
endif